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

handle concurrent metrics_test.go hiccups #258

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion pkg/metrics/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,19 @@ import (
"math/big"
"net/http"
"os"
"sync"
"testing"

io_prometheus_client "github.com/prometheus/client_model/go"
"github.com/prometheus/common/expfmt"
)

var testMetricLock sync.Mutex

func init() {
testMetricLock = sync.Mutex{}
}

func TestMain(m *testing.M) {
var err error

Expand Down Expand Up @@ -74,6 +81,8 @@ func generateTempCertificates() (string, string, error) {
}

func TestRun(t *testing.T) {
testMetricLock.Lock()
defer testMetricLock.Unlock()
ch := make(chan struct{})
defer close(ch)
srv := BuildServer(6789)
Expand All @@ -90,6 +99,8 @@ func TestRun(t *testing.T) {
}

func TestBinaryMetrics(t *testing.T) {
testMetricLock.Lock()
defer testMetricLock.Unlock()
ch := make(chan struct{})
defer close(ch)
srv := BuildServer(6789)
Expand All @@ -108,7 +119,7 @@ func TestBinaryMetrics(t *testing.T) {
},
{
method: TBRInaccessibleOnBoot,
query: tbrInaccessibleOnBootstrapQuery,
query: tbrInaccessibleOnBootstrapQuery,
},
} {
for _, tt := range []struct {
Expand Down