tests/str: Rework invocation

Let's make our `run.sh` generically support any playbook. This is prep for
writing further tests in Ansible. Along with that, rework the Ansible so that
`tests.yml` is a playbook, and then the other bits are just task lists. It's
easier to read.

I also started to add a `use_git_build` variable with the idea that we'll be
able to run these same tests against an upstream image by setting that variable
off.

Closes: #1493
Approved by: jlebon
This commit is contained in:
Colin Walters 2018-03-09 13:26:07 -05:00 committed by Atomic Bot
parent 5b3f79d4bb
commit 10fb74025d
5 changed files with 57 additions and 57 deletions

View File

@ -15,7 +15,7 @@ tests:
- ./tests/fedora-str/provision.sh - ./tests/fedora-str/provision.sh
# TODO: enhance papr to have caching, a bit like https://docs.travis-ci.com/user/caching/ # TODO: enhance papr to have caching, a bit like https://docs.travis-ci.com/user/caching/
- curl -Lo fedora-atomic-host.qcow2 https://getfedora.org/atomic_qcow2_latest - curl -Lo fedora-atomic-host.qcow2 https://getfedora.org/atomic_qcow2_latest
- env "TEST_SUBJECTS=$(pwd)/fedora-atomic-host.qcow2" ./tests/fedora-str/run.sh - env "TEST_SUBJECTS=$(pwd)/fedora-atomic-host.qcow2" ./tests/fedora-str/playbook-run.sh tests/fedora-str/tests.yml
artifacts: artifacts:
- tests/fedora-str/artifacts/fedora-atomic-host.qcow2.log - tests/fedora-str/artifacts/fedora-atomic-host.qcow2.log

View File

@ -1,31 +1,27 @@
--- # Run "admin unlock" and add locally built RPMs, then
- hosts: localhost # copy the whole tests/ directory into the VM.
tags: - command: ostree --version
- atomic
remote_user: root
tasks:
- command: ostree --version
changed_when: False changed_when: False
register: ostree_orig_version register: ostree_orig_version
- set_fact: - set_fact:
ostree_orig_version_yaml: "{{ ostree_orig_version.stdout | from_yaml }}" ostree_orig_version_yaml: "{{ ostree_orig_version.stdout | from_yaml }}"
- name: Copy locally built RPMs - name: Copy locally built RPMs
synchronize: src=x86_64/ dest=/root/x86_64/ archive=yes synchronize: src=x86_64/ dest=/root/x86_64/ archive=yes
- shell: ostree admin unlock || true - shell: ostree admin unlock || true
# Install the RPMs we already have. For the test suite we use rpm2cpio # Install the RPMs we already have. For the test suite we use rpm2cpio
# since it depends on libsoup, but we're not using that yet for the sysinstalled tests # since it depends on libsoup, but we're not using that yet for the sysinstalled tests
- shell: > - shell: >
/usr/bin/rpm -Fvh /root/x86_64/*.rpm && \ /usr/bin/rpm -Fvh /root/x86_64/*.rpm && \
cd / && rpm2cpio /root/x86_64/ostree-tests-2*.rpm | cpio -div cd / && rpm2cpio /root/x86_64/ostree-tests-2*.rpm | cpio -div
- command: ostree --version - command: ostree --version
register: ostree_new_version register: ostree_new_version
- set_fact: - set_fact:
ostree_new_version_yaml: "{{ ostree_new_version.stdout | from_yaml }}" ostree_new_version_yaml: "{{ ostree_new_version.stdout | from_yaml }}"
- name: "Fail if we didn't change the ostree version" - name: "Fail if we didn't change the ostree version"
when: ostree_orig_version_yaml['libostree']['Git'] == ostree_new_version_yaml['libostree']['Git'] when: ostree_orig_version_yaml['libostree']['Git'] == ostree_new_version_yaml['libostree']['Git']
fail: fail:
msg: "Failed to change ostree version" msg: "Failed to change ostree version"
# Next copy all of the tests/ directory # Next copy all of the tests/ directory
- name: Copy test data - name: Copy test data
synchronize: src=../../ dest=/root/tests/ archive=yes synchronize: src=../../ dest=/root/tests/ archive=yes

View File

@ -1,9 +1,8 @@
#!/usr/bin/bash #!/usr/bin/bash
# A thin wrapper for ansible-playbook which has a nice check for
# TEST_SUBJECTS being set.
set -xeuo pipefail set -xeuo pipefail
dn=$(cd $(dirname $0) && pwd)
cd ${dn}
# https://fedoraproject.org/wiki/CI/Tests # https://fedoraproject.org/wiki/CI/Tests
if test -z "${TEST_SUBJECTS:-}"; then if test -z "${TEST_SUBJECTS:-}"; then
cat <<EOF cat <<EOF
@ -22,4 +21,4 @@ ls -al ${TEST_SUBJECTS}
export ANSIBLE_INVENTORY=${ANSIBLE_INVENTORY:-$(test -e inventory && echo inventory || echo /usr/share/ansible/inventory)} export ANSIBLE_INVENTORY=${ANSIBLE_INVENTORY:-$(test -e inventory && echo inventory || echo /usr/share/ansible/inventory)}
ls -al /dev/kvm ls -al /dev/kvm
ansible-playbook --tags=atomic tests.yml exec ansible-playbook --tags=atomic "$@"

View File

@ -1,20 +1,17 @@
--- # Run the system installed tests
- hosts: localhost - import_tasks: overlay-git.yml
tags: when: use_git_build
- atomic # Down the line perhaps do each log file separately?
remote_user: root - name: Run sysinstalled tests
tasks:
# Down the line perhaps do each log file separately?
- name: Run sysinstalled tests
shell: /root/tests/installed/run.sh &> /root/installed-tests.log shell: /root/tests/installed/run.sh &> /root/installed-tests.log
register: sysinstalled_result register: sysinstalled_result
failed_when: False failed_when: False
- name: Fetch sysinstalled results - name: Fetch sysinstalled results
fetch: fetch:
src: /root/installed-tests.log src: /root/installed-tests.log
dest: artifacts/installed-tests.log dest: artifacts/installed-tests.log
flat: yes flat: yes
- name: Assert that sysinstalled tests succeeded - name: Assert that sysinstalled tests succeeded
when: sysinstalled_result.rc != 0 when: sysinstalled_result.rc != 0
fail: fail:
msg: "sysinstalled tests failed" msg: "sysinstalled tests failed"

View File

@ -1,2 +1,10 @@
- include: overlay-git.yml # This entrypoint right now just runs the sysinstalled-tests.
- include: sysinstall-tests.yml ---
- hosts: localhost
tags:
- atomic
remote_user: root
vars:
use_git_build: True
tasks:
- import_tasks: sysinstall-tests.yml