diff --git a/charts/sqnc-node/Chart.yaml b/charts/sqnc-node/Chart.yaml index 8c166272..1c9998a6 100644 --- a/charts/sqnc-node/Chart.yaml +++ b/charts/sqnc-node/Chart.yaml @@ -6,6 +6,6 @@ maintainers: url: www.digicatapult.org.uk description: A Helm chart to deploy SQNC nodes type: application -version: 7.1.1 +version: 7.1.2 # renovate: image=digicatapult/sqnc-node appVersion: '11.3.0' diff --git a/charts/sqnc-node/README.md b/charts/sqnc-node/README.md index c8ee2423..783ed0ed 100644 --- a/charts/sqnc-node/README.md +++ b/charts/sqnc-node/README.md @@ -78,27 +78,32 @@ helm install kusama-node parity/node --set node.chainDataSnapshotUrl=https://ksm | `node.tracing.enabled` | If true, creates a jaeger agent sidecar | `false` | | `node.subtrateApiSiecar.enabled` | If true, creates a substrate api sidecar | `false` | -### Other parameters +### Other parameters -| Parameter | Description | Default | -|------------------------------------|--------------------------------------------------------------------------------------------------------|---------------------| -| `image.repository` | Node image name | `parity/polkadot` | -| `image.tag` | Node image tag | `v11.3.0` | -| `image.pullPolicy` | Node image pull policy | `Always` | -| `initContainer.image.repository` | Download-chain-snapshot init container image name | `crazymax/7zip` | -| `initContainer.image.tag` | Download-chain-snapshot init container image tag | `latest` | -| `googleCloudSdk.image.repository` | Sync-chain-gcs init container image name | `google/cloud-sdk` | -| `googleCloudSdk.image.tag` | Sync-chain-gcs init container image tag | `slim` | -| `googleCloudSdk.serviceAccountKey` | Service account key (JSON) to inject into the Sync-chain-gcs init container using a Kubernetes secret | `nil` | -| `ingress.enabled` | If true, creates an ingress | `false` | -| `ingress.annotations` | Annotations to add to the ingress (key/value pairs) | `{}` | -| `ingress.rules` | Set rules on the ingress | `[]` | -| `ingress.tls` | Set TLS configuration on the ingress | `[]` | -| `podSecurityContext` | Set the pod security context for the substrate node container | `{ runAsUser: 1000, runAsGroup: 1000, fsGroup: 1000 }`| -| `jaegerAgent.image.repository` | Jaeger agent image repository | `jaegertracing/jaeger-agent` | -| `jaegerAgent.image.tag` | Jaeger agent image tag | `1.28.0` | -| `jaegerAgent.ports.compactPort` | Port to use for jaeger.thrift over compact thrift protocol | `6831` | -| `jaegerAgent.ports.binaryPort` | Port to use for jaeger.thrift over binary thrift protocol | `6832` | -| `jaegerAgent.ports.samplingPort` | Port for HTTP sampling strategies | `5778` | -| `jaegerAgent.collector.url` | The URL which jaeger agent sends data | `nil` | -| `jaegerAgent.collector.port ` | The port which jaeger agent sends data | `14250` | +| Parameter | Description | Default | +|-------------------------------------|-------------------------------------------------------------------------------------------------------|---------------------| +| `image.repository` | Node image name | `parity/polkadot` | +| `image.tag` | Node image tag | `v11.3.0` | +| `image.pullPolicy` | Node image pull policy | `Always` | +| `initContainer.image.repository` | Download-chain-snapshot init container image name | `crazymax/7zip` | +| `initContainer.image.tag` | Download-chain-snapshot init container image tag | `latest` | +| `googleCloudSdk.image.repository` | Sync-chain-gcs init container image name | `google/cloud-sdk` | +| `googleCloudSdk.image.tag` | Sync-chain-gcs init container image tag | `slim` | +| `googleCloudSdk.serviceAccountKey` | Service account key (JSON) to inject into the Sync-chain-gcs init container using a Kubernetes secret | `nil` | +| `ingress.enabled` | If true, creates an ingress | `false` | +| `ingress.annotations` | Annotations to add to the ingress (key/value pairs) | `{}` | +| `ingress.rules` | Set rules on the ingress | `[]` | +| `ingress.tls` | Set TLS configuration on the ingress | `[]` | +| `podSecurityContext` | Set the pod security context for the substrate node container | `{ runAsUser: 1000, runAsGroup: 1000, fsGroup: 1000 }`| +| `jaegerAgent.image.repository` | Jaeger agent image repository | `jaegertracing/jaeger-agent` | +| `jaegerAgent.image.tag` | Jaeger agent image tag | `1.28.0` | +| `jaegerAgent.ports.compactPort` | Port to use for jaeger.thrift over compact thrift protocol | `6831` | +| `jaegerAgent.ports.binaryPort` | Port to use for jaeger.thrift over binary thrift protocol | `6832` | +| `jaegerAgent.ports.samplingPort` | Port for HTTP sampling strategies | `5778` | +| `jaegerAgent.collector.url` | The URL which jaeger agent sends data | `nil` | +| `jaegerAgent.collector.port` | The port which jaeger agent sends data | `14250` | +| `tests.osShell.image.repository` | Utility init container image name | `bitnami/os-shell` | +| `tests.osShell.image.tag` | Utility init container image tag | `latest` | +| `tests.blockHeight.waitSeconds` | The delay in seconds before testing the block height | `30` | +| `tests.nodeConnection.waitSeconds` | The delay in seconds before testing peer connections against the node | `30` | +| `tests.nodeConnection.minPeerCount` | The minimum number of peers needed for production chains; dev and local chains require none | `2` | diff --git a/charts/sqnc-node/ci/ct-values.yaml b/charts/sqnc-node/ci/ct-values.yaml index a6844b40..8dcd2403 100644 --- a/charts/sqnc-node/ci/ct-values.yaml +++ b/charts/sqnc-node/ci/ct-values.yaml @@ -1,2 +1,17 @@ node: dataVolumeSize: 1Gi + role: validator + chain: dev + flags: + - "--rpc-external" + - "--rpc-methods=Unsafe" + - "--alice" + - "--rpc-cors=all" + - "--unsafe-rpc-external" + - "--detailed-log-output" +tests: + blockHeight: + waitSeconds: 30 + nodeConnection: + waitSeconds: 30 + minPeerCount: 0 diff --git a/charts/sqnc-node/templates/tests/checkPostDeployment.yaml b/charts/sqnc-node/templates/tests/checkPostDeployment.yaml new file mode 100644 index 00000000..6834c807 --- /dev/null +++ b/charts/sqnc-node/templates/tests/checkPostDeployment.yaml @@ -0,0 +1,81 @@ +{{ $fullname := include "sqnc-node.fullname" . }} +{{ $serviceLabels := include "sqnc-node.serviceLabels" . }} +{{ $selectorLabels := include "sqnc-node.selectorLabels" . }} + +{{range $i := until ($.Values.node.replicas | int) }} +apiVersion: v1 +kind: Pod +metadata: + name: "{{ $fullname }}-{{ $i }}-post-install-test-suite" + labels: + {{- $serviceLabels | nindent 4 }} + annotations: + "helm.sh/hook": post-install +spec: + containers: + - name: block-height-check + image: {{ $.Values.tests.osShell.image.repository }}:{{ $.Values.tests.osShell.image.tag }} + command: [ "/bin/sh" ] + args: + - -c + - | + sleep $BLOCK_HEIGHT_WAIT + SYNC_STATE=`curl -sS -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "system_syncState", "params": []}' "http://{{ $fullname }}-{{ $i }}:9944" | jq '.result'` + + eval "$(echo $SYNC_STATE | jq -r 'to_entries | map("\(.key | ascii_upcase)=\(.value | @sh)") | .[]')" + + BLOCK_DIFF=$(($HIGHESTBLOCK - $STARTINGBLOCK)) + + if [ "$STARTINGBLOCK" = "$HIGHESTBLOCK" ]; then + echo "block height failed to increase; started at $STARTINGBLOCK and still at $HIGHESTBLOCK" + exit + else + echo "block height is now $HIGHESTBLOCK, having grown by $BLOCK_DIFF" + fi + env: + - name: BLOCK_HEIGHT_WAIT + value: {{ default 30 $.Values.tests.blockHeight.waitSeconds | quote }} + - name: node-connection-check + image: {{ $.Values.tests.osShell.image.repository }}:{{ $.Values.tests.osShell.image.tag }} + command: [ "/bin/sh" ] + args: + - -c + - | + sleep $NODE_CONNECTION_WAIT + SYSTEM_HEALTH=`curl -sS -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "system_health", "params": []}' "http://{{ $fullname }}-{{ $i }}:9944" | jq '.result'` + + eval "$(echo $SYSTEM_HEALTH | jq -r 'to_entries | map("\(.key | ascii_upcase)=\(.value | @sh)") | .[]')" + + if [ "$MIN_PEER_COUNT" != 0 ]; then + if [ "$SHOULDHAVEPEERS" = "true" ]; then + echo "expecting that peers connect to the node" + if [ "$PEERS" -lt "$MIN_PEER_COUNT" ]; then + echo "insufficient peers connected" + exit + else + echo "found peers: $PEERS connected" + fi + else + echo "no peers were expected; $PEERS connected" + fi + else + echo "$CHAIN_TYPE chain detected; no peers were required" + fi + + if [ "$ISSYNCING" = "false" ]; then + echo "node is not synchronising" + exit + fi + env: + - name: NODE_CONNECTION_WAIT + value: {{ default 30 $.Values.tests.nodeConnection.waitSeconds | quote }} + - name: CHAIN_TYPE + value: {{ $.Values.node.chain }} + - name: MIN_PEER_COUNT + {{- if eq $.Values.node.chain "dev" }} + value: {{ 0 | quote }} + {{- else }} + value: {{ default 2 $.Values.tests.minPeerCount | quote }} + {{- end }} + restartPolicy: Never +{{ end }} diff --git a/charts/sqnc-node/values.yaml b/charts/sqnc-node/values.yaml index 4062a391..4b65f393 100644 --- a/charts/sqnc-node/values.yaml +++ b/charts/sqnc-node/values.yaml @@ -156,3 +156,16 @@ tolerations: [] affinity: {} storageClass: "" + +# Continuous integration tests +tests: + # The default image for the testing container + osShell: + image: + repository: bitnami/os-shell + tag: latest + # blockHeight: + # waitSeconds: 30 + # nodeConnection: + # waitSeconds: 30 + # minPeerCount: 2