From 9e43f6a7e63bfcc2395e426ff38bcf39cb0970a1 Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Mon, 4 Apr 2022 19:52:02 +0700 Subject: [PATCH 01/12] run test 100 times Signed-off-by: Nikita Skrynnik --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 40bc91659..39fcf4227 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -33,7 +33,7 @@ jobs: - name: Build run: go build -race ./... - name: Test - run: go test -race ./... + run: go test -race ./... -run Test_RefreshNSEClient_SetsCorrectExpireTime -count 100 golangci-lint: name: golangci-lint runs-on: ubuntu-latest From 85e33589caa71e783fce7bc58ac9e4557c439337 Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Mon, 4 Apr 2022 22:32:03 +0700 Subject: [PATCH 02/12] add logs Signed-off-by: Nikita Skrynnik --- .github/workflows/ci.yaml | 4 ++-- pkg/registry/common/refresh/nse_registry_client.go | 3 +++ pkg/registry/common/refresh/nse_registry_client_test.go | 7 +++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 39fcf4227..00a96ae2a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -22,7 +22,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macos-latest, windows-latest] + os: [windows-latest] steps: - name: Check out code uses: actions/checkout@v2 @@ -33,7 +33,7 @@ jobs: - name: Build run: go build -race ./... - name: Test - run: go test -race ./... -run Test_RefreshNSEClient_SetsCorrectExpireTime -count 100 + run: go test -race ./... -run Test_RefreshNSEClient_SetsCorrectExpireTime -count 30 golangci-lint: name: golangci-lint runs-on: ubuntu-latest diff --git a/pkg/registry/common/refresh/nse_registry_client.go b/pkg/registry/common/refresh/nse_registry_client.go index ce154c377..f4a233d37 100644 --- a/pkg/registry/common/refresh/nse_registry_client.go +++ b/pkg/registry/common/refresh/nse_registry_client.go @@ -27,6 +27,7 @@ import ( "github.com/networkservicemesh/sdk/pkg/registry/common/begin" "github.com/networkservicemesh/sdk/pkg/registry/core/next" "github.com/networkservicemesh/sdk/pkg/tools/clock" + "github.com/networkservicemesh/sdk/pkg/tools/log" ) type refreshNSEClient struct { @@ -69,7 +70,9 @@ func (c *refreshNSEClient) Register(ctx context.Context, nse *registry.NetworkSe case <-refreshCtx.Done(): return case <-refreshCh: + log.FromContext(c.ctx).Infof("[REFRESH] Reregister begin") <-factory.Register(begin.CancelContext(refreshCtx)) + log.FromContext(c.ctx).Infof("[REFRESH] Reregister end") } }() } diff --git a/pkg/registry/common/refresh/nse_registry_client_test.go b/pkg/registry/common/refresh/nse_registry_client_test.go index d81f2cae7..a4df34e0e 100644 --- a/pkg/registry/common/refresh/nse_registry_client_test.go +++ b/pkg/registry/common/refresh/nse_registry_client_test.go @@ -39,6 +39,8 @@ import ( "github.com/networkservicemesh/sdk/pkg/tools/clock" "github.com/networkservicemesh/sdk/pkg/tools/clockmock" "github.com/networkservicemesh/sdk/pkg/tools/interdomain" + "github.com/networkservicemesh/sdk/pkg/tools/log" + "github.com/networkservicemesh/sdk/pkg/tools/log/logruslogger" ) const ( @@ -226,6 +228,9 @@ func Test_RefreshNSEClient_SetsCorrectExpireTime(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() + logger := logruslogger.New(ctx) + ctx = log.WithLog(ctx, logger) + clockMock := clockmock.New(ctx) ctx = clock.WithClock(ctx, clockMock) @@ -246,9 +251,11 @@ func Test_RefreshNSEClient_SetsCorrectExpireTime(t *testing.T) { count := int32(i) clockMock.Add(expireTimeout / 3 * 2) + logger.Info("[TEST] require.Eventually begin") require.Eventually(t, func() bool { return atomic.LoadInt32(&countClient.requestCount) > count }, testWait, testTick) + logger.Info("[TEST] require.Eventually end") // Wait for the Refresh to fully happen time.Sleep(testWait) From 8b19f5e481c7d78c907e1f2b1c31fb8ae6c28f83 Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Mon, 4 Apr 2022 23:28:13 +0700 Subject: [PATCH 03/12] increase testWait for require.Eventually Signed-off-by: Nikita Skrynnik --- pkg/registry/common/refresh/nse_registry_client_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/registry/common/refresh/nse_registry_client_test.go b/pkg/registry/common/refresh/nse_registry_client_test.go index a4df34e0e..c68dba037 100644 --- a/pkg/registry/common/refresh/nse_registry_client_test.go +++ b/pkg/registry/common/refresh/nse_registry_client_test.go @@ -45,7 +45,7 @@ import ( const ( expireTimeout = 3 * time.Minute - testWait = 100 * time.Millisecond + testWait = 300 * time.Millisecond testTick = testWait / 100 ) From d411804f5ab312068d42861e8bc51d3ef6aeac1e Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Mon, 4 Apr 2022 23:41:12 +0700 Subject: [PATCH 04/12] run test 300 times Signed-off-by: Nikita Skrynnik --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 00a96ae2a..3b1e79e44 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -33,7 +33,7 @@ jobs: - name: Build run: go build -race ./... - name: Test - run: go test -race ./... -run Test_RefreshNSEClient_SetsCorrectExpireTime -count 30 + run: go test -race ./... -run Test_RefreshNSEClient_SetsCorrectExpireTime -count 300 golangci-lint: name: golangci-lint runs-on: ubuntu-latest From 4f5ffe65b7c51eba1a0efb5f339703832ab6baf1 Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Mon, 4 Apr 2022 23:46:17 +0700 Subject: [PATCH 05/12] run test 2000 times Signed-off-by: Nikita Skrynnik --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3b1e79e44..73c2a288d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -33,7 +33,7 @@ jobs: - name: Build run: go build -race ./... - name: Test - run: go test -race ./... -run Test_RefreshNSEClient_SetsCorrectExpireTime -count 300 + run: go test -race ./... -run Test_RefreshNSEClient_SetsCorrectExpireTime -count 2000 golangci-lint: name: golangci-lint runs-on: ubuntu-latest From 287e6ef056edaff8fadc21f377e4f7fe47fb80b4 Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Tue, 5 Apr 2022 00:02:58 +0700 Subject: [PATCH 06/12] run test 1500 times Signed-off-by: Nikita Skrynnik --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 73c2a288d..d83209a69 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -33,7 +33,7 @@ jobs: - name: Build run: go build -race ./... - name: Test - run: go test -race ./... -run Test_RefreshNSEClient_SetsCorrectExpireTime -count 2000 + run: go test -race ./... -run Test_RefreshNSEClient_SetsCorrectExpireTime -count 1500 golangci-lint: name: golangci-lint runs-on: ubuntu-latest From b291988ec7b055a2e5b8133895265b9abd3ef8dc Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Tue, 5 Apr 2022 00:29:04 +0700 Subject: [PATCH 07/12] run test 1000 times Signed-off-by: Nikita Skrynnik --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d83209a69..943b36fa1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -33,7 +33,7 @@ jobs: - name: Build run: go build -race ./... - name: Test - run: go test -race ./... -run Test_RefreshNSEClient_SetsCorrectExpireTime -count 1500 + run: go test -race ./... -run Test_RefreshNSEClient_SetsCorrectExpireTime -count 1000 -timeout 20m golangci-lint: name: golangci-lint runs-on: ubuntu-latest From 5bb90535ad6383b4571fa14ecacf45d4ae0a562a Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Wed, 6 Apr 2022 15:50:08 +0700 Subject: [PATCH 08/12] run test 10000 times Signed-off-by: Nikita Skrynnik --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 943b36fa1..d086c9fda 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -33,7 +33,7 @@ jobs: - name: Build run: go build -race ./... - name: Test - run: go test -race ./... -run Test_RefreshNSEClient_SetsCorrectExpireTime -count 1000 -timeout 20m + run: go test -race ./... -run Test_RefreshNSEClient_SetsCorrectExpireTime -count 10000 -timeout 2000m golangci-lint: name: golangci-lint runs-on: ubuntu-latest From c2630bf4173da4ee08f03d98ebb512d3bf3d5bd9 Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Wed, 6 Apr 2022 23:56:17 +0700 Subject: [PATCH 09/12] increase testWait Signed-off-by: Nikita Skrynnik --- pkg/registry/common/refresh/nse_registry_client_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/registry/common/refresh/nse_registry_client_test.go b/pkg/registry/common/refresh/nse_registry_client_test.go index c68dba037..071ba4db7 100644 --- a/pkg/registry/common/refresh/nse_registry_client_test.go +++ b/pkg/registry/common/refresh/nse_registry_client_test.go @@ -45,7 +45,7 @@ import ( const ( expireTimeout = 3 * time.Minute - testWait = 300 * time.Millisecond + testWait = 400 * time.Millisecond testTick = testWait / 100 ) From cd6a78de989e18d184f8caa1768f30246eaa734b Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Thu, 7 Apr 2022 14:57:14 +0700 Subject: [PATCH 10/12] cleanup Signed-off-by: Nikita Skrynnik --- .github/workflows/ci.yaml | 2 +- pkg/registry/common/refresh/nse_registry_client.go | 3 --- .../common/refresh/nse_registry_client_test.go | 11 ++--------- 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d086c9fda..540a57cde 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -22,7 +22,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [windows-latest] + os: [ubuntu-latest, macos-latest, windows-latest] steps: - name: Check out code uses: actions/checkout@v2 diff --git a/pkg/registry/common/refresh/nse_registry_client.go b/pkg/registry/common/refresh/nse_registry_client.go index f4a233d37..ce154c377 100644 --- a/pkg/registry/common/refresh/nse_registry_client.go +++ b/pkg/registry/common/refresh/nse_registry_client.go @@ -27,7 +27,6 @@ import ( "github.com/networkservicemesh/sdk/pkg/registry/common/begin" "github.com/networkservicemesh/sdk/pkg/registry/core/next" "github.com/networkservicemesh/sdk/pkg/tools/clock" - "github.com/networkservicemesh/sdk/pkg/tools/log" ) type refreshNSEClient struct { @@ -70,9 +69,7 @@ func (c *refreshNSEClient) Register(ctx context.Context, nse *registry.NetworkSe case <-refreshCtx.Done(): return case <-refreshCh: - log.FromContext(c.ctx).Infof("[REFRESH] Reregister begin") <-factory.Register(begin.CancelContext(refreshCtx)) - log.FromContext(c.ctx).Infof("[REFRESH] Reregister end") } }() } diff --git a/pkg/registry/common/refresh/nse_registry_client_test.go b/pkg/registry/common/refresh/nse_registry_client_test.go index 071ba4db7..629e8f15e 100644 --- a/pkg/registry/common/refresh/nse_registry_client_test.go +++ b/pkg/registry/common/refresh/nse_registry_client_test.go @@ -39,13 +39,11 @@ import ( "github.com/networkservicemesh/sdk/pkg/tools/clock" "github.com/networkservicemesh/sdk/pkg/tools/clockmock" "github.com/networkservicemesh/sdk/pkg/tools/interdomain" - "github.com/networkservicemesh/sdk/pkg/tools/log" - "github.com/networkservicemesh/sdk/pkg/tools/log/logruslogger" ) const ( expireTimeout = 3 * time.Minute - testWait = 400 * time.Millisecond + testWait = 100 * time.Millisecond testTick = testWait / 100 ) @@ -228,9 +226,6 @@ func Test_RefreshNSEClient_SetsCorrectExpireTime(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - logger := logruslogger.New(ctx) - ctx = log.WithLog(ctx, logger) - clockMock := clockmock.New(ctx) ctx = clock.WithClock(ctx, clockMock) @@ -251,11 +246,9 @@ func Test_RefreshNSEClient_SetsCorrectExpireTime(t *testing.T) { count := int32(i) clockMock.Add(expireTimeout / 3 * 2) - logger.Info("[TEST] require.Eventually begin") require.Eventually(t, func() bool { return atomic.LoadInt32(&countClient.requestCount) > count - }, testWait, testTick) - logger.Info("[TEST] require.Eventually end") + }, 4*testWait, testTick) // Wait for the Refresh to fully happen time.Sleep(testWait) From 6b49c23ca94141455a441d25c9a2687ac9612c1e Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Thu, 7 Apr 2022 17:31:07 +0700 Subject: [PATCH 11/12] run test 100000 times Signed-off-by: Nikita Skrynnik --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 540a57cde..0d6d806d3 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -33,7 +33,7 @@ jobs: - name: Build run: go build -race ./... - name: Test - run: go test -race ./... -run Test_RefreshNSEClient_SetsCorrectExpireTime -count 10000 -timeout 2000m + run: go test -race ./... -run Test_RefreshNSEClient_SetsCorrectExpireTime -count 100000 -timeout 2000m golangci-lint: name: golangci-lint runs-on: ubuntu-latest From a0c7d2bb6838639049c8f92af46ccefabe5f336a Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Fri, 8 Apr 2022 22:07:27 +0700 Subject: [PATCH 12/12] cleanup Signed-off-by: Nikita Skrynnik --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0d6d806d3..40bc91659 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -33,7 +33,7 @@ jobs: - name: Build run: go build -race ./... - name: Test - run: go test -race ./... -run Test_RefreshNSEClient_SetsCorrectExpireTime -count 100000 -timeout 2000m + run: go test -race ./... golangci-lint: name: golangci-lint runs-on: ubuntu-latest