Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IND-2154 build and test workflow added #172

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8a4b717
testing
KaushikiAnand Feb 4, 2025
1e5f883
IND-2154 build and test workflow added
KaushikiAnand Feb 4, 2025
362ddbe
IND-2154 go version changed
KaushikiAnand Feb 4, 2025
22c3fc4
IND-2154 changes made
KaushikiAnand Feb 4, 2025
0abef87
IND-2154 updated workflow, statsd_test.go, statsite_test.go
KaushikiAnand Feb 4, 2025
4ccc706
IND-2154 statsite image corrected
KaushikiAnand Feb 4, 2025
119ec1e
IND-2154 updated statsite image
KaushikiAnand Feb 4, 2025
85b49f9
IND-2154 port for statsd changed
KaushikiAnand Feb 5, 2025
f131e62
IND-2154 test file updated
KaushikiAnand Feb 5, 2025
0c90b10
IND-2154 workflow updated
KaushikiAnand Feb 5, 2025
a2d0427
IND-2154 updation to workflow and statsd_test
KaushikiAnand Feb 5, 2025
e6138f4
IND-2154 updation to workflow
KaushikiAnand Feb 5, 2025
020b8c5
IND-2154 workflow updation
KaushikiAnand Feb 5, 2025
1b92e44
IND-2154 changes ti statsd_test file
KaushikiAnand Feb 6, 2025
1750a56
IND-2154 changes in statsite_test file
KaushikiAnand Feb 6, 2025
49f364b
IND-2154 updation to test files
KaushikiAnand Feb 11, 2025
55076db
IND-2154 updated workflow
KaushikiAnand Feb 11, 2025
77cef08
IND-2154 updation of port for statsd
KaushikiAnand Feb 11, 2025
fc76ad4
IND-2154 updation to workflow for debugging
KaushikiAnand Feb 11, 2025
b1353e5
IND-2154 commented out statsd test func
KaushikiAnand Feb 11, 2025
8e0b45a
IND-2154 workflow debug process added
KaushikiAnand Feb 11, 2025
110d62c
IND-2154 port change
KaushikiAnand Feb 11, 2025
f94b865
IND-2154 port changed
KaushikiAnand Feb 11, 2025
dedefd9
IND-2154 updation to statsd test
KaushikiAnand Feb 11, 2025
d1c696f
IND-2154 port changes
KaushikiAnand Feb 12, 2025
70a96b4
IND-2154 changes made
KaushikiAnand Feb 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build and Test

on:
pull_request:
branches: [master]

jobs:
build:
runs-on: ubuntu-latest
services:
statsd:
image: statsd/statsd
ports:
- 8125:8125/udp
statsite:
image: quay.io/prometheus/statsd-exporter
ports:
- 7523:7523

steps:
- name: Checkout Code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: Setup Go
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a
with:
go-version: '1.18'
- name: Debug active processes
run: |
sudo lsof -i
- name: Test Go
run: |
for dir in $(find . -name "go.mod" -exec dirname {} \;); do
echo "Running tests in module $dir"
(cd $dir && go test -v ./...)
done
- name: Build Go
run: |
for dir in $(find . -name "go.mod" -exec dirname {} \;); do
echo "Running build in module $dir"
(cd $dir && go build -v ./...)
done
17 changes: 16 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/hashicorp/go-metrics

go 1.12
go 1.18

