Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
util/tests/image-test.bats
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
66 lines (61 sloc)
1.95 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bats | |
load ../common | |
@test "Build Docker Image $imagename/$maintainer" { | |
run bash -c "ps -eaf |grep -v grep|grep -c docker" | |
if [ $output -eq 0 ]; then | |
skip "Docker service is not running" | |
fi | |
run bash -c "ls -l Dockerfile" | |
if [ $status -ne 0 ]; then | |
skip "Dockerfile is not present" | |
fi | |
run bash -c "grep -c -e imagename -e maintainer -e version common.bash " | |
if [ $output -ne 3 ]; then | |
skip "imagename,maintainer and version are not defined" | |
fi | |
run bash -c "grep -c -e version -e imagename -e maintainer Dockerfile" | |
if [ $output -lt 3 ]; then | |
skip "imagename,maintainer and version are not defined in Dockerfile" | |
fi | |
run bash -c "bin/build.sh" | |
[ $status -eq 0 ] | |
} | |
@test "Starting Docker Image $maintainer7$imagename" { | |
run bash -c "docker ps -a -f name=$imagename -q|wc -l" | |
if [ $output -eq 1 ]; then | |
skip "Can not start $imagename because exist a previous image with same name " | |
fi | |
run bash -c "bin/start.sh" | |
run bash -c "docker ps -f name=$imagename -q|wc -l" | |
[ $output -eq 1 ] | |
} | |
@test "Stopping Docker Image $maintainer/$imagename" { | |
run bash -c "docker ps -f name=$imagename -q|wc -l" | |
if [ $output -eq 0 ]; then | |
skip "Image $imagename is not running, nothing to stop" | |
fi | |
run bash -c "bin/stop.sh" | |
run bash -c "docker ps -a -f name=$imagename -q|wc -l" | |
[ $output -eq 1 ] | |
} | |
@test "Destroying Image $maintainer/$imagename" { | |
run bash -c "docker ps -q -a -f name=$imagename -q|wc -l" | |
if [ $output -eq 0 ]; then | |
skip "Cannot destroy a non created container" | |
fi | |
run bash -c "docker start $imagename" | |
run bash -c "docker ps -q -f name=$imagename -q|wc -l" | |
if [ $output -eq 0 ]; then | |
skip "Cannot destroy a non started container" | |
fi | |
run bash -c "bin/destroy.sh" | |
[ $status -eq 0 ] | |
} | |
@test "Rebuilding and destroying in one step" { | |
run bash -c "bin/build.sh" | |
if [ $status -ne 0 ]; then | |
skip "Cannot rebuild the image" | |
fi | |
run bash -c "bin/rebuild.sh" | |
[ $status -eq 0 ] | |
} |