Skip to content

Commit

Permalink
Issue490/postman testing addition (#759)
Browse files Browse the repository at this point in the history
* Added a cronjob for the newman runs and a service account.  Initially this setup shouldn't need any role/rolebindings as this setup will not be interacting with k8s APIs.  In the future this may change if the tests are wanting to be run against each pod individually

Signed-off-by: Matt Halder <rustyShacklefurd@users.noreply.github.com>

* setting default test values and making this testing disabled by default

Signed-off-by: Matt Halder <rustyShacklefurd@users.noreply.github.com>

* These two cronjobs cannot have the same name

Signed-off-by: Matt Halder <rustyShacklefurd@users.noreply.github.com>

* k8s cronjob names must be no more than 52 characters so using name instead of fullname and truncated the name value

Signed-off-by: Matt Halder <rustyShacklefurd@users.noreply.github.com>

* Adding small blurb about adding Postman addition via Helm

Signed-off-by: Matt Halder <rustyShacklefurd@users.noreply.github.com>

* Adding a newline for formatting consistency

Signed-off-by: Matt Halder <rustyShacklefurd@users.noreply.github.com>

Signed-off-by: Matt Halder <rustyShacklefurd@users.noreply.github.com>
  • Loading branch information
rustyShacklefurd authored Dec 12, 2022
1 parent 05193c7 commit a3062db
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 4 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ npm install -g newman
newman run packages/server/tests/postman.json --env-var baseUrl=http://localhost:7546
```

To enable Postman test to run via helm deployment add
```
test:
enabled: true
schedule: '@daily' #How often to run the Postman test
baseUrl: "http://127.0.0.1:7546" # Relay URL to run the test against
### Acceptance Tests
The relay has a suite of acceptance tests that may be run to confirm E2E operation of the relay in either a `hedera-local-node` or deployed env.
Expand Down
52 changes: 49 additions & 3 deletions helm-chart/templates/cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ include "json-rpc-relay.fullname" . }}
name: {{ printf "%s-%s" (include "json-rpc-relay.name" .) "restart" | trimSuffix "-"| trunc 52 }}
namespace: {{ .Release.Namespace }}
spec:
concurrencyPolicy: Forbid
schedule: {{ .Values.rolling_restart.schedule }}
schedule: {{ .Values.rolling_restart.schedule }}
jobTemplate:
spec:
backoffLimit: 2
Expand All @@ -24,5 +24,51 @@ spec:
- >-
kubectl rollout restart deployment/{{ include "json-rpc-relay.fullname" . }} &&
kubectl rollout status deployment/{{ include "json-rpc-relay.fullname" . }}
{{- end }}
{{- end }}

---
{{- if .Values.test.enabled }}
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ printf "%s-%s" (include "json-rpc-relay.name" .) "test" | trimSuffix "-"| trunc 52 }}
namespace: {{ .Release.Namespace }}
spec:
concurrencyPolicy: Allow
schedule: {{ .Values.test.schedule }}
jobTemplate:
spec:
backoffLimit: 2
template:
spec:
serviceAccountName: {{ include "json-rpc-relay.serviceAccountName" . }}-test
restartPolicy: Never
initContainers:
- name: curl-config
image: curlimages/curl
command:
- curl
- https://github.com/hashgraph/hedera-json-rpc-relay/blob/main/packages/server/tests/postman.json
- -o
- postman.json
volumeMounts:
- name: config-json
mountPath: "/"
containers:
- name: newman
image: postman/newman
command:
- newman
- run
- postman.json
- --env-var
- baseUrl={{ .Values.test.baseUrl | quote }}
volumeMounts:
- name: config-json
mountPath: "/"
readOnly: true
volumes:
- name: config-json
emptyDir: {}
{{- end }}

3 changes: 2 additions & 1 deletion helm-chart/templates/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ rules:
resources: ["deployments"]
resourceNames: [{{ include "json-rpc-relay.fullname" . }}]
verbs: ["get", "list", "patch", "watch"]
{{- end }}
{{- end }}

16 changes: 16 additions & 0 deletions helm-chart/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,19 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}

---
{{- if .Values.test.enabled }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "json-rpc-relay.serviceAccountName" . }}-test
namespace: {{ .Release.Namespace }}
labels:
{{- include "json-rpc-relay.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}

6 changes: 6 additions & 0 deletions helm-chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,9 @@ config:
rolling_restart:
enabled: false
schedule: '@daily'

# Enable periodic tests of the hashio base URL
test:
enabled: false
schedule: '@daily'
baseUrl: "http://127.0.0.1:7546"

0 comments on commit a3062db

Please sign in to comment.