Skip to content

Commit

Permalink
tests: add tests for all tasks alloc restart
Browse files Browse the repository at this point in the history
  • Loading branch information
lgfa29 committed Aug 17, 2022
1 parent 05ef55e commit 3e99369
Show file tree
Hide file tree
Showing 4 changed files with 627 additions and 0 deletions.
39 changes: 39 additions & 0 deletions client/alloc_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,45 @@ func TestAllocations_Restart(t *testing.T) {
})
}

func TestAllocations_RestartAllTasks(t *testing.T) {
ci.Parallel(t)

require := require.New(t)
client, cleanup := TestClient(t, nil)
defer cleanup()

alloc := mock.LifecycleAlloc()
require.Nil(client.addAlloc(alloc, ""))

// Can't restart all tasks while specifying a task name.
req := &nstructs.AllocRestartRequest{
AllocID: alloc.ID,
AllTasks: true,
TaskName: "web",
}
var resp nstructs.GenericResponse
err := client.ClientRPC("Allocations.Restart", &req, &resp)
require.Error(err)

// Good request.
req = &nstructs.AllocRestartRequest{
AllocID: alloc.ID,
AllTasks: true,
}

testutil.WaitForResult(func() (bool, error) {
var resp2 nstructs.GenericResponse
err := client.ClientRPC("Allocations.Restart", &req, &resp2)
if err != nil && strings.Contains(err.Error(), "not running") {
return false, err
}

return true, nil
}, func(err error) {
t.Fatalf("err: %v", err)
})
}

func TestAllocations_Restart_ACL(t *testing.T) {
ci.Parallel(t)
require := require.New(t)
Expand Down
Loading

0 comments on commit 3e99369

Please sign in to comment.