Skip to content

Commit

Permalink
e2e: do not use eventually when waiting for allocs
Browse files Browse the repository at this point in the history
This test is causing panics. Unlike the other similar tests, this
one is using require.Eventually which is doing something bad, and
this change replaces it with a for-loop like the other tests.

Failure:

=== RUN   TestE2E/Connect
=== RUN   TestE2E/Connect/*connect.ConnectE2ETest
=== RUN   TestE2E/Connect/*connect.ConnectE2ETest/TestConnectDemo
=== RUN   TestE2E/Connect/*connect.ConnectE2ETest/TestMultiServiceConnect
=== RUN   TestE2E/Connect/*connect.ConnectClientStateE2ETest
panic: Fail in goroutine after TestE2E/Connect/*connect.ConnectE2ETest has completed

goroutine 38 [running]:
testing.(*common).Fail(0xc000656500)
	/opt/google/go/src/testing/testing.go:565 +0x11e
testing.(*common).Fail(0xc000656100)
	/opt/google/go/src/testing/testing.go:559 +0x96
testing.(*common).FailNow(0xc000656100)
	/opt/google/go/src/testing/testing.go:587 +0x2b
testing.(*common).Fatalf(0xc000656100, 0x1512f90, 0x10, 0xc000675f88, 0x1, 0x1)
	/opt/google/go/src/testing/testing.go:672 +0x91
github.com/hashicorp/nomad/e2e/connect.(*ConnectE2ETest).TestMultiServiceConnect.func1(0x0)
	/home/shoenig/go/src/github.com/hashicorp/nomad/e2e/connect/multi_service.go:72 +0x296
github.com/hashicorp/nomad/vendor/github.com/stretchr/testify/assert.Eventually.func1(0xc0004962a0, 0xc0002338f0)
	/home/shoenig/go/src/github.com/hashicorp/nomad/vendor/github.com/stretchr/testify/assert/assertions.go:1494 +0x27
created by github.com/hashicorp/nomad/vendor/github.com/stretchr/testify/assert.Eventually
	/home/shoenig/go/src/github.com/hashicorp/nomad/vendor/github.com/stretchr/testify/assert/assertions.go:1493 +0x272
FAIL	github.com/hashicorp/nomad/e2e	21.427s
  • Loading branch information
shoenig committed Jan 24, 2020
1 parent 7cfe726 commit d51f8c9
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions e2e/connect/multi_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ EVAL:
require.Len(t, eval.QueuedAllocations, 1, pretty.Sprint(eval.QueuedAllocations))

// Assert allocs are running
require.Eventually(t, func() bool {
for i := 0; i < 20; i++ {
allocs, qmeta, err := evalapi.Allocations(eval.ID, qopts)
require.NoError(t, err)
require.Len(t, allocs, 1)
Expand All @@ -69,15 +69,16 @@ EVAL:
case "pending":
// keep trying
default:
t.Fatalf("alloc failed: %s", pretty.Sprint(alloc))
require.Failf(t, "alloc failed", "alloc: %s", pretty.Sprint(alloc))
}
}

if running == len(allocs) {
return true
break
}
return false
}, 10*time.Second, 500*time.Millisecond)

time.Sleep(500 * time.Millisecond)
}

allocs, _, err := evalapi.Allocations(eval.ID, qopts)
require.NoError(t, err)
Expand Down

0 comments on commit d51f8c9

Please sign in to comment.