Skip to content

Commit

Permalink
e2e: cleanup errors should use assert, not require (#8989)
Browse files Browse the repository at this point in the history
The E2E framework wraps testify's `require` so that by default we can stop
tests on errors, but the cleanup functions should use `assert` so that we
continue to try to cleanup the test environment even if there's a failure.
  • Loading branch information
tgross authored Sep 30, 2020
1 parent ce1c15a commit 8cf583f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions e2e/nodedrain/nodedrain.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ func (tc *NodeDrainE2ETest) AfterEach(f *framework.F) {

for _, id := range tc.jobIDs {
_, err := e2e.Command("nomad", "job", "stop", "-purge", id)
f.NoError(err)
f.Assert().NoError(err)
}
tc.jobIDs = []string{}

for _, id := range tc.nodeIDs {
_, err := e2e.Command("nomad", "node", "drain", "-disable", "-yes", id)
f.NoError(err)
f.Assert().NoError(err)
}
tc.nodeIDs = []string{}

_, err := e2e.Command("nomad", "system", "gc")
f.NoError(err)
f.Assert().NoError(err)
}

func nodesForJob(jobID string) ([]string, error) {
Expand Down
4 changes: 2 additions & 2 deletions e2e/rescheduling/rescheduling.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ func (tc *RescheduleE2ETest) AfterEach(f *framework.F) {

for _, id := range tc.jobIds {
_, err := e2e.Command("nomad", "job", "stop", "-purge", id)
f.NoError(err)
f.Assert().NoError(err)
}
tc.jobIds = []string{}
_, err := e2e.Command("nomad", "system", "gc")
f.NoError(err)
f.Assert().NoError(err)
}

// TestNoReschedule runs a job that should fail and never reschedule
Expand Down
4 changes: 2 additions & 2 deletions e2e/volumes/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ func (tc *VolumesTest) AfterEach(f *framework.F) {

for _, id := range tc.jobIDs {
_, err := e2e.Command("nomad", "job", "stop", "-purge", id)
f.NoError(err)
f.Assert().NoError(err)
}
tc.jobIDs = []string{}

_, err := e2e.Command("nomad", "system", "gc")
f.NoError(err)
f.Assert().NoError(err)
}

// TestVolumeMounts exercises host volume and Docker volume functionality for
Expand Down

0 comments on commit 8cf583f

Please sign in to comment.