@@ -34,9 +34,6 @@ var _ = Describe("controller", Ordered, func() {
34
34
By ("installing prometheus operator" )
35
35
Expect (utils .InstallPrometheusOperator ()).To (Succeed ())
36
36
37
- By ("installing the cert-manager" )
38
- Expect (utils .InstallCertManager ()).To (Succeed ())
39
-
40
37
By ("creating manager namespace" )
41
38
cmd := exec .Command ("kubectl" , "create" , "ns" , namespace )
42
39
_ , _ = utils .Run (cmd )
@@ -46,11 +43,28 @@ var _ = Describe("controller", Ordered, func() {
46
43
By ("uninstalling the Prometheus manager bundle" )
47
44
utils .UninstallPrometheusOperator ()
48
45
49
- By ("uninstalling the cert-manager bundle" )
50
- utils .UninstallCertManager ()
46
+ By ("removing all ingresses" )
47
+ cmd := exec .Command ("kubectl" , "delete" , "ingresses" , "--all" , "--all-namespaces" )
48
+ _ , _ = utils .Run (cmd )
49
+
50
+ By ("removing all dnsrecords" )
51
+ cmd = exec .Command ("kubectl" , "delete" , "dnsrecords" , "--all" , "--all-namespaces" )
52
+ _ , _ = utils .Run (cmd )
53
+
54
+ By ("removing all ips" )
55
+ cmd = exec .Command ("kubectl" , "delete" , "ips" , "--all" , "--all-namespaces" )
56
+ _ , _ = utils .Run (cmd )
57
+
58
+ By ("removing all zones" )
59
+ cmd = exec .Command ("kubectl" , "delete" , "zones" , "--all" , "--all-namespaces" )
60
+ _ , _ = utils .Run (cmd )
61
+
62
+ By ("removing all accounts" )
63
+ cmd = exec .Command ("kubectl" , "delete" , "accounts" , "--all" , "--all-namespaces" )
64
+ _ , _ = utils .Run (cmd )
51
65
52
66
By ("removing manager namespace" )
53
- cmd : = exec .Command ("kubectl" , "delete" , "ns" , namespace )
67
+ cmd = exec .Command ("kubectl" , "delete" , "ns" , namespace )
54
68
_ , _ = utils .Run (cmd )
55
69
})
56
70
@@ -60,7 +74,7 @@ var _ = Describe("controller", Ordered, func() {
60
74
var err error
61
75
62
76
// projectimage stores the name of the image used in the example
63
- projectimage := "example.com /cloudflare-operator:v0.0.1 "
77
+ projectimage := "containeroo /cloudflare-operator:test "
64
78
65
79
By ("building the manager(Operator) image" )
66
80
cmd := exec .Command ("make" , "docker-build" , fmt .Sprintf ("IMG=%s" , projectimage ))
@@ -74,6 +88,7 @@ var _ = Describe("controller", Ordered, func() {
74
88
By ("installing CRDs" )
75
89
cmd = exec .Command ("make" , "install" )
76
90
_ , err = utils .Run (cmd )
91
+ ExpectWithOffset (1 , err ).NotTo (HaveOccurred ())
77
92
78
93
By ("deploying the controller-manager" )
79
94
cmd = exec .Command ("make" , "deploy" , fmt .Sprintf ("IMG=%s" , projectimage ))
@@ -117,4 +132,74 @@ var _ = Describe("controller", Ordered, func() {
117
132
EventuallyWithOffset (1 , verifyControllerUp , time .Minute , time .Second ).Should (Succeed ())
118
133
})
119
134
})
135
+
136
+ It ("should reconcile account" , func () {
137
+ command := "envsubst < config/samples/cloudflareoperatorio_v1_account.yaml | kubectl apply -f -"
138
+ cmd := exec .Command ("sh" , "-c" , command )
139
+ _ , err := utils .Run (cmd )
140
+ Expect (err ).NotTo (HaveOccurred ())
141
+
142
+ Eventually (utils .VerifyObjectReady , time .Minute , time .Second ).
143
+ WithArguments ("account" , "account-sample" ).Should (Succeed ())
144
+ })
145
+
146
+ It ("should reconcile zone" , func () {
147
+ cmd := exec .Command ("kubectl" , "apply" , "-f" , "config/samples/cloudflareoperatorio_v1_zone.yaml" )
148
+ _ , err := utils .Run (cmd )
149
+ Expect (err ).NotTo (HaveOccurred ())
150
+
151
+ Eventually (utils .VerifyObjectReady , time .Minute , time .Second ).WithArguments ("zone" , "zone-sample" ).Should (Succeed ())
152
+ })
153
+
154
+ It ("should reconcile ip" , func () {
155
+ cmd := exec .Command ("kubectl" , "apply" , "-f" , "config/samples/cloudflareoperatorio_v1_ip.yaml" )
156
+ _ , err := utils .Run (cmd )
157
+ Expect (err ).NotTo (HaveOccurred ())
158
+
159
+ Eventually (utils .VerifyObjectReady , time .Minute , time .Second ).
160
+ WithArguments ("ip" , "ip-sample" ).Should (Succeed ())
161
+ })
162
+
163
+ It ("should reconcile dnsreocrd" , func () {
164
+ cmd := exec .Command ("kubectl" , "apply" , "-f" , "config/samples/cloudflareoperatorio_v1_dnsrecord.yaml" )
165
+ _ , err := utils .Run (cmd )
166
+ Expect (err ).NotTo (HaveOccurred ())
167
+
168
+ Eventually (utils .VerifyObjectReady , time .Minute , time .Second ).
169
+ WithArguments ("dnsrecord" , "dnsrecord-sample" ).Should (Succeed ())
170
+ })
171
+
172
+ It ("should reconcile dnsrecord with ipRef" , func () {
173
+ Eventually (utils .VerifyDNSRecordContent , time .Minute , time .Second ).
174
+ WithArguments ("dnsrecord-ip-ref-sample" , "1.1.1.1" ).Should (Succeed ())
175
+ })
176
+
177
+ It ("should reconcile dnsrecord with ipRef when ip changes" , func () {
178
+ cmd := exec .Command ("kubectl" , "patch" , "ip" , "ip-sample" , "--type=merge" , "-p" , `{"spec":{"address":"9.9.9.9"}}` )
179
+ _ , err := utils .Run (cmd )
180
+ Expect (err ).NotTo (HaveOccurred ())
181
+
182
+ Eventually (utils .VerifyDNSRecordContent , time .Minute , time .Second ).
183
+ WithArguments ("dnsrecord-ip-ref-sample" , "9.9.9.9" ).Should (Succeed ())
184
+ })
185
+
186
+ It ("should create dnsrecord from an ingress" , func () {
187
+ cmd := exec .Command ("kubectl" , "apply" , "-f" , "config/samples/networking_v1_ingress.yaml" )
188
+ _ , err := utils .Run (cmd )
189
+ Expect (err ).NotTo (HaveOccurred ())
190
+
191
+ Eventually (utils .VerifyObjectReady , time .Minute , time .Second ).
192
+ WithArguments ("dnsrecord" , "ingress-containeroo-test-org" ).Should (Succeed ())
193
+ })
194
+
195
+ It ("should update dnsrecord when ingress annotations change" , func () {
196
+ cmd := exec .Command (
197
+ "kubectl" , "-n" , namespace , "patch" , "ingress" , "ingress-sample" ,
198
+ "--type=merge" , "-p" , `{"metadata":{"annotations":{"cloudflare-operator.io/content":"145.145.145.145"}}}` )
199
+ _ , err := utils .Run (cmd )
200
+ Expect (err ).NotTo (HaveOccurred ())
201
+
202
+ Eventually (utils .VerifyDNSRecordContent , time .Minute , time .Second ).
203
+ WithArguments ("ingress-containeroo-test-org" , "145.145.145.145" ).Should (Succeed ())
204
+ })
120
205
})
0 commit comments