integration: faster. faster. faster.

- Use start_with_busybox everywhere it's possible.
- Start only what we need.
- Improved correctness of a few tests at the same time.

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi 2015-05-06 01:36:43 -07:00
parent 0bf6cf6dc9
commit c75992a3bd
39 changed files with 141 additions and 137 deletions

View File

@ -8,10 +8,10 @@ function teardown() {
}
@test "container affinty" {
start_docker 2
start_docker_with_busybox 2
swarm_manage
run docker_swarm run --name c1 -e constraint:node==node-0 -d busybox:latest sh
run docker_swarm run --name c1 -e constraint:node==node-1 -d busybox:latest sh
[ "$status" -eq 0 ]
run docker_swarm run --name c2 -e affinity:container==c1 -d busybox:latest sh
[ "$status" -eq 0 ]
@ -24,33 +24,35 @@ function teardown() {
run docker_swarm inspect c1
[ "$status" -eq 0 ]
[[ "${output}" == *'"Name": "node-0"'* ]]
[[ "${output}" == *'"Name": "node-1"'* ]]
run docker_swarm inspect c2
[ "$status" -eq 0 ]
[[ "${output}" == *'"Name": "node-0"'* ]]
[[ "${output}" == *'"Name": "node-1"'* ]]
run docker_swarm inspect c3
[ "$status" -eq 0 ]
[[ "${output}" != *'"Name": "node-0"'* ]]
[[ "${output}" != *'"Name": "node-1"'* ]]
run docker_swarm inspect c4
[ "$status" -eq 0 ]
[[ "${output}" == *'"Name": "node-0"'* ]]
[[ "${output}" == *'"Name": "node-1"'* ]]
run docker_swarm inspect c5
[ "$status" -eq 0 ]
[[ "${output}" != *'"Name": "node-0"'* ]]
[[ "${output}" != *'"Name": "node-1"'* ]]
}
@test "image affinity" {
start_docker 2
start_docker_with_busybox 2
swarm_manage
run docker -H ${HOSTS[0]} build -t test $TESTDATA/build
# Create a new image just on the second host.
run docker -H ${HOSTS[1]} tag busybox test
[ "$status" -eq 0 ]
# pull busybox to force the refresh images
# FIXME: this is slow.
run docker_swarm pull busybox
[ "$status" -eq 0 ]
@ -65,26 +67,26 @@ function teardown() {
run docker_swarm inspect c1
[ "$status" -eq 0 ]
[[ "${output}" == *'"Name": "node-0"'* ]]
[[ "${output}" == *'"Name": "node-1"'* ]]
run docker_swarm inspect c2
[ "$status" -eq 0 ]
[[ "${output}" != *'"Name": "node-0"'* ]]
[[ "${output}" != *'"Name": "node-1"'* ]]
run docker_swarm inspect c3
[ "$status" -eq 0 ]
[[ "${output}" == *'"Name": "node-0"'* ]]
[[ "${output}" == *'"Name": "node-1"'* ]]
run docker_swarm inspect c4
[ "$status" -eq 0 ]
[[ "${output}" != *'"Name": "node-0"'* ]]
[[ "${output}" != *'"Name": "node-1"'* ]]
}
@test "label affinity" {
start_docker 2
start_docker_with_busybox 2
swarm_manage
run docker_swarm run --name c1 --label test.label=true -e constraint:node==node-0 -d busybox:latest sh
run docker_swarm run --name c1 --label test.label=true -e constraint:node==node-1 -d busybox:latest sh
[ "$status" -eq 0 ]
run docker_swarm run --name c2 -e affinity:test.label==true -d busybox:latest sh
[ "$status" -eq 0 ]
@ -97,21 +99,21 @@ function teardown() {
run docker_swarm inspect c1
[ "$status" -eq 0 ]
[[ "${output}" == *'"Name": "node-0"'* ]]
[[ "${output}" == *'"Name": "node-1"'* ]]
run docker_swarm inspect c2
[ "$status" -eq 0 ]
[[ "${output}" == *'"Name": "node-0"'* ]]
[[ "${output}" == *'"Name": "node-1"'* ]]
run docker_swarm inspect c3
[ "$status" -eq 0 ]
[[ "${output}" != *'"Name": "node-0"'* ]]
[[ "${output}" != *'"Name": "node-1"'* ]]
run docker_swarm inspect c4
[ "$status" -eq 0 ]
[[ "${output}" == *'"Name": "node-0"'* ]]
[[ "${output}" == *'"Name": "node-1"'* ]]
run docker_swarm inspect c5
[ "$status" -eq 0 ]
[[ "${output}" != *'"Name": "node-0"'* ]]
[[ "${output}" != *'"Name": "node-1"'* ]]
}

View File

@ -8,7 +8,7 @@ function teardown() {
}
@test "docker attach" {
start_docker 3
start_docker_with_busybox 2
swarm_manage
# container run in background
@ -27,7 +27,7 @@ function teardown() {
@test "docker attach through websocket" {
CLIENT_API_VERSION="v1.17"
start_docker 2
start_docker_with_busybox 2
swarm_manage
#create a container

View File

@ -8,7 +8,7 @@ function teardown() {
}
@test "docker build" {
start_docker 3
start_docker 2
swarm_manage
run docker_swarm images -q

View File

@ -8,7 +8,7 @@ function teardown() {
}
@test "docker commit" {
start_docker 3
start_docker_with_busybox 2
swarm_manage
run docker_swarm run -d --name test_container busybox sleep 500

View File

@ -8,7 +8,7 @@ function teardown() {
}
@test "docker cp" {
start_docker 3
start_docker_with_busybox 2
swarm_manage
test_file="/bin/busybox"

View File

@ -8,7 +8,7 @@ function teardown() {
}
@test "docker create" {
start_docker 3
start_docker_with_busybox 2
swarm_manage
# make sure no contaienr exist

View File

@ -8,7 +8,7 @@ function teardown() {
}
@test "docker diff" {
start_docker 3
start_docker_with_busybox 2
swarm_manage
run docker_swarm run -d --name test_container busybox sleep 500
[ "$status" -eq 0 ]

View File

@ -9,7 +9,7 @@ function teardown() {
@test "docker events" {
TEMP_FILE=$(mktemp)
start_docker 3
start_docker_with_busybox 2
swarm_manage
# start events, report real time events to TEMP_FILE

View File

@ -8,7 +8,7 @@ function teardown() {
}
@test "docker exec" {
start_docker 3
start_docker_with_busybox 2
swarm_manage
run docker_swarm create --name test_container busybox sleep 100
[ "$status" -eq 0 ]

View File

@ -8,7 +8,7 @@ function teardown() {
}
@test "docker export" {
start_docker 3
start_docker_with_busybox 2
swarm_manage
# run a container to export
run docker_swarm run -d --name test_container busybox sleep 500

View File

@ -8,13 +8,12 @@ function teardown() {
}
@test "docker history" {
start_docker 3
# Start one empty host and one with busybox to ensure swarm selects the
# right one (and not one at random).
start_docker 1
start_docker_with_busybox 1
swarm_manage
# pull busybox image
run docker_swarm pull busybox
[ "$status" -eq 0 ]
# make sure the image of busybox exists
run docker_swarm images
[ "$status" -eq 0 ]

View File

@ -8,41 +8,35 @@ function teardown() {
}
@test "docker images" {
start_docker 3
# Start one empty host and two with busybox to ensure swarm selects the
# right ones.
start_docker 1
start_docker_with_busybox 2
swarm_manage
# no image exist
run docker_swarm images -q
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 0 ]
# make sure every node has no image
for((i=0; i<3; i++)); do
run docker_swarm images --filter node=node-$i -q
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 0 ]
done
# pull image
run docker_swarm pull busybox
[ "$status" -eq 0 ]
# show all node images, including reduplicated
# we should get 2 busyboxes, plus the header.
run docker_swarm images
[ "$status" -eq 0 ]
# check pull busybox, if download sucessfully, the busybox have one tag(lastest) at least
# if there are 3 nodes, the output lines of "docker images" are greater or equal 4(1 header + 3 busybox:latest)
# so use -ge here, the following(pull/tag) is the same reason
[ "${#lines[@]}" -ge 4 ]
# Every line should contain "busybox" exclude the first head line
[ "${#lines[@]}" -eq 3 ]
# Every line should contain "busybox" except for the header
for((i=1; i<${#lines[@]}; i++)); do
[[ "${lines[i]}" == *"busybox"* ]]
done
# verify
for((i=0; i<3; i++)); do
run docker_swarm images --filter node=node-$i
[ "$status" -eq 0 ]
[ "${#lines[@]}" -ge 2 ]
[[ "${lines[1]}" == *"busybox"* ]]
done
# Try with --filter.
run docker_swarm images --filter node=node-0
echo $output
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 1 ]
run docker_swarm images --filter node=node-1
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 2 ]
[[ "${lines[1]}" == *"busybox"* ]]
run docker_swarm images --filter node=node-2
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 2 ]
[[ "${lines[1]}" == *"busybox"* ]]
}

View File

@ -8,7 +8,7 @@ function teardown() {
}
@test "docker inspect" {
start_docker 3
start_docker_with_busybox 2
swarm_manage
# run container
run docker_swarm run -d --name test_container busybox sleep 500
@ -32,7 +32,7 @@ function teardown() {
# FIXME: Broken in docker master. See #717
skip
start_docker 3
start_docker_with_busybox 2
swarm_manage
# run container
run docker_swarm run -d --name test_container busybox sleep 500

View File

@ -8,7 +8,7 @@ function teardown() {
}
@test "docker kill" {
start_docker 3
start_docker_with_busybox 2
swarm_manage
# run
run docker_swarm run -d --name test_container busybox sleep 1000

View File

@ -8,30 +8,34 @@ function teardown() {
}
@test "docker load" {
# temp file for saving image
# pull the image only if not available on the host and save it somewhere.
[ "$(docker_host images -q busybox)" ] || docker_host pull busybox
IMAGE_FILE=$(mktemp)
# create a tar file
docker_host pull busybox:latest
docker_host save -o $IMAGE_FILE busybox:latest
start_docker 2
swarm_manage
# ensure we start from a clean cluster.
run docker_swarm images -q
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 0 ]
run docker_swarm load -i $IMAGE_FILE
[ "$status" -eq 0 ]
# and now swarm should have cought the image just loaded.
run docker_swarm images -q
[ "$status" -eq 0 ]
[ "${#lines[@]}" -ge 1 ]
# check node0
run docker -H ${HOSTS[0]} images
run docker -H ${HOSTS[0]} images
[ "${#lines[@]}" -eq 2 ]
[[ "${lines[1]}" == *"busybox"* ]]
# check node1
run docker -H ${HOSTS[1]} images
run docker -H ${HOSTS[1]} images
[ "${#lines[@]}" -eq 2 ]
[[ "${lines[1]}" == *"busybox"* ]]

View File

@ -8,7 +8,7 @@ function teardown() {
}
@test "docker logs" {
start_docker 3
start_docker_with_busybox 2
swarm_manage
# run a container with echo command

View File

@ -8,7 +8,7 @@ function teardown() {
}
@test "docker pause" {
start_docker 3
start_docker_with_busybox 2
swarm_manage
run docker_swarm run -d --name test_container busybox sleep 1000

View File

@ -8,7 +8,7 @@ function teardown() {
}
@test "docker port" {
start_docker 3
start_docker_with_busybox 2
swarm_manage
run docker_swarm run -d -p 8000 --name test_container busybox sleep 500
[ "$status" -eq 0 ]

View File

@ -8,8 +8,9 @@ function teardown() {
}
@test "docker ps -n" {
start_docker 1
start_docker_with_busybox 2
swarm_manage
run docker_swarm run -d busybox sleep 42
run docker_swarm run -d busybox false
run docker_swarm ps -n 3
@ -26,8 +27,9 @@ function teardown() {
}
@test "docker ps -l" {
start_docker 1
start_docker_with_busybox 2
swarm_manage
run docker_swarm run -d busybox sleep 42
sleep 1 #sleep so the 2 containers don't start at the same second
run docker_swarm run -d busybox true

View File

@ -8,7 +8,7 @@ function teardown() {
}
@test "docker pull" {
start_docker 3
start_docker 2
swarm_manage
# make sure no image exists
@ -19,16 +19,16 @@ function teardown() {
run docker_swarm pull busybox
[ "$status" -eq 0 ]
# swarm verify
# we should get 2 busyboxes, plus the header.
run docker_swarm images
[ "$status" -eq 0 ]
[ "${#lines[@]}" -ge 4 ]
[ "${#lines[@]}" -eq 3 ]
# every line should contain "busybox" exclude the first head line
for((i=1; i<${#lines[@]}; i++)); do
[[ "${lines[i]}" == *"busybox"* ]]
done
# node verify
# verify on the nodes
for host in ${HOSTS[@]}; do
run docker -H $host images
[ "$status" -eq 0 ]

View File

@ -8,7 +8,7 @@ function teardown() {
}
@test "docker rename" {
start_docker 3
start_docker_with_busybox 2
swarm_manage
run docker_swarm run -d --name test_container busybox sleep 500

View File

@ -8,7 +8,7 @@ function teardown() {
}
@test "docker restart" {
start_docker 3
start_docker_with_busybox 2
swarm_manage
# run
run docker_swarm run -d --name test_container busybox sleep 1000

View File

@ -8,7 +8,7 @@ function teardown() {
}
@test "docker rm" {
start_docker 3
start_docker_with_busybox 2
swarm_manage
run docker_swarm run -d --name test_container busybox
@ -28,7 +28,7 @@ function teardown() {
}
@test "docker rm -f" {
start_docker 3
start_docker_with_busybox 2
swarm_manage
run docker_swarm run -d --name test_container busybox sleep 500

View File

@ -8,25 +8,31 @@ function teardown() {
}
@test "docker rmi" {
start_docker 3
# Start one empty host and two with busybox to ensure swarm selects the
# right ones and rmi doesn't fail if one host doesn't have the image.
start_docker 1
start_docker_with_busybox 2
swarm_manage
run docker_swarm pull busybox
[ "$status" -eq 0 ]
# make sure image exists
# swarm check image
run docker_swarm images
[ "$status" -eq 0 ]
[[ "${output}" == *"busybox"* ]]
# node check image
for host in ${HOSTS[@]}; do
run docker -H $host images
[ "$status" -eq 0 ]
[[ "${output}" == *"busybox"* ]]
done
# this test presupposition: do not run image
# verify the nodes: the first one shouldn't have the image while the other
# two yes.
run docker -H ${HOSTS[0]} images
[ "$status" -eq 0 ]
[[ "${output}" != *"busybox"* ]]
run docker -H ${HOSTS[1]} images
[ "$status" -eq 0 ]
[[ "${output}" == *"busybox"* ]]
run docker -H ${HOSTS[1]} images
[ "$status" -eq 0 ]
[[ "${output}" == *"busybox"* ]]
# wipe busybox.
run docker_swarm rmi busybox
[ "$status" -eq 0 ]
@ -34,7 +40,8 @@ function teardown() {
run docker_swarm images -q
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 0 ]
# node verify
# verify the image was actually removed from every node.
for host in ${HOSTS[@]}; do
run docker -H $host images -q
[ "$status" -eq 0 ]

View File

@ -8,7 +8,7 @@ function teardown() {
}
@test "docker run" {
start_docker 3
start_docker_with_busybox 2
swarm_manage
# make sure no container exist

View File

@ -8,19 +8,20 @@ function teardown() {
}
@test "docker save" {
start_docker 3
# Start one empty host and one with busybox to ensure swarm selects the
# right one (and not one at random).
start_docker 1
start_docker_with_busybox 1
swarm_manage
run docker_swarm pull busybox
[ "$status" -eq 0 ]
temp_file_name=$(mktemp)
temp_file_name_o=$(mktemp)
# make sure busybox image exists
run docker_swarm images
[ "$status" -eq 0 ]
[[ "${output}" == *"busybox"* ]]
temp_file_name=$(mktemp)
temp_file_name_o=$(mktemp)
# save >, image->tar
docker_swarm save busybox > $temp_file_name
# save -o, image->tar

View File

@ -8,7 +8,7 @@ function teardown() {
}
@test "docker search" {
start_docker 3
start_docker 2
swarm_manage
# search image (not exist), the name of images only [a-z0-9-_.] are allowed

View File

@ -8,7 +8,7 @@ function teardown() {
}
@test "docker start" {
start_docker 3
start_docker_with_busybox 2
swarm_manage
# create
run docker_swarm create --name test_container busybox sleep 1000

View File

@ -9,7 +9,7 @@ function teardown() {
@test "docker stats" {
TEMP_FILE=$(mktemp)
start_docker 3
start_docker_with_busybox 2
swarm_manage
# stats running container

View File

@ -8,7 +8,7 @@ function teardown() {
}
@test "docker stop" {
start_docker 3
start_docker_with_busybox 2
swarm_manage
# run
run docker_swarm run -d --name test_container busybox sleep 500

View File

@ -8,12 +8,12 @@ function teardown() {
}
@test "docker tag" {
start_docker 3
# Start one empty host and one with busybox to ensure swarm selects the
# right one (and not one at random).
start_docker 1
start_docker_with_busybox 1
swarm_manage
run docker_swarm pull busybox
[ "$status" -eq 0 ]
# make sure the image of busybox exists
# the comming image of tag_busybox not exsit
run docker_swarm images

View File

@ -8,7 +8,7 @@ function teardown() {
}
@test "docker top" {
start_docker 3
start_docker_with_busybox 2
swarm_manage
run docker_swarm run -d --name test_container busybox sleep 500

View File

@ -8,7 +8,7 @@ function teardown() {
}
@test "docker unpause" {
start_docker 3
start_docker_with_busybox 2
swarm_manage
run docker_swarm run -d --name test_container busybox sleep 1000

View File

@ -8,7 +8,8 @@ function teardown() {
}
@test "docker version" {
start_docker 3
# FIXME: No reason here to start docker.
start_docker 1
swarm_manage
# version

View File

@ -8,7 +8,7 @@ function teardown() {
}
@test "docker wait" {
start_docker 3
start_docker_with_busybox 2
swarm_manage
# run after 1 seconds, test_container will exit

View File

@ -8,7 +8,7 @@ function teardown() {
}
@test "node constraint" {
start_docker 2
start_docker_with_busybox 2
swarm_manage
run docker_swarm run --name c1 -e constraint:node==node-0 -d busybox:latest sh
@ -38,8 +38,8 @@ function teardown() {
}
@test "label constraints" {
start_docker 1 --label foo=a
start_docker 1 --label foo=b
start_docker_with_busybox 1 --label foo=a
start_docker_with_busybox 1 --label foo=b
swarm_manage
run docker_swarm run --name c1 -e constraint:foo==a -d busybox:latest sh

View File

@ -8,11 +8,11 @@ function teardown() {
}
@test "shared volumes dependency" {
start_docker 2
start_docker_with_busybox 2
swarm_manage
# Running the second container with shared volumes.
run docker_swarm run --name b1 -e constraint:node==node-0 -d busybox:latest sleep 500
run docker_swarm run --name b1 -e constraint:node==node-1 -d busybox:latest sleep 500
[ "$status" -eq 0 ]
run docker_swarm run --name b2 --volumes-from=/b1 -d busybox:latest sh
[ "$status" -eq 0 ]
@ -25,15 +25,15 @@ function teardown() {
# check if both containers are started on the same node
run docker_swarm inspect b1
[ "$status" -eq 0 ]
[[ "${output}" == *'"Name": "node-0"'* ]]
[[ "${output}" == *'"Name": "node-1"'* ]]
run docker_swarm inspect b2
[ "$status" -eq 0 ]
[[ "${output}" == *'"Name": "node-0"'* ]]
[[ "${output}" == *'"Name": "node-1"'* ]]
}
@test "links dependency" {
start_docker 2
start_docker_with_busybox 2
swarm_manage
# Running the second container with link dependency.
@ -58,11 +58,11 @@ function teardown() {
}
@test "shared network stack dependency" {
start_docker 2
start_docker_with_busybox 2
swarm_manage
# Running the second container with network stack dependency.
run docker_swarm run --name b1 -e constraint:node==node-0 -d busybox:latest sleep 500
run docker_swarm run --name b1 -e constraint:node==node-1 -d busybox:latest sleep 500
[ "$status" -eq 0 ]
run docker_swarm run --name b2 --net=container:/b1 -d busybox:latest sh
[ "$status" -eq 0 ]
@ -75,9 +75,9 @@ function teardown() {
# check if both containers are started on the same node
run docker_swarm inspect b1
[ "$status" -eq 0 ]
[[ "${output}" == *'"Name": "node-0"'* ]]
[[ "${output}" == *'"Name": "node-1"'* ]]
run docker_swarm inspect b2
[ "$status" -eq 0 ]
[[ "${output}" == *'"Name": "node-0"'* ]]
[[ "${output}" == *'"Name": "node-1"'* ]]
}

View File

@ -8,28 +8,22 @@ function teardown() {
}
@test "docker should filter port in host mode correctly" {
start_docker 2
start_docker_with_busybox 2
swarm_manage
#
# Use busybox to save image pulling time for integration test.
# Running the first 2 containers, it should be fine.
#
run docker_swarm run -d --expose=80 --net=host busybox sh
[ "$status" -eq 0 ]
run docker_swarm run -d --expose=80 --net=host busybox sh
[ "$status" -eq 0 ]
#
# When trying to start the 3rd one, it should be error finding port 80.
#
run docker_swarm run -d --expose=80 --net=host busybox sh
[ "$status" -ne 0 ]
[[ "${lines[0]}" == *"unable to find a node with port 80/tcp available in the Host mode"* ]]
#
# And the number of running containers should be still 2.
#
run docker_swarm ps -n 2
[ "${#lines[@]}" -eq 3 ]
}

View File

@ -48,7 +48,7 @@ function wait_containers_exit {
@test "spawning $CONTAINERS containers on $NODES nodes" {
# Start N engines.
start_docker $NODES
start_docker_with_busybox $NODES
# Start the manager and wait until all nodes join the cluster.
swarm_manage