Skip to content

Commit

Permalink
PMM-7 fix TestPerDBInstanceLimit. (#3120)
Browse files Browse the repository at this point in the history
  • Loading branch information
BupycHuk authored Aug 1, 2024
1 parent a598c48 commit a06f8fd
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions agent/runner/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,36 +156,36 @@ func TestPerDBInstanceLimit(t *testing.T) {
db2j2 := testJob{id: "test-5", timeout: time.Second, dsn: "postgresql://db2"}
db2j3 := testJob{id: "test-6", timeout: time.Second, dsn: "postgresql://db2"}

require.NoError(t, cr.StartJob(db1j1))
require.NoError(t, cr.StartJob(db2j1))
require.NoError(t, cr.StartJob(db1j1), "start job db1j1 failed")
require.NoError(t, cr.StartJob(db2j1), "start job db2j1 failed")

// Let jobs to start
time.Sleep(200 * time.Millisecond)

require.NoError(t, cr.StartJob(db1j2))
require.NoError(t, cr.StartJob(db2j2))
require.NoError(t, cr.StartJob(db1j3))
require.NoError(t, cr.StartJob(db2j3))
require.NoError(t, cr.StartJob(db1j2), "start job db1j2 failed")
require.NoError(t, cr.StartJob(db2j2), "start job db2j2 failed")
require.NoError(t, cr.StartJob(db1j3), "start job db1j3 failed")
require.NoError(t, cr.StartJob(db2j3), "start job db2j3 failed")

// Let rest jobs to reach semaphores
time.Sleep(300 * time.Millisecond)

assert.True(t, cr.IsRunning(db1j1.ID()))
assert.True(t, cr.IsRunning(db2j1.ID()))
assert.False(t, cr.IsRunning(db1j2.ID()))
assert.False(t, cr.IsRunning(db2j2.ID()))
assert.False(t, cr.IsRunning(db1j3.ID()))
assert.False(t, cr.IsRunning(db2j3.ID()))
assert.True(t, cr.IsRunning(db1j1.ID()), "db1j1 is not running")
assert.True(t, cr.IsRunning(db2j1.ID()), "db2j1 is not running")
assert.False(t, cr.IsRunning(db1j2.ID()), "db1j2 is running")
assert.False(t, cr.IsRunning(db2j2.ID()), "db2j2 is running")
assert.False(t, cr.IsRunning(db1j3.ID()), "db1j3 is running")
assert.False(t, cr.IsRunning(db2j3.ID()), "db2j3 is running")

// Over time all jobs are terminated
time.Sleep(2 * time.Second)

assert.False(t, cr.IsRunning(db1j1.ID()))
assert.False(t, cr.IsRunning(db2j1.ID()))
assert.False(t, cr.IsRunning(db1j2.ID()))
assert.False(t, cr.IsRunning(db2j2.ID()))
assert.False(t, cr.IsRunning(db1j3.ID()))
assert.False(t, cr.IsRunning(db2j3.ID()))
time.Sleep(3 * time.Second)

assert.False(t, cr.IsRunning(db1j1.ID()), "db1j1 is running")
assert.False(t, cr.IsRunning(db2j1.ID()), "db2j1 is running")
assert.False(t, cr.IsRunning(db1j2.ID()), "db1j2 is running")
assert.False(t, cr.IsRunning(db2j2.ID()), "db2j2 is running")
assert.False(t, cr.IsRunning(db1j3.ID()), "db1j3 is running")
assert.False(t, cr.IsRunning(db2j3.ID()), "db2j3 is running")
}

func TestDefaultPerDBInstanceLimit(t *testing.T) {
Expand Down

0 comments on commit a06f8fd

Please sign in to comment.