@@ -3,6 +3,7 @@ package manager
33import (
44 "fmt"
55
6+ "github.com/aws/aws-sdk-go/aws"
67 . "github.com/onsi/ginkgo"
78 . "github.com/onsi/gomega"
89 "github.com/pkg/errors"
@@ -59,83 +60,67 @@ var _ = Describe("StackCollection Tasks", func() {
5960 }
6061
6162 Describe ("TaskTree" , func () {
62- Context ( "With real tasks" , func () {
63-
64- BeforeEach ( func () {
65-
66- p = mockprovider . NewMockProvider ( )
63+ BeforeEach ( func () {
64+ p = mockprovider . NewMockProvider ()
65+ cfg = newClusterConfig ( "test-cluster" )
66+ stackManager = NewStackCollection ( p , cfg )
67+ } )
6768
68- cfg = newClusterConfig ("test-cluster" )
69+ It ("should have nice description" , func () {
70+ fakeVPCImporter := new (vpcfakes.FakeImporter )
71+ // TODO use DescribeTable
72+
73+ // The supportsManagedNodes argument has no effect on the Describe call, so the values are alternated
74+ // in these tests
75+ {
76+ tasks := stackManager .NewUnmanagedNodeGroupTask (makeNodeGroups ("bar" , "foo" ), false , fakeVPCImporter )
77+ Expect (tasks .Describe ()).To (Equal (`2 parallel tasks: { create nodegroup "bar", create nodegroup "foo" }` ))
78+ }
79+ {
80+ tasks := stackManager .NewUnmanagedNodeGroupTask (makeNodeGroups ("bar" ), false , fakeVPCImporter )
81+ Expect (tasks .Describe ()).To (Equal (`1 task: { create nodegroup "bar" }` ))
82+ }
83+ {
84+ tasks := stackManager .NewUnmanagedNodeGroupTask (makeNodeGroups ("foo" ), false , fakeVPCImporter )
85+ Expect (tasks .Describe ()).To (Equal (`1 task: { create nodegroup "foo" }` ))
86+ }
87+ {
88+ tasks := stackManager .NewUnmanagedNodeGroupTask (nil , false , fakeVPCImporter )
89+ Expect (tasks .Describe ()).To (Equal (`no tasks` ))
90+ }
91+ {
92+ tasks := stackManager .NewTasksToCreateClusterWithNodeGroups (makeNodeGroups ("bar" , "foo" ), nil , true )
93+ Expect (tasks .Describe ()).To (Equal (`2 sequential tasks: { create cluster control plane "test-cluster", 2 parallel sub-tasks: { create nodegroup "bar", create nodegroup "foo" } }` ))
94+ }
95+ {
96+ tasks := stackManager .NewTasksToCreateClusterWithNodeGroups (makeNodeGroups ("bar" ), nil , false )
97+ Expect (tasks .Describe ()).To (Equal (`2 sequential tasks: { create cluster control plane "test-cluster", create nodegroup "bar" }` ))
98+ }
99+ {
100+ tasks := stackManager .NewTasksToCreateClusterWithNodeGroups (nil , nil , true )
101+ Expect (tasks .Describe ()).To (Equal (`1 task: { create cluster control plane "test-cluster" }` ))
102+ }
103+ {
104+ tasks := stackManager .NewTasksToCreateClusterWithNodeGroups (makeNodeGroups ("bar" , "foo" ), makeManagedNodeGroups ("m1" , "m2" ), false )
105+ Expect (tasks .Describe ()).To (Equal (`2 sequential tasks: { create cluster control plane "test-cluster", 4 parallel sub-tasks: { create nodegroup "bar", create nodegroup "foo", create managed nodegroup "m1", create managed nodegroup "m2" } }` ))
106+ }
107+ {
108+ tasks := stackManager .NewTasksToCreateClusterWithNodeGroups (makeNodeGroups ("foo" ), makeManagedNodeGroups ("m1" ), true )
109+ Expect (tasks .Describe ()).To (Equal (`2 sequential tasks: { create cluster control plane "test-cluster", 2 parallel sub-tasks: { create nodegroup "foo", create managed nodegroup "m1" } }` ))
110+ }
111+ {
112+ tasks := stackManager .NewTasksToCreateClusterWithNodeGroups (makeNodeGroups ("bar" ), nil , false , & task {id : 1 })
113+ Expect (tasks .Describe ()).To (Equal (`2 sequential tasks: { create cluster control plane "test-cluster", 2 sequential sub-tasks: { task 1, create nodegroup "bar" } }` ))
114+ }
115+ })
69116
70- stackManager = NewStackCollection (p , cfg )
117+ When ("IPFamily is set to ipv6" , func () {
118+ BeforeEach (func () {
119+ cfg .VPC .IPFamily = aws .String (string (api .IPV6Family ))
71120 })
72-
73- It ("should have nice description" , func () {
74- makeNodeGroups := func (names ... string ) []* api.NodeGroup {
75- var nodeGroups []* api.NodeGroup
76- for _ , name := range names {
77- ng := api .NewNodeGroup ()
78- ng .Name = name
79- nodeGroups = append (nodeGroups , ng )
80- }
81- return nodeGroups
82- }
83-
84- makeManagedNodeGroups := func (names ... string ) []* api.ManagedNodeGroup {
85- var managedNodeGroups []* api.ManagedNodeGroup
86- for _ , name := range names {
87- ng := api .NewManagedNodeGroup ()
88- ng .Name = name
89- managedNodeGroups = append (managedNodeGroups , ng )
90- }
91- return managedNodeGroups
92- }
93-
94- fakeVPCImporter := new (vpcfakes.FakeImporter )
95- // TODO use DescribeTable
96-
97- // The supportsManagedNodes argument has no effect on the Describe call, so the values are alternated
98- // in these tests
99- {
100- tasks := stackManager .NewUnmanagedNodeGroupTask (makeNodeGroups ("bar" , "foo" ), false , fakeVPCImporter )
101- Expect (tasks .Describe ()).To (Equal (`2 parallel tasks: { create nodegroup "bar", create nodegroup "foo" }` ))
102- }
103- {
104- tasks := stackManager .NewUnmanagedNodeGroupTask (makeNodeGroups ("bar" ), false , fakeVPCImporter )
105- Expect (tasks .Describe ()).To (Equal (`1 task: { create nodegroup "bar" }` ))
106- }
107- {
108- tasks := stackManager .NewUnmanagedNodeGroupTask (makeNodeGroups ("foo" ), false , fakeVPCImporter )
109- Expect (tasks .Describe ()).To (Equal (`1 task: { create nodegroup "foo" }` ))
110- }
111- {
112- tasks := stackManager .NewUnmanagedNodeGroupTask (nil , false , fakeVPCImporter )
113- Expect (tasks .Describe ()).To (Equal (`no tasks` ))
114- }
115- {
116- tasks := stackManager .NewTasksToCreateClusterWithNodeGroups (makeNodeGroups ("bar" , "foo" ), nil , true )
117- Expect (tasks .Describe ()).To (Equal (`2 sequential tasks: { create cluster control plane "test-cluster", 2 parallel sub-tasks: { create nodegroup "bar", create nodegroup "foo" } }` ))
118- }
119- {
120- tasks := stackManager .NewTasksToCreateClusterWithNodeGroups (makeNodeGroups ("bar" ), nil , false )
121- Expect (tasks .Describe ()).To (Equal (`2 sequential tasks: { create cluster control plane "test-cluster", create nodegroup "bar" }` ))
122- }
123- {
124- tasks := stackManager .NewTasksToCreateClusterWithNodeGroups (nil , nil , true )
125- Expect (tasks .Describe ()).To (Equal (`1 task: { create cluster control plane "test-cluster" }` ))
126- }
127- {
128- tasks := stackManager .NewTasksToCreateClusterWithNodeGroups (makeNodeGroups ("bar" , "foo" ), makeManagedNodeGroups ("m1" , "m2" ), false )
129- Expect (tasks .Describe ()).To (Equal (`2 sequential tasks: { create cluster control plane "test-cluster", 4 parallel sub-tasks: { create nodegroup "bar", create nodegroup "foo", create managed nodegroup "m1", create managed nodegroup "m2" } }` ))
130- }
131- {
132- tasks := stackManager .NewTasksToCreateClusterWithNodeGroups (makeNodeGroups ("foo" ), makeManagedNodeGroups ("m1" ), true )
133- Expect (tasks .Describe ()).To (Equal (`2 sequential tasks: { create cluster control plane "test-cluster", 2 parallel sub-tasks: { create nodegroup "foo", create managed nodegroup "m1" } }` ))
134- }
135- {
136- tasks := stackManager .NewTasksToCreateClusterWithNodeGroups (makeNodeGroups ("bar" ), nil , false , & task {id : 1 })
137- Expect (tasks .Describe ()).To (Equal (`2 sequential tasks: { create cluster control plane "test-cluster", 2 sequential sub-tasks: { task 1, create nodegroup "bar" } }` ))
138- }
121+ It ("appends the AssignIpv6AddressOnCreation task to occur after the cluster creation" , func () {
122+ tasks := stackManager .NewTasksToCreateClusterWithNodeGroups (makeNodeGroups ("bar" , "foo" ), nil , true )
123+ Expect (tasks .Describe ()).To (Equal (`3 sequential tasks: { create cluster control plane "test-cluster", set AssignIpv6AddressOnCreation to true for public subnets, 2 parallel sub-tasks: { create nodegroup "bar", create nodegroup "foo" } }` ))
139124 })
140125 })
141126 })
@@ -175,3 +160,23 @@ var _ = Describe("StackCollection Tasks", func() {
175160 })
176161 })
177162})
163+
164+ func makeNodeGroups (names ... string ) []* api.NodeGroup {
165+ var nodeGroups []* api.NodeGroup
166+ for _ , name := range names {
167+ ng := api .NewNodeGroup ()
168+ ng .Name = name
169+ nodeGroups = append (nodeGroups , ng )
170+ }
171+ return nodeGroups
172+ }
173+
174+ func makeManagedNodeGroups (names ... string ) []* api.ManagedNodeGroup {
175+ var managedNodeGroups []* api.ManagedNodeGroup
176+ for _ , name := range names {
177+ ng := api .NewManagedNodeGroup ()
178+ ng .Name = name
179+ managedNodeGroups = append (managedNodeGroups , ng )
180+ }
181+ return managedNodeGroups
182+ }
0 commit comments