From 6e5cd103997b4176dbacaafbb51a545a3f736895 Mon Sep 17 00:00:00 2001 From: Emmanuel Odeke Date: Wed, 25 Oct 2017 19:20:33 -0700 Subject: [PATCH] rpc/lib/client: jitter test updates and only to-be run on releases * Updated code with feedback from @melekes, @ebuchman and @silasdavis. * Added Makefile clause `release` to only run the test on seeing tag `release` during releases i.e ```shell make release ``` which will run the comprehensive and long integration-ish tests. --- Makefile | 3 ++ rpc/lib/client/integration_test.go | 66 ++++++++++++++++++++++++++++++ rpc/lib/client/ws_client.go | 7 ++-- rpc/lib/client/ws_client_test.go | 55 ------------------------- 4 files changed, 73 insertions(+), 58 deletions(-) create mode 100644 rpc/lib/client/integration_test.go diff --git a/Makefile b/Makefile index dfb0dc3a9..2271abebf 100644 --- a/Makefile +++ b/Makefile @@ -35,6 +35,9 @@ test_race: test_integrations: @bash ./test/test.sh +release: + @go test -tags release $(PACKAGES) + test100: @for i in {1..100}; do make test; done diff --git a/rpc/lib/client/integration_test.go b/rpc/lib/client/integration_test.go new file mode 100644 index 000000000..d3d993374 --- /dev/null +++ b/rpc/lib/client/integration_test.go @@ -0,0 +1,66 @@ +// +build release + +// The code in here is comprehensive as an integration +// test and is long, hence is only run before releases. + +package rpcclient + +import ( + "bytes" + "errors" + "net" + "regexp" + "testing" + "time" + + "github.com/stretchr/testify/require" + "github.com/tendermint/tmlibs/log" +) + +func TestWSClientReconnectWithJitter(t *testing.T) { + n := 8 + maxReconnectAttempts := 3 + // Max wait time is ceil(1+0.999) + ceil(2+0.999) + ceil(4+0.999) + ceil(...) = 2 + 3 + 5 = 10s + ... + maxSleepTime := time.Second * time.Duration(((1<