forked from openshift/openshift-ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request openshift#3816 from sosiouxme/20170328-integration…
…-tests Merged by openshift-bot
- Loading branch information
Showing
30 changed files
with
948 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Integration tests | ||
|
||
Integration tests exercise the OpenShift Ansible playbooks by running them | ||
against an inventory with Docker containers as hosts. | ||
|
||
## Requirements | ||
|
||
The tests assume that: | ||
|
||
* docker is running on localhost and the present user has access to use it. | ||
* golang is installed and the go binary is in PATH. | ||
* python and tox are installed. | ||
|
||
## Building images | ||
|
||
The tests rely on images built in the local docker index. You can build them | ||
from the repository root with: | ||
|
||
``` | ||
./test/integration/build-images.sh | ||
``` | ||
|
||
Use the `--help` option to view available options. | ||
|
||
## Running the tests | ||
|
||
From the repository root, run the integration tests with: | ||
|
||
``` | ||
./test/integration/run-tests.sh | ||
``` | ||
|
||
Use the `--help` option to view available options. | ||
|
||
You can also run tests more directly, for example to run a specific check: | ||
|
||
``` | ||
go test ./test/integration/... -run TestPackageUpdateDepMissing | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#!/bin/bash | ||
|
||
# This is intended to run either locally (in which case a push is not | ||
# necessary) or in a CI job (where the results should be pushed to a | ||
# registry for use in later CI test jobs). Images are tagged locally with | ||
# both the base name (e.g. "test-target-base") and with the prefix given; | ||
# then only the prefixed name is pushed if --push is specified, assuming | ||
# any necessary credentials are available for the push. The same prefix | ||
# can then be used for the testing script. By default a local (non-registry) | ||
# prefix is used and no push can occur. To push to e.g. dockerhub: | ||
# | ||
# ./build-images.sh --push --prefix=docker.io/openshift/ansible-integration- | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
STARTTIME=$(date +%s) | ||
source_root=$(dirname "${0}") | ||
|
||
prefix="${PREFIX:-openshift-ansible-integration-}" | ||
push=false | ||
verbose=false | ||
build_options="${DOCKER_BUILD_OPTIONS:-}" | ||
help=false | ||
|
||
for args in "$@" | ||
do | ||
case $args in | ||
--prefix=*) | ||
prefix="${args#*=}" | ||
;; | ||
--push) | ||
push=true | ||
;; | ||
--no-cache) | ||
build_options="${build_options} --no-cache" | ||
;; | ||
--verbose) | ||
verbose=true | ||
;; | ||
--help) | ||
help=true | ||
;; | ||
esac | ||
done | ||
|
||
if [ "$help" = true ]; then | ||
echo "Builds the docker images for openshift-ansible integration tests" | ||
echo "and pushes them to a central registry." | ||
echo | ||
echo "Options: " | ||
echo " --prefix=PREFIX" | ||
echo " The prefix to use for the image names." | ||
echo " default: openshift-ansible-integration-" | ||
echo | ||
echo " --push" | ||
echo " If set will push the tagged image" | ||
echo | ||
echo " --no-cache" | ||
echo " If set will perform the build without a cache." | ||
echo | ||
echo " --verbose" | ||
echo " Enables printing of the commands as they run." | ||
echo | ||
echo " --help" | ||
echo " Prints this help message" | ||
echo | ||
exit 0 | ||
fi | ||
|
||
if [ "$verbose" = true ]; then | ||
set -x | ||
fi | ||
|
||
|
||
declare -a build_order ; declare -A images | ||
build_order+=( test-target-base ) ; images[test-target-base]=openshift_health_checker/builds/test-target-base | ||
build_order+=( preflight-aos-package-checks ); images[preflight-aos-package-checks]=openshift_health_checker/builds/aos-package-checks | ||
for image in "${build_order[@]}"; do | ||
BUILD_STARTTIME=$(date +%s) | ||
docker_tag=${prefix}${image} | ||
echo | ||
echo "--- Building component '$image' with docker tag '$docker_tag' ---" | ||
docker build ${build_options} -t $image -t $docker_tag "$source_root/${images[$image]}" | ||
echo | ||
BUILD_ENDTIME=$(date +%s); echo "--- build $docker_tag took $(($BUILD_ENDTIME - $BUILD_STARTTIME)) seconds ---" | ||
if [ "$push" = true ]; then | ||
docker push $docker_tag | ||
PUSH_ENDTIME=$(date +%s); echo "--- push $docker_tag took $(($PUSH_ENDTIME - $BUILD_ENDTIME)) seconds ---" | ||
fi | ||
done | ||
|
||
echo | ||
echo | ||
echo "++ Active images" | ||
docker images | grep ${prefix} | sort | ||
echo | ||
|
||
|
||
ret=$?; ENDTIME=$(date +%s); echo "$0 took $(($ENDTIME - $STARTTIME)) seconds"; exit "$ret" |
30 changes: 30 additions & 0 deletions
30
test/integration/openshift_health_checker/builds/aos-package-checks/Dockerfile
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
FROM test-target-base | ||
|
||
RUN yum install -y rpm-build rpmdevtools createrepo && \ | ||
rpmdev-setuptree && \ | ||
mkdir -p /mnt/localrepo | ||
ADD root / | ||
|
||
# we will build some RPMs that can be used to break yum update in tests. | ||
RUN cd /root/rpmbuild/SOURCES && \ | ||
mkdir break-yum-update-1.0 && \ | ||
tar zfc foo.tgz break-yum-update-1.0 && \ | ||
rpmbuild -bb /root/break-yum-update.spec && \ | ||
yum install -y /root/rpmbuild/RPMS/noarch/break-yum-update-1.0-1.noarch.rpm && \ | ||
rpmbuild -bb /root/break-yum-update-2.spec && \ | ||
mkdir /mnt/localrepo/break-yum && \ | ||
cp /root/rpmbuild/RPMS/noarch/break-yum-update-1.0-2.noarch.rpm /mnt/localrepo/break-yum && \ | ||
createrepo /mnt/localrepo/break-yum | ||
|
||
# we'll also build some RPMs that can be used to exercise OCP package version tests. | ||
RUN cd /root/rpmbuild/SOURCES && \ | ||
mkdir atomic-openshift-3.2 && \ | ||
mkdir atomic-openshift-3.3 && \ | ||
tar zfc ose.tgz atomic-openshift-3.{2,3} && \ | ||
rpmbuild -bb /root/ose-3.2.spec && \ | ||
rpmbuild -bb /root/ose-3.3.spec && \ | ||
mkdir /mnt/localrepo/ose-3.{2,3} && \ | ||
cp /root/rpmbuild/RPMS/noarch/atomic-openshift*-3.2-1.noarch.rpm /mnt/localrepo/ose-3.2 && \ | ||
createrepo /mnt/localrepo/ose-3.2 && \ | ||
cp /root/rpmbuild/RPMS/noarch/atomic-openshift*-3.3-1.noarch.rpm /mnt/localrepo/ose-3.3 && \ | ||
createrepo /mnt/localrepo/ose-3.3 |
5 changes: 5 additions & 0 deletions
5
...on/openshift_health_checker/builds/aos-package-checks/root/etc/yum.repos.d/break-yum.repo
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[break-yum] | ||
name=break-yum | ||
baseurl=file:///mnt/localrepo/break-yum | ||
enabled=0 | ||
gpgcheck=0 |
5 changes: 5 additions & 0 deletions
5
...tion/openshift_health_checker/builds/aos-package-checks/root/etc/yum.repos.d/ose-3.2.repo
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[ose-3.2] | ||
name=ose-3.2 | ||
baseurl=file:///mnt/localrepo/ose-3.2 | ||
enabled=0 | ||
gpgcheck=0 |
5 changes: 5 additions & 0 deletions
5
...tion/openshift_health_checker/builds/aos-package-checks/root/etc/yum.repos.d/ose-3.3.repo
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[ose-3.3] | ||
name=ose-3.3 | ||
baseurl=file:///mnt/localrepo/ose-3.3 | ||
enabled=0 | ||
gpgcheck=0 |
33 changes: 33 additions & 0 deletions
33
...tion/openshift_health_checker/builds/aos-package-checks/root/root/break-yum-update-2.spec
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
Name: break-yum-update | ||
Version: 1.0 | ||
Release: 2 | ||
Summary: Package for breaking updates by requiring things that don't exist | ||
|
||
License: NA | ||
|
||
Requires: package-that-does-not-exist | ||
Source0: http://example.com/foo.tgz | ||
BuildArch: noarch | ||
|
||
%description | ||
Package for breaking updates by requiring things that don't exist | ||
|
||
|
||
%prep | ||
%setup -q | ||
|
||
|
||
%build | ||
|
||
|
||
%install | ||
rm -rf $RPM_BUILD_ROOT | ||
mkdir -p $RPM_BUILD_ROOT | ||
|
||
|
||
%files | ||
%doc | ||
|
||
|
||
|
||
%changelog |
32 changes: 32 additions & 0 deletions
32
...ration/openshift_health_checker/builds/aos-package-checks/root/root/break-yum-update.spec
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
Name: break-yum-update | ||
Version: 1.0 | ||
Release: 1 | ||
Summary: Package for breaking updates by requiring things that don't exist | ||
|
||
License: NA | ||
|
||
Source0: http://example.com/foo.tgz | ||
BuildArch: noarch | ||
|
||
%description | ||
Package for breaking updates by requiring things that don't exist | ||
|
||
|
||
%prep | ||
%setup -q | ||
|
||
|
||
%build | ||
|
||
|
||
%install | ||
rm -rf $RPM_BUILD_ROOT | ||
mkdir -p $RPM_BUILD_ROOT | ||
|
||
|
||
%files | ||
%doc | ||
|
||
|
||
|
||
%changelog |
44 changes: 44 additions & 0 deletions
44
test/integration/openshift_health_checker/builds/aos-package-checks/root/root/ose-3.2.spec
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
Name: atomic-openshift | ||
Version: 3.2 | ||
Release: 1 | ||
Summary: package the critical aos packages | ||
|
||
License: NA | ||
|
||
Source0: http://example.com/ose.tgz | ||
BuildArch: noarch | ||
|
||
%package master | ||
Summary: package the critical aos packages | ||
%package node | ||
Summary: package the critical aos packages | ||
|
||
%description | ||
Package for pretending to provide AOS | ||
|
||
%description master | ||
Package for pretending to provide AOS | ||
|
||
%description node | ||
Package for pretending to provide AOS | ||
|
||
%prep | ||
%setup -q | ||
|
||
|
||
%build | ||
|
||
|
||
%install | ||
rm -rf $RPM_BUILD_ROOT | ||
mkdir -p $RPM_BUILD_ROOT | ||
|
||
|
||
%files | ||
%files master | ||
%files node | ||
%doc | ||
|
||
|
||
|
||
%changelog |
44 changes: 44 additions & 0 deletions
44
test/integration/openshift_health_checker/builds/aos-package-checks/root/root/ose-3.3.spec
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
Name: atomic-openshift | ||
Version: 3.3 | ||
Release: 1 | ||
Summary: package the critical aos packages | ||
|
||
License: NA | ||
|
||
Source0: http://example.com/ose.tgz | ||
BuildArch: noarch | ||
|
||
%package master | ||
Summary: package the critical aos packages | ||
%package node | ||
Summary: package the critical aos packages | ||
|
||
%description | ||
Package for pretending to provide AOS | ||
|
||
%description master | ||
Package for pretending to provide AOS | ||
|
||
%description node | ||
Package for pretending to provide AOS | ||
|
||
%prep | ||
%setup -q | ||
|
||
|
||
%build | ||
|
||
|
||
%install | ||
rm -rf $RPM_BUILD_ROOT | ||
mkdir -p $RPM_BUILD_ROOT | ||
|
||
|
||
%files | ||
%files master | ||
%files node | ||
%doc | ||
|
||
|
||
|
||
%changelog |
2 changes: 2 additions & 0 deletions
2
test/integration/openshift_health_checker/builds/test-target-base/Dockerfile
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
FROM centos/systemd | ||
RUN yum install -y iproute python-dbus PyYAML yum-utils |
Oops, something went wrong.