Skip to content

Commit

Permalink
Improve(?) integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
mortenlj committed Apr 24, 2024
1 parent 3114457 commit 9633243
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pkg/election/candidate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,12 @@ func newTestRig(t *testing.T) (*testRig, error) {
rig.electionResults = make(chan string)

rig.fakeClock = testclock.FakeClock{}
logger := logrus.New()
logger.Level = logrus.DebugLevel
rig.candidate = Candidate{
Client: rig.client,
Clock: &rig.fakeClock,
Logger: logrus.New(),
Logger: logger,
ElectionResults: rig.electionResults,
ElectionName: types.NamespacedName{
Namespace: namespace,
Expand Down Expand Up @@ -203,8 +205,8 @@ func TestCandidate_WinRaceToElection(t *testing.T) {
t.FailNow()
}

// Allow 15 seconds for test to complete
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
// Allow 25 seconds for test to complete
ctx, cancel := context.WithTimeout(context.Background(), 25*time.Second)
t.Cleanup(cancel)

rig.commonSetupForTest(ctx)
Expand All @@ -231,7 +233,8 @@ func TestCandidate_WinRaceToElection(t *testing.T) {
t.Errorf("failed to delete lease")
cancel()
}
rig.fakeClock.Step(1 * time.Minute)
time.Sleep(1 * time.Second)
rig.fakeClock.Step(65 * time.Second)
}()

run(t, rig, ctx)
Expand Down

0 comments on commit 9633243

Please sign in to comment.