Skip to content

Commit

Permalink
End-to-end tests in Travis against Consul 1.0.x (#226) (#228)
Browse files Browse the repository at this point in the history
* Test in travis against Consul 1.0.x (#226)

* Remove recursor option from Consul test config (#226)

* Add integration tests (#226)

* Make only 1 stage in order to use the env matrix (#226)
  • Loading branch information
Gerrrr authored and fusiondog committed Mar 5, 2018
1 parent b152eb4 commit 4cf21a6
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
30 changes: 30 additions & 0 deletions .travis.yml
Expand Up @@ -6,16 +6,46 @@ env:
- CONSUL_VERSION: 0.7.5
- CONSUL_VERSION: 0.8.5
- CONSUL_VERSION: 0.9.3
- CONSUL_VERSION: 1.0.0
- CONSUL_VERSION: 1.0.1
- CONSUL_VERSION: 1.0.2
- CONSUL_VERSION: 1.0.3
- CONSUL_VERSION: 1.0.5
- CONSUL_VERSION: 1.0.6

before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq python-pip python-apt
- sudo pip install ansible
# the playbook and the test require "192.168.10.10" ip address
- sudo ifconfig eth0:1 192.168.10.10 netmask 255.255.255.0 up

install:
- "ansible-playbook -i 'localhost,' -c local provision/site.yml -e \"{'ansible_eth1': {'ipv4': {'address': '192.168.10.10'}}}\" -e bootstrap_expect=1 -e consul_version=$CONSUL_VERSION"
- go get -v -t ./...

script:
# build, configure, start consul-alerts
- make build
- make test
- curl -XPUT -d @provision/fixtures/notif-profile.json 192.168.10.10:8500/v1/kv/consul-alerts/config/notif-profiles/log
- curl -XPUT -d @provision/fixtures/notif-selection.json 192.168.10.10:8500/v1/kv/consul-alerts/config/notif-selection/hosts
- curl -XPUT -d 1 192.168.10.10:8500/v1/kv/consul-alerts/config/checks/change-threshold
- build/bin/Linux-x86_64/latest/consul-alerts start --watch-events --watch-checks --consul-addr=192.168.10.10:8500 &
# install and start nomad
- wget https://releases.hashicorp.com/nomad/0.7.1/nomad_0.7.1_linux_amd64.zip
- unzip nomad_0.7.1_linux_amd64.zip
- chmod +x nomad
- sudo mv nomad /usr/local/bin/nomad
- nomad agent -dev -consul-address=192.168.10.10:8500 &
- sleep 15 # give nomad some time to start
# drop packets between nomad and consul to make the nomad service unhealthy
- sudo iptables -A INPUT -s 127.0.0.1 -p tcp --dport 4646 -j DROP
- sleep 45 # give consul-alerts some time to report
# make sure that consul-alerts reported that the service is failing
- cat /tmp/consul-notifications.log | grep "Service=nomad-client, Check=Nomad Client HTTP Check, Status=critical"
# restore the connection between nomad and consul
- sudo iptables -D INPUT -s 127.0.0.1 -p tcp --dport 4646 -j DROP
- sleep 45
# make sure that consul-alerts reported that the service is healthy
- cat /tmp/consul-notifications.log | grep "Service=nomad-client, Check=Nomad Client HTTP Check, Status=passing"
1 change: 0 additions & 1 deletion provision/config.json
Expand Up @@ -3,7 +3,6 @@
"data_dir": "/var/lib/consul",
"log_level": "INFO",
"domain": "consul.",
"recursor": "8.8.8.8",
"encrypt": "XOo6dThdD/2/bNaRNx1avQ==",
"server": true,
"disable_update_check": true
Expand Down
7 changes: 7 additions & 0 deletions provision/fixtures/notif-profile.json
@@ -0,0 +1,7 @@
{
"Interval": 0,
"NotifList": {
"log":true,
"email":false
}
}
3 changes: 3 additions & 0 deletions provision/fixtures/notif-selection.json
@@ -0,0 +1,3 @@
{
"^.*$": "log"
}

0 comments on commit 4cf21a6

Please sign in to comment.