Skip to content

Commit

Permalink
fix: Close factory in plugin/storage/es/ test (#5467)
Browse files Browse the repository at this point in the history
## Which problem is this PR solving?
- Part of #5083

## Description of the changes
- Added f.close() in TestArhiveEnabled based on
#5083 (comment)

## How was this change tested?
-  CI workflow

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [ ] I have added unit tests for the new functionality
- [x] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `yarn lint` and `yarn test`

---------

Signed-off-by: Vamshi Maskuri <gwcchintu@gmail.com>
Signed-off-by: Yuri Shkuro <github@ysh.us>
Signed-off-by: Vamshi Maskuri <117595548+varshith257@users.noreply.github.com>
Co-authored-by: Yuri Shkuro <github@ysh.us>
  • Loading branch information
varshith257 and yurishkuro authored May 21, 2024
1 parent c840816 commit 2f2c4ac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
14 changes: 10 additions & 4 deletions cmd/agent/app/reporter/grpc/collector_proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"
"io"
"net"
"sync"
"testing"
"time"

Expand All @@ -35,15 +36,13 @@ var _ io.Closer = (*ProxyBuilder)(nil)

func TestMultipleCollectors(t *testing.T) {
spanHandler1 := &mockSpanHandler{}
s1, addr1 := initializeGRPCTestServer(t, func(s *grpc.Server) {
_, addr1 := initializeGRPCTestServer(t, func(s *grpc.Server) {
api_v2.RegisterCollectorServiceServer(s, spanHandler1)
})
defer s1.Stop()
spanHandler2 := &mockSpanHandler{}
s2, addr2 := initializeGRPCTestServer(t, func(s *grpc.Server) {
_, addr2 := initializeGRPCTestServer(t, func(s *grpc.Server) {
api_v2.RegisterCollectorServiceServer(s, spanHandler2)
})
defer s2.Stop()

mFactory := metricstest.NewFactory(time.Microsecond)
defer mFactory.Stop()
Expand Down Expand Up @@ -79,8 +78,15 @@ func initializeGRPCTestServer(t *testing.T, beforeServe func(server *grpc.Server
lis, err := net.Listen("tcp", "localhost:0")
require.NoError(t, err)
beforeServe(server)
var wg sync.WaitGroup
wg.Add(1)
go func() {
require.NoError(t, server.Serve(lis))
wg.Done()
}()
t.Cleanup(func() {
server.Stop()
wg.Wait()
})
return server, lis.Addr()
}
1 change: 1 addition & 0 deletions plugin/storage/es/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ func TestArchiveEnabled(t *testing.T) {
f.newClientFn = (&mockClientBuilder{}).NewClient
err := f.Initialize(metrics.NullFactory, zap.NewNop())
require.NoError(t, err)
defer f.Close() // Ensure resources are cleaned up if initialization is successful
w, err := f.CreateArchiveSpanWriter()
require.NoError(t, err)
assert.NotNil(t, w)
Expand Down

0 comments on commit 2f2c4ac

Please sign in to comment.