forked from sleighzy/ansible-zookeeper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
76 lines (59 loc) · 2.43 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
---
sudo: required
services:
- docker
before_install:
# Update the host with latest versions
- sudo apt-get update -qq
install:
# Install Ansible on host
- pip install ansible --user
# Install docker-py
- pip install --upgrade docker-py --user
# Add ansible.cfg to pick up roles path.
- printf '[defaults]\nroles_path = ../' > ansible.cfg
# Pull a CentOS image with systemd installed for the Docker containers
- docker pull centos/systemd
script:
# Check syntax of Ansible role
- ansible-playbook tests/test.yaml -i tests/inventory --syntax-check
# Run Ansible role
- ansible-playbook tests/test.yaml -i tests/inventory --verbose
# Run the playbook and role again to ensure that it is idempotent and nothing has changed
- >
ansible-playbook tests/test.yaml -i tests/inventory --verbose
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
# Check that the ZooKeeper service is running
- >
docker exec zookeeper-1 systemctl status zookeeper 2>&1
| awk 'FNR == 3 {print}' | grep "active (running)"
&& (echo "Service running - pass" && exit 0)
|| (echo "Service running - fail" && exit 1)
# Check that a Znode can be successfully created
- >
docker exec zookeeper-1 /usr/share/zookeeper/bin/zkCli.sh create /TestZnode1 "test-node-1" 2>&1
| awk -F\" '/Created/ {print $1}' | grep "Created"
&& (echo "Znode ceate test - pass" && exit 0)
|| (echo "Znode create test - fail" && exit 1)
# Check that the Znode is available on all nodes in the cluster
- >
docker exec zookeeper-2 /usr/share/zookeeper/bin/zkCli.sh ls /TestZnode1 2>&1
| awk 'END{print}' | grep 'Node does not exist'
&& (echo "Znode cluster ceate test - fail" && exit 1)
|| (echo "Znode cluster create test - pass" && exit 0)
- >
docker exec zookeeper-3 /usr/share/zookeeper/bin/zkCli.sh ls /TestZnode1 2>&1
| awk 'END{print}' | grep 'Node does not exist'
&& (echo "Znode cluster ceate test - fail" && exit 1)
|| (echo "Znode cluster create test - pass" && exit 0)
after_script:
# Stop and remove the Docker containers
- docker stop zookeeper-1 && docker rm zookeeper-1
- docker stop zookeeper-2 && docker rm zookeeper-2
- docker stop zookeeper-3 && docker rm zookeeper-3
# Remove the Docker network
- docker network rm zookeeper
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/