diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 80e138ef09..674099c7c4 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -60,4 +60,4 @@ jobs: restore-keys: ${{ runner.os }}-go-mod - name: Run integration tests - run: go test -timeout=30m -tags integration ${{ matrix.packages }} + run: go test -timeout=45m -tags integration ${{ matrix.packages }} diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 9924289545..0132ee7cc0 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -67,7 +67,7 @@ jobs: echo "$HOME/.local/bin" >> $GITHUB_PATH - name: Run unit tests - run: go test -short -coverprofile=coverage.out -covermode=atomic -timeout=30m ./... + run: go test -short -coverprofile=coverage.out -covermode=atomic -timeout=45m ./... - name: Test State - Race run: make test-state-race diff --git a/dot/peerset/peerset.go b/dot/peerset/peerset.go index df19ec2d51..dea6956f90 100644 --- a/dot/peerset/peerset.go +++ b/dot/peerset/peerset.go @@ -712,15 +712,28 @@ func (ps *PeerSet) start(ctx context.Context, actionQueue chan action) { ps.actionQueue = actionQueue ps.resultMsgCh = make(chan Message, msgChanSize) - go ps.listenAction(ctx) - go ps.periodicallyAllocateSlots(ctx) + go ps.listenActionAllocSlots(ctx) } -func (ps *PeerSet) listenAction(ctx context.Context) { +func (ps *PeerSet) listenActionAllocSlots(ctx context.Context) { + ticker := time.NewTicker(ps.nextPeriodicAllocSlots) + + defer func() { + ticker.Stop() + close(ps.resultMsgCh) + }() + for { select { case <-ctx.Done(): + logger.Debugf("peerset slot allocation exiting: %s", ctx.Err()) return + case <-ticker.C: + for setID := 0; setID < ps.peerState.getSetLength(); setID++ { + if err := ps.allocSlots(setID); err != nil { + logger.Warnf("failed to allocate slots: %s", err) + } + } case act, ok := <-ps.actionQueue: if !ok { return @@ -758,26 +771,3 @@ func (ps *PeerSet) listenAction(ctx context.Context) { } } } - -func (ps *PeerSet) periodicallyAllocateSlots(ctx context.Context) { - ticker := time.NewTicker(ps.nextPeriodicAllocSlots) - - defer func() { - ticker.Stop() - close(ps.resultMsgCh) - }() - - for { - select { - case <-ctx.Done(): - logger.Debugf("peerset slot allocation exiting: %s", ctx.Err()) - return - case <-ticker.C: - for setID := 0; setID < ps.peerState.getSetLength(); setID++ { - if err := ps.allocSlots(setID); err != nil { - logger.Warnf("failed to allocate slots: %s", err) - } - } - } - } -}