2015-09-08 22:37:07 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
2019-11-07 20:39:41 +00:00
|
|
|
"context"
|
2019-11-08 20:49:04 +00:00
|
|
|
"fmt"
|
2019-11-07 20:39:41 +00:00
|
|
|
"os"
|
2015-09-17 19:40:51 +00:00
|
|
|
"sort"
|
2015-09-08 22:37:07 +00:00
|
|
|
"testing"
|
2018-01-25 17:46:12 +00:00
|
|
|
"time"
|
|
|
|
|
2020-10-09 05:21:41 +00:00
|
|
|
"github.com/hashicorp/nomad/api/internal/testutil"
|
2023-03-03 20:52:41 +00:00
|
|
|
"github.com/shoenig/test"
|
2023-01-01 18:57:26 +00:00
|
|
|
"github.com/shoenig/test/must"
|
2015-09-08 22:37:07 +00:00
|
|
|
)
|
|
|
|
|
2015-09-09 00:49:31 +00:00
|
|
|
func TestAllocations_List(t *testing.T) {
|
2022-12-22 14:21:00 +00:00
|
|
|
testutil.RequireRoot(t)
|
2022-03-17 13:34:57 +00:00
|
|
|
testutil.Parallel(t)
|
2022-12-22 14:21:00 +00:00
|
|
|
|
2020-10-09 05:21:41 +00:00
|
|
|
c, s := makeClient(t, nil, func(c *testutil.TestServerConfig) {
|
|
|
|
c.DevMode = true
|
|
|
|
})
|
2015-09-08 22:37:07 +00:00
|
|
|
defer s.Stop()
|
2015-09-09 00:49:31 +00:00
|
|
|
a := c.Allocations()
|
2015-09-08 22:37:07 +00:00
|
|
|
|
2023-01-03 22:11:35 +00:00
|
|
|
// wait for node
|
|
|
|
_ = oneNodeFromNodeList(t, c.Nodes())
|
|
|
|
|
2015-09-08 22:37:07 +00:00
|
|
|
// Querying when no allocs exist returns nothing
|
2015-09-09 20:18:50 +00:00
|
|
|
allocs, qm, err := a.List(nil)
|
2023-01-01 18:57:26 +00:00
|
|
|
must.NoError(t, err)
|
|
|
|
must.Zero(t, qm.LastIndex)
|
|
|
|
must.Len(t, 0, allocs)
|
2015-09-09 00:20:52 +00:00
|
|
|
|
2020-10-09 05:21:41 +00:00
|
|
|
// Create a job and attempt to register it
|
|
|
|
job := testJob()
|
|
|
|
resp, wm, err := c.Jobs().Register(job, nil)
|
2023-01-01 18:57:26 +00:00
|
|
|
must.NoError(t, err)
|
|
|
|
must.NotNil(t, resp)
|
|
|
|
must.UUIDv4(t, resp.EvalID)
|
2020-10-09 05:21:41 +00:00
|
|
|
assertWriteMeta(t, wm)
|
|
|
|
|
|
|
|
// List the allocations again
|
|
|
|
qo := &QueryOptions{
|
|
|
|
WaitIndex: wm.LastIndex,
|
|
|
|
}
|
|
|
|
allocs, qm, err = a.List(qo)
|
2023-01-01 18:57:26 +00:00
|
|
|
must.NoError(t, err)
|
|
|
|
must.NonZero(t, qm.LastIndex)
|
2015-09-09 00:20:52 +00:00
|
|
|
|
2020-10-09 05:21:41 +00:00
|
|
|
// Check that we got the allocation back
|
2023-01-01 18:57:26 +00:00
|
|
|
must.Len(t, 1, allocs)
|
|
|
|
must.Eq(t, resp.EvalID, allocs[0].EvalID)
|
2017-02-28 00:00:19 +00:00
|
|
|
|
2020-10-09 05:21:41 +00:00
|
|
|
// Resources should be unset by default
|
2023-01-01 18:57:26 +00:00
|
|
|
must.Nil(t, allocs[0].AllocatedResources)
|
2015-09-08 22:37:07 +00:00
|
|
|
}
|
2015-09-17 19:40:51 +00:00
|
|
|
|
2015-12-24 10:46:59 +00:00
|
|
|
func TestAllocations_PrefixList(t *testing.T) {
|
2022-03-17 13:34:57 +00:00
|
|
|
testutil.Parallel(t)
|
2023-01-01 18:57:26 +00:00
|
|
|
|
2015-12-24 10:46:59 +00:00
|
|
|
c, s := makeClient(t, nil, nil)
|
|
|
|
defer s.Stop()
|
|
|
|
a := c.Allocations()
|
|
|
|
|
|
|
|
// Querying when no allocs exist returns nothing
|
|
|
|
allocs, qm, err := a.PrefixList("")
|
2023-01-01 18:57:26 +00:00
|
|
|
must.NoError(t, err)
|
|
|
|
must.Zero(t, qm.LastIndex)
|
|
|
|
must.Len(t, 0, allocs)
|
2015-12-24 10:46:59 +00:00
|
|
|
|
|
|
|
// TODO: do something that causes an allocation to actually happen
|
|
|
|
// so we can query for them.
|
|
|
|
return
|
|
|
|
|
2017-02-28 00:00:19 +00:00
|
|
|
//job := &Job{
|
2019-01-18 18:28:35 +00:00
|
|
|
//ID: stringToPtr("job1"),
|
|
|
|
//Name: stringToPtr("Job #1"),
|
|
|
|
//Type: stringToPtr(JobTypeService),
|
2017-02-28 00:00:19 +00:00
|
|
|
//}
|
|
|
|
|
|
|
|
//eval, _, err := c.Jobs().Register(job, nil)
|
|
|
|
//if err != nil {
|
|
|
|
//t.Fatalf("err: %s", err)
|
|
|
|
//}
|
|
|
|
|
|
|
|
//// List the allocations by prefix
|
|
|
|
//allocs, qm, err = a.PrefixList("foobar")
|
|
|
|
//if err != nil {
|
|
|
|
//t.Fatalf("err: %s", err)
|
|
|
|
//}
|
|
|
|
//if qm.LastIndex == 0 {
|
|
|
|
//t.Fatalf("bad index: %d", qm.LastIndex)
|
|
|
|
//}
|
|
|
|
|
|
|
|
//// Check that we got the allocation back
|
|
|
|
//if len(allocs) == 0 || allocs[0].EvalID != eval {
|
|
|
|
//t.Fatalf("bad: %#v", allocs)
|
|
|
|
//}
|
2015-12-24 10:46:59 +00:00
|
|
|
}
|
|
|
|
|
2020-10-09 05:21:41 +00:00
|
|
|
func TestAllocations_List_Resources(t *testing.T) {
|
2022-12-22 14:21:00 +00:00
|
|
|
testutil.RequireRoot(t)
|
2022-03-17 13:34:57 +00:00
|
|
|
testutil.Parallel(t)
|
2022-12-22 14:21:00 +00:00
|
|
|
|
2020-10-09 05:21:41 +00:00
|
|
|
c, s := makeClient(t, nil, func(c *testutil.TestServerConfig) {
|
|
|
|
c.DevMode = true
|
|
|
|
})
|
|
|
|
defer s.Stop()
|
|
|
|
a := c.Allocations()
|
|
|
|
|
2023-01-03 22:11:35 +00:00
|
|
|
// wait for node
|
|
|
|
_ = oneNodeFromNodeList(t, c.Nodes())
|
|
|
|
|
2020-10-09 05:21:41 +00:00
|
|
|
// Create a job and register it
|
|
|
|
job := testJob()
|
|
|
|
resp, wm, err := c.Jobs().Register(job, nil)
|
2023-01-01 18:57:26 +00:00
|
|
|
must.NoError(t, err)
|
|
|
|
must.NotNil(t, resp)
|
|
|
|
must.UUIDv4(t, resp.EvalID)
|
2020-10-09 05:21:41 +00:00
|
|
|
assertWriteMeta(t, wm)
|
|
|
|
|
|
|
|
qo := &QueryOptions{
|
|
|
|
Params: map[string]string{"resources": "true"},
|
|
|
|
WaitIndex: wm.LastIndex,
|
|
|
|
}
|
2023-01-03 22:11:35 +00:00
|
|
|
var allocationStubs []*AllocationListStub
|
|
|
|
var qm *QueryMeta
|
|
|
|
allocationStubs, qm, err = a.List(qo)
|
2023-01-01 18:57:26 +00:00
|
|
|
must.NoError(t, err)
|
2020-10-09 05:21:41 +00:00
|
|
|
|
|
|
|
// Check that we got the allocation back with resources
|
2023-01-03 22:11:35 +00:00
|
|
|
must.Positive(t, qm.LastIndex)
|
|
|
|
must.Len(t, 1, allocationStubs)
|
|
|
|
alloc := allocationStubs[0]
|
|
|
|
must.Eq(t, resp.EvalID, alloc.EvalID,
|
|
|
|
must.Sprintf("registration: %#v", resp),
|
|
|
|
must.Sprintf("allocation: %#v", alloc),
|
|
|
|
)
|
|
|
|
must.NotNil(t, alloc.AllocatedResources)
|
2020-10-09 05:21:41 +00:00
|
|
|
}
|
|
|
|
|
2015-09-17 19:40:51 +00:00
|
|
|
func TestAllocations_CreateIndexSort(t *testing.T) {
|
2022-03-17 13:34:57 +00:00
|
|
|
testutil.Parallel(t)
|
2023-01-01 18:57:26 +00:00
|
|
|
|
2015-09-17 19:40:51 +00:00
|
|
|
allocs := []*AllocationListStub{
|
2017-09-26 22:26:33 +00:00
|
|
|
{CreateIndex: 2},
|
|
|
|
{CreateIndex: 1},
|
|
|
|
{CreateIndex: 5},
|
2015-09-17 19:40:51 +00:00
|
|
|
}
|
|
|
|
sort.Sort(AllocIndexSort(allocs))
|
|
|
|
|
|
|
|
expect := []*AllocationListStub{
|
2017-09-26 22:26:33 +00:00
|
|
|
{CreateIndex: 5},
|
|
|
|
{CreateIndex: 2},
|
|
|
|
{CreateIndex: 1},
|
2015-09-17 19:40:51 +00:00
|
|
|
}
|
2023-01-01 18:57:26 +00:00
|
|
|
must.Eq(t, allocs, expect)
|
2015-09-17 19:40:51 +00:00
|
|
|
}
|
2018-01-25 17:46:12 +00:00
|
|
|
|
|
|
|
func TestAllocations_RescheduleInfo(t *testing.T) {
|
2022-03-17 13:34:57 +00:00
|
|
|
testutil.Parallel(t)
|
2023-01-01 18:57:26 +00:00
|
|
|
|
2018-01-25 17:46:12 +00:00
|
|
|
// Create a job, task group and alloc
|
|
|
|
job := &Job{
|
2022-08-17 16:26:34 +00:00
|
|
|
Name: pointerOf("foo"),
|
|
|
|
Namespace: pointerOf(DefaultNamespace),
|
|
|
|
ID: pointerOf("bar"),
|
|
|
|
ParentID: pointerOf("lol"),
|
2018-01-25 17:46:12 +00:00
|
|
|
TaskGroups: []*TaskGroup{
|
|
|
|
{
|
2022-08-17 16:26:34 +00:00
|
|
|
Name: pointerOf("bar"),
|
2018-01-25 17:46:12 +00:00
|
|
|
Tasks: []*Task{
|
|
|
|
{
|
|
|
|
Name: "task1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
job.Canonicalize()
|
|
|
|
|
|
|
|
alloc := &Allocation{
|
2019-11-12 14:47:18 +00:00
|
|
|
ID: generateUUID(),
|
2018-01-25 17:46:12 +00:00
|
|
|
Namespace: DefaultNamespace,
|
2019-11-12 14:47:18 +00:00
|
|
|
EvalID: generateUUID(),
|
2018-01-25 17:46:12 +00:00
|
|
|
Name: "foo-bar[1]",
|
2019-11-12 14:47:18 +00:00
|
|
|
NodeID: generateUUID(),
|
2018-01-25 17:46:12 +00:00
|
|
|
TaskGroup: *job.TaskGroups[0].Name,
|
|
|
|
JobID: *job.ID,
|
|
|
|
Job: job,
|
|
|
|
}
|
|
|
|
|
|
|
|
type testCase struct {
|
|
|
|
desc string
|
|
|
|
reschedulePolicy *ReschedulePolicy
|
|
|
|
rescheduleTracker *RescheduleTracker
|
|
|
|
time time.Time
|
|
|
|
expAttempted int
|
|
|
|
expTotal int
|
|
|
|
}
|
|
|
|
|
|
|
|
testCases := []testCase{
|
|
|
|
{
|
|
|
|
desc: "no reschedule policy",
|
|
|
|
expAttempted: 0,
|
|
|
|
expTotal: 0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "no reschedule events",
|
|
|
|
reschedulePolicy: &ReschedulePolicy{
|
2022-08-17 16:26:34 +00:00
|
|
|
Attempts: pointerOf(3),
|
|
|
|
Interval: pointerOf(15 * time.Minute),
|
2018-01-25 17:46:12 +00:00
|
|
|
},
|
|
|
|
expAttempted: 0,
|
|
|
|
expTotal: 3,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "all reschedule events within interval",
|
|
|
|
reschedulePolicy: &ReschedulePolicy{
|
2022-08-17 16:26:34 +00:00
|
|
|
Attempts: pointerOf(3),
|
|
|
|
Interval: pointerOf(15 * time.Minute),
|
2018-01-25 17:46:12 +00:00
|
|
|
},
|
|
|
|
time: time.Now(),
|
|
|
|
rescheduleTracker: &RescheduleTracker{
|
|
|
|
Events: []*RescheduleEvent{
|
|
|
|
{
|
|
|
|
RescheduleTime: time.Now().Add(-5 * time.Minute).UTC().UnixNano(),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
expAttempted: 1,
|
|
|
|
expTotal: 3,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "some reschedule events outside interval",
|
|
|
|
reschedulePolicy: &ReschedulePolicy{
|
2022-08-17 16:26:34 +00:00
|
|
|
Attempts: pointerOf(3),
|
|
|
|
Interval: pointerOf(15 * time.Minute),
|
2018-01-25 17:46:12 +00:00
|
|
|
},
|
|
|
|
time: time.Now(),
|
|
|
|
rescheduleTracker: &RescheduleTracker{
|
|
|
|
Events: []*RescheduleEvent{
|
|
|
|
{
|
|
|
|
RescheduleTime: time.Now().Add(-45 * time.Minute).UTC().UnixNano(),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
RescheduleTime: time.Now().Add(-30 * time.Minute).UTC().UnixNano(),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
RescheduleTime: time.Now().Add(-10 * time.Minute).UTC().UnixNano(),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
RescheduleTime: time.Now().Add(-5 * time.Minute).UTC().UnixNano(),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
expAttempted: 2,
|
|
|
|
expTotal: 3,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, tc := range testCases {
|
|
|
|
t.Run(tc.desc, func(t *testing.T) {
|
|
|
|
alloc.RescheduleTracker = tc.rescheduleTracker
|
|
|
|
job.TaskGroups[0].ReschedulePolicy = tc.reschedulePolicy
|
|
|
|
attempted, total := alloc.RescheduleInfo(tc.time)
|
2023-01-01 18:57:26 +00:00
|
|
|
must.Eq(t, tc.expAttempted, attempted)
|
|
|
|
must.Eq(t, tc.expTotal, total)
|
2018-01-25 17:46:12 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2018-03-07 00:23:21 +00:00
|
|
|
|
2023-03-03 20:52:41 +00:00
|
|
|
func TestAllocations_Stop(t *testing.T) {
|
|
|
|
testutil.RequireRoot(t)
|
|
|
|
testutil.Parallel(t)
|
|
|
|
|
|
|
|
c, s := makeClient(t, nil, func(c *testutil.TestServerConfig) {
|
|
|
|
c.DevMode = true
|
|
|
|
})
|
|
|
|
defer s.Stop()
|
|
|
|
a := c.Allocations()
|
|
|
|
|
|
|
|
// wait for node
|
|
|
|
_ = oneNodeFromNodeList(t, c.Nodes())
|
|
|
|
|
|
|
|
// Create a job and register it
|
|
|
|
job := testJob()
|
|
|
|
_, wm, err := c.Jobs().Register(job, nil)
|
|
|
|
must.NoError(t, err)
|
|
|
|
|
|
|
|
// List allocations.
|
|
|
|
stubs, qm, err := a.List(&QueryOptions{WaitIndex: wm.LastIndex})
|
|
|
|
must.NoError(t, err)
|
|
|
|
must.SliceLen(t, 1, stubs)
|
|
|
|
|
|
|
|
// Stop the first allocation.
|
|
|
|
resp, err := a.Stop(&Allocation{ID: stubs[0].ID}, &QueryOptions{WaitIndex: qm.LastIndex})
|
|
|
|
must.NoError(t, err)
|
|
|
|
test.UUIDv4(t, resp.EvalID)
|
|
|
|
test.NonZero(t, resp.LastIndex)
|
|
|
|
|
|
|
|
// Stop allocation that doesn't exist.
|
|
|
|
resp, err = a.Stop(&Allocation{ID: "invalid"}, &QueryOptions{WaitIndex: qm.LastIndex})
|
|
|
|
must.Error(t, err)
|
|
|
|
}
|
|
|
|
|
2019-11-07 20:39:41 +00:00
|
|
|
// TestAllocations_ExecErrors ensures errors are properly formatted
|
|
|
|
func TestAllocations_ExecErrors(t *testing.T) {
|
2023-01-01 18:57:26 +00:00
|
|
|
testutil.Parallel(t)
|
|
|
|
|
2019-11-07 20:39:41 +00:00
|
|
|
c, s := makeClient(t, nil, nil)
|
|
|
|
defer s.Stop()
|
|
|
|
a := c.Allocations()
|
|
|
|
|
|
|
|
job := &Job{
|
2022-08-17 16:26:34 +00:00
|
|
|
Name: pointerOf("foo"),
|
|
|
|
Namespace: pointerOf(DefaultNamespace),
|
|
|
|
ID: pointerOf("bar"),
|
|
|
|
ParentID: pointerOf("lol"),
|
2019-11-07 20:39:41 +00:00
|
|
|
TaskGroups: []*TaskGroup{
|
|
|
|
{
|
2022-08-17 16:26:34 +00:00
|
|
|
Name: pointerOf("bar"),
|
2019-11-07 20:39:41 +00:00
|
|
|
Tasks: []*Task{
|
|
|
|
{
|
|
|
|
Name: "task1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
job.Canonicalize()
|
|
|
|
|
2019-11-12 14:47:18 +00:00
|
|
|
allocID := generateUUID()
|
2019-11-08 20:49:04 +00:00
|
|
|
|
2019-11-07 20:39:41 +00:00
|
|
|
alloc := &Allocation{
|
2019-11-08 20:49:04 +00:00
|
|
|
ID: allocID,
|
2019-11-07 20:39:41 +00:00
|
|
|
Namespace: DefaultNamespace,
|
2019-11-12 14:47:18 +00:00
|
|
|
EvalID: generateUUID(),
|
2019-11-07 20:39:41 +00:00
|
|
|
Name: "foo-bar[1]",
|
2019-11-12 14:47:18 +00:00
|
|
|
NodeID: generateUUID(),
|
2019-11-07 20:39:41 +00:00
|
|
|
TaskGroup: *job.TaskGroups[0].Name,
|
|
|
|
JobID: *job.ID,
|
|
|
|
Job: job,
|
|
|
|
}
|
|
|
|
// Querying when no allocs exist returns nothing
|
|
|
|
sizeCh := make(chan TerminalSize, 1)
|
|
|
|
|
|
|
|
// make a request that will result in an error
|
|
|
|
// ensure the error is what we expect
|
2019-11-08 20:49:04 +00:00
|
|
|
exitCode, err := a.Exec(context.Background(), alloc, "bar", false, []string{"command"}, os.Stdin, os.Stdout, os.Stderr, sizeCh, nil)
|
|
|
|
|
2023-01-01 18:57:26 +00:00
|
|
|
must.Eq(t, -2, exitCode)
|
|
|
|
must.EqError(t, err, fmt.Sprintf("Unknown allocation \"%s\"", allocID))
|
2019-11-07 20:39:41 +00:00
|
|
|
}
|
|
|
|
|
2021-03-25 07:52:59 +00:00
|
|
|
func TestAllocation_ServerTerminalStatus(t *testing.T) {
|
2022-03-17 13:34:57 +00:00
|
|
|
testutil.Parallel(t)
|
2021-03-25 07:52:59 +00:00
|
|
|
|
|
|
|
testCases := []struct {
|
|
|
|
inputAllocation *Allocation
|
|
|
|
expectedOutput bool
|
|
|
|
name string
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
inputAllocation: &Allocation{DesiredStatus: AllocDesiredStatusEvict},
|
|
|
|
expectedOutput: true,
|
|
|
|
name: "alloc desired status evict",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
inputAllocation: &Allocation{DesiredStatus: AllocDesiredStatusStop},
|
|
|
|
expectedOutput: true,
|
|
|
|
name: "alloc desired status stop",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
inputAllocation: &Allocation{DesiredStatus: AllocDesiredStatusRun},
|
|
|
|
expectedOutput: false,
|
|
|
|
name: "alloc desired status run",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, tc := range testCases {
|
|
|
|
t.Run(tc.name, func(t *testing.T) {
|
2023-01-01 18:57:26 +00:00
|
|
|
must.Eq(t, tc.expectedOutput, tc.inputAllocation.ServerTerminalStatus())
|
2021-03-25 07:52:59 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestAllocation_ClientTerminalStatus(t *testing.T) {
|
2022-03-17 13:34:57 +00:00
|
|
|
testutil.Parallel(t)
|
2021-03-25 07:52:59 +00:00
|
|
|
|
|
|
|
testCases := []struct {
|
|
|
|
inputAllocation *Allocation
|
|
|
|
expectedOutput bool
|
|
|
|
name string
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
inputAllocation: &Allocation{ClientStatus: AllocClientStatusLost},
|
|
|
|
expectedOutput: true,
|
|
|
|
name: "alloc client status lost",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
inputAllocation: &Allocation{ClientStatus: AllocClientStatusFailed},
|
|
|
|
expectedOutput: true,
|
|
|
|
name: "alloc client status failed",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
inputAllocation: &Allocation{ClientStatus: AllocClientStatusComplete},
|
|
|
|
expectedOutput: true,
|
|
|
|
name: "alloc client status complete",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
inputAllocation: &Allocation{ClientStatus: AllocClientStatusRunning},
|
|
|
|
expectedOutput: false,
|
|
|
|
name: "alloc client status complete",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
inputAllocation: &Allocation{ClientStatus: AllocClientStatusPending},
|
|
|
|
expectedOutput: false,
|
|
|
|
name: "alloc client status running",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, tc := range testCases {
|
|
|
|
t.Run(tc.name, func(t *testing.T) {
|
2023-01-01 18:57:26 +00:00
|
|
|
must.Eq(t, tc.expectedOutput, tc.inputAllocation.ClientTerminalStatus())
|
2021-03-25 07:52:59 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-07 00:23:21 +00:00
|
|
|
func TestAllocations_ShouldMigrate(t *testing.T) {
|
2022-03-17 13:34:57 +00:00
|
|
|
testutil.Parallel(t)
|
2023-01-01 18:57:26 +00:00
|
|
|
|
|
|
|
must.True(t, DesiredTransition{Migrate: pointerOf(true)}.ShouldMigrate())
|
|
|
|
must.False(t, DesiredTransition{}.ShouldMigrate())
|
|
|
|
must.False(t, DesiredTransition{Migrate: pointerOf(false)}.ShouldMigrate())
|
2018-03-07 00:23:21 +00:00
|
|
|
}
|
2022-03-03 11:14:00 +00:00
|
|
|
|
|
|
|
func TestAllocations_Services(t *testing.T) {
|
2023-01-01 18:57:26 +00:00
|
|
|
t.Skip("needs to be implemented")
|
2022-03-03 11:14:00 +00:00
|
|
|
// TODO(jrasell) add tests once registration process is in place.
|
|
|
|
}
|