diff --git a/templates/service.yaml b/templates/service.yaml index 427d60318ae8a66d8bb96fac69a6ea2b180117b7..29a3e4583044cafe9fd2c785cce8583361a7b8ff 100644 --- a/templates/service.yaml +++ b/templates/service.yaml @@ -5,7 +5,7 @@ metadata: namespace: {{ include "app.namespace" . }} labels: {{- include "app.defaultLabels" . | indent 4 }} - component: intelliform-adapter-service + component: afm-adapter-service spec: ports: - name: http @@ -20,4 +20,4 @@ spec: type: ClusterIP selector: {{- include "app.matchLabels" . | indent 4 }} - component: intelliform-adapter \ No newline at end of file + component: afm-adapter \ No newline at end of file diff --git a/templates/service_monitor.yaml b/templates/service_monitor.yaml index f7052d4d7eb9ed092a76b109bc43f470e3694135..05fb7b00f7d1a4545e363021f84f37da1a7f28ca 100644 --- a/templates/service_monitor.yaml +++ b/templates/service_monitor.yaml @@ -6,6 +6,7 @@ metadata: namespace: {{ include "app.namespace" . }} labels: {{- include "app.defaultLabels" . | indent 4 }} + component: afm-adapter-service-monitor spec: endpoints: - port: metrics @@ -16,5 +17,5 @@ spec: selector: matchLabels: {{- include "app.matchLabels" . | indent 6 }} - component: intelliform-adapter-service + component: afm-adapter-service {{- end }} \ No newline at end of file diff --git a/unit-tests/service_monitor_test.yaml b/unit-tests/service_monitor_test.yaml new file mode 100644 index 0000000000000000000000000000000000000000..beb6ba56fb086d0e1f080a3906a90f1c0f892d99 --- /dev/null +++ b/unit-tests/service_monitor_test.yaml @@ -0,0 +1,54 @@ +suite: test deployment +release: + name: afm-adapter + namespace: sh-helm-test +templates: + - templates/service_monitor.yaml +tests: + - it: should have the label component with value afm-adapter-service-monitor attached + asserts: + - isKind: + of: ServiceMonitor + - equal: + path: metadata.labels.[component] + value: afm-adapter-service-monitor + - it: should have the metrics endpoint configured by default + set: + env.springProfiles: oc,stage + asserts: + - isKind: + of: ServiceMonitor + - contains: + path: spec.endpoints + content: + port: metrics + path: /actuator/prometheus + - it: should be able to disable the endpoint + set: + scrapeMetricsDisabled: false + asserts: + - isKind: + of: ServiceMonitor + - contains: + path: spec.endpoints + content: + port: metrics + path: /actuator/prometheus + - it: namespace selector should contain the namespace + asserts: + - contains: + path: spec.namespaceSelector.matchNames + content: sh-helm-test + - it: selector should contain the component label with the value afm-adapter-service + asserts: + - equal: + path: spec.selector.matchLabels.[component] + value: afm-adapter-service + - it: selector should contain helm recommended labels name and namespace + asserts: + - equal: + path: spec.selector.matchLabels.[app.kubernetes.io/name] + value: afm-adapter + - equal: + path: spec.selector.matchLabels.[app.kubernetes.io/namespace] + value: sh-helm-test diff --git a/unit-tests/service_test.yaml b/unit-tests/service_test.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4a24297a85d1a344424aba8952950640c4f5735c --- /dev/null +++ b/unit-tests/service_test.yaml @@ -0,0 +1,66 @@ +suite: test deployment +release: + name: afm-adapter + namespace: sh-helm-test +templates: + - templates/service.yaml +tests: + - it: should have the label component with value afm-adapter-service attached + asserts: + - isKind: + of: Service + - equal: + path: metadata.labels.[component] + value: afm-adapter-service + - it: should be of type ClusterIP + asserts: + - equal: + path: spec.type + value: ClusterIP + - it: ports should contain the 8080 default http port + asserts: + - contains: + path: spec.ports + content: + name: http + port: 8080 + protocol: TCP + targetPort: 8080 + count: 1 + any: true + - it: ports should contain the metrics port + asserts: + - contains: + path: spec.ports + content: + name: metrics + port: 8081 + protocol: TCP + count: 1 + any: true + - it: ports should not contain the metrics port when deactivated + set: + scrapeMetricsDisabled: true + asserts: + - notContains: + path: spec.ports + content: + name: metrics + port: 8081 + protocol: TCP + count: 1 + any: true + - it: selector should contain the component label with the value afm-adapter + asserts: + - equal: + path: spec.selector.[component] + value: afm-adapter + - it: selector should contain helm recommended labels name and namespace + asserts: + - equal: + path: spec.selector.[app.kubernetes.io/name] + value: afm-adapter + - equal: + path: spec.selector.[app.kubernetes.io/namespace] + value: sh-helm-test + \ No newline at end of file