diff --git a/nomad/plan_normalization_test.go b/nomad/plan_normalization_test.go index 0f34abc9eec..fe43e072721 100644 --- a/nomad/plan_normalization_test.go +++ b/nomad/plan_normalization_test.go @@ -76,5 +76,5 @@ func TestPlanNormalize(t *testing.T) { optimizedLogSize := buf.Len() ratio := float64(optimizedLogSize) / float64(unoptimizedLogSize) - must.Less(t, 0.66, ratio) + must.Less(t, 0.6, ratio) } diff --git a/nomad/structs/diff.go b/nomad/structs/diff.go index c00f150983d..673de6b80ad 100644 --- a/nomad/structs/diff.go +++ b/nomad/structs/diff.go @@ -2809,10 +2809,10 @@ func portDiffs(old, new []Port, dynamic bool, contextual bool) []*ObjectDiff { oldPorts := makeSet(old) newPorts := makeSet(new) - var filter []string + filter := []string{"_struct"} name := "Static Port" if dynamic { - filter = []string{"Value"} + filter = []string{"_struct", "Value"} name = "Dynamic Port" } diff --git a/nomad/structs/diff_test.go b/nomad/structs/diff_test.go index cd80675ce58..1d4070d21ac 100644 --- a/nomad/structs/diff_test.go +++ b/nomad/structs/diff_test.go @@ -6843,9 +6843,7 @@ func TestTaskDiff(t *testing.T) { "a": 1, "b": 2, }, - "boom": &Port{ - Label: "boom_port", - }, + "boom": []string{"boom_port"}, }, }, New: &Task{ @@ -6857,9 +6855,7 @@ func TestTaskDiff(t *testing.T) { "a": 1, "b": 2, }, - "boom": &Port{ - Label: "boom_port", - }, + "boom": []string{"boom_port"}, }, }, Expected: &TaskDiff{ @@ -6877,9 +6873,7 @@ func TestTaskDiff(t *testing.T) { "a": 1, "b": 2, }, - "boom": &Port{ - Label: "boom_port", - }, + "boom": []string{"boom_port"}, }, }, New: &Task{ @@ -6891,9 +6885,7 @@ func TestTaskDiff(t *testing.T) { "b": 3, "c": 4, }, - "boom": &Port{ - Label: "boom_port2", - }, + "boom": []string{"boom_port2"}, }, }, Expected: &TaskDiff{ @@ -6935,7 +6927,7 @@ func TestTaskDiff(t *testing.T) { }, { Type: DiffTypeEdited, - Name: "boom.Label", + Name: "boom[0]", Old: "boom_port", New: "boom_port2", }, @@ -6962,9 +6954,7 @@ func TestTaskDiff(t *testing.T) { "a": 1, "b": 2, }, - "boom": &Port{ - Label: "boom_port", - }, + "boom": []string{"boom_port"}, }, }, New: &Task{ @@ -6976,9 +6966,7 @@ func TestTaskDiff(t *testing.T) { "a": 1, "b": 2, }, - "boom": &Port{ - Label: "boom_port", - }, + "boom": []string{"boom_port"}, }, }, Expected: &TaskDiff{ @@ -7026,28 +7014,10 @@ func TestTaskDiff(t *testing.T) { }, { Type: DiffTypeNone, - Name: "boom.HostNetwork", - Old: "", - New: "", - }, - { - Type: DiffTypeNone, - Name: "boom.Label", + Name: "boom[0]", Old: "boom_port", New: "boom_port", }, - { - Type: DiffTypeNone, - Name: "boom.To", - Old: "0", - New: "0", - }, - { - Type: DiffTypeNone, - Name: "boom.Value", - Old: "0", - New: "0", - }, { Type: DiffTypeEdited, Name: "foo", diff --git a/nomad/structs/funcs_test.go b/nomad/structs/funcs_test.go index c73d01720f1..55c8ce91b66 100644 --- a/nomad/structs/funcs_test.go +++ b/nomad/structs/funcs_test.go @@ -177,7 +177,7 @@ func TestAllocsFit(t *testing.T) { { Mode: "host", IP: "10.0.0.1", - ReservedPorts: []Port{{"main", 8000, 0, ""}}, + ReservedPorts: []Port{{Label: "main", Value: 8000}}, }, }, Ports: AllocatedPorts{ @@ -268,7 +268,7 @@ func TestAllocsFit_TerminalAlloc(t *testing.T) { Device: "eth0", IP: "10.0.0.1", MBits: 50, - ReservedPorts: []Port{{"main", 8000, 80, ""}}, + ReservedPorts: []Port{{Label: "main", Value: 8000, To: 80}}, }, }, }, @@ -322,7 +322,7 @@ func TestAllocsFit_ClientTerminalAlloc(t *testing.T) { Device: "eth0", IP: "10.0.0.1", MBits: 50, - ReservedPorts: []Port{{"main", 8000, 80, ""}}, + ReservedPorts: []Port{{Label: "main", Value: 8000, To: 80}}, }, }, }, @@ -373,7 +373,7 @@ func TestAllocsFit_ServerTerminalAlloc(t *testing.T) { Device: "eth0", IP: "10.0.0.1", MBits: 50, - ReservedPorts: []Port{{"main", 8000, 80, ""}}, + ReservedPorts: []Port{{Label: "main", Value: 8000, To: 80}}, }, }, }, diff --git a/nomad/structs/network_test.go b/nomad/structs/network_test.go index 64f6c2b6725..5b370971314 100644 --- a/nomad/structs/network_test.go +++ b/nomad/structs/network_test.go @@ -70,7 +70,7 @@ func TestNetworkIndex_Copy(t *testing.T) { Device: "eth0", IP: "192.168.0.100", MBits: 20, - ReservedPorts: []Port{{"one", 8000, 0, ""}, {"two", 9000, 0, ""}}, + ReservedPorts: []Port{{Label: "one", Value: 8000}, {Label: "two", Value: 9000}}, }, }, }, @@ -86,7 +86,7 @@ func TestNetworkIndex_Copy(t *testing.T) { Device: "eth0", IP: "192.168.0.100", MBits: 50, - ReservedPorts: []Port{{"one", 10000, 0, ""}}, + ReservedPorts: []Port{{Label: "one", Value: 10000}}, }, }, }, @@ -115,7 +115,7 @@ func TestNetworkIndex_Copy(t *testing.T) { Device: "eth1", IP: "192.168.0.104", MBits: 50, - ReservedPorts: []Port{{"one", 4567, 0, ""}}, + ReservedPorts: []Port{{Label: "one", Value: 4567}}, }, }, }, @@ -139,7 +139,7 @@ func TestNetworkIndex_Overcommitted(t *testing.T) { Device: "eth0", IP: "192.168.0.100", MBits: 505, - ReservedPorts: []Port{{"one", 8000, 0, ""}, {"two", 9000, 0, ""}}, + ReservedPorts: []Port{{Label: "one", Value: 8000}, {Label: "two", Value: 9000}}, } collide, reasons := idx.AddReserved(reserved) if collide || len(reasons) != 0 { @@ -216,7 +216,7 @@ func TestNetworkIndex_AddAllocs(t *testing.T) { Device: "eth0", IP: "192.168.0.100", MBits: 20, - ReservedPorts: []Port{{"one", 8000, 0, ""}, {"two", 9000, 0, ""}}, + ReservedPorts: []Port{{Label: "one", Value: 8000}, {Label: "two", Value: 9000}}, }, }, }, @@ -234,7 +234,7 @@ func TestNetworkIndex_AddAllocs(t *testing.T) { Device: "eth0", IP: "192.168.0.100", MBits: 50, - ReservedPorts: []Port{{"one", 10000, 0, ""}}, + ReservedPorts: []Port{{Label: "one", Value: 10000}}, }, }, }, @@ -254,7 +254,7 @@ func TestNetworkIndex_AddAllocs(t *testing.T) { Device: "eth0", IP: "192.168.0.100", MBits: 50, - ReservedPorts: []Port{{"one", 10001, 0, ""}}, + ReservedPorts: []Port{{Label: "one", Value: 10001}}, }, }, }, @@ -275,7 +275,7 @@ func TestNetworkIndex_AddAllocs(t *testing.T) { Device: "eth0", IP: "192.168.0.100", MBits: 50, - ReservedPorts: []Port{{"one", 10001, 0, ""}}, + ReservedPorts: []Port{{Label: "one", Value: 10001}}, }, }, }, @@ -302,7 +302,7 @@ func TestNetworkIndex_AddReserved(t *testing.T) { Device: "eth0", IP: "192.168.0.100", MBits: 20, - ReservedPorts: []Port{{"one", 8000, 0, ""}, {"two", 9000, 0, ""}}, + ReservedPorts: []Port{{Label: "one", Value: 8000}, {Label: "two", Value: 9000}}, } collide, reasons := idx.AddReserved(reserved) if collide || len(reasons) > 0 { @@ -400,8 +400,8 @@ func TestNetworkIndex_AssignPorts(t *testing.T) { // Ask for 2 dynamic ports ask := &NetworkResource{ - ReservedPorts: []Port{{"static", 443, 443, "default"}}, - DynamicPorts: []Port{{"http", 0, 80, "default"}, {"admin", 0, 8080, "default"}}, + ReservedPorts: []Port{{Label: "static", Value: 443, To: 443, HostNetwork: "default"}}, + DynamicPorts: []Port{{Label: "http", To: 80, HostNetwork: "default"}, {Label: "admin", To: 8080, HostNetwork: "default"}}, } offer, err := idx.AssignPorts(ask) must.NoError(t, err) @@ -459,21 +459,21 @@ func TestNetworkIndex_AssignPortss_SmallRange(t *testing.T) { name: "1 dynamic port avail and 1 port requested", min: 20000, max: 20000, - ask: []Port{{"http", 0, 80, "default"}}, + ask: []Port{{Label: "http", To: 80, HostNetwork: "default"}}, expectErr: "", }, { name: "1 dynamic port avail and 2 ports requested", min: 20000, max: 20000, - ask: []Port{{"http", 0, 80, "default"}, {"admin", 0, 80, "default"}}, + ask: []Port{{Label: "http", To: 80, HostNetwork: "default"}, {Label: "admin", To: 80, HostNetwork: "default"}}, expectErr: "dynamic port selection failed", }, { name: "2 dynamic ports avail and 2 ports requested", min: 20000, max: 20001, - ask: []Port{{"http", 0, 80, "default"}, {"admin", 0, 80, "default"}}, + ask: []Port{{Label: "http", To: 80, HostNetwork: "default"}, {Label: "admin", To: 80, HostNetwork: "default"}}, expectErr: "", }, } @@ -546,17 +546,17 @@ func TestNetworkIndex_AssignPorts_TwoIp(t *testing.T) { }{ { name: "1 reserved port asked, 2 ip, 1 already used", - allocated: []AllocatedPortMapping{{"static", 7000, 7000, "192.168.0.100"}}, - ask: []Port{{"static", 7000, 7000, "two_ip_test"}}, + allocated: []AllocatedPortMapping{{Label: "static", Value: 7000, To: 7000, HostIP: "192.168.0.100"}}, + ask: []Port{{Label: "static", Value: 7000, To: 7000, HostNetwork: "two_ip_test"}}, expectErr: "", }, { name: "1 reserved port asked, 2 ip, 2 already used", allocated: []AllocatedPortMapping{ - {"static", 7000, 7000, "192.168.0.100"}, - {"static", 7000, 7000, "192.168.0.101"}, + {Label: "static", Value: 7000, To: 7000, HostIP: "192.168.0.100"}, + {Label: "static", Value: 7000, To: 7000, HostIP: "192.168.0.101"}, }, - ask: []Port{{"static", 7000, 7000, "two_ip_test"}}, + ask: []Port{{Label: "static", Value: 7000, To: 7000, HostNetwork: "two_ip_test"}}, expectErr: "reserved port collision static=7000", }, } @@ -609,7 +609,7 @@ func TestNetworkIndex_AssignTaskNetwork(t *testing.T) { Device: "eth0", IP: "192.168.0.100", MBits: 20, - ReservedPorts: []Port{{"one", 8000, 0, ""}, {"two", 9000, 0, ""}}, + ReservedPorts: []Port{{Label: "one", Value: 8000}, {Label: "two", Value: 9000}}, }, }, }, @@ -623,7 +623,7 @@ func TestNetworkIndex_AssignTaskNetwork(t *testing.T) { Device: "eth0", IP: "192.168.0.100", MBits: 50, - ReservedPorts: []Port{{"main", 10000, 0, ""}}, + ReservedPorts: []Port{{Label: "main", Value: 10000}}, }, }, }, @@ -634,19 +634,19 @@ func TestNetworkIndex_AssignTaskNetwork(t *testing.T) { // Ask for a reserved port ask := &NetworkResource{ - ReservedPorts: []Port{{"main", 8000, 0, ""}}, + ReservedPorts: []Port{{Label: "main", Value: 8000}}, } offer, err := idx.AssignTaskNetwork(ask) require.NoError(t, err) require.NotNil(t, offer) require.Equal(t, "192.168.0.101", offer.IP) - rp := Port{"main", 8000, 0, ""} + rp := Port{Label: "main", Value: 8000} require.Len(t, offer.ReservedPorts, 1) require.Exactly(t, rp, offer.ReservedPorts[0]) // Ask for dynamic ports ask = &NetworkResource{ - DynamicPorts: []Port{{"http", 0, 80, ""}, {"https", 0, 443, ""}, {"admin", 0, -1, ""}}, + DynamicPorts: []Port{{Label: "http", To: 80}, {Label: "https", To: 443}, {Label: "admin", To: -1}}, } offer, err = idx.AssignTaskNetwork(ask) require.NoError(t, err) @@ -664,15 +664,15 @@ func TestNetworkIndex_AssignTaskNetwork(t *testing.T) { // Ask for reserved + dynamic ports ask = &NetworkResource{ - ReservedPorts: []Port{{"main", 2345, 0, ""}}, - DynamicPorts: []Port{{"http", 0, 80, ""}, {"https", 0, 443, ""}, {"admin", 0, 8080, ""}}, + ReservedPorts: []Port{{Label: "main", Value: 2345}}, + DynamicPorts: []Port{{Label: "http", To: 80}, {Label: "https", To: 443}, {Label: "admin", To: 8080}}, } offer, err = idx.AssignTaskNetwork(ask) require.NoError(t, err) require.NotNil(t, offer) require.Equal(t, "192.168.0.100", offer.IP) - rp = Port{"main", 2345, 0, ""} + rp = Port{Label: "main", Value: 2345} require.Len(t, offer.ReservedPorts, 1) require.Exactly(t, rp, offer.ReservedPorts[0]) @@ -716,7 +716,7 @@ func TestNetworkIndex_AssignTaskNetwork_Dynamic_Contention(t *testing.T) { // Ask for 2 dynamic ports ask := &NetworkResource{ - DynamicPorts: []Port{{"http", 0, 80, ""}, {"admin", 0, 443, ""}}, + DynamicPorts: []Port{{Label: "http", To: 80}, {Label: "admin", To: 443}}, } offer, err := idx.AssignTaskNetwork(ask) must.NoError(t, err) @@ -750,7 +750,7 @@ func TestNetworkIndex_SetNode_Old(t *testing.T) { { Device: "eth0", IP: "192.168.0.100", - ReservedPorts: []Port{{"ssh", 22, 0, ""}}, + ReservedPorts: []Port{{Label: "ssh", Value: 22}}, MBits: 1, }, }, @@ -777,7 +777,7 @@ func TestNetworkIndex_AddAllocs_Old(t *testing.T) { Device: "eth0", IP: "192.168.0.100", MBits: 20, - ReservedPorts: []Port{{"one", 8000, 0, ""}, {"two", 9000, 0, ""}}, + ReservedPorts: []Port{{Label: "one", Value: 8000}, {Label: "two", Value: 9000}}, }, }, }, @@ -791,7 +791,7 @@ func TestNetworkIndex_AddAllocs_Old(t *testing.T) { Device: "eth0", IP: "192.168.0.100", MBits: 50, - ReservedPorts: []Port{{"one", 10000, 0, ""}}, + ReservedPorts: []Port{{Label: "one", Value: 10000}}, }, }, }, @@ -837,7 +837,7 @@ func TestNetworkIndex_yieldIP_Old(t *testing.T) { { Device: "eth0", IP: "192.168.0.100", - ReservedPorts: []Port{{"ssh", 22, 0, ""}}, + ReservedPorts: []Port{{Label: "ssh", Value: 22}}, MBits: 1, }, }, @@ -878,7 +878,7 @@ func TestNetworkIndex_AssignTaskNetwork_Old(t *testing.T) { { Device: "eth0", IP: "192.168.0.100", - ReservedPorts: []Port{{"ssh", 22, 0, ""}}, + ReservedPorts: []Port{{Label: "ssh", Value: 22}}, MBits: 1, }, }, @@ -895,7 +895,7 @@ func TestNetworkIndex_AssignTaskNetwork_Old(t *testing.T) { Device: "eth0", IP: "192.168.0.100", MBits: 20, - ReservedPorts: []Port{{"one", 8000, 0, ""}, {"two", 9000, 0, ""}}, + ReservedPorts: []Port{{Label: "one", Value: 8000}, {Label: "two", Value: 9000}}, }, }, }, @@ -909,7 +909,7 @@ func TestNetworkIndex_AssignTaskNetwork_Old(t *testing.T) { Device: "eth0", IP: "192.168.0.100", MBits: 50, - ReservedPorts: []Port{{"main", 10000, 0, ""}}, + ReservedPorts: []Port{{Label: "main", Value: 10000}}, }, }, }, @@ -920,7 +920,7 @@ func TestNetworkIndex_AssignTaskNetwork_Old(t *testing.T) { // Ask for a reserved port ask := &NetworkResource{ - ReservedPorts: []Port{{"main", 8000, 0, ""}}, + ReservedPorts: []Port{{Label: "main", Value: 8000}}, } offer, err := idx.AssignTaskNetwork(ask) if err != nil { @@ -932,14 +932,14 @@ func TestNetworkIndex_AssignTaskNetwork_Old(t *testing.T) { if offer.IP != "192.168.0.101" { t.Fatalf("bad: %#v", offer) } - rp := Port{"main", 8000, 0, ""} + rp := Port{Label: "main", Value: 8000} if len(offer.ReservedPorts) != 1 || offer.ReservedPorts[0] != rp { t.Fatalf("bad: %#v", offer) } // Ask for dynamic ports ask = &NetworkResource{ - DynamicPorts: []Port{{"http", 0, 80, ""}, {"https", 0, 443, ""}, {"admin", 0, 8080, ""}}, + DynamicPorts: []Port{{Label: "http", To: 80}, {Label: "https", To: 443}, {Label: "admin", To: 8080}}, } offer, err = idx.AssignTaskNetwork(ask) if err != nil { @@ -962,8 +962,8 @@ func TestNetworkIndex_AssignTaskNetwork_Old(t *testing.T) { // Ask for reserved + dynamic ports ask = &NetworkResource{ - ReservedPorts: []Port{{"main", 2345, 0, ""}}, - DynamicPorts: []Port{{"http", 0, 80, ""}, {"https", 0, 443, ""}, {"admin", 0, 8080, ""}}, + ReservedPorts: []Port{{Label: "main", Value: 2345}}, + DynamicPorts: []Port{{Label: "http", To: 80}, {Label: "https", To: 443}, {Label: "admin", To: 8080}}, } offer, err = idx.AssignTaskNetwork(ask) if err != nil { @@ -976,7 +976,7 @@ func TestNetworkIndex_AssignTaskNetwork_Old(t *testing.T) { t.Fatalf("bad: %#v", offer) } - rp = Port{"main", 2345, 0, ""} + rp = Port{Label: "main", Value: 2345} if len(offer.ReservedPorts) != 1 || offer.ReservedPorts[0] != rp { t.Fatalf("bad: %#v", offer) } @@ -1030,7 +1030,7 @@ func TestNetworkIndex_AssignTaskNetwork_Dynamic_Contention_Old(t *testing.T) { // Ask for dynamic ports ask := &NetworkResource{ - DynamicPorts: []Port{{"http", 0, 80, ""}}, + DynamicPorts: []Port{{Label: "http", To: 80}}, } offer, err := idx.AssignTaskNetwork(ask) if err != nil { diff --git a/nomad/structs/structs.go b/nomad/structs/structs.go index a12c62342b8..4ce8e05c395 100644 --- a/nomad/structs/structs.go +++ b/nomad/structs/structs.go @@ -2802,6 +2802,9 @@ type NodeNetworkAddress struct { } type AllocatedPortMapping struct { + // msgpack omit empty fields during serialization + _struct bool `codec:",omitempty"` // nolint: structcheck + Label string Value int To int @@ -2853,6 +2856,9 @@ func (p AllocatedPorts) Get(label string) (AllocatedPortMapping, bool) { } type Port struct { + // msgpack omit empty fields during serialization + _struct bool `codec:",omitempty"` // nolint: structcheck + // Label is the key for HCL port blocks: port "foo" {} Label string diff --git a/nomad/structs/structs_test.go b/nomad/structs/structs_test.go index 79da3505e4d..176d3309867 100644 --- a/nomad/structs/structs_test.go +++ b/nomad/structs/structs_test.go @@ -1518,7 +1518,7 @@ func TestTaskGroup_Validate(t *testing.T) { tg: &TaskGroup{ Networks: []*NetworkResource{ { - DynamicPorts: []Port{{"http", 0, 80, ""}}, + DynamicPorts: []Port{{Label: "http", To: 80}}, }, }, Tasks: []*Task{ @@ -1526,7 +1526,7 @@ func TestTaskGroup_Validate(t *testing.T) { Resources: &Resources{ Networks: []*NetworkResource{ { - DynamicPorts: []Port{{"http", 0, 80, ""}}, + DynamicPorts: []Port{{Label: "http", To: 80}}, }, }, }, @@ -3805,7 +3805,7 @@ func TestResource_Add(t *testing.T) { { CIDR: "10.0.0.0/8", MBits: 100, - ReservedPorts: []Port{{"ssh", 22, 0, ""}}, + ReservedPorts: []Port{{Label: "ssh", Value: 22}}, }, }, } @@ -3818,7 +3818,7 @@ func TestResource_Add(t *testing.T) { { IP: "10.0.0.1", MBits: 50, - ReservedPorts: []Port{{"web", 80, 0, ""}}, + ReservedPorts: []Port{{Label: "web", Value: 80}}, }, }, Devices: []*RequestedDevice{ @@ -3841,7 +3841,7 @@ func TestResource_Add(t *testing.T) { { CIDR: "10.0.0.0/8", MBits: 150, - ReservedPorts: []Port{{"ssh", 22, 0, ""}, {"web", 80, 0, ""}}, + ReservedPorts: []Port{{Label: "ssh", Value: 22}, {Label: "web", Value: 80}}, }, }, Devices: []*RequestedDevice{ @@ -3863,7 +3863,7 @@ func TestResource_Add_Network(t *testing.T) { Networks: []*NetworkResource{ { MBits: 50, - DynamicPorts: []Port{{"http", 0, 80, ""}, {"https", 0, 443, ""}}, + DynamicPorts: []Port{{Label: "http", To: 80}, {Label: "https", To: 443}}, }, }, } @@ -3871,7 +3871,7 @@ func TestResource_Add_Network(t *testing.T) { Networks: []*NetworkResource{ { MBits: 25, - DynamicPorts: []Port{{"admin", 0, 8080, ""}}, + DynamicPorts: []Port{{Label: "admin", To: 8080}}, }, }, } @@ -3883,7 +3883,7 @@ func TestResource_Add_Network(t *testing.T) { Networks: []*NetworkResource{ { MBits: 75, - DynamicPorts: []Port{{"http", 0, 80, ""}, {"https", 0, 443, ""}, {"admin", 0, 8080, ""}}, + DynamicPorts: []Port{{Label: "http", To: 80}, {Label: "https", To: 443}, {Label: "admin", To: 8080}}, }, }, } @@ -3910,7 +3910,7 @@ func TestComparableResources_Subtract(t *testing.T) { { CIDR: "10.0.0.0/8", MBits: 100, - ReservedPorts: []Port{{"ssh", 22, 0, ""}}, + ReservedPorts: []Port{{Label: "ssh", Value: 22}}, }, }, }, @@ -3933,7 +3933,7 @@ func TestComparableResources_Subtract(t *testing.T) { { CIDR: "10.0.0.0/8", MBits: 20, - ReservedPorts: []Port{{"ssh", 22, 0, ""}}, + ReservedPorts: []Port{{Label: "ssh", Value: 22}}, }, }, }, @@ -3957,7 +3957,7 @@ func TestComparableResources_Subtract(t *testing.T) { { CIDR: "10.0.0.0/8", MBits: 100, - ReservedPorts: []Port{{"ssh", 22, 0, ""}}, + ReservedPorts: []Port{{Label: "ssh", Value: 22}}, }, }, }, @@ -6771,12 +6771,12 @@ func TestNetworkResourcesEquals(t *testing.T) { { IP: "10.0.0.1", MBits: 50, - ReservedPorts: []Port{{"web", 80, 0, ""}}, + ReservedPorts: []Port{{Label: "web", Value: 80}}, }, { IP: "10.0.0.1", MBits: 50, - ReservedPorts: []Port{{"web", 80, 0, ""}}, + ReservedPorts: []Port{{Label: "web", Value: 80}}, }, }, true, @@ -6787,12 +6787,12 @@ func TestNetworkResourcesEquals(t *testing.T) { { IP: "10.0.0.0", MBits: 50, - ReservedPorts: []Port{{"web", 80, 0, ""}}, + ReservedPorts: []Port{{Label: "web", Value: 80}}, }, { IP: "10.0.0.1", MBits: 50, - ReservedPorts: []Port{{"web", 80, 0, ""}}, + ReservedPorts: []Port{{Label: "web", Value: 80}}, }, }, false, @@ -6803,12 +6803,12 @@ func TestNetworkResourcesEquals(t *testing.T) { { IP: "10.0.0.1", MBits: 40, - ReservedPorts: []Port{{"web", 80, 0, ""}}, + ReservedPorts: []Port{{Label: "web", Value: 80}}, }, { IP: "10.0.0.1", MBits: 50, - ReservedPorts: []Port{{"web", 80, 0, ""}}, + ReservedPorts: []Port{{Label: "web", Value: 80}}, }, }, false, @@ -6819,12 +6819,12 @@ func TestNetworkResourcesEquals(t *testing.T) { { IP: "10.0.0.1", MBits: 50, - ReservedPorts: []Port{{"web", 80, 0, ""}}, + ReservedPorts: []Port{{Label: "web", Value: 80}}, }, { IP: "10.0.0.1", MBits: 50, - ReservedPorts: []Port{{"web", 80, 0, ""}, {"web", 80, 0, ""}}, + ReservedPorts: []Port{{Label: "web", Value: 80}, {Label: "web", Value: 80}}, }, }, false, @@ -6835,7 +6835,7 @@ func TestNetworkResourcesEquals(t *testing.T) { { IP: "10.0.0.1", MBits: 50, - ReservedPorts: []Port{{"web", 80, 0, ""}}, + ReservedPorts: []Port{{Label: "web", Value: 80}}, }, { IP: "10.0.0.1", @@ -6851,12 +6851,12 @@ func TestNetworkResourcesEquals(t *testing.T) { { IP: "10.0.0.1", MBits: 50, - ReservedPorts: []Port{{"web", 80, 0, ""}}, + ReservedPorts: []Port{{Label: "web", Value: 80}}, }, { IP: "10.0.0.1", MBits: 50, - ReservedPorts: []Port{{"notweb", 80, 0, ""}}, + ReservedPorts: []Port{{Label: "notweb", Value: 80}}, }, }, false, @@ -6867,12 +6867,12 @@ func TestNetworkResourcesEquals(t *testing.T) { { IP: "10.0.0.1", MBits: 50, - DynamicPorts: []Port{{"web", 80, 0, ""}}, + DynamicPorts: []Port{{Label: "web", Value: 80}}, }, { IP: "10.0.0.1", MBits: 50, - DynamicPorts: []Port{{"web", 80, 0, ""}, {"web", 80, 0, ""}}, + DynamicPorts: []Port{{Label: "web", Value: 80}, {Label: "web", Value: 80}}, }, }, false, @@ -6883,7 +6883,7 @@ func TestNetworkResourcesEquals(t *testing.T) { { IP: "10.0.0.1", MBits: 50, - DynamicPorts: []Port{{"web", 80, 0, ""}}, + DynamicPorts: []Port{{Label: "web", Value: 80}}, }, { IP: "10.0.0.1", @@ -6899,12 +6899,12 @@ func TestNetworkResourcesEquals(t *testing.T) { { IP: "10.0.0.1", MBits: 50, - DynamicPorts: []Port{{"web", 80, 0, ""}}, + DynamicPorts: []Port{{Label: "web", Value: 80}}, }, { IP: "10.0.0.1", MBits: 50, - DynamicPorts: []Port{{"notweb", 80, 0, ""}}, + DynamicPorts: []Port{{Label: "notweb", Value: 80}}, }, }, false, @@ -7412,7 +7412,7 @@ func TestAllocatedResources_Canonicalize(t *testing.T) { Networks: Networks{ { IP: "127.0.0.1", - DynamicPorts: []Port{{"admin", 8080, 0, "default"}}, + DynamicPorts: []Port{{Label: "admin", Value: 8080, HostNetwork: "default"}}, }, }, }, @@ -7424,7 +7424,7 @@ func TestAllocatedResources_Canonicalize(t *testing.T) { Networks: Networks{ { IP: "127.0.0.1", - DynamicPorts: []Port{{"admin", 8080, 0, "default"}}, + DynamicPorts: []Port{{Label: "admin", Value: 8080, HostNetwork: "default"}}, }, }, }, @@ -7448,7 +7448,7 @@ func TestAllocatedResources_Canonicalize(t *testing.T) { Networks: Networks{ { IP: "127.0.0.1", - DynamicPorts: []Port{{"admin", 8080, 0, "default"}}, + DynamicPorts: []Port{{Label: "admin", Value: 8080, HostNetwork: "default"}}, }, }, }, @@ -7470,7 +7470,7 @@ func TestAllocatedResources_Canonicalize(t *testing.T) { Networks: Networks{ { IP: "127.0.0.1", - DynamicPorts: []Port{{"admin", 8080, 0, "default"}}, + DynamicPorts: []Port{{Label: "admin", Value: 8080, HostNetwork: "default"}}, }, }, },