Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix race condition in ramping-vus tests #3760

Merged
merged 1 commit into from
May 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 26 additions & 22 deletions lib/executor/ramping_vus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,49 +20,53 @@ import (

func TestRampingVUsConfigValidation(t *testing.T) {
t.Parallel()
const maxConcurrentVUs = 100_000_000

errs := NewRampingVUsConfig("default").Validate()
require.NotEmpty(t, errs)
assert.Contains(t, errs[0].Error(), "one stage has to be specified")

c := NewRampingVUsConfig("stage")
c.Stages = []Stage{
{Target: null.IntFrom(0), Duration: types.NullDurationFrom(12 * time.Second)},
}
errs = c.Validate()
require.Empty(t, errs) // by default StartVUs is 1

c.StartVUs = null.IntFrom(0)
errs = c.Validate()
require.NotEmpty(t, errs)
assert.Contains(t, errs[0].Error(), "greater than 0")
t.Run("no stages", func(t *testing.T) {
t.Parallel()
errs := NewRampingVUsConfig("default").Validate()
require.NotEmpty(t, errs)
assert.Contains(t, errs[0].Error(), "one stage has to be specified")
})
t.Run("basic 1 stage", func(t *testing.T) {
t.Parallel()
c := NewRampingVUsConfig("stage")
c.Stages = []Stage{
{Target: null.IntFrom(0), Duration: types.NullDurationFrom(12 * time.Second)},
}
errs := c.Validate()
require.Empty(t, errs) // by default StartVUs is 1

const maxConcurrentVUs = 100_000_000
c.StartVUs = null.IntFrom(0)
errs = c.Validate()
require.NotEmpty(t, errs)
assert.Contains(t, errs[0].Error(), "greater than 0")
})

t.Run("If startVUs are larger than maxConcurrentVUs, the validation should return an error", func(t *testing.T) {
t.Parallel()

c = NewRampingVUsConfig("stage")
c := NewRampingVUsConfig("stage")
c.StartVUs = null.IntFrom(maxConcurrentVUs + 1)
c.Stages = []Stage{
{Target: null.IntFrom(0), Duration: types.NullDurationFrom(1 * time.Second)},
}

errs = c.Validate()
errs := c.Validate()
require.NotEmpty(t, errs)
assert.Contains(t, errs[0].Error(), "the startVUs exceed max limit of")
})

t.Run("For multiple VU values larger than maxConcurrentVUs, multiple errors are returned", func(t *testing.T) {
t.Parallel()

c = NewRampingVUsConfig("stage")
c := NewRampingVUsConfig("stage")
c.StartVUs = null.IntFrom(maxConcurrentVUs + 1)
c.Stages = []Stage{
{Target: null.IntFrom(maxConcurrentVUs + 2), Duration: types.NullDurationFrom(1 * time.Second)},
}

errs = c.Validate()
errs := c.Validate()
require.Equal(t, 2, len(errs))
assert.Contains(t, errs[0].Error(), "the startVUs exceed max limit of")

Expand All @@ -72,13 +76,13 @@ func TestRampingVUsConfigValidation(t *testing.T) {
t.Run("VU values below maxConcurrentVUs will pass validation", func(t *testing.T) {
t.Parallel()

c = NewRampingVUsConfig("stage")
c := NewRampingVUsConfig("stage")
c.StartVUs = null.IntFrom(0)
c.Stages = []Stage{
{Target: null.IntFrom(maxConcurrentVUs - 1), Duration: types.NullDurationFrom(1 * time.Second)},
}

errs = c.Validate()
errs := c.Validate()
require.Empty(t, errs)
})
}
Expand Down