Skip to content

Commit

Permalink
Consul - Add consul tests and upgrade consul to 0.8.x (helm#1126)
Browse files Browse the repository at this point in the history
* Bump consul version to 0.8.3
Add app version tag
Update chart maintainers to github username
Add consul helm tests
Update documentation
Remove existing test.sh

* Update helm test command in notes
  • Loading branch information
lachie83 authored and prydonius committed Jun 8, 2017
1 parent 44e05c4 commit 33414f4
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 41 deletions.
4 changes: 2 additions & 2 deletions stable/consul/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: consul
home: https://github.com/hashicorp/consul
version: 0.2.5
appVersion: 0.7.5
version: 0.3.0
appVersion: 0.8.3
description: Highly available and distributed service discovery and key-value store designed with support for the modern data center to make distributed systems and configuration easy.
icon: https://raw.githubusercontent.com/hashicorp/consul/bce3809dfca37b883828c3715b84143dd71c0f85/website/source/assets/images/favicons/android-chrome-512x512.png
sources:
Expand Down
12 changes: 11 additions & 1 deletion stable/consul/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ The following tables lists the configurable parameters of the consul chart and t
| `ui.enabled` | Enable Consul Web UI | `false` |
| `uiService.enabled` | Create dedicated Consul Web UI svc | `false` |
| `uiService.type` | Dedicate Consul Web UI svc type | `NodePort` |
| `test.image` | Test container image requires kubectl + bash (used for helm test) | `lachlanevenson/k8s-kubectl` |
| `test.imageTag` | Test container image tag (used for helm test) | `v1.4.8-bash` |

Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`.

Expand All @@ -72,7 +74,15 @@ $ kubectl delete pvc -l component=${RELEASE-NAME}-consul

## Testing

Execute test.sh. It will confirm that there are at least 3 consul servers present.
Helm tests are included and they confirm the first three cluster members have quorum.

```bash
helm test <RELEASE_NAME>
RUNNING: inky-marsupial-ui-test-nn6lv
PASSED: inky-marsupial-ui-test-nn6lv
```

It will confirm that there are at least 3 consul servers present.

## Cluster Health

Expand Down
6 changes: 4 additions & 2 deletions stable/consul/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
1. Watch all cluster members come up.
$ kubectl get pods --namespace={{ .Release.Namespace }} -w
2. Confirm consul cluster is healthy
$ kubectl exec {{ .Release.Name }}-consul-0 consul members --namespace={{ .Release.Namespace }} | grep server
2. Test cluster health using Helm test.
$ helm test {{ .Release.Name }}
3. (Optional) Manually confirm consul cluster is healthy.
$ kubectl exec {{ .Release.Name }}-consul-0 consul members --namespace={{ .Release.Namespace }} | grep server
38 changes: 38 additions & 0 deletions stable/consul/templates/consul-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{.Release.Name}}-ui-test-{{ randAlphaNum 5 | lower }}"
annotations:
"helm.sh/hook": test-success
"pod.beta.kubernetes.io/init-containers": '[
{
"name": "test-framework",
"image": "dduportal/bats:0.4.0",
"command": ["bash", "-c", "
set -ex\n
# copy bats to tools dir\n
cp -R /usr/local/libexec/ /tools/bats/\n
"],
"volumeMounts": [
{"name": "tools", "mountPath": "/tools"}
]
}
]'
spec:
containers:
- name: {{.Release.Name}}-ui-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 "fullname" . }}-tests
- name: tools
emptyDir: {}
restartPolicy: Never
16 changes: 16 additions & 0 deletions stable/consul/templates/test-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "fullname" . }}-tests
data:
run.sh: |-
@test "Testing Consul cluster has quorum" {
for i in {0..2}; do
if [ `kubectl exec {{.Release.Name}}-consul-$i consul members --namespace={{.Release.Namespace}} | grep server | wc -l` -ge "3" ]; then
echo "{{.Release.Name}}-consul-$i OK. consul members returning at least 3 records."
else
echo "{{.Release.Name}}-consul-$i ERROR. consul members returning less than 3 records."
exit 1
fi
done
}
35 changes: 0 additions & 35 deletions stable/consul/test.sh

This file was deleted.

7 changes: 6 additions & 1 deletion stable/consul/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ConsulDnsPort: 8600
Component: "consul"
Replicas: 3
Image: "consul"
ImageTag: "0.7.5"
ImageTag: "0.8.3"
ImagePullPolicy: "Always"
Cpu: "100m"
Memory: "256Mi"
Expand Down Expand Up @@ -44,3 +44,8 @@ ui:
uiService:
enabled: true
type: "NodePort"

## test container details
test:
image: lachlanevenson/k8s-kubectl
imageTag: v1.4.8-bash

0 comments on commit 33414f4

Please sign in to comment.