Skip to content

Commit da38b95

Browse files
committed
handle 'container is marked for removal and cannot be started' and the like
1 parent ecab120 commit da38b95

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

chaos_tests/chaos_test.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,25 @@ func PostgresChaosMonkey(t *testing.T, ctx context.Context, wg *sync.WaitGroup)
114114

115115
// Stop PostgreSQL
116116
t.Logf("🐒 Chaos Monkey: Stopping PostgreSQL")
117-
stopPostgres(t, cliPath)
117+
require.Eventually(t, func() bool {
118+
stopPostgres(t, cliPath)
119+
return true
120+
}, 5*time.Second, 100*time.Millisecond)
118121

119122
// Sleep for random down time
120123
select {
121124
case <-time.After(downTime):
122125
// Start PostgreSQL again
123-
startPostgres(t, cliPath)
126+
require.Eventually(t, func() bool {
127+
startPostgres(t, cliPath)
128+
return true
129+
}, 5*time.Second, 100*time.Millisecond)
124130
case <-ctx.Done():
125131
// Ensure PostgreSQL is started before exiting
126-
startPostgres(t, cliPath)
132+
require.Eventually(t, func() bool {
133+
startPostgres(t, cliPath)
134+
return true
135+
}, 5*time.Second, 100*time.Millisecond)
127136
return
128137
}
129138

0 commit comments

Comments
 (0)