Skip to content

Commit

Permalink
Test pods implementation
Browse files Browse the repository at this point in the history
Complete implementation of pods for testing various deployment cloud scenarios
Documentation in readme
  • Loading branch information
blaskoa committed Dec 13, 2023
1 parent 5a1f456 commit de5999a
Show file tree
Hide file tree
Showing 9 changed files with 262 additions and 24 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,18 @@ jobs:
- name: Install helm chart
run: |
helm install -f ci-values.yaml smartface .
kubectl rollout status deployment sf-api --timeout=600s || true
kubectl rollout status deployment sf-api --timeout=300s
- name: Test helm chart
run: |
helm test smartface
- name: Dump cluster info
if: ${{ always() }}
run: |
kubectl cluster-info dump > cluster-info.txt
- name: Archive cluster-info
- name: Upload cluster-info
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: cluster-info
path: |
cluster-info.txt
- name: Test helm chart
run: |
helm test smartface
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ The helm chart needs certain objects to be present in the cluster before it can

By default an ingress object is created with the helm chart. To configure the ingress please see the `ingress.*` values

## Tests

[Helm chart tests](https://helm.sh/docs/topics/chart_tests/) are included and can be run using `helm test` command. The aim of these tests is to touch most of the deployments to check wether SmartFace components deployed successfully and are working. Their successful completion is not a guarantee that the application is fully functional.

Based on the configured functionality of the helm chart (values) some tests might not be run as they might require functionality which is not deployed. Please see the test pod templates to see the impact of configured values to test pods which are run in the helm chart tests.

In case the tests fail please refer to the output of the test pod to identify the issue.

### Test data

During the tests some data (Watchlists / EdgeStreams) will be created in the deployed smartface. The tests will try to cleanup all data they created without touching any other data present in the system, but the note that the cleanup might fail for various reasons, resulting in test data being left behind in the system.

## Requirements

| Repository | Name | Version |
Expand Down Expand Up @@ -528,6 +540,15 @@ metadata:
| streamDataDbWorker.resources.requests.cpu | string | `"100m"` | |
| streamDataDbWorker.resources.requests.memory | string | `"100M"` | |
| streamDataDbWorker.tolerations | list | `[]` | |
| tests.image.digest | string | `nil` | Overrides the image tag with an image digest |
| tests.image.pullPolicy | string | `"IfNotPresent"` | Docker image pull policy |
| tests.image.registry | string | `nil` | The Docker registry, overrides `global.image.registry` |
| tests.image.repository | string | `"innovatrics/smartface/sf-cloud-func-tests"` | Docker image repository |
| tests.image.tag | string | `"v5_4.22.0.5164-dev"` | Countly publisher follows different versioning, so the chart app needs to be overridden |
| tests.nodeSelector | object | `{}` | |
| tests.podAnnotations | object | `{}` | Annotations for test pods |
| tests.podLabels | object | `{}` | Additional labels for test pods |
| tests.tolerations | list | `[]` | |

## Maintainers

Expand Down
12 changes: 12 additions & 0 deletions README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ The helm chart needs certain objects to be present in the cluster before it can

By default an ingress object is created with the helm chart. To configure the ingress please see the `ingress.*` values

## Tests

[Helm chart tests](https://helm.sh/docs/topics/chart_tests/) are included and can be run using `helm test` command. The aim of these tests is to touch most of the deployments to check wether SmartFace components deployed successfully and are working. Their successful completion is not a guarantee that the application is fully functional.

Based on the configured functionality of the helm chart (values) some tests might not be run as they might require functionality which is not deployed. Please see the test pod templates to see the impact of configured values to test pods which are run in the helm chart tests.

In case the tests fail please refer to the output of the test pod to identify the issue.

### Test data

During the tests some data (Watchlists / EdgeStreams) will be created in the deployed smartface. The tests will try to cleanup all data they created without touching any other data present in the system, but the note that the cleanup might fail for various reasons, resulting in test data being left behind in the system.

{{ template "chart.requirementsSection" . }}

All chart dependencies are optional and can be disabled and supplemented with other (for example cloud-based) alternatives
Expand Down
31 changes: 31 additions & 0 deletions templates/_components.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -465,3 +465,34 @@ Template used for resolving S3 config map name
{{- $suffix := "s3" -}}
{{- printf "%s-%s" $prefix $suffix -}}
{{- end -}}

{{/*
Tests
*/}}

{{/*
Template used for resolving Watchlist tests name
*/}}
{{- define "smartface.watchlistTests.name" }}
{{- $prefix := include "smartface.name" . -}}
{{- $suffix := "watchlist-tests" -}}
{{- printf "%s-%s" $prefix $suffix -}}
{{- end -}}

{{/*
Template used for resolving Edge Stream tests name
*/}}
{{- define "smartface.edgeStreamTests.name" }}
{{- $prefix := include "smartface.name" . -}}
{{- $suffix := "edge-stream-tests" -}}
{{- printf "%s-%s" $prefix $suffix -}}
{{- end -}}

{{/*
Template used for resolving GraphQL tests name
*/}}
{{- define "smartface.graphQlTests.name" }}
{{- $prefix := include "smartface.name" . -}}
{{- $suffix := "graphql-tests" -}}
{{- printf "%s-%s" $prefix $suffix -}}
{{- end -}}
66 changes: 66 additions & 0 deletions templates/tests/edge-stream-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{{- if (and .Values.features.edgeStreams.enabled .Values.api.enabled .Values.graphqlApi.enabled (not .Values.graphqlApi.enableAuth) (eq .Values.edgeStreamProcessor.operationMode.matchingDataStrategy "ServerOnly")) }}
{{- $name := include "smartface.edgeStreamTests.name" . -}}
apiVersion: v1
kind: Pod
metadata:
name: {{ $name | quote }}
annotations:
"helm.sh/hook": test
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.tests.podAnnotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- with .Values.podLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.tests.podLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
serviceAccountName: {{ .Values.serviceAccount.name | quote }}
automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 4 }}
{{- end }}
containers:
- name: {{ $name | quote }}
image: {{ include "smartface.image" (dict "local" .Values.tests.image "global" .Values.global.image "defaultVersion" .Chart.AppVersion) }}
imagePullPolicy: {{ .Values.tests.image.pullPolicy }}
args: ['--filter', 'Category=EdgeStreams']
env:
- name: "SF_TEST_API_URL"
value: "http://{{ include "smartface.api.name" . }}.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.api.servicePort }}"
- name: "SF_TEST_GQL_API_URL"
value: "http://{{ include "smartface.graphqlApi.name" . }}.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.graphqlApi.servicePort }}"
- name: "SF_ZMQ_HOST"
value: "{{ include "smartface.base.name" . }}.{{ .Release.Namespace }}.svc.cluster.local"
- name: "SF_ZMQ_PORT"
value: "{{ .Values.base.zmqServicePort }}"

