mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
f33a362b48
- Create a wrapper script to run intergation tests so that setups and teardowns happen in more optimal manner - Add traps to cleanup containers on failure or user interrupt - Introduce basic multi-node integration tests - Removed default network, default driver tests as they may not be useful in the near future Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
119 lines
3.4 KiB
Bash
119 lines
3.4 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
load helpers
|
|
|
|
@test "Test multinode network create" {
|
|
echo $(docker ps)
|
|
for i in `seq 1 3`;
|
|
do
|
|
oname="mh$i"
|
|
run dnet_cmd $(inst_id2port $i) network create -d test ${oname}
|
|
echo ${output}
|
|
[ "$status" -eq 0 ]
|
|
|
|
for j in `seq 1 3`;
|
|
do
|
|
line=$(dnet_cmd $(inst_id2port $j) network ls | grep ${oname})
|
|
echo ${output}
|
|
[ "$status" -eq 0 ]
|
|
echo ${line}
|
|
name=$(echo ${line} | cut -d" " -f2)
|
|
driver=$(echo ${line} | cut -d" " -f3)
|
|
echo ${name} ${driver}
|
|
[ "$name" = "$oname" ]
|
|
[ "$driver" = "test" ]
|
|
done
|
|
|
|
# Always try to remove the network from the first node
|
|
dnet_cmd $(inst_id2port 1) network rm ${oname}
|
|
done
|
|
}
|
|
|
|
@test "Test multinode service create" {
|
|
echo $(docker ps)
|
|
dnet_cmd $(inst_id2port 1) network create -d test multihost
|
|
for i in `seq 1 3`;
|
|
do
|
|
oname="svc$i"
|
|
run dnet_cmd $(inst_id2port $i) service publish ${oname}.multihost
|
|
echo ${output}
|
|
[ "$status" -eq 0 ]
|
|
|
|
for j in `seq 1 3`;
|
|
do
|
|
run dnet_cmd $(inst_id2port $j) service ls
|
|
[ "$status" -eq 0 ]
|
|
echo ${output}
|
|
echo ${lines[1]}
|
|
svc=$(echo ${lines[1]} | cut -d" " -f2)
|
|
network=$(echo ${lines[1]} | cut -d" " -f3)
|
|
echo ${svc} ${network}
|
|
[ "$network" = "multihost" ]
|
|
[ "$svc" = "${oname}" ]
|
|
done
|
|
dnet_cmd $(inst_id2port 2) service unpublish ${oname}.multihost
|
|
done
|
|
dnet_cmd $(inst_id2port 3) network rm multihost
|
|
}
|
|
|
|
@test "Test multinode service attach" {
|
|
echo $(docker ps)
|
|
dnet_cmd $(inst_id2port 2) network create -d test multihost
|
|
dnet_cmd $(inst_id2port 3) service publish svc.multihost
|
|
for i in `seq 1 3`;
|
|
do
|
|
dnet_cmd $(inst_id2port $i) container create container_${i}
|
|
dnet_cmd $(inst_id2port $i) service attach container_${i} svc.multihost
|
|
run dnet_cmd $(inst_id2port $i) service ls
|
|
[ "$status" -eq 0 ]
|
|
echo ${output}
|
|
echo ${lines[1]}
|
|
container=$(echo ${lines[1]} | cut -d" " -f4)
|
|
[ "$container" = "container_$i" ]
|
|
for j in `seq 1 3`;
|
|
do
|
|
if [ "$j" = "$i" ]; then
|
|
continue
|
|
fi
|
|
dnet_cmd $(inst_id2port $j) container create container_${j}
|
|
run dnet_cmd $(inst_id2port $j) service attach container_${j} svc.multihost
|
|
echo ${output}
|
|
[ "$status" -ne 0 ]
|
|
dnet_cmd $(inst_id2port $j) container rm container_${j}
|
|
done
|
|
dnet_cmd $(inst_id2port $i) service detach container_${i} svc.multihost
|
|
dnet_cmd $(inst_id2port $i) container rm container_${i}
|
|
done
|
|
dnet_cmd $(inst_id2port 1) service unpublish svc.multihost
|
|
dnet_cmd $(inst_id2port 3) network rm multihost
|
|
}
|
|
|
|
@test "Test multinode network and service delete" {
|
|
echo $(docker ps)
|
|
for i in `seq 1 3`;
|
|
do
|
|
oname="mh$i"
|
|
osvc="svc$i"
|
|
dnet_cmd $(inst_id2port $i) network create -d test ${oname}
|
|
dnet_cmd $(inst_id2port $i) service publish ${osvc}.${oname}
|
|
dnet_cmd $(inst_id2port $i) container create container_${i}
|
|
dnet_cmd $(inst_id2port $i) service attach container_${i} ${osvc}.${oname}
|
|
|
|
for j in `seq 1 3`;
|
|
do
|
|
run dnet_cmd $(inst_id2port 2) service unpublish ${osvc}.${oname}
|
|
echo ${output}
|
|
[ "$status" -ne 0 ]
|
|
run dnet_cmd $(inst_id2port $j) network rm ${oname}
|
|
echo ${output}
|
|
[ "$status" -ne 0 ]
|
|
done
|
|
|
|
dnet_cmd $(inst_id2port $i) service detach container_${i} ${osvc}.${oname}
|
|
dnet_cmd $(inst_id2port $i) container rm container_${i}
|
|
|
|
# Always try to remove the service from different nodes
|
|
dnet_cmd $(inst_id2port 2) service unpublish ${osvc}.${oname}
|
|
dnet_cmd $(inst_id2port 3) network rm ${oname}
|
|
done
|
|
}
|