Skip to content

Commit

Permalink
ping health check
Browse files Browse the repository at this point in the history
Signed-off-by: Yuri Shkuro <[email protected]>
  • Loading branch information
yurishkuro committed May 19, 2024
1 parent fb5ebb7 commit b3a750b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
6 changes: 3 additions & 3 deletions cmd/jaeger/internal/integration/e2e_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,14 @@ func (s *E2EStorageIntegration) e2eInitialize(t *testing.T, storage string) {
// A Github Actions special annotation to create a foldable section
// in the Github runner output.
// https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#grouping-log-lines
fmt.Println("::group::Jaeger-v2 binary logs")
fmt.Println("::group::🚧 🚧 🚧 Jaeger-v2 binary logs")
outLogs, err := os.ReadFile(outFile.Name())
require.NoError(t, err)
fmt.Printf("Jaeger-v2 output logs:\n%s", outLogs)
fmt.Printf("🚧 🚧 🚧 Jaeger-v2 output logs:\n%s", outLogs)

errLogs, err := os.ReadFile(errFile.Name())
require.NoError(t, err)
fmt.Printf("Jaeger-v2 error logs:\n%s", errLogs)
fmt.Printf("🚧 🚧 🚧 Jaeger-v2 error logs:\n%s", errLogs)
// End of Github Actions foldable section annotation.
fmt.Println("::endgroup::")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/jaeger/internal/integration/span_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (r *spanReader) GetTrace(ctx context.Context, traceID model.TraceID) (*mode
for i := range received.Spans {
spans = append(spans, &received.Spans[i])
}
r.logger.Info(fmt.Sprintf("GetTrace received %d spans (total %d)", len(received.Spans), len(spans)))
// r.logger.Info(fmt.Sprintf("GetTrace received %d spans (total %d)", len(received.Spans), len(spans)))
}
r.logger.Info(fmt.Sprintf("GetTraces received a total of %d spans", len(spans)))

Expand Down
2 changes: 1 addition & 1 deletion pkg/testutils/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func newRecordingCore() (zapcore.Core, *Buffer) {
// NewEchoLogger is similar to NewLogger, but the logs are also echoed to t.Log.
func NewEchoLogger(t *testing.T) (*zap.Logger, *Buffer) {
core, buf := newRecordingCore()
echo := zaptest.NewLogger(t, zaptest.WrapOptions(zap.AddCaller())).Core()
echo := zaptest.NewLogger(t).Core()
logger := zap.New(zapcore.NewTee(core, echo))
return logger, buf
}
Expand Down
25 changes: 25 additions & 0 deletions plugin/storage/integration/remote_memory_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@
package integration

import (
"context"
"os"
"testing"
"time"

"github.com/stretchr/testify/require"
"go.uber.org/zap"
"go.uber.org/zap/zaptest"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/health/grpc_health_v1"

"github.com/jaegertracing/jaeger/cmd/remote-storage/app"
"github.com/jaegertracing/jaeger/pkg/config"
Expand Down Expand Up @@ -46,6 +51,26 @@ func StartNewRemoteMemoryStorage(t *testing.T) *RemoteMemoryStorage {
require.NoError(t, err)
require.NoError(t, server.Start())

conn, err := grpc.NewClient(
opts.GRPCHostPort,
grpc.WithTransportCredentials(insecure.NewCredentials()),
)
require.NoError(t, err)
defer conn.Close()
healthClient := grpc_health_v1.NewHealthClient(conn)
require.Eventually(t, func() bool {
req := &grpc_health_v1.HealthCheckRequest{}
ctx, cancel := context.WithTimeout(context.Background(), time.Second*1)
defer cancel()
resp, err := healthClient.Check(ctx, req)
if err != nil {
t.Logf("remote storage server is not ready: err=%v", err)
return false
}
t.Logf("remote storage server status: %v", resp.Status)
return resp.GetStatus() == grpc_health_v1.HealthCheckResponse_SERVING
}, 30*time.Second, time.Second, "failed to ensure remote storage server is ready")

return &RemoteMemoryStorage{
server: server,
storageFactory: storageFactory,
Expand Down

0 comments on commit b3a750b

Please sign in to comment.