Fix up helm test to use the local client

This commit is contained in:
Mitchell Hashimoto 2018-09-11 19:43:05 -07:00
parent 9ef4efc5c4
commit 52e069d67f
No known key found for this signature in database
GPG key ID: 744E147AA52F5B0A
3 changed files with 23 additions and 42 deletions

View file

@ -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" ]
}

View file

@ -1,37 +1,31 @@
apiVersion: v1 apiVersion: v1
kind: Pod kind: Pod
metadata: 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: annotations:
"helm.sh/hook": test-success "helm.sh/hook": test-success
spec: 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: containers:
- name: {{ .Release.Name }}-test - name: consul-test
image: {{ .Values.test.image }}:{{ .Values.test.imageTag }} image: "{{ .Values.global.image }}"
command: ["/tools/bats/bats", "-t", "/tests/run.sh"] env:
volumeMounts: - name: HOST_IP
- mountPath: /tests valueFrom:
name: tests fieldRef:
readOnly: true fieldPath: status.hostIP
- mountPath: /tools command:
name: tools - "/bin/sh"
volumes: - "-ec"
- name: tests - |
configMap: export VALUE="{{randAlphaNum 24 | lower }}"
name: {{ template "consul.fullname" . }}-tests export CONSUL_HTTP_ADDR="${HOST_IP}:8500"
- name: tools consul kv delete _consul_helm_test
emptyDir: {} consul kv put _consul_helm_test $VALUE
[ `consul kv get _consul_helm_test` = "$VALUE" ]
consul kv delete _consul_helm_test
restartPolicy: Never restartPolicy: Never

View file

@ -152,7 +152,3 @@ connectInject:
# defaults but can be customized if necessary. # defaults but can be customized if necessary.
certName: tls.crt certName: tls.crt
keyName: tls.key keyName: tls.key
test:
image: lachlanevenson/k8s-kubectl
imageTag: v1.4.8-bash