forked from bitsofinfo/hazelcast-docker-swarm-discovery-spi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
129 lines (109 loc) · 5.32 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
sudo: required
language: java
addons:
apt:
packages:
- net-tools
services:
- docker
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
before_script:
script:
# Build FAT jar and Docker container for the test
# and start socat to map docker socket to 2376 tcp port
- ./gradlew --refresh-dependencies shadowJar
- ls -al build/libs
- docker version
- docker run -d -v /var/run/docker.sock:/var/run/docker.sock -p 2376:2375 bobrik/socat TCP4-LISTEN:2375,fork,reuseaddr UNIX-CONNECT:/var/run/docker.sock
- docker build -t hazelcast-docker-swarm-discovery-spi-test -f Test.Dockerfile .
- docker images
# Init swarm and network
- docker swarm init
- docker node ls
- docker network create -d overlay hazelcast-docker-swarm-discovery-spi-test
# Capture the VM's IP
- export MY_IP=`ifconfig eth0 | grep "inet addr" | cut -d ':' -f 2 | cut -d ' ' -f 1`
- echo $MY_IP
# Create the service
- docker service create --network hazelcast-docker-swarm-discovery-spi-test --name hazelcast-docker-swarm-discovery-spi-test -e "DOCKER_HOST=http://$MY_IP:2376" hazelcast-docker-swarm-discovery-spi-test java -DdockerNetworkNames=hazelcast-docker-swarm-discovery-spi-test -DdockerServiceNames=hazelcast-docker-swarm-discovery-spi-test -DhazelcastPeerPort=5701 -Dhazelcast.diagnostics.enabled=true -Dswarm-bind-method=member-address-provider -DswarmMgrUri=http://$MY_IP:2376 -DskipVerifySsl=false -DlogAllServiceNamesOnFailedDiscovery=true -DstrictDockerServiceNameComparison=true -Dhazelcast.max.no.heartbeat.seconds=30 -jar /test.jar
- docker service ls
- sleep 10
- docker service logs hazelcast-docker-swarm-discovery-spi-test
# Dump logs of first container and scale to 10
- docker ps
- export CONTAINER1_ID=`docker ps -f "name=hazelcast-docker-swarm-discovery-spi-test.1" --format "{{.ID}}"`
- docker logs $CONTAINER1_ID
- docker service scale hazelcast-docker-swarm-discovery-spi-test=10
# Let cluster form w/ 10 nodes and verify there are 10 hz members
- sleep 80
- docker ps
- docker logs $CONTAINER1_ID
- export CONTAINER10_ID=`docker ps -f "name=hazelcast-docker-swarm-discovery-spi-test.10" --format "{{.ID}}"`
- docker logs $CONTAINER10_ID
- export MEMBER_TOTAL=`docker logs --tail 50 $CONTAINER1_ID 2>&1 | grep "Members {size:10"`
- echo $MEMBER_TOTAL
- if [[ "$MEMBER_TOTAL" == 'Members {size:10'* ]]; then echo "OK"; else exit 1; fi
# Scale cluster down to 2 nodes, wait 2 minutes then verify only 2 nodes
- docker service scale hazelcast-docker-swarm-discovery-spi-test=2
- sleep 160
- docker ps
- export CONTAINERX_ID=`docker ps -f "name=hazelcast-docker-swarm-discovery-spi-test." --format "{{.ID}}"`
- CONTAINERX_ID=`echo $CONTAINERX_ID | awk '{ print $1 }'`
- docker logs --tail 100 $CONTAINERX_ID
- export MEMBER_TOTAL=`docker logs --tail 100 $CONTAINERX_ID 2>&1 | grep "Members {size:2"`
- echo $MEMBER_TOTAL
- if [[ "$MEMBER_TOTAL" == 'Members {size:2'* ]]; then echo "OK"; else exit 1; fi
# Remove the service
- docker service rm hazelcast-docker-swarm-discovery-spi-test
# Test Docker Swarm DNSRR discovery
- >
docker service create
--network hazelcast-docker-swarm-discovery-spi-test
--name hazelcast-docker-swarm-dnsrr-discovery-spi-service
--endpoint-mode dnsrr
hazelcast-docker-swarm-discovery-spi-test
java
-Dswarm-bind-method=dockerDNSRR
-DserviceName=hazelcast-docker-swarm-dnsrr-discovery-spi-service
-DservicePort=5701
-DpeerServicesCsv=hazelcast-docker-swarm-dnsrr-discovery-spi-service:5701
-Dhazelcast.diagnostics.enabled=true
-Dhazelcast.max.no.heartbeat.seconds=30
-jar /test.jar
# Wait for startup
- docker service ls
- sleep 10
- docker service logs hazelcast-docker-swarm-dnsrr-discovery-spi-service
# Dump logs of first container and scale to 10
- docker ps
- export CONTAINER1_ID=`docker ps -f "name=hazelcast-docker-swarm-dnsrr-discovery-spi-service.1" --format "{{.ID}}"`
- docker logs $CONTAINER1_ID
- docker service scale hazelcast-docker-swarm-dnsrr-discovery-spi-service=10
# Let cluster form w/ 10 nodes and verify there are 10 hz members
- sleep 80
- docker ps
- docker logs $CONTAINER1_ID
- export CONTAINER10_ID=`docker ps -f "name=hazelcast-docker-swarm-dnsrr-discovery-spi-service.10" --format "{{.ID}}"`
- docker logs $CONTAINER10_ID
- export MEMBER_TOTAL=`docker logs --tail 150 $CONTAINER1_ID 2>&1 | grep "Members {size:10"`
- echo $MEMBER_TOTAL
- if [[ "$MEMBER_TOTAL" == 'Members {size:10'* ]]; then echo "OK"; else exit 1; fi
# Scale cluster down to 2 nodes, wait 2 minutes then verify only 2 nodes
- docker service scale hazelcast-docker-swarm-dnsrr-discovery-spi-service=2
- sleep 160
- docker ps
- export CONTAINERX_ID=`docker ps -f "name=hazelcast-docker-swarm-dnsrr-discovery-spi-service." --format "{{.ID}}"`
- CONTAINERX_ID=`echo $CONTAINERX_ID | awk '{ print $1 }'`
- docker logs --tail 150 $CONTAINERX_ID
- export MEMBER_TOTAL=`docker logs --tail 150 $CONTAINERX_ID 2>&1 | grep "Members {size:2"`
- echo $MEMBER_TOTAL
- if [[ "$MEMBER_TOTAL" == 'Members {size:2'* ]]; then echo "OK"; else exit 1; fi
- docker service rm hazelcast-docker-swarm-dnsrr-discovery-spi-service
jdk:
- oraclejdk8