diff --git a/.github/workflows/go_test.yml b/.github/workflows/go_test.yml index 19ecb2f..c9d1966 100644 --- a/.github/workflows/go_test.yml +++ b/.github/workflows/go_test.yml @@ -14,7 +14,7 @@ go-version: - "1.21" - "1.22" -# - "1.23" + - "1.23" name: lint and test runs-on: ubuntu-latest steps: @@ -25,8 +25,8 @@ with: go-version: ${{ matrix.go-version }} - name: golangci-lint - uses: golangci/golangci-lint-action@v6.5.0 + uses: golangci/golangci-lint-action@v6.3.2 with: - version: v1.59.1 + version: v1.61.0 - name: test run: make test_ci diff --git a/Makefile b/Makefile index de74714..c5ba90b 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ test_coverage: @go test -race -v $(GO_FLAGS) -count=1 -coverprofile=coverage.out -covermode=atomic $(GO_PKGS) test_ci: - @TEST_ENV=ci go test -race -v $(GO_FLAGS) -count=1 $(GO_PKGS) + @go test -race -v $(GO_FLAGS) -count=1 $(GO_PKGS) mocks: @go generate ./... diff --git a/scheduler_test.go b/scheduler_test.go index edc0ffe..9f84562 100644 --- a/scheduler_test.go +++ b/scheduler_test.go @@ -362,6 +362,7 @@ func TestScheduler_StopTimeout(t *testing.T) { } func TestScheduler_StopLongRunningJobs(t *testing.T) { + defer verifyNoGoroutineLeaks(t) t.Run("start, run job, stop jobs before job is completed", func(t *testing.T) { s := newTestScheduler(t, WithStopTimeout(50*time.Millisecond), @@ -393,6 +394,8 @@ func TestScheduler_StopLongRunningJobs(t *testing.T) { // the running job is canceled, no unexpected timeout error require.NoError(t, s.StopJobs()) time.Sleep(100 * time.Millisecond) + + require.NoError(t, s.Shutdown()) }) t.Run("start, run job, stop jobs before job is completed - manual context cancel", func(t *testing.T) { s := newTestScheduler(t, @@ -428,6 +431,8 @@ func TestScheduler_StopLongRunningJobs(t *testing.T) { cancel() require.NoError(t, s.StopJobs()) time.Sleep(100 * time.Millisecond) + + require.NoError(t, s.Shutdown()) }) t.Run("start, run job, stop jobs before job is completed - manual context cancel WithContext", func(t *testing.T) { s := newTestScheduler(t, @@ -464,18 +469,18 @@ func TestScheduler_StopLongRunningJobs(t *testing.T) { cancel() require.NoError(t, s.StopJobs()) time.Sleep(100 * time.Millisecond) + + require.NoError(t, s.Shutdown()) }) } func TestScheduler_StopAndStartLongRunningJobs(t *testing.T) { + defer verifyNoGoroutineLeaks(t) t.Run("start, run job, stop jobs before job is completed", func(t *testing.T) { s := newTestScheduler(t, WithStopTimeout(50*time.Millisecond), ) - restart := false - restartP := &restart - _, err := s.NewJob( DurationJob( 50*time.Millisecond, @@ -484,14 +489,7 @@ func TestScheduler_StopAndStartLongRunningJobs(t *testing.T) { func(ctx context.Context) { select { case <-ctx.Done(): - if *restartP { - t.Fatal("job should not been canceled after restart") - } case <-time.After(100 * time.Millisecond): - if !*restartP { - t.Fatal("job can not been canceled") - } - } }, ), @@ -508,11 +506,10 @@ func TestScheduler_StopAndStartLongRunningJobs(t *testing.T) { // the running job is canceled, no unexpected timeout error require.NoError(t, s.StopJobs()) - *restartP = true - s.Start() time.Sleep(200 * time.Millisecond) + require.NoError(t, s.Shutdown()) }) }