Skip to content

Commit

Permalink
fix-test
Browse files Browse the repository at this point in the history
Signed-off-by: Yuri Shkuro <[email protected]>
  • Loading branch information
yurishkuro committed Jul 12, 2024
1 parent 047c3cd commit a5c5654
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
31 changes: 29 additions & 2 deletions cmd/jaeger/internal/extension/jaegerquery/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ package jaegerquery
import (
"context"
"fmt"
"net/http"
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand All @@ -17,6 +19,7 @@ import (

"github.com/jaegertracing/jaeger/cmd/jaeger/internal/extension/jaegerstorage"
"github.com/jaegertracing/jaeger/cmd/query/app/querysvc"
"github.com/jaegertracing/jaeger/internal/grpctest"
"github.com/jaegertracing/jaeger/pkg/metrics"
"github.com/jaegertracing/jaeger/pkg/testutils"
"github.com/jaegertracing/jaeger/storage"
Expand Down Expand Up @@ -160,13 +163,37 @@ func TestServerStart(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
telemetrySettings := component.TelemetrySettings{
Logger: zaptest.NewLogger(t, zaptest.WrapOptions(zap.AddCaller())),
Logger: zaptest.NewLogger(t, zaptest.WrapOptions(zap.AddCaller())),
ReportStatus: func(*component.StatusEvent) {},
}
server := newServer(tt.config, telemetrySettings)
err := server.Start(context.Background(), host)

if tt.expectedErr == "" {
require.NoError(t, err)
// We need to wait for servers to become available.
// Otherwise, we could call shutdown before the servers are even started,
// which could cause flaky code coverage by going through error cases.
require.Eventually(t,
func() bool {
resp, err := http.Get("http://localhost:16686/")
if err != nil {
return false
}
defer resp.Body.Close()
return resp.StatusCode == http.StatusOK
},
10*time.Second,
100*time.Millisecond,
"server not started")
grpctest.ReflectionServiceValidator{
HostPort: ":16685",
ExpectedServices: []string{
"jaeger.api_v2.QueryService",
"jaeger.api_v3.QueryService",
"jaeger.api_v2.metrics.MetricsQueryService",
"grpc.health.v1.Health",
},
}.Execute(t)
defer server.Shutdown(context.Background())
} else {
require.ErrorContains(t, err, tt.expectedErr)
Expand Down
1 change: 0 additions & 1 deletion cmd/query/app/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,6 @@ func TestServerHandlesPortZero(t *testing.T) {

grpctest.ReflectionServiceValidator{
HostPort: fmt.Sprintf(":%v", port),
Server: server.grpcServer,
ExpectedServices: []string{
"jaeger.api_v2.QueryService",
"jaeger.api_v3.QueryService",
Expand Down

0 comments on commit a5c5654

Please sign in to comment.