@@ -25,10 +25,103 @@ import (
25
25
26
26
. "github.com/onsi/ginkgo/v2"
27
27
. "github.com/onsi/gomega"
28
+ appsv1 "k8s.io/api/apps/v1"
29
+ apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
30
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
31
+ "k8s.io/utils/ptr"
32
+ operatorv1 "sigs.k8s.io/cluster-api-operator/api/v1alpha2"
28
33
. "sigs.k8s.io/cluster-api-operator/test/framework"
34
+ "sigs.k8s.io/cluster-api/test/framework"
35
+ "sigs.k8s.io/controller-runtime/pkg/client"
29
36
)
30
37
31
38
var _ = Describe ("Create a proper set of manifests when using helm charts" , func () {
39
+ It ("should deploy a quick-start cluster-api-operator chart" , func () {
40
+ clusterProxy := helmClusterProxy .GetClient ()
41
+
42
+ fullHelmChart := & HelmChart {
43
+ BinaryPath : helmBinaryPath ,
44
+ Path : chartPath ,
45
+ Name : "capi-operator" ,
46
+ Kubeconfig : helmClusterProxy .GetKubeconfigPath (),
47
+ Wait : true ,
48
+ Output : Full ,
49
+ AdditionalFlags : Flags ("--create-namespace" , "--namespace" , operatorNamespace ),
50
+ }
51
+
52
+ defer func () {
53
+ fullHelmChart .Commands = Commands (Uninstall )
54
+ fullHelmChart .AdditionalFlags = Flags ("--namespace" , operatorNamespace )
55
+ fullHelmChart .Run (nil )
56
+
57
+ err := clusterProxy .DeleteAllOf (ctx , & apiextensionsv1.CustomResourceDefinition {}, client.MatchingLabels {
58
+ "clusterctl.cluster.x-k8s.io/core" : "capi-operator" ,
59
+ })
60
+ Expect (err ).ToNot (HaveOccurred ())
61
+ }()
62
+
63
+ _ , err := fullHelmChart .Run (nil )
64
+ Expect (err ).ToNot (HaveOccurred ())
65
+
66
+ coreProvider := & operatorv1.CoreProvider {
67
+ ObjectMeta : metav1.ObjectMeta {
68
+ Name : coreProviderName ,
69
+ Namespace : operatorNamespace ,
70
+ },
71
+ }
72
+ Expect (clusterProxy .Create (ctx , coreProvider )).To (Succeed ())
73
+
74
+ By ("Waiting for the core provider deployment to be ready" )
75
+ framework .WaitForDeploymentsAvailable (ctx , framework.WaitForDeploymentsAvailableInput {
76
+ Getter : clusterProxy ,
77
+ Deployment : & appsv1.Deployment {ObjectMeta : metav1.ObjectMeta {Name : coreProviderDeploymentName , Namespace : operatorNamespace }},
78
+ }, e2eConfig .GetIntervals (helmClusterProxy .GetName (), "wait-controllers" )... )
79
+
80
+ By ("Waiting for core provider to be ready" )
81
+ WaitFor (ctx , For (coreProvider ).In (clusterProxy ).ToSatisfy (
82
+ HaveStatusCondition (& coreProvider .Status .Conditions , operatorv1 .ProviderInstalledCondition ),
83
+ ), e2eConfig .GetIntervals (helmClusterProxy .GetName (), "wait-controllers" )... )
84
+
85
+ By ("Waiting for status.IntalledVersion to be set" )
86
+ WaitFor (ctx , For (coreProvider ).In (clusterProxy ).ToSatisfy (func () bool {
87
+ return ptr .Equal (coreProvider .Status .InstalledVersion , ptr .To (coreProvider .Spec .Version ))
88
+ }), e2eConfig .GetIntervals (helmClusterProxy .GetName (), "wait-controllers" )... )
89
+
90
+ bootstrapProvider := & operatorv1.BootstrapProvider {ObjectMeta : metav1.ObjectMeta {
91
+ Name : bootstrapProviderName ,
92
+ Namespace : operatorNamespace ,
93
+ }}
94
+ deployment := & appsv1.Deployment {ObjectMeta : metav1.ObjectMeta {
95
+ Name : bootstrapProviderDeploymentName ,
96
+ Namespace : operatorNamespace ,
97
+ }}
98
+
99
+ Expect (clusterProxy .Create (ctx , bootstrapProvider )).To (Succeed ())
100
+
101
+ By ("Waiting for the bootstrap provider deployment to be ready" )
102
+ framework .WaitForDeploymentsAvailable (ctx , framework.WaitForDeploymentsAvailableInput {
103
+ Getter : clusterProxy ,
104
+ Deployment : deployment ,
105
+ }, e2eConfig .GetIntervals (helmClusterProxy .GetName (), "wait-controllers" )... )
106
+
107
+ By ("Waiting for bootstrap provider to be ready" )
108
+ WaitFor (ctx , For (bootstrapProvider ).In (clusterProxy ).ToSatisfy (
109
+ HaveStatusCondition (& bootstrapProvider .Status .Conditions , operatorv1 .ProviderInstalledCondition )),
110
+ e2eConfig .GetIntervals (helmClusterProxy .GetName (), "wait-controllers" )... )
111
+
112
+ By ("Waiting for status.IntalledVersion to be set" )
113
+ WaitFor (ctx , For (bootstrapProvider ).In (clusterProxy ).ToSatisfy (func () bool {
114
+ return ptr .Equal (bootstrapProvider .Status .InstalledVersion , & bootstrapProvider .Spec .Version )
115
+ }), e2eConfig .GetIntervals (helmClusterProxy .GetName (), "wait-controllers" )... )
116
+ Expect (clusterProxy .Delete (ctx , bootstrapProvider )).To (Succeed ())
117
+
118
+ By ("Waiting for the bootstrap provider deployment to be deleted" )
119
+ WaitForDelete (ctx , For (deployment ).In (clusterProxy ),
120
+ e2eConfig .GetIntervals (helmClusterProxy .GetName (), "wait-controllers" )... )
121
+
122
+ Expect (clusterProxy .Delete (ctx , coreProvider )).To (Succeed ())
123
+ })
124
+
32
125
It ("should deploy default manifest set for quick-start process" , func () {
33
126
fullRun := & HelmChart {
34
127
BinaryPath : helmChart .BinaryPath ,
0 commit comments