Skip to content
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

[FIXED] Flaky tests picking same ports more than once #1284

Merged
merged 2 commits into from
Jun 1, 2023
Merged

Conversation

piotrpio
Copy link
Collaborator

@piotrpio piotrpio commented Jun 1, 2023

Some clustered tests were failing with "Unable to start NATS Server in Go Routine" panic from server.

This was most probably caused by client choosing random server/cluster ports, where it sometimes chose same port more than once, as observed by adding this log after each test using withJSCluster()

=== RUN   TestJetStreamConsumerReplicasOption/TestJetStreamConsumerReplicasOption-3

Server 0 , server name:  NODE_0 , server port:  38473 , cluster port:  44391 , routes:  [127.0.0.1:44391 127.0.0.1:44625 127.0.0.1:38473]

Server 1 , server name:  NODE_1 , server port:  39243 , cluster port:  44625 , routes:  [127.0.0.1:44391 127.0.0.1:44625 127.0.0.1:38473]

Server 2 , server name:  NODE_2 , server port:  45755 , cluster port:  38473 , routes:  [127.0.0.1:44391 127.0.0.1:44625 127.0.0.1:38473]

In the example above, the test panicked because server port on Server 0 was the same as cluster port on Server 2.

scripts/cov.sh Outdated
go test -modfile=go_test.mod --failfast -vet=off -v -covermode=atomic -coverprofile=./cov/jetstream.out -coverpkg=github.com/nats-io/nats.go/jetstream ./jetstream/test -tags=skip_no_race_tests
go test -modfile=go_test.mod --failfast -vet=off -v -covermode=atomic -coverprofile=./cov/builtin.out -coverpkg=github.com/nats-io/nats.go/encoders/builtin ./test -run EncBuiltin -tags=skip_no_race_tests
go test -modfile=go_test.mod --failfast -vet=off -v -covermode=atomic -coverprofile=./cov/protobuf.out -coverpkg=github.com/nats-io/nats.go/encoders/protobuf ./test -run EncProto -tags=skip_no_race_tests
# go test -modfile=go_test.mod --failfast -vet=off -v -covermode=atomic -coverprofile=./cov/jetstream.out -coverpkg=github.com/nats-io/nats.go/jetstream ./jetstream/test -tags=skip_no_race_tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will these be uncommented before merging?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I though I did that!

Signed-off-by: Piotr Piotrowski <piotr@synadia.com>
test/js_test.go Outdated Show resolved Hide resolved
Signed-off-by: Piotr Piotrowski <piotr@synadia.com>
Copy link
Member

@wallyqs wallyqs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@piotrpio piotrpio merged commit 21df434 into main Jun 1, 2023
2 checks passed
@piotrpio piotrpio deleted the fix-test-panic branch June 1, 2023 15:52
@piotrpio piotrpio mentioned this pull request Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants