@@ -27,26 +27,18 @@ import (
2727)
2828
2929var (
30- gwLabels = map [string ]string {"gwlabel" : "foo" }
31- gwAnnos = map [string ]string {"gwanno" : "bar" }
32-
3330 defaultKnativeServing = v1alpha1.KnativeServing {
3431 ObjectMeta : metav1.ObjectMeta {
3532 Name : "knative-serving" ,
3633 Namespace : "knative-serving" ,
3734 },
38- Spec : v1alpha1.KnativeServingSpec {
39- CommonSpec : v1alpha1.CommonSpec {
40- DeploymentOverride : []v1alpha1.DeploymentOverride {{
41- Name : "3scale-kourier-gateway" ,
42- Labels : gwLabels ,
43- Annotations : gwAnnos ,
44- }},
45- },
46- },
4735 Status : v1alpha1.KnativeServingStatus {
4836 Status : duckv1.Status {
4937 Conditions : []pkgapis.Condition {
38+ {
39+ Status : "True" ,
40+ Type : "Ready" ,
41+ },
5042 {
5143 Status : "True" ,
5244 Type : "DeploymentsAvailable" ,
@@ -131,14 +123,13 @@ var (
131123
132124func init () {
133125 os .Setenv ("OPERATOR_NAME" , "TEST_OPERATOR" )
134- os .Setenv ("KOURIER_MANIFEST_PATH" , "kourier/testdata/kourier-latest.yaml" )
135126 os .Setenv (quickstart .EnvKey , "../../../deploy/resources/quickstart/serverless-application-quickstart.yaml" )
136127 os .Setenv (dashboard .ServingResourceDashboardPathEnvVar , "../dashboard/testdata/grafana-dash-knative-serving-resources.yaml" )
137128 os .Setenv ("TEST_ROLE_PATH" , "../dashboard/testdata/role-service-monitor.yaml" )
138129 apis .AddToScheme (scheme .Scheme )
139130}
140131
141- // TestExtraResourcesReconcile runs Reconcile to verify if extra resources such as Kourier and ConsoleCLIDownload are reconciled.
132+ // TestExtraResourcesReconcile runs Reconcile to verify if extra resources are reconciled.
142133func TestExtraResourcesReconcile (t * testing.T ) {
143134 tests := []struct {
144135 name string
@@ -182,24 +173,8 @@ func TestExtraResourcesReconcile(t *testing.T) {
182173 t .Fatalf ("reconcile: (%v)" , err )
183174 }
184175
185- // Check if Kourier is deployed.
186- deploy := & appsv1.Deployment {}
187- err := cl .Get (context .TODO (), types.NamespacedName {Name : "3scale-kourier-gateway" , Namespace : "knative-serving-ingress" }, deploy )
188- if err != nil {
189- t .Fatalf ("get: (%v)" , err )
190- }
191-
192- // Check if Kourier labels and annotations are added.
193- if deploy .GetLabels ()["gwlabel" ] != gwLabels ["gwlabel" ] {
194- t .Fatalf ("got = %v, want = %v" , deploy .GetLabels ()["gwlabel" ], gwLabels ["gwlabel" ])
195- }
196-
197- if deploy .GetAnnotations ()["gwanno" ] != gwAnnos ["gwanno" ] {
198- t .Fatalf ("got = %v, want = %v" , deploy .GetAnnotations ()["gwanno" ], gwAnnos ["gwanno" ])
199- }
200-
201176 // Check kn ConsoleCLIDownload CR
202- err = cl .Get (context .TODO (), types.NamespacedName {Name : "kn" , Namespace : "" }, ccd )
177+ err : = cl .Get (context .TODO (), types.NamespacedName {Name : "kn" , Namespace : "" }, ccd )
203178 if err != nil {
204179 t .Fatalf ("get: (%v)" , err )
205180 }
@@ -211,12 +186,6 @@ func TestExtraResourcesReconcile(t *testing.T) {
211186 t .Fatalf ("get: (%v)" , err )
212187 }
213188
214- // Delete Kourier deployment.
215- err = cl .Delete (context .TODO (), deploy )
216- if err != nil {
217- t .Fatalf ("delete: (%v)" , err )
218- }
219-
220189 // Delete ConsoleCLIDownload CR
221190 err = cl .Delete (context .TODO (), ccd )
222191 if err != nil {
@@ -250,19 +219,6 @@ func TestExtraResourcesReconcile(t *testing.T) {
250219 }
251220 }
252221
253- // Check again if Kourier deployment is created after reconcile.
254- err = cl .Get (context .TODO (), types.NamespacedName {Name : "3scale-kourier-gateway" , Namespace : "knative-serving-ingress" }, deploy )
255- checkError (t , err )
256-
257- // Check again if Kourier labels and annotations are added.
258- if deploy .GetLabels ()["gwlabel" ] != gwLabels ["gwlabel" ] {
259- t .Fatalf ("got = %v, want = %v" , deploy .GetLabels ()["gwlabel" ], gwLabels ["gwlabel" ])
260- }
261-
262- if deploy .GetAnnotations ()["gwanno" ] != gwAnnos ["gwanno" ] {
263- t .Fatalf ("got = %v, want = %v" , deploy .GetAnnotations ()["gwanno" ], gwAnnos ["gwanno" ])
264- }
265-
266222 // Check again if Serving dashboard configmap is available.
267223 err = cl .Get (context .TODO (), types.NamespacedName {Name : "grafana-dashboard-definition-knative-serving-resources" , Namespace : ns .Name }, dashboardCM )
268224 checkError (t , err )
@@ -399,44 +355,6 @@ func TestCustomCertsConfigMap(t *testing.T) {
399355 }
400356}
401357
402- // TestKnativeServingStatus tests KnativeServing CR status with Kourier's installation failure.
403- func TestKnativeServingStatus (t * testing.T ) {
404- cl := fake .NewClientBuilder ().
405- WithObjects (& defaultKnativeServing , & defaultIngress , & defaultKnService , & servingNamespace ).
406- Build ()
407-
408- r := & ReconcileKnativeServing {client : cl , scheme : scheme .Scheme }
409-
410- // Test with invalid Kourier manifest file.
411- os .Setenv ("KOURIER_MANIFEST_PATH" , "kourier/testdata/non-exist-file" )
412- if _ , err := r .Reconcile (context .Background (), defaultRequest ); err == nil {
413- t .Fatalf ("reconcile does not fail with invalid manifest path" )
414- }
415-
416- failedKs := & v1alpha1.KnativeServing {}
417- err := cl .Get (context .TODO (), types.NamespacedName {Name : "knative-serving" , Namespace : "knative-serving" }, failedKs )
418- if err != nil {
419- t .Fatalf ("get: (%v)" , err )
420- }
421- if failedKs .Status .GetCondition (v1alpha1 .DependenciesInstalled ).Status != corev1 .ConditionFalse {
422- t .Fatalf ("status: (%v)" , failedKs .Status .GetCondition (v1alpha1 .DependenciesInstalled ))
423- }
424-
425- // Reconcile with correct Kourier manifest file.
426- os .Setenv ("KOURIER_MANIFEST_PATH" , "kourier/testdata/kourier-latest.yaml" )
427- if _ , err := r .Reconcile (context .Background (), defaultRequest ); err != nil {
428- t .Fatalf ("reconcile: (%v)" , err )
429- }
430- successKs := & v1alpha1.KnativeServing {}
431- err = cl .Get (context .TODO (), types.NamespacedName {Name : "knative-serving" , Namespace : "knative-serving" }, successKs )
432- if err != nil {
433- t .Fatalf ("get: (%v)" , err )
434- }
435- if successKs .Status .GetCondition (v1alpha1 .DependenciesInstalled ).Status != corev1 .ConditionTrue {
436- t .Fatalf ("status: (%v)" , failedKs .Status .GetCondition (v1alpha1 .DependenciesInstalled ))
437- }
438- }
439-
440358func ctrl (certVersion string ) * appsv1.Deployment {
441359 return & appsv1.Deployment {
442360 TypeMeta : metav1.TypeMeta {
0 commit comments