diff --git a/tests/functional/base_test.go b/tests/functional/base_test.go index 928255e..ef6a431 100644 --- a/tests/functional/base_test.go +++ b/tests/functional/base_test.go @@ -51,6 +51,8 @@ func GetDefaultWatcherAPISpec() map[string]interface{} { "databaseInstance": "openstack", "secret": SecretName, "memcachedInstance": "memcached", + "serviceAccount": "watcher-sa", + "containerImage": "test://watcher", } } diff --git a/tests/functional/watcher_test_data.go b/tests/functional/watcher_test_data.go index f9e35ad..3a44c42 100644 --- a/tests/functional/watcher_test_data.go +++ b/tests/functional/watcher_test_data.go @@ -46,6 +46,7 @@ type WatcherTestData struct { RoleName types.NamespacedName RoleBindingName types.NamespacedName WatcherDBSync types.NamespacedName + WatcherAPIDeployment types.NamespacedName } // GetWatcherTestData is a function that initialize the WatcherTestData @@ -110,5 +111,9 @@ func GetWatcherTestData(watcherName types.NamespacedName) WatcherTestData { Namespace: watcherName.Namespace, Name: fmt.Sprintf("%s-db-sync", watcherName.Name), }, + WatcherAPIDeployment: types.NamespacedName{ + Namespace: watcherName.Namespace, + Name: "watcher-api-api", + }, } } diff --git a/tests/functional/watcherapi_controller_test.go b/tests/functional/watcherapi_controller_test.go index 3c37bd1..2e0ae8c 100644 --- a/tests/functional/watcherapi_controller_test.go +++ b/tests/functional/watcherapi_controller_test.go @@ -156,6 +156,33 @@ var _ = Describe("WatcherAPI controller", func() { corev1.ConditionTrue, ) }) + It("creates a deployment for the watcher-api service", func() { + th.SimulateDeploymentReplicaReady(watcherTest.WatcherAPIDeployment) + th.ExpectCondition( + watcherTest.WatcherAPI, + ConditionGetterFunc(WatcherAPIConditionGetter), + condition.DeploymentReadyCondition, + corev1.ConditionTrue, + ) + + deployment := th.GetDeployment(watcherTest.WatcherAPIDeployment) + Expect(deployment.Spec.Template.Spec.ServiceAccountName).To(Equal("watcher-sa")) + Expect(int(*deployment.Spec.Replicas)).To(Equal(1)) + Expect(deployment.Spec.Template.Spec.Volumes).To(HaveLen(3)) + Expect(deployment.Spec.Template.Spec.Containers).To(HaveLen(2)) + Expect(deployment.Spec.Selector.MatchLabels).To(Equal(map[string]string{"service": "watcher-api"})) + + container := deployment.Spec.Template.Spec.Containers[0] + Expect(container.VolumeMounts).To(HaveLen(1)) + Expect(container.Image).To(Equal("test://watcher")) + + container = deployment.Spec.Template.Spec.Containers[1] + Expect(container.VolumeMounts).To(HaveLen(4)) + Expect(container.Image).To(Equal("test://watcher")) + + Expect(container.LivenessProbe.HTTPGet.Port.IntVal).To(Equal(int32(9322))) + Expect(container.ReadinessProbe.HTTPGet.Port.IntVal).To(Equal(int32(9322))) + }) }) When("the secret is created but missing fields", func() { BeforeEach(func() { diff --git a/tests/kuttl/test-suites/default/watcher-api/03-assert.yaml b/tests/kuttl/test-suites/default/watcher-api/03-assert.yaml index 12f35a9..4bda4a6 100644 --- a/tests/kuttl/test-suites/default/watcher-api/03-assert.yaml +++ b/tests/kuttl/test-suites/default/watcher-api/03-assert.yaml @@ -14,6 +14,10 @@ status: reason: Ready status: "True" type: Ready + - message: Deployment completed + reason: Ready + status: "True" + type: DeploymentReady - message: Input data complete reason: Ready status: "True" @@ -32,3 +36,32 @@ kind: Secret metadata: name: watcher-kuttl type: Opaque +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: watcherapi-kuttl-api + labels: + service: watcher-api +spec: + replicas: 1 + template: + spec: + containers: + - name: watcherapi-kuttl-log + - name: watcher-api +status: + readyReplicas: 1 + replicas: 1 +--- +apiVersion: v1 +kind: Pod +metadata: + labels: + service: watcher-api +spec: + containers: + - name: watcherapi-kuttl-log + - name: watcher-api +status: + phase: Running diff --git a/tests/kuttl/test-suites/default/watcher-api/03-deploy-watcher-api.yaml b/tests/kuttl/test-suites/default/watcher-api/03-deploy-watcher-api.yaml index 1f6a939..fcd4585 100644 --- a/tests/kuttl/test-suites/default/watcher-api/03-deploy-watcher-api.yaml +++ b/tests/kuttl/test-suites/default/watcher-api/03-deploy-watcher-api.yaml @@ -5,3 +5,5 @@ metadata: spec: secret: watcher-kuttl memcachedInstance: "memcached" + containerImage: "quay.io/podified-master-centos9/openstack-watcher-api:current-podified" + serviceAccount: watcher-watcher-kuttl diff --git a/tests/kuttl/test-suites/default/watcher-api/05-errors.yaml b/tests/kuttl/test-suites/default/watcher-api/05-errors.yaml new file mode 100644 index 0000000..672ed5d --- /dev/null +++ b/tests/kuttl/test-suites/default/watcher-api/05-errors.yaml @@ -0,0 +1,15 @@ +apiVersion: watcher.openstack.org/v1beta1 +kind: WatcherAPI +metadata: + name: watcherapi-kuttl +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: watcherapi-kuttl-api +--- +apiVersion: v1 +kind: Pod +metadata: + labels: + service: watcher-api