diff --git a/templates/tests/test-config.yaml b/templates/tests/test-config.yaml deleted file mode 100644 index 26fef08..0000000 --- a/templates/tests/test-config.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ template "consul.fullname" . }}-tests -data: - run.sh: |- - @test "Testing Consul cluster has quorum" { - [ `kubectl exec {{ template "consul.fullname" . }}-server-0 consul members --namespace={{ .Release.Namespace }} | grep server | wc -l` -ge "3" ] - } diff --git a/templates/tests/test-runner.yaml b/templates/tests/test-runner.yaml index 65b6b60..473b873 100644 --- a/templates/tests/test-runner.yaml +++ b/templates/tests/test-runner.yaml @@ -1,37 +1,31 @@ apiVersion: v1 kind: Pod metadata: - name: "{{ .Release.Name }}-test-{{ randAlphaNum 5 | lower }}" + name: "{{ template "consul.fullname" . }}-test-{{ randAlphaNum 5 | lower }}" + labels: + app: {{ template "consul.name" . }} + chart: {{ template "consul.chart" . }} + heritage: {{ .Release.Service }} + release: {{ .Release.Name }} annotations: "helm.sh/hook": test-success spec: - initContainers: - - name: test-framework - image: dduportal/bats:0.4.0 - command: - - "bash" - - "-c" - - | - set -ex - # copy bats to tools dir - cp -R /usr/local/libexec/ /tools/bats/ - volumeMounts: - - mountPath: /tools - name: tools containers: - - name: {{ .Release.Name }}-test - image: {{ .Values.test.image }}:{{ .Values.test.imageTag }} - command: ["/tools/bats/bats", "-t", "/tests/run.sh"] - volumeMounts: - - mountPath: /tests - name: tests - readOnly: true - - mountPath: /tools - name: tools - volumes: - - name: tests - configMap: - name: {{ template "consul.fullname" . }}-tests - - name: tools - emptyDir: {} + - name: consul-test + image: "{{ .Values.global.image }}" + env: + - name: HOST_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + command: + - "/bin/sh" + - "-ec" + - | + export VALUE="{{randAlphaNum 24 | lower }}" + export CONSUL_HTTP_ADDR="${HOST_IP}:8500" + consul kv delete _consul_helm_test + consul kv put _consul_helm_test $VALUE + [ `consul kv get _consul_helm_test` = "$VALUE" ] + consul kv delete _consul_helm_test restartPolicy: Never diff --git a/values.yaml b/values.yaml index 27bd0a7..55e6dfe 100644 --- a/values.yaml +++ b/values.yaml @@ -152,7 +152,3 @@ connectInject: # defaults but can be customized if necessary. certName: tls.crt keyName: tls.key - -test: - image: lachlanevenson/k8s-kubectl - imageTag: v1.4.8-bash