github.com/kaisenlinux/docker.io@v0.0.0-20230510090727-ea55db55fac7/libnetwork/test/integration/dnet/simple.bats (about) 1 #!/usr/bin/env bats 2 3 load helpers 4 5 @test "Test network create" { 6 echo $(docker ps) 7 run dnet_cmd $(inst_id2port 1) network create -d test mh1 8 echo ${output} 9 [ "$status" -eq 0 ] 10 run dnet_cmd $(inst_id2port 1) network ls 11 echo ${output} 12 line=$(dnet_cmd $(inst_id2port 1) network ls | grep mh1) 13 echo ${line} 14 name=$(echo ${line} | cut -d" " -f2) 15 driver=$(echo ${line} | cut -d" " -f3) 16 echo ${name} ${driver} 17 [ "$name" = "mh1" ] 18 [ "$driver" = "test" ] 19 dnet_cmd $(inst_id2port 1) network rm mh1 20 } 21 22 @test "Test network delete with id" { 23 echo $(docker ps) 24 run dnet_cmd $(inst_id2port 1) network create -d test mh1 25 [ "$status" -eq 0 ] 26 echo ${output} 27 dnet_cmd $(inst_id2port 1) network rm ${output} 28 } 29 30 @test "Test service create" { 31 echo $(docker ps) 32 dnet_cmd $(inst_id2port 1) network create -d test multihost 33 run dnet_cmd $(inst_id2port 1) service publish svc1.multihost 34 echo ${output} 35 [ "$status" -eq 0 ] 36 run dnet_cmd $(inst_id2port 1) service ls 37 echo ${output} 38 echo ${lines[1]} 39 [ "$status" -eq 0 ] 40 svc=$(echo ${lines[1]} | cut -d" " -f2) 41 network=$(echo ${lines[1]} | cut -d" " -f3) 42 echo ${svc} ${network} 43 [ "$network" = "multihost" ] 44 [ "$svc" = "svc1" ] 45 dnet_cmd $(inst_id2port 1) service unpublish svc1.multihost 46 dnet_cmd $(inst_id2port 1) network rm multihost 47 } 48 49 @test "Test service delete with id" { 50 echo $(docker ps) 51 dnet_cmd $(inst_id2port 1) network create -d test multihost 52 run dnet_cmd $(inst_id2port 1) service publish svc1.multihost 53 [ "$status" -eq 0 ] 54 echo ${output} 55 run dnet_cmd $(inst_id2port 1) service ls 56 [ "$status" -eq 0 ] 57 echo ${output} 58 echo ${lines[1]} 59 id=$(echo ${lines[1]} | cut -d" " -f1) 60 dnet_cmd $(inst_id2port 1) service unpublish ${id}.multihost 61 dnet_cmd $(inst_id2port 1) network rm multihost 62 } 63 64 @test "Test service attach" { 65 echo $(docker ps) 66 dnet_cmd $(inst_id2port 1) network create -d test multihost 67 dnet_cmd $(inst_id2port 1) service publish svc1.multihost 68 dnet_cmd $(inst_id2port 1) container create container_1 69 dnet_cmd $(inst_id2port 1) service attach container_1 svc1.multihost 70 run dnet_cmd $(inst_id2port 1) service ls 71 [ "$status" -eq 0 ] 72 echo ${output} 73 echo ${lines[1]} 74 container=$(echo ${lines[1]} | cut -d" " -f4) 75 [ "$container" = "container_1" ] 76 dnet_cmd $(inst_id2port 1) service detach container_1 svc1.multihost 77 dnet_cmd $(inst_id2port 1) container rm container_1 78 dnet_cmd $(inst_id2port 1) service unpublish svc1.multihost 79 dnet_cmd $(inst_id2port 1) network rm multihost 80 }