@@ -38,13 +38,15 @@ func SecondClusterSpec(ctx context.Context, inputGetter func() CommonSpecInput)
38
38
39
39
var (
40
40
input CommonSpecInput
41
- namespace * corev1.Namespace
42
- cancelWatches context.CancelFunc
41
+ namespace1 * corev1.Namespace
42
+ namespace2 * corev1.Namespace
43
+ cancelWatches1 context.CancelFunc
44
+ cancelWatches2 context.CancelFunc
43
45
clusterResources1 * clusterctl.ApplyClusterTemplateAndWaitResult
44
46
clusterResources2 * clusterctl.ApplyClusterTemplateAndWaitResult
45
47
)
46
48
47
- createCluster := func (flavor string , resources * clusterctl.ApplyClusterTemplateAndWaitResult ) {
49
+ createCluster := func (flavor string , namespace * corev1. Namespace , resources * clusterctl.ApplyClusterTemplateAndWaitResult ) {
48
50
clusterctl .ApplyClusterTemplateAndWait (ctx , clusterctl.ApplyClusterTemplateAndWaitInput {
49
51
ClusterProxy : input .BootstrapClusterProxy ,
50
52
CNIManifestPath : input .E2EConfig .GetVariable (CNIPath ),
@@ -76,34 +78,42 @@ func SecondClusterSpec(ctx context.Context, inputGetter func() CommonSpecInput)
76
78
Expect (input .E2EConfig .Variables ).To (HaveKey (KubernetesVersion ))
77
79
Expect (input .E2EConfig .Variables ).To (HaveValidVersion (input .E2EConfig .GetVariable (KubernetesVersion )))
78
80
79
- // Setup a Namespace where to host objects for this spec and create a watcher for the namespace events.
80
- namespace , cancelWatches = setupSpecNamespace (ctx , specName , input .BootstrapClusterProxy , input .ArtifactFolder )
81
+ // Set up namespaces to host objects for this spec and create watchers for the namespace events.
82
+ namespace1 , cancelWatches1 = setupSpecNamespace (ctx , specName , input .BootstrapClusterProxy , input .ArtifactFolder )
83
+ namespace2 , cancelWatches2 = setupSpecNamespace (ctx , specName , input .BootstrapClusterProxy , input .ArtifactFolder )
81
84
clusterResources1 = new (clusterctl.ApplyClusterTemplateAndWaitResult )
82
85
clusterResources2 = new (clusterctl.ApplyClusterTemplateAndWaitResult )
83
86
})
84
87
85
88
It ("should successfully add and remove a second cluster" , func () {
86
- By ("create the first cluster" )
87
- createCluster (clusterctl .DefaultFlavor , clusterResources1 )
89
+ mgmtClient := input .BootstrapClusterProxy .GetClient ()
88
90
89
- By ("create the second cluster" )
90
- createCluster ("second-cluster" , clusterResources2 )
91
+ By ("create the first cluster and verify that it's ready" )
92
+ createCluster (clusterctl .DefaultFlavor , namespace1 , clusterResources1 )
93
+ Expect (IsClusterReady (ctx , mgmtClient , clusterResources1 .Cluster )).To (BeTrue ())
91
94
92
- By ("verify that the second cluster works" )
95
+ By ("create the second cluster and verify that it's ready" )
96
+ createCluster ("second-cluster" , namespace2 , clusterResources2 )
97
+ Expect (IsClusterReady (ctx , mgmtClient , clusterResources2 .Cluster )).To (BeTrue ())
93
98
94
99
By ("delete the second cluster" )
95
- dumpSpecResourcesAndCleanup (ctx , specName , input .BootstrapClusterProxy , input .ArtifactFolder , namespace , cancelWatches , clusterResources2 .Cluster , input .E2EConfig .GetIntervals , input .SkipCleanup )
100
+ dumpSpecResourcesAndCleanup (ctx , specName , input .BootstrapClusterProxy , input .ArtifactFolder , namespace2 ,
101
+ cancelWatches2 , clusterResources2 .Cluster , input .E2EConfig .GetIntervals , false )
96
102
97
- By ("verify that the second cluster is gone" )
103
+ By ("verify the second cluster is gone" )
104
+ Expect (ClusterExists (ctx , mgmtClient , clusterResources2 .Cluster )).To (BeFalse ())
98
105
99
- By ("verify that the first cluster still works" )
106
+ By ("verify the first cluster is still ready" )
107
+ Expect (IsClusterReady (ctx , mgmtClient , clusterResources1 .Cluster )).To (BeTrue ())
100
108
101
109
By ("PASSED!" )
102
110
})
103
111
104
112
AfterEach (func () {
105
113
// Dumps all the resources in the spec namespace, then cleanups the cluster object and the spec namespace itself.
106
- dumpSpecResourcesAndCleanup (ctx , specName , input .BootstrapClusterProxy , input .ArtifactFolder , namespace , cancelWatches , clusterResources1 .Cluster , input .E2EConfig .GetIntervals , input .SkipCleanup )
107
- dumpSpecResourcesAndCleanup (ctx , specName , input .BootstrapClusterProxy , input .ArtifactFolder , namespace , cancelWatches , clusterResources2 .Cluster , input .E2EConfig .GetIntervals , input .SkipCleanup )
114
+ dumpSpecResourcesAndCleanup (ctx , specName , input .BootstrapClusterProxy , input .ArtifactFolder , namespace1 , cancelWatches1 , clusterResources1 .Cluster , input .E2EConfig .GetIntervals , input .SkipCleanup )
115
+ if clusterResources2 .Cluster != nil && ClusterExists (ctx , input .BootstrapClusterProxy .GetClient (), clusterResources2 .Cluster ) {
116
+ dumpSpecResourcesAndCleanup (ctx , specName , input .BootstrapClusterProxy , input .ArtifactFolder , namespace2 , cancelWatches2 , clusterResources2 .Cluster , input .E2EConfig .GetIntervals , input .SkipCleanup )
117
+ }
108
118
})
109
119
}
0 commit comments