From 7e5213584c5e77d4582164d7c4cd8b54045ec98c Mon Sep 17 00:00:00 2001 From: Jakub Jarosz Date: Fri, 1 Apr 2022 09:44:14 +0100 Subject: [PATCH 1/2] Run tests in parallel --- Makefile | 2 +- client/nginx_test.go | 2 ++ collector/helper_test.go | 2 ++ exporter_test.go | 8 ++++++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b6040e78..6012a74e 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ lint: .PHONY: test test: - go test ./... + go test ./... -race -shuffle=on .PHONY: container container: diff --git a/client/nginx_test.go b/client/nginx_test.go index b9e867cb..68005cb1 100644 --- a/client/nginx_test.go +++ b/client/nginx_test.go @@ -8,6 +8,8 @@ import ( const validStabStats = "Active connections: 1457 \nserver accepts handled requests\n 6717066 6717066 65844359 \nReading: 1 Writing: 8 Waiting: 1448 \n" func TestParseStubStatsValidInput(t *testing.T) { + t.Parallel() + tests := []struct { input []byte expectedResult StubStats diff --git a/collector/helper_test.go b/collector/helper_test.go index cfbfec75..31cb0228 100644 --- a/collector/helper_test.go +++ b/collector/helper_test.go @@ -6,6 +6,8 @@ import ( ) func TestMergeLabels(t *testing.T) { + t.Parallel() + tests := []struct { name string mapA, mapB, want map[string]string diff --git a/exporter_test.go b/exporter_test.go index 99eb3837..0417f127 100644 --- a/exporter_test.go +++ b/exporter_test.go @@ -8,6 +8,8 @@ import ( ) func TestCreateClientWithRetries(t *testing.T) { + t.Parallel() + type args struct { client interface{} err error @@ -83,6 +85,8 @@ func TestCreateClientWithRetries(t *testing.T) { } func TestParsePositiveDuration(t *testing.T) { + t.Parallel() + tests := []struct { name string testInput string @@ -123,6 +127,8 @@ func TestParsePositiveDuration(t *testing.T) { } func TestParseUnixSocketAddress(t *testing.T) { + t.Parallel() + tests := []struct { name string testInput string @@ -177,6 +183,8 @@ func TestParseUnixSocketAddress(t *testing.T) { } func TestParseConstLabels(t *testing.T) { + t.Parallel() + tests := []struct { name string labels string From 2eb379ce4d12caf12d6c175ed2d5f545767dc721 Mon Sep 17 00:00:00 2001 From: Jakub Jarosz Date: Fri, 1 Apr 2022 10:38:43 +0100 Subject: [PATCH 2/2] Make linter pass all tests --- collector/nginx_plus.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/collector/nginx_plus.go b/collector/nginx_plus.go index 75c7cb10..007eb330 100644 --- a/collector/nginx_plus.go +++ b/collector/nginx_plus.go @@ -206,7 +206,8 @@ type VariableLabelNames struct { // NewVariableLabels creates a new struct for VariableNames for the collector func NewVariableLabelNames(upstreamServerVariableLabelNames []string, serverZoneVariableLabelNames []string, upstreamServerPeerVariableLabelNames []string, - streamUpstreamServerVariableLabelNames []string, streamServerZoneLabels []string, streamUpstreamServerPeerVariableLabelNames []string) VariableLabelNames { + streamUpstreamServerVariableLabelNames []string, streamServerZoneLabels []string, streamUpstreamServerPeerVariableLabelNames []string, +) VariableLabelNames { return VariableLabelNames{ UpstreamServerVariableLabelNames: upstreamServerVariableLabelNames, ServerZoneVariableLabelNames: serverZoneVariableLabelNames,