-
Notifications
You must be signed in to change notification settings - Fork 30
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 #86 from dirgim/fedora28-testing-parallel
Add fedora28 testing container, run container tests in parallel
- Loading branch information
Showing
14 changed files
with
494 additions
and
37 deletions.
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
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
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
59 changes: 59 additions & 0 deletions
59
test/config/Dockerfiles/contra-env-setup-test-f28/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,59 @@ | ||
FROM fedora:28 | ||
MAINTAINER "Krunoslav Pavic" <[email protected]> | ||
|
||
ENV container docker | ||
ENV HOME=/home | ||
|
||
WORKDIR $HOME | ||
|
||
COPY prepare_and_test.sh $HOME/ | ||
COPY test_contra_env_setup.py $HOME/ | ||
COPY debug_vars.yml $HOME/ | ||
|
||
RUN dnf -y install libguestfs libguestfs-tools-c \ | ||
git libvirt-client \ | ||
PyYAML python2-setuptools virt-install \ | ||
python-pip python-devel gcc net-tools \ | ||
openssh-clients sshpass \ | ||
libselinux-python libffi-devel\ | ||
openssl-devel openssh-server libyaml-devel \ | ||
python-lxml libvirt libvirt-devel \ | ||
libvirt-python ansible pytest \ | ||
&& dnf clean all | ||
|
||
RUN dnf -y update && dnf clean all | ||
RUN dnf -y install systemd | ||
|
||
RUN ssh-keygen -f /root/.ssh/id_rsa -t rsa -N '' | ||
RUN printf "Host *\n StrictHostKeyChecking no" > /root/.ssh/config | ||
|
||
RUN dnf -y install libvirt-daemon-driver-* libvirt-daemon libvirt-daemon-kvm qemu-kvm socat && dnf clean all; \ | ||
(cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \ | ||
rm -f /lib/systemd/system/multi-user.target.wants/*;\ | ||
rm -f /etc/systemd/system/*.wants/*;\ | ||
rm -f /lib/systemd/system/local-fs.target.wants/*; \ | ||
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \ | ||
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \ | ||
rm -f /lib/systemd/system/basic.target.wants/*;\ | ||
rm -f /lib/systemd/system/anaconda.target.wants/*; \ | ||
systemctl enable libvirtd; \ | ||
systemctl enable virtlockd | ||
#systemctl enable debug-shell.service | ||
|
||
RUN pip install ara | ||
|
||
# The default.xml needs to be have an unique network if there are multiple containers running | ||
COPY default.xml /etc/libvirt/qemu/networks/ | ||
COPY docker-machines.xml /etc/libvirt/qemu/networks/ | ||
|
||
# Edit the service file which includes ExecStartPost to chmod /dev/kvm | ||
RUN sed -i "/Service/a ExecStartPost=\/bin\/chmod 666 /dev/kvm" /usr/lib/systemd/system/libvirtd.service | ||
|
||
# Fix for libvirt namespaces | ||
RUN echo "namespaces = []" >> /etc/libvirt/qemu.conf | ||
|
||
RUN curl -o /root/minishift.tgz -L https://github.com/minishift/minishift/releases/download/v1.23.0/minishift-1.23.0-linux-amd64.tgz && tar xvzf /root/minishift.tgz -C /root/ | ||
RUN curl -o /usr/local/bin/docker-machine-driver-kvm -L https://github.com/dhiltgen/docker-machine-kvm/releases/download/v0.10.0/docker-machine-driver-kvm-centos7 && chmod 755 /usr/local/bin/docker-machine-driver-kvm | ||
COPY fix-minishift.sh $HOME/ | ||
|
||
CMD ["/usr/sbin/init"] |
10 changes: 10 additions & 0 deletions
10
test/config/Dockerfiles/contra-env-setup-test-f28/debug_vars.yml
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,10 @@ | ||
- name: "Set debug vars" | ||
set_fact: | ||
test_run_info: | ||
minishift_bin: "{{ minishift_bin }}" | ||
oc_bin: "{{ oc_bin }}" | ||
profile: "{{ profile }}" | ||
|
||
- name: "debug-vars" | ||
debug: | ||
var: test_run_info |
12 changes: 12 additions & 0 deletions
12
test/config/Dockerfiles/contra-env-setup-test-f28/default.xml
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,12 @@ | ||
<network> | ||
<name>default</name> | ||
<uuid>f487971c-469a-4752-ba15-ff85024834a8</uuid> | ||
<forward mode='nat'/> | ||
<bridge name='virbr4' stp='on' delay='0'/> | ||
<ip address='192.168.126.1' netmask='255.255.255.0'> | ||
<dhcp> | ||
<range start='192.168.126.2' end='192.168.126.254'/> | ||
</dhcp> | ||
</ip> | ||
</network> | ||
|
11 changes: 11 additions & 0 deletions
11
test/config/Dockerfiles/contra-env-setup-test-f28/docker-machines.xml
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,11 @@ | ||
<network> | ||
<name>docker-machines</name> | ||
<uuid>f487971c-469a-4752-ba15-ff85024834a9</uuid> | ||
<forward mode='nat'/> | ||
<bridge name='virbr1' stp='on' delay='0'/> | ||
<ip address='192.168.43.1' netmask='255.255.255.0'> | ||
<dhcp> | ||
<range start='192.168.43.2' end='192.168.43.254'/> | ||
</dhcp> | ||
</ip> | ||
</network> |
7 changes: 7 additions & 0 deletions
7
test/config/Dockerfiles/contra-env-setup-test-f28/fix-minishift.sh
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,7 @@ | ||
#!/bin/bash | ||
|
||
systemctl start libvirtd || true | ||
|
||
/root/minishift-1.23.0-linux-amd64/minishift start -v 5 --profile minishift --disk-size 40gb --memory 8092mb --openshift-version v3.10.0 || /root/minishift-1.23.0-linux-amd64/minishift delete -f | ||
|
||
/root/minishift-1.23.0-linux-amd64/minishift delete -f |
47 changes: 47 additions & 0 deletions
47
test/config/Dockerfiles/contra-env-setup-test-f28/prepare_and_test.sh
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,47 @@ | ||
#!/bin/bash | ||
|
||
base_dir=/home | ||
|
||
# Set log dir to the WORKSPACE where it can be archived | ||
if [ ! -z "${WORKSPACE}" ]; then | ||
log_dir=${WORKSPACE} | ||
else | ||
log_dir=${base_dir}/logs | ||
fi | ||
|
||
# Set environment to use ara with ansible | ||
export ara_location=$(python -c "import os,ara; print(os.path.dirname(ara.__file__))") | ||
export ANSIBLE_CALLBACK_PLUGINS=$ara_location/plugins/callbacks | ||
export ANSIBLE_ACTION_PLUGINS=$ara_location/plugins/actions | ||
export ANSIBLE_LIBRARY=$ara_location/plugins/modules | ||
|
||
export USER=$(whoami) | ||
|
||
cd ${base_dir} | ||
|
||
# Prepare repo and logs directories | ||
mkdir -p ${log_dir} | ||
|
||
git clone https://github.com/CentOS-PaaS-SIG/contra-env-setup.git | ||
|
||
pushd ${PROJECT_REPO} | ||
|
||
# Sync the repository | ||
if [ -z ${PR_NUM} ]; then | ||
git fetch origin ${ACTUAL_COMMIT} | ||
git checkout FETCH_HEAD | ||
else | ||
# PR was specified so we need to fetch it | ||
git fetch origin pull/${PR_NUM}/head:local-testing-branch | ||
git checkout local-testing-branch | ||
fi | ||
|
||
popd | ||
|
||
# Run the playbook locally with added hook for debugging variables needed for testing | ||
/usr/bin/ansible-playbook -vv -i "localhost," ${base_dir}/contra-env-setup/playbooks/setup.yml -e user=root \ | ||
-e ansible_connection=local -e setup_nested_virt=false -e setup_playbook_hooks=true \ | ||
--extra-vars='{"hooks": ["/home/debug_vars.yml"]}' | ||
|
||
# Run tests with pytest | ||
python -m pytest ${base_dir}/test_contra_env_setup.py -v --junitxml=${log_dir}/contra_env_setup_fedora28.xml > ${log_dir}/contra_env_setup_fedora28.log |
Oops, something went wrong.