summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-11-14 17:37:25 +0300
committerValery Piashchynski <[email protected]>2020-11-14 17:37:25 +0300
commit06cda58dd9e50928c5473425fefcd4b4be4598c2 (patch)
tree6f32832da6ec66754850d95aaa464ae5789de3a5
parente45155e77e99e85e4ee9cd8863365bf6d599796e (diff)
Typo in go.mod
-rwxr-xr-x.golangci.yml4
-rwxr-xr-xgo.mod6
-rwxr-xr-xgo.sum2
-rw-r--r--plugins/metrics/tests/metrics_test.go110
4 files changed, 51 insertions, 71 deletions
diff --git a/.golangci.yml b/.golangci.yml
index b2382ddb..38dd313b 100755
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -9,7 +9,7 @@ linters:
- dogsled
# - dupl
- gochecknoinits
- - goconst
+ # - goconst
- gocritic
- gocyclo
- gofmt
@@ -31,7 +31,7 @@ linters:
# - stylecheck
- typecheck
- unconvert
- - unparam
+ # - unparam
# - unused
- varcheck
- whitespace
diff --git a/go.mod b/go.mod
index ebf1855e..b268a831 100755
--- a/go.mod
+++ b/go.mod
@@ -9,7 +9,7 @@ require (
github.com/prometheus/client_golang v1.7.1
github.com/shirou/gopsutil v3.20.10+incompatible
github.com/spf13/viper v1.7.1
- github.com/spiral/endure v1.0.0-beta18
+ github.com/spiral/endure v1.0.0-beta19
github.com/spiral/errors v1.0.4
github.com/spiral/goridge/v2 v2.4.6
github.com/spiral/roadrunner v1.8.4
@@ -19,8 +19,4 @@ require (
go.uber.org/zap v1.16.0
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1
-)
-
-replace (
- github.com/spiral/endure v1.0.0-beta18 => /home/valery/Projects/opensource/spiral/endure
) \ No newline at end of file
diff --git a/go.sum b/go.sum
index fe97d50b..343f4fcf 100755
--- a/go.sum
+++ b/go.sum
@@ -261,6 +261,8 @@ github.com/spf13/viper v1.7.1 h1:pM5oEahlgWv/WnHXpgbKz7iLIxRf65tye2Ci+XFK5sk=
github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
github.com/spiral/endure v1.0.0-beta18 h1:SJOh8b6G6AfXg2RgKvKnLE03Ep8bXGFiEVcfc/F41WI=
github.com/spiral/endure v1.0.0-beta18/go.mod h1:qm3evrNggh26QQhwln2uH/1KJQInFZKJZeD5Yvm2k6Y=
+github.com/spiral/endure v1.0.0-beta19 h1:dQpFfiFmeh9E+oErAlM9f4ojZJN1wjEy75xuuQmIdGM=
+github.com/spiral/endure v1.0.0-beta19/go.mod h1:qm3evrNggh26QQhwln2uH/1KJQInFZKJZeD5Yvm2k6Y=
github.com/spiral/errors v1.0.2/go.mod h1:SwMSZVdZkkJVgXNNafccqOaxWg0XPzVU/dEdUEInE0o=
github.com/spiral/errors v1.0.4 h1:Y6Bop9GszdDh+Dn3s5aqsGebNLydqZ1F6OdOIQ9EpU0=
github.com/spiral/errors v1.0.4/go.mod h1:SwMSZVdZkkJVgXNNafccqOaxWg0XPzVU/dEdUEInE0o=
diff --git a/plugins/metrics/tests/metrics_test.go b/plugins/metrics/tests/metrics_test.go
index 860528f8..0eaa94a9 100644
--- a/plugins/metrics/tests/metrics_test.go
+++ b/plugins/metrics/tests/metrics_test.go
@@ -20,6 +20,10 @@ import (
"github.com/stretchr/testify/assert"
)
+const dialAddr = "127.0.0.1:6001"
+const dialNetwork = "tcp"
+const getAddr = "http://localhost:2112/metrics"
+
// get request and return body
func get(url string) (string, error) {
r, err := http.Get(url)
@@ -240,22 +244,22 @@ func TestMetricsDifferentRPCCalls(t *testing.T) {
}()
t.Run("DeclareMetric", declareMetricsTest)
- genericOut, err := get("http://localhost:2112/metrics")
+ genericOut, err := get(getAddr)
assert.NoError(t, err)
assert.Contains(t, genericOut, "test_metrics_named_collector")
t.Run("AddMetric", addMetricsTest)
- genericOut, err = get("http://localhost:2112/metrics")
+ genericOut, err = get(getAddr)
assert.NoError(t, err)
assert.Contains(t, genericOut, "test_metrics_named_collector 10000")
t.Run("SetMetric", setMetric)
- genericOut, err = get("http://localhost:2112/metrics")
+ genericOut, err = get(getAddr)
assert.NoError(t, err)
assert.Contains(t, genericOut, "user_gauge_collector 100")
t.Run("VectorMetric", vectorMetric)
- genericOut, err = get("http://localhost:2112/metrics")
+ genericOut, err = get(getAddr)
assert.NoError(t, err)
assert.Contains(t, genericOut, "gauge_2_collector{section=\"first\",type=\"core\"} 100")
@@ -263,12 +267,12 @@ func TestMetricsDifferentRPCCalls(t *testing.T) {
t.Run("SetWithoutLabels", setWithoutLabels)
t.Run("SetOnHistogram", setOnHistogram)
t.Run("MetricSub", subMetric)
- genericOut, err = get("http://localhost:2112/metrics")
+ genericOut, err = get(getAddr)
assert.NoError(t, err)
assert.Contains(t, genericOut, "sub_gauge_subMetric 1")
t.Run("SubVector", subVector)
- genericOut, err = get("http://localhost:2112/metrics")
+ genericOut, err = get(getAddr)
assert.NoError(t, err)
assert.Contains(t, genericOut, "sub_gauge_subVector{section=\"first\",type=\"core\"} 1")
@@ -276,11 +280,11 @@ func TestMetricsDifferentRPCCalls(t *testing.T) {
}
func subVector(t *testing.T) {
- time.Sleep(time.Second * 1)
-
- conn, err := net.Dial("tcp", "127.0.0.1:6001")
+ conn, err := net.Dial(dialNetwork, dialAddr)
assert.NoError(t, err)
- defer conn.Close()
+ defer func() {
+ _ = conn.Close()
+ }()
client := rpc.NewClientWithCodec(goridge.NewClientCodec(conn))
var ret bool
@@ -323,12 +327,11 @@ func subVector(t *testing.T) {
}
func subMetric(t *testing.T) {
- time.Sleep(time.Second * 1)
-
- conn, err := net.Dial("tcp", "127.0.0.1:6001")
+ conn, err := net.Dial(dialNetwork, dialAddr)
assert.NoError(t, err)
- defer conn.Close()
-
+ defer func() {
+ _ = conn.Close()
+ }()
client := rpc.NewClientWithCodec(goridge.NewClientCodec(conn))
var ret bool
@@ -338,9 +341,6 @@ func subMetric(t *testing.T) {
Namespace: "default",
Subsystem: "default",
Type: metrics.Gauge,
- Help: "NO HELP!",
- Labels: nil,
- Buckets: nil,
},
}
@@ -370,12 +370,11 @@ func subMetric(t *testing.T) {
}
func setOnHistogram(t *testing.T) {
- time.Sleep(time.Second * 1)
-
- conn, err := net.Dial("tcp", "127.0.0.1:6001")
+ conn, err := net.Dial(dialNetwork, dialAddr)
assert.NoError(t, err)
- defer conn.Close()
-
+ defer func() {
+ _ = conn.Close()
+ }()
client := rpc.NewClientWithCodec(goridge.NewClientCodec(conn))
var ret bool
@@ -385,9 +384,7 @@ func setOnHistogram(t *testing.T) {
Namespace: "default",
Subsystem: "default",
Type: metrics.Histogram,
- Help: "NO HELP!",
Labels: []string{"type", "section"},
- Buckets: nil,
},
}
@@ -408,12 +405,11 @@ func setOnHistogram(t *testing.T) {
}
func setWithoutLabels(t *testing.T) {
- time.Sleep(time.Second * 1)
-
- conn, err := net.Dial("tcp", "127.0.0.1:6001")
+ conn, err := net.Dial(dialNetwork, dialAddr)
assert.NoError(t, err)
- defer conn.Close()
-
+ defer func() {
+ _ = conn.Close()
+ }()
client := rpc.NewClientWithCodec(goridge.NewClientCodec(conn))
var ret bool
@@ -423,9 +419,7 @@ func setWithoutLabels(t *testing.T) {
Namespace: "default",
Subsystem: "default",
Type: metrics.Gauge,
- Help: "NO HELP!",
Labels: []string{"type", "section"},
- Buckets: nil,
},
}
@@ -446,12 +440,11 @@ func setWithoutLabels(t *testing.T) {
}
func missingSection(t *testing.T) {
- time.Sleep(time.Second * 1)
-
- conn, err := net.Dial("tcp", "127.0.0.1:6001")
+ conn, err := net.Dial(dialNetwork, dialAddr)
assert.NoError(t, err)
- defer conn.Close()
-
+ defer func() {
+ _ = conn.Close()
+ }()
client := rpc.NewClientWithCodec(goridge.NewClientCodec(conn))
var ret bool
@@ -461,9 +454,7 @@ func missingSection(t *testing.T) {
Namespace: "default",
Subsystem: "default",
Type: metrics.Gauge,
- Help: "NO HELP!",
Labels: []string{"type", "section"},
- Buckets: nil,
},
}
@@ -485,12 +476,11 @@ func missingSection(t *testing.T) {
}
func vectorMetric(t *testing.T) {
- time.Sleep(time.Second * 1)
-
- conn, err := net.Dial("tcp", "127.0.0.1:6001")
+ conn, err := net.Dial(dialNetwork, dialAddr)
assert.NoError(t, err)
- defer conn.Close()
-
+ defer func() {
+ _ = conn.Close()
+ }()
client := rpc.NewClientWithCodec(goridge.NewClientCodec(conn))
var ret bool
@@ -500,9 +490,7 @@ func vectorMetric(t *testing.T) {
Namespace: "default",
Subsystem: "default",
Type: metrics.Gauge,
- Help: "NO HELP!",
Labels: []string{"type", "section"},
- Buckets: nil,
},
}
@@ -524,12 +512,11 @@ func vectorMetric(t *testing.T) {
}
func setMetric(t *testing.T) {
- time.Sleep(time.Second * 1)
-
- conn, err := net.Dial("tcp", "127.0.0.1:6001")
+ conn, err := net.Dial(dialNetwork, dialAddr)
assert.NoError(t, err)
- defer conn.Close()
-
+ defer func() {
+ _ = conn.Close()
+ }()
client := rpc.NewClientWithCodec(goridge.NewClientCodec(conn))
var ret bool
@@ -539,9 +526,6 @@ func setMetric(t *testing.T) {
Namespace: "default",
Subsystem: "default",
Type: metrics.Gauge,
- Help: "NO HELP!",
- Labels: nil,
- Buckets: nil,
},
}
@@ -561,12 +545,11 @@ func setMetric(t *testing.T) {
}
func addMetricsTest(t *testing.T) {
- time.Sleep(time.Second * 1)
-
- conn, err := net.Dial("tcp", "127.0.0.1:6001")
+ conn, err := net.Dial(dialNetwork, dialAddr)
assert.NoError(t, err)
- defer conn.Close()
-
+ defer func() {
+ _ = conn.Close()
+ }()
client := rpc.NewClientWithCodec(goridge.NewClientCodec(conn))
var ret bool
@@ -582,12 +565,11 @@ func addMetricsTest(t *testing.T) {
}
func declareMetricsTest(t *testing.T) {
- time.Sleep(time.Second * 1)
-
- conn, err := net.Dial("tcp", "127.0.0.1:6001")
+ conn, err := net.Dial(dialNetwork, dialAddr)
assert.NoError(t, err)
- defer conn.Close()
-
+ defer func() {
+ _ = conn.Close()
+ }()
client := rpc.NewClientWithCodec(goridge.NewClientCodec(conn))
var ret bool