2015-09-08 22:26:54 -04:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load helpers
|
|
|
|
|
|
|
|
function setup() {
|
2015-09-16 01:26:27 -04:00
|
|
|
if [ "${BATS_TEST_NUMBER}" -eq 1 ]; then
|
2015-09-08 22:26:54 -04:00
|
|
|
start_consul
|
2015-09-16 01:26:27 -04:00
|
|
|
start_dnet 1 simple multihost overlay
|
2015-09-08 22:26:54 -04:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function teardown() {
|
2015-09-16 01:26:27 -04:00
|
|
|
if [ "${BATS_TEST_NUMBER}" -eq 6 ]; then
|
|
|
|
stop_dnet 1 simple
|
2015-09-08 22:26:54 -04:00
|
|
|
stop_consul
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Test default network" {
|
|
|
|
echo $(docker ps)
|
2015-09-16 01:26:27 -04:00
|
|
|
run dnet_cmd $(inst_id2port 1) network ls
|
|
|
|
[ "$status" -eq 0 ]
|
2015-09-08 22:26:54 -04:00
|
|
|
echo ${output}
|
|
|
|
echo ${lines[1]}
|
|
|
|
name=$(echo ${lines[1]} | cut -d" " -f2)
|
|
|
|
driver=$(echo ${lines[1]} | cut -d" " -f3)
|
|
|
|
echo ${name} ${driver}
|
|
|
|
[ "$name" = "multihost" ]
|
|
|
|
[ "$driver" = "overlay" ]
|
|
|
|
}
|
2015-09-16 01:26:27 -04:00
|
|
|
|
|
|
|
@test "Test network create" {
|
|
|
|
echo $(docker ps)
|
|
|
|
run dnet_cmd $(inst_id2port 1) network create -d overlay mh1
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
line=$(dnet_cmd $(inst_id2port 1) network ls | grep mh1)
|
|
|
|
echo ${line}
|
|
|
|
name=$(echo ${line} | cut -d" " -f2)
|
|
|
|
driver=$(echo ${line} | cut -d" " -f3)
|
|
|
|
echo ${name} ${driver}
|
|
|
|
[ "$name" = "mh1" ]
|
|
|
|
[ "$driver" = "overlay" ]
|
|
|
|
dnet_cmd $(inst_id2port 1) network rm mh1
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Test network delete with id" {
|
|
|
|
echo $(docker ps)
|
|
|
|
run dnet_cmd $(inst_id2port 1) network create -d overlay mh1
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
echo ${output}
|
|
|
|
dnet_cmd $(inst_id2port 1) network rm ${output}
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Test service create" {
|
|
|
|
echo $(docker ps)
|
|
|
|
run dnet_cmd $(inst_id2port 1) service publish svc1.multihost
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
echo ${output}
|
|
|
|
run dnet_cmd $(inst_id2port 1) 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" = "svc1" ]
|
|
|
|
dnet_cmd $(inst_id2port 1) service unpublish svc1.multihost
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Test service delete with id" {
|
|
|
|
echo $(docker ps)
|
|
|
|
run dnet_cmd $(inst_id2port 1) service publish svc1.multihost
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
echo ${output}
|
|
|
|
run dnet_cmd $(inst_id2port 1) service ls
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
echo ${output}
|
|
|
|
echo ${lines[1]}
|
|
|
|
id=$(echo ${lines[1]} | cut -d" " -f1)
|
|
|
|
dnet_cmd $(inst_id2port 1) service unpublish ${id}
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Test service attach" {
|
|
|
|
skip_for_circleci
|
|
|
|
echo $(docker ps)
|
|
|
|
dnet_cmd $(inst_id2port 1) service publish svc1.multihost
|
|
|
|
dnet_cmd $(inst_id2port 1) container create container_1
|
|
|
|
dnet_cmd $(inst_id2port 1) service attach container_1 svc1.multihost
|
|
|
|
run dnet_cmd $(inst_id2port 1) service ls
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
echo ${output}
|
|
|
|
echo ${lines[1]}
|
|
|
|
container=$(echo ${lines[1]} | cut -d" " -f4)
|
|
|
|
[ "$container" = "container_1" ]
|
|
|
|
dnet_cmd $(inst_id2port 1) service detach container_1 svc1.multihost
|
|
|
|
dnet_cmd $(inst_id2port 1) container rm container_1
|
|
|
|
dnet_cmd $(inst_id2port 1) service unpublish svc1.multihost
|
|
|
|
}
|