Skip to content

Commit

Permalink
e2e: remove gometa from e2eutils (#7610)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross committed Apr 3, 2020
1 parent e577dfe commit 17ffbde
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions e2e/e2eutil/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/hashicorp/nomad/nomad/structs"
"github.com/hashicorp/nomad/testutil"
"github.com/kr/pretty"
. "github.com/onsi/gomega"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -62,11 +61,10 @@ func stringToPtrOrNil(s string) *string {
}

func RegisterAllocs(t *testing.T, nomadClient *api.Client, jobFile, jobID, cToken string) []*api.AllocationListStub {
r := require.New(t)

// Parse job
job, err := jobspec.ParseFile(jobFile)
r.Nil(err)
require.NoError(t, err)

// Set custom job ID (distinguish among tests)
job.ID = helper.StringToPtr(jobID)
Expand All @@ -85,7 +83,7 @@ func RegisterAllocs(t *testing.T, nomadClient *api.Client, jobFile, jobID, cToke
idx = meta.LastIndex
return resp.EvalID != "", fmt.Errorf("expected EvalID:%s", pretty.Sprint(resp))
}, func(err error) {
r.NoError(err)
require.NoError(t, err)
})

allocs, _, err := jobs.Allocations(jobID, false, &api.QueryOptions{WaitIndex: idx})
Expand All @@ -94,22 +92,20 @@ func RegisterAllocs(t *testing.T, nomadClient *api.Client, jobFile, jobID, cToke
}

func RegisterAndWaitForAllocs(t *testing.T, nomadClient *api.Client, jobFile, jobID, cToken string) []*api.AllocationListStub {
r := require.New(t)
g := NewGomegaWithT(t)
jobs := nomadClient.Jobs()

// Start allocations
RegisterAllocs(t, nomadClient, jobFile, jobID, cToken)
var allocs []*api.AllocationListStub
var err error

// Wrap in retry to wait until placement
g.Eventually(func() []*api.AllocationListStub {
// Look for allocations
allocs, _, _ := jobs.Allocations(jobID, false, nil)
return allocs
}, 30*time.Second, time.Second).ShouldNot(BeEmpty())

allocs, _, err := jobs.Allocations(jobID, false, nil)
r.NoError(err)
require.Eventually(t, func() bool {
allocs, _, err = jobs.Allocations(jobID, false, nil)
return len(allocs) > 0
}, 30*time.Second, time.Second)

require.NoError(t, err)
return allocs
}

Expand Down

0 comments on commit 17ffbde

Please sign in to comment.