{{- include "smartface.mqttConfig" . | nindent 4 }}
- name: "SF_MQTT_HOST"
value: "$(MQTT__Hostname)"
- name: "SF_MQTT_PORT"
value: "$(MQTT__Port)"
- name: "SF_MQTT_USER"
value: "$(MQTT__Username)"
- name: "SF_MQTT_PASS"
value: "$(MQTT__Password)"
volumeMounts:
{{- include "smartface.licVolumeMount" . | nindent 4 }}
volumes:
{{- include "smartface.licVolume" . | nindent 4 }}
{{- with .Values.tests.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.tests.tolerations }}
tolerations:
{{- toYaml . | nindent 4 }}
{{- end }}
restartPolicy: Never
{{- end }}
52 changes: 52 additions & 0 deletions templates/tests/graphql-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{{- if (and .Values.api.enabled .Values.graphqlApi.enabled (not .Values.graphqlApi.enableAuth)) }}
{{- $name := include "smartface.graphQlTests.name" . -}}
apiVersion: v1
kind: Pod
metadata:
name: {{ $name | quote }}
annotations:
"helm.sh/hook": test
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.tests.podAnnotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- with .Values.podLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.tests.podLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
serviceAccountName: {{ .Values.serviceAccount.name | quote }}
automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 4 }}
{{- end }}
containers:
- name: {{ $name | quote }}
image: {{ include "smartface.image" (dict "local" .Values.tests.image "global" .Values.global.image "defaultVersion" .Chart.AppVersion) }}
imagePullPolicy: {{ .Values.tests.image.pullPolicy }}
args: ['--filter', 'Category=GraphQL']
env:
- name: "SF_TEST_API_URL"
value: "http://{{ include "smartface.api.name" . }}.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.api.servicePort }}"
- name: "SF_TEST_GQL_API_URL"
value: "http://{{ include "smartface.graphqlApi.name" . }}.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.graphqlApi.servicePort }}"
volumeMounts:
{{- include "smartface.licVolumeMount" . | nindent 4 }}
volumes:
{{- include "smartface.licVolume" . | nindent 4 }}
{{- with .Values.tests.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.tests.tolerations }}
tolerations:
{{- toYaml . | nindent 4 }}
{{- end }}
restartPolicy: Never
{{- end }}
19 changes: 0 additions & 19 deletions templates/tests/watchlist-api-test.yaml

This file was deleted.

52 changes: 52 additions & 0 deletions templates/tests/watchlist-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{{- if .Values.api.enabled }}
{{- $name := include "smartface.watchlistTests.name" . -}}
apiVersion: v1
kind: Pod
metadata:
name: {{ $name | quote }}
annotations:
"helm.sh/hook": test
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.tests.podAnnotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- with .Values.podLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.tests.podLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
serviceAccountName: {{ .Values.serviceAccount.name | quote }}
automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 4 }}
{{- end }}
containers:
- name: {{ $name | quote }}
image: {{ include "smartface.image" (dict "local" .Values.tests.image "global" .Values.global.image "defaultVersion" .Chart.AppVersion) }}
imagePullPolicy: {{ .Values.tests.image.pullPolicy }}
args: ['--filter', 'Category=Watchlists&SkipOnPlatform!=Cloud']
env:
- name: "SF_TEST_API_URL"
value: "http://{{ include "smartface.api.name" . }}.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.api.servicePort }}"
# .Values.api.enabled
# .Values.graphqlApi.enableAuth
volumeMounts:
{{- include "smartface.licVolumeMount" . | nindent 4 }}
volumes:
{{- include "smartface.licVolume" . | nindent 4 }}
{{- with .Values.tests.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.tests.tolerations }}
tolerations:
{{- toYaml . | nindent 4 }}
{{- end }}
restartPolicy: Never
{{- end }}
19 changes: 19 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,25 @@ countlyPublisher:
# -- Docker image pull policy
pullPolicy: IfNotPresent

tests:
# -- Annotations for test pods
podAnnotations: {}
# -- Additional labels for test pods
podLabels: {}
nodeSelector: {}
tolerations: []
image:
# -- The Docker registry, overrides `global.image.registry`
registry: null
# -- Docker image repository
repository: innovatrics/smartface/sf-cloud-func-tests
# -- Countly publisher follows different versioning, so the chart app needs to be overridden
tag: "v5_4.22.0.5164-dev"
# -- Overrides the image tag with an image digest
digest: null
# -- Docker image pull policy
pullPolicy: IfNotPresent

metrics:
enabled: false
monitorDiscoveryLabel:
Expand Down

0 comments on commit de5999a

Please sign in to comment.