Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: docker/util
base: master
Choose a base ref
...
head repository: docker/util
compare: minorchanges
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 14 commits
  • 5 files changed
  • 1 contributor

Commits on Aug 25, 2016

  1. Copy the full SHA
    42c382b View commit details
  2. Imagename is not necessary in build argument and it is not supported …

    …in FROM tag.
    villadalmine committed Aug 25, 2016
    Copy the full SHA
    fb8d21f View commit details
  3. Added test.sh file. This file execute the bats tests

    villadalmine committed Aug 25, 2016
    Copy the full SHA
    08a3eda View commit details
  4. Added tests in install script

    villadalmine committed Aug 25, 2016
    Copy the full SHA
    de7fbc4 View commit details
  5. Added command to execute test

    villadalmine committed Aug 25, 2016
    Copy the full SHA
    3a92b9a View commit details
  6. Added again imagename

    villadalmine committed Aug 25, 2016
    Copy the full SHA
    da9f582 View commit details
  7. Added first test

    villadalmine committed Aug 25, 2016
    Copy the full SHA
    74710ec View commit details
  8. Copy the full SHA
    1d18a20 View commit details

Commits on Aug 26, 2016

  1. Added more logic to first test

    villadalmine committed Aug 26, 2016
    Copy the full SHA
    5e3d22e View commit details
  2. Added test to start container

    villadalmine committed Aug 26, 2016
    Copy the full SHA
    71bad8f View commit details
  3. Added test for destroy image

    villadalmine committed Aug 26, 2016
    Copy the full SHA
    5bf904d View commit details
  4. Added rebuild images

    villadalmine committed Aug 26, 2016
    Copy the full SHA
    87a228d View commit details
  5. Minor fix in variable

    villadalmine committed Aug 26, 2016
    Copy the full SHA
    ea7f188 View commit details
  6. Removed some previous control in build test

    villadalmine committed Aug 26, 2016
    Copy the full SHA
    0cf5e9f View commit details
Showing with 77 additions and 5 deletions.
  1. +3 −2 README.md
  2. +1 −1 bin/build.sh
  3. +3 −1 bin/install.sh
  4. +4 −1 bin/test.sh
  5. +66 −0 tests/image-test.bats
5 changes: 3 additions & 2 deletions README.md
@@ -9,7 +9,7 @@ If you are reading this file in BINSCRIPTS.md, your container project is likely
To use these scripts yourself, issue this command:

```
curl "https://github.internet2.edu/raw/docker/util/master/bin/install.sh?token=AAAAETsVKUnOEAMM8TvUUZccPYi13wsnks5Xq46jwA%3D%3D" | bash
curl -u user:token "https://github.internet2.edu/raw/docker/util/master/bin/install.sh" | bash
```

### common.bash
@@ -38,4 +38,5 @@ This will also install a Jenkinsfile to your repository, if it doesn't have one.


### Testing
#### test.sh
#### test.sh
`bin/test.sh`
2 changes: 1 addition & 1 deletion bin/build.sh
@@ -3,4 +3,4 @@
source common.bash .

echo "Building new Docker image($maintainer/$imagename)"
docker build --rm -t $maintainer/$imagename --build-arg maintainer=$maintainer --build-arg imagename=$imagename --build-arg version=$version .
docker build --rm -t $maintainer/$imagename --build-arg maintainer=$maintainer --build-arg imagename=$imagename --build-arg version=$version .
4 changes: 3 additions & 1 deletion bin/install.sh
@@ -2,6 +2,8 @@
git clone git@github.internet2.edu:docker/util.git
find util/bin -name "*.sh" -exec sh -c 'echo "$1" | sed "s/util\///" >> .gitignore' -- {} \;
mkdir -p bin
mkdir -p tests
mv util/tests/* tests/.
mv util/bin/* bin/.
mv util/README.md BINSCRIPTS.md
if [ ! -f common.bash ]; then
@@ -10,4 +12,4 @@ fi
if [ ! -f Jenkinsfile ]; then
mv util/Jenkinsfile.sample Jenkinsfile
fi
rm -rf util
rm -rf util
5 changes: 4 additions & 1 deletion bin/test.sh
@@ -1,3 +1,6 @@
#!/bin/bash

bats tests
for i in $( ls tests/)
do
bats --tap tests/$i
done
66 changes: 66 additions & 0 deletions tests/image-test.bats
@@ -0,0 +1,66 @@
#!/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 ]
}