Skip to content

Commit

Permalink
re-enable goleak detection in ci (#832)
Browse files Browse the repository at this point in the history
* re-enable goleak detection in ci

* fix version string

* re-add go 1.23
  • Loading branch information
JohnRoesler authored Feb 17, 2025
1 parent 129f89c commit 08b53d7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/go_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
go-version:
- "1.21"
- "1.22"
# - "1.23"
- "1.23"
name: lint and test
runs-on: ubuntu-latest
steps:
Expand All @@ -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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ./...
21 changes: 9 additions & 12 deletions scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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")
}

}
},
),
Expand All @@ -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())
})
}

Expand Down

0 comments on commit 08b53d7

Please sign in to comment.