Skip to content

Commit

Permalink
chore: test with Go 1.22 (#1352)
Browse files Browse the repository at this point in the history
- Rather than hard-coding the Go version in the workflow, we will use the
  `stable` and `oldstable` tags which today resolve to 1.22.0 and 1.21.7,
  but will float as Go versions change.
- Some anonymous function names seem to have changed in Go 1.22 and a
  test had to be modified as a result
  • Loading branch information
blgm authored Feb 7, 2024
1 parent 17ae120 commit 898cba9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: '1.20'
go-version: 'oldstable'
- uses: actions/checkout@v4
- run: go mod tidy && git diff --exit-code go.mod go.sum
build:
runs-on: ubuntu-latest
strategy:
matrix:
version: [ '1.20', '1.21' ]
version: [ 'oldstable', 'stable' ]
name: Go ${{ matrix.version }}
steps:
- uses: actions/setup-go@v5
Expand Down
6 changes: 6 additions & 0 deletions integration/profiling_go1.21_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//go:build !go1.22

package integration_test

// lockContestPrefix is the function name prefix with Go 1.21 and earlier
const lockContestPrefix = "lock_contest_test.glob.."
6 changes: 6 additions & 0 deletions integration/profiling_go1.22_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//go:build go1.22

package integration_test

// lockContestPrefix is the function name prefix with Go 1.22 and later
const lockContestPrefix = "lock_contest_test.init."
9 changes: 5 additions & 4 deletions integration/profiling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,14 @@ var _ = Describe("Profiling Specs", func() {
// The MutexProfile for the lock_contest test should list two functions that wait on a lock.
// Unfortunately go doesn't seem to capture the names of the functions - so they're listed here as
// lock_contest_test.glob..func1.1 is called 10 times and takes ~5ms per call
// lock_contest_test.glob..func2.1 is called once and teakes ~500ms per call
// lock_contest_test.glob..func2.1 is called once and takes ~500ms per call
// Note that in Go 1.22 and later, the functions are called lock_contest_test.init.func1.1 and lock_contest_test.init.func2.1
// Asserting that both times are within a range should be stable across tests. The function names should be as well
// but that might become a source of failure in the future
// Note: these numbers are adjusted slightly to tolerate variance during test runs
Ω(mutexProfile.FindCaller("lock_contest_test.glob..func1.1").CumStat).Should(BeNumerically(">=", 45))
Ω(mutexProfile.FindCaller("lock_contest_test.glob..func1.1").CumStat).Should(BeNumerically("<", 500))
Ω(mutexProfile.FindCaller("lock_contest_test.glob..func2.1").CumStat).Should(BeNumerically(">=", 450))
Ω(mutexProfile.FindCaller(fmt.Sprintf("%sfunc1.1", lockContestPrefix)).CumStat).Should(BeNumerically(">=", 45))
Ω(mutexProfile.FindCaller(fmt.Sprintf("%sfunc1.1", lockContestPrefix)).CumStat).Should(BeNumerically("<", 500))
Ω(mutexProfile.FindCaller(fmt.Sprintf("%sfunc2.1", lockContestPrefix)).CumStat).Should(BeNumerically(">=", 450))
},

Entry("when running in series",
Expand Down

0 comments on commit 898cba9

Please sign in to comment.