Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Nikita Skrynnik <nikita.skrynnik@xored.com>
  • Loading branch information
NikitaSkrynnik committed Apr 7, 2022
1 parent fc2990b commit 4498903
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,7 +33,8 @@ 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 ./... log.FromContext(c.ctx).Infof("[REFRESH] Reregister end")

golangci-lint:
name: golangci-lint
runs-on: ubuntu-latest
Expand Down
3 changes: 0 additions & 3 deletions pkg/registry/common/refresh/nse_registry_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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")
}
}()
}
Expand Down
11 changes: 2 additions & 9 deletions pkg/registry/common/refresh/nse_registry_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down Expand Up @@ -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)

Expand All @@ -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)
Expand Down

0 comments on commit 4498903

Please sign in to comment.