require (
github.com/DataDog/datadog-go v3.2.0+incompatible
Expand All @@ -14,5 +14,20 @@ require (
github.com/prometheus/common v0.26.0
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/circonus-labs/circonusllhist v0.1.3 // indirect
github.com/hashicorp/go-cleanhttp v0.5.0 // indirect
github.com/hashicorp/go-retryablehttp v0.5.3 // indirect
github.com/hashicorp/golang-lru v0.5.0 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926 // indirect
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40 // indirect
google.golang.org/protobuf v1.26.0-rc.1 // indirect
)

// Introduced undocumented breaking change to metrics sink interface
retract v0.3.11
3 changes: 0 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,8 @@ github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
Expand Down Expand Up @@ -164,7 +162,6 @@ google.golang.org/protobuf v1.26.0-rc.1 h1:7QnIQpGRHE5RnLKnESfDoxm2dTapTZua5a0kS
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Expand Down
4 changes: 2 additions & 2 deletions sink_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,12 @@ func TestNewMetricSinkFromURL(t *testing.T) {
}{
{
desc: "statsd scheme yields a StatsdSink",
input: "statsd://someserver:123",
input: "statsd://127.0.0.1:7524",
expect: reflect.TypeOf(&StatsdSink{}),
},
{
desc: "statsite scheme yields a StatsiteSink",
input: "statsite://someserver:123",
input: "statsite://127.0.0.1:7523",
expect: reflect.TypeOf(&StatsiteSink{}),
},
{
Expand Down
17 changes: 12 additions & 5 deletions statsd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package metrics
import (
"bufio"
"bytes"
"fmt"
"net"
"net/url"
"strings"
Expand Down Expand Up @@ -40,6 +41,9 @@ func TestStatsd_PushFullQueue(t *testing.T) {
}
}

// initially there was some error connecting to the server.
// to correct it used the 8125 port which is a standard udp port and also added container creation in workflow
// but on above changes showed address already in use.
func TestStatsd_Conn(t *testing.T) {
addr := "127.0.0.1:7524"
done := make(chan bool)
Expand All @@ -49,6 +53,9 @@ func TestStatsd_Conn(t *testing.T) {
panic(err)
}
defer list.Close()

fmt.Println("UDP server listening on", list.LocalAddr())

buf := make([]byte, 1500)
n, err := list.Read(buf)
if err != nil {
Expand Down Expand Up @@ -133,7 +140,7 @@ func TestStatsd_Conn(t *testing.T) {
select {
case <-done:
s.Shutdown()
case <-time.After(3 * time.Second):
case <-time.After(5 * time.Second):
t.Fatalf("timeout")
}
}
Expand All @@ -147,13 +154,13 @@ func TestNewStatsdSinkFromURL(t *testing.T) {
}{
{
desc: "address is populated",
input: "statsd://statsd.service.consul",
expectAddr: "statsd.service.consul",
input: "statsd://127.0.0.1:8125",
expectAddr: "127.0.0.1:8125",
},
{
desc: "address includes port",
input: "statsd://statsd.service.consul:1234",
expectAddr: "statsd.service.consul:1234",
input: "statsd://127.0.0.1:8125",
expectAddr: "127.0.0.1:8125",
},
} {
t.Run(tc.desc, func(t *testing.T) {
Expand Down
15 changes: 9 additions & 6 deletions statsite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ func TestStatsite_PushFullQueue(t *testing.T) {
}
}

// initially there was some error connecting to the server.
// to correct it used the 8126 port and also added container creation in workflow
// but on above changes showed invalid address or nil pointer reference
func TestStatsite_Conn(t *testing.T) {
addr := "localhost:7523"
addr := "127.0.0.1:7523"

ln, _ := net.Listen("tcp", addr)

Expand Down Expand Up @@ -130,7 +133,7 @@ func TestStatsite_Conn(t *testing.T) {
select {
case <-done:
s.Shutdown()
case <-time.After(3 * time.Second):
case <-time.After(5 * time.Second):
t.Fatalf("timeout")
}
}
Expand All @@ -144,13 +147,13 @@ func TestNewStatsiteSinkFromURL(t *testing.T) {
}{
{
desc: "address is populated",
input: "statsd://statsd.service.consul",
expectAddr: "statsd.service.consul",
input: "statsd://127.0.0.1:7523",
expectAddr: "127.0.0.1:7523",
},
{
desc: "address includes port",
input: "statsd://statsd.service.consul:1234",
expectAddr: "statsd.service.consul:1234",
input: "statsd://127.0.0.1:7523",
expectAddr: "127.0.0.1:7523",
},
} {
t.Run(tc.desc, func(t *testing.T) {
Expand Down
Loading