-
Notifications
You must be signed in to change notification settings - Fork 6.2k
br: use random port to avoid flaky test #65186
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,6 @@ package importclient_test | |
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "net" | ||
| "sync" | ||
| "testing" | ||
|
|
@@ -79,18 +78,12 @@ func (s *mockImportServer) MultiIngest(_ context.Context, req *import_sstpb.Mult | |
|
|
||
| func TestImportClient(t *testing.T) { | ||
| ctx := context.Background() | ||
| var port int | ||
| var lis net.Listener | ||
| var err error | ||
| for port = 0; port < 1000; port += 1 { | ||
| addr := fmt.Sprintf(":%d", 51111+port) | ||
| lis, err = net.Listen("tcp", addr) | ||
| if err == nil { | ||
| break | ||
| } | ||
| t.Log(err) | ||
| } | ||
|
|
||
| addr := ":0" | ||
| lis, err = net.Listen("tcp", addr) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we have used a library
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's also an option, but if it can be accomplished using only the official libraries, it's better not to introduce third-party libraries. |
||
| t.Log(err) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should use require.NoError?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated. |
||
| addr = lis.Addr().String() | ||
| s := grpc.NewServer() | ||
| import_sstpb.RegisterImportSSTServer(s, &mockImportServer{ErrCount: 3}) | ||
|
|
||
|
|
@@ -102,7 +95,7 @@ func TestImportClient(t *testing.T) { | |
| require.NoError(t, err) | ||
| }() | ||
|
|
||
| client := importclient.NewImportClient(&storeClient{addr: fmt.Sprintf(":%d", 51111+port)}, nil, keepalive.ClientParameters{}) | ||
| client := importclient.NewImportClient(&storeClient{addr: addr}, nil, keepalive.ClientParameters{}) | ||
|
|
||
| { | ||
| resp, err := client.ClearFiles(ctx, 1, &import_sstpb.ClearRequest{Prefix: "test"}) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.