Skip to content

Commit

Permalink
[chore] Fix Target Allocator tests (open-telemetry#1403)
Browse files Browse the repository at this point in the history
* Change the github action to match the operator

* Add chloggen

* Fix tests

* imports
  • Loading branch information
jaronoff97 authored Jan 27, 2023
1 parent 3e90a0f commit 0807259
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 7 additions & 2 deletions cmd/otel-allocator/server/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"testing"
"time"

"github.com/gin-gonic/gin"
"github.com/prometheus/common/model"
promconfig "github.com/prometheus/prometheus/config"

Expand Down Expand Up @@ -81,8 +82,12 @@ func BenchmarkScrapeConfigsHandler(b *testing.B) {
for i := 0; i < b.N; i++ {
s.compareHash = 0
s.discoveryManager = &mockDiscoveryManager{m: data}
resp := httptest.NewRecorder()
s.ScrapeConfigsHandler(resp, nil)

c, _ := gin.CreateTestContext(httptest.NewRecorder())
gin.SetMode(gin.ReleaseMode)
c.Request = httptest.NewRequest("GET", "/scrape_configs", nil)

s.ScrapeConfigsHandler(c)
}
})
}
Expand Down
7 changes: 5 additions & 2 deletions cmd/otel-allocator/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"testing"
"time"

"github.com/gin-gonic/gin"
"github.com/prometheus/common/config"
"github.com/prometheus/common/model"
promconfig "github.com/prometheus/prometheus/config"
Expand Down Expand Up @@ -640,10 +641,12 @@ func TestScrapeConfigsHandler_Hashing(t *testing.T) {
t.Run(tc.description, func(t *testing.T) {
dm := &mockDiscoveryManager{m: tc.scrapeConfigs}
s.discoveryManager = dm
request := httptest.NewRequest("GET", "/scrape_configs", nil)
w := httptest.NewRecorder()
c, _ := gin.CreateTestContext(w)
gin.SetMode(gin.ReleaseMode)
c.Request = httptest.NewRequest("GET", "/scrape_configs", nil)

s.ScrapeConfigsHandler(w, request)
s.ScrapeConfigsHandler(c)
result := w.Result()

assert.Equal(t, http.StatusOK, result.StatusCode)
Expand Down

0 comments on commit 0807259

Please sign in to comment.