Skip to content
Snippets Groups Projects
Commit cbc6a9c3 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-1928: add tests. servicemonitor and service objects are test complete

parent 4212db27
Branches
Tags
No related merge requests found
...@@ -5,7 +5,7 @@ metadata: ...@@ -5,7 +5,7 @@ metadata:
namespace: {{ include "app.namespace" . }} namespace: {{ include "app.namespace" . }}
labels: labels:
{{- include "app.defaultLabels" . | indent 4 }} {{- include "app.defaultLabels" . | indent 4 }}
component: intelliform-adapter-service component: afm-adapter-service
spec: spec:
ports: ports:
- name: http - name: http
...@@ -20,4 +20,4 @@ spec: ...@@ -20,4 +20,4 @@ spec:
type: ClusterIP type: ClusterIP
selector: selector:
{{- include "app.matchLabels" . | indent 4 }} {{- include "app.matchLabels" . | indent 4 }}
component: intelliform-adapter component: afm-adapter
\ No newline at end of file \ No newline at end of file
...@@ -6,6 +6,7 @@ metadata: ...@@ -6,6 +6,7 @@ metadata:
namespace: {{ include "app.namespace" . }} namespace: {{ include "app.namespace" . }}
labels: labels:
{{- include "app.defaultLabels" . | indent 4 }} {{- include "app.defaultLabels" . | indent 4 }}
component: afm-adapter-service-monitor
spec: spec:
endpoints: endpoints:
- port: metrics - port: metrics
...@@ -16,5 +17,5 @@ spec: ...@@ -16,5 +17,5 @@ spec:
selector: selector:
matchLabels: matchLabels:
{{- include "app.matchLabels" . | indent 6 }} {{- include "app.matchLabels" . | indent 6 }}
component: intelliform-adapter-service component: afm-adapter-service
{{- end }} {{- end }}
\ No newline at end of file
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
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment