Skip to content

Commit

Permalink
Helm acceptance tests (#2002)
Browse files Browse the repository at this point in the history
* Add a pod template to run the mirror node acceptance tests
* Add a secret template to hold the acceptance tests application.yml
* Update documentation to explain new helm tests.

Signed-off-by: Ian Jungmann <ian.jungmann@hedera.com>
  • Loading branch information
Ian Jungmann authored May 25, 2021
1 parent ae2a4c7 commit 310f21c
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 6 deletions.
24 changes: 22 additions & 2 deletions charts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,30 @@ When deploying in GCP, the following steps may be taken to use container-native
## Testing

To verify the chart installation is successful, you can run the helm tests. These tests are not automatically executed
by helm on install/upgrade, they have to be executed manually:
by helm on install/upgrade, they have to be executed manually. The tests require the `existingTopicNum`, `operatorId`,
and `operatorKey` properties be set in a local values file in order to execute, as well as `network` if using an environment other
than testnet, and `nodes` if using a custom environment.

To configure:

```yaml
test:
config:
hedera:
mirror:
test:
acceptance:
existingTopicNum:
network:
# Do not use use 0.0.2 or 0.0.50 for operator to ensure crypto transfers are not waived
operatorId:
operatorKey:
```

To execute:

```shell script
helm test "${RELEASE}"
helm test "${RELEASE} " --timeout 10m
```

## Using
Expand Down
34 changes: 34 additions & 0 deletions charts/hedera-mirror/templates/tests/pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{{- if .Values.test.enabled -}}
apiVersion: v1
kind: Pod
metadata:
labels: {{- include "hedera-mirror.labels" . | nindent 4 }}
name: {{ include "hedera-mirror.fullname" . }}-acceptance-test
namespace: {{ include "hedera-mirror.namespace" . }}
annotations:
helm.sh/hook: test
helm.sh/hook-delete-policy: hook-failed,hook-succeeded
spec:
containers:
- name: acceptance-tests
image: "{{ .Values.test.image.repository }}:{{ .Values.global.image.tag | default .Values.test.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.test.image.pullPolicy }}
command:
- 'sh'
- '-c'
# Copying the contents of the secret to the directory the image reads from without overwriting the existing yml.
- |
cp /etc/secrets/* /usr/etc/hedera-mirror-node/hedera-mirror-test/src/test/resources/
./mvnw integration-test --projects hedera-mirror-test/ -P=acceptance-tests -Dcucumber.filter.tags={{ .Values.test.cucumberTags }}
volumeMounts:
- name: acceptance-tests
mountPath: /etc/secrets
readOnly: true
restartPolicy: Never
terminationGracePeriodSeconds: 1
volumes:
- name: acceptance-tests
secret:
defaultMode: 420
secretName: {{ include "hedera-mirror.fullname" . }}-acceptance-test
{{- end -}}
16 changes: 16 additions & 0 deletions charts/hedera-mirror/templates/tests/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{- if .Values.test.enabled -}}
apiVersion: v1
kind: Secret
metadata:
labels: {{ include "hedera-mirror.labels" . | nindent 4 }}
name: {{ include "hedera-mirror.fullname" . }}-acceptance-test
namespace: {{ include "hedera-mirror.namespace" . }}
annotations:
helm.sh/hook: test
helm.sh/hook-delete-policy: hook-failed,hook-succeeded
type: Opaque
stringData:
# application-default.yml as application.yml will overwrite the existing yml in the hedera-mirror-test image.
application-default.yml: |-
{{- tpl (toYaml .Values.test.config) $ | nindent 4 }}
{{- end -}}
32 changes: 28 additions & 4 deletions charts/hedera-mirror/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ applicationResource:
partnerName: ""
solutionId: ""

global:
namespaceOverride: ""
useReleaseForNameLabel: false # Set the name label to the release name for Marketplace

db:
host: "{{ .Release.Name }}"
name: mirror_node
Expand All @@ -60,6 +56,11 @@ db:
password: "" # Randomly generated if left blank
username: mirror_node

global:
image: {}
namespaceOverride: ""
useReleaseForNameLabel: false # Set the name label to the release name for Marketplace

grpc:
db:
password: "" # Randomly generated if left blank
Expand Down Expand Up @@ -259,6 +260,29 @@ rest:
name: mirror-passwords
key: HEDERA_MIRROR_IMPORTER_DB_RESTUSERNAME

test:
config:
hedera:
mirror:
test:
acceptance:
existingTopicNum:
# grpc endpoint
mirrorNodeAddress: "{{ .Release.Name }}-grpc:5600"
network:
# Do not use use 0.0.2 or 0.0.50 for operator to ensure crypto transfers are not waived
operatorId:
operatorKey:
rest:
baseUrl: "http://{{ .Release.Name }}-rest/api/v1"
retrieveAddressBook: false
cucumberTags: "@acceptance"
enabled: false
image:
pullPolicy: IfNotPresent
repository: gcr.io/mirrornode/hedera-mirror-test
tag: "" # Defaults to the chart's app version

timescaledb:
enabled: false
image:
Expand Down

0 comments on commit 310f21c

Please sign in to comment.