Initial smoke tests run from upstream Cockpit project
Later once the upstream no longer uses phantomjs, we should be able to execute the entire integration test suite. This includes the standard-test-overlay role, and the standard-test-scripts role. These will be suggested to the standard-test-roles repo.
This commit is contained in:
parent
090ad330f6
commit
d9a218b7d5
3
tests/.gitignore
vendored
Normal file
3
tests/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
*.retry
|
||||
artifacts/
|
||||
source/
|
12
tests/roles/standard-test-overlay/README.md
Normal file
12
tests/roles/standard-test-overlay/README.md
Normal file
@ -0,0 +1,12 @@
|
||||
# Ansible role for overlaying Atomic Host packages
|
||||
|
||||
Certain Atomic Host use cases require that packages are
|
||||
overlaid onto the host. This role allows you to do that.
|
||||
|
||||
You should not use this role to indiscriminately overlay test
|
||||
dependencies into the Atomic Host unless those dependencies are
|
||||
part of a real end user story.
|
||||
|
||||
You should define the following variables:
|
||||
|
||||
* packages: A list of packages to overlay
|
17
tests/roles/standard-test-overlay/tasks/main.yml
Normal file
17
tests/roles/standard-test-overlay/tasks/main.yml
Normal file
@ -0,0 +1,17 @@
|
||||
---
|
||||
- block:
|
||||
- name: Overlaying end user packages onto Atomic Host
|
||||
shell: rpm-ostree install {{ packages | join(" ") }}
|
||||
|
||||
- name: Reboot the Atomic Host
|
||||
shell: sleep 2 && systemctl reboot
|
||||
ignore_errors: true
|
||||
async: 1
|
||||
poll: 0
|
||||
|
||||
- name: Waiting for Atomic Host to restart
|
||||
local_action: wait_for host={{ ansible_ssh_host }} search_regex=OpenSSH port={{ ansible_ssh_port }} timeout=300 delay=20 connect_timeout=20
|
||||
become: false
|
||||
|
||||
# All these commands only apply to Atomic Host
|
||||
tags: atomic
|
2
tests/roles/standard-test-overlay/vars/main.yml
Normal file
2
tests/roles/standard-test-overlay/vars/main.yml
Normal file
@ -0,0 +1,2 @@
|
||||
---
|
||||
packages: []
|
17
tests/roles/standard-test-scripts/README.md
Normal file
17
tests/roles/standard-test-scripts/README.md
Normal file
@ -0,0 +1,17 @@
|
||||
# Ansible role for executing test scripts
|
||||
|
||||
Put this role in your tests.yml playbook and specify a
|
||||
number of test scripts to execute as tests. The results
|
||||
of each script will be piped into log file in the artifacts
|
||||
directory. If any script exits with a non-zero exit code
|
||||
the role will fail.
|
||||
|
||||
In the case of test subjects such a host or container, these
|
||||
test scripts and related files will be copied to the target into
|
||||
/usr/local/bin before execution.
|
||||
|
||||
You should define the following variables:
|
||||
|
||||
* tests: An array of scripts to run
|
||||
* files: A list of files or directories needed by the scripts
|
||||
|
2
tests/roles/standard-test-scripts/defaults/main.yml
Normal file
2
tests/roles/standard-test-scripts/defaults/main.yml
Normal file
@ -0,0 +1,2 @@
|
||||
---
|
||||
artifacts: "{{ lookup('env', 'TEST_ARTIFACTS') | default('./artifacts', true) }}"
|
33
tests/roles/standard-test-scripts/tasks/main.yml
Normal file
33
tests/roles/standard-test-scripts/tasks/main.yml
Normal file
@ -0,0 +1,33 @@
|
||||
---
|
||||
- name: Copy test scripts to target
|
||||
synchronize:
|
||||
src: "{{ item }}"
|
||||
dest: /usr/local/bin/
|
||||
ssh_args: "-o UserKnownHostsFile=/dev/null"
|
||||
with_items:
|
||||
- "{{ tests }}"
|
||||
- "{{ files }}"
|
||||
|
||||
- block:
|
||||
- name: Execute test scripts
|
||||
shell: |
|
||||
mkdir -p /tmp/artifacts
|
||||
logfile=/tmp/artifacts/test.$(echo {{ item }} | sed -e 's/\//-/g').log
|
||||
exec 2>>$logfile 1>>$logfile
|
||||
cd /usr/local/bin
|
||||
if [ -x {{ item }} ]; then
|
||||
./$(basename {{ item }}) && result="PASS" || result="FAIL"
|
||||
else
|
||||
/bin/sh -e ./$(basename {{ item }}) && result="PASS" || result="FAIL"
|
||||
fi
|
||||
echo "$result {{ item }}" >> /tmp/artifacts/test.log
|
||||
with_items:
|
||||
- "{{ tests }}"
|
||||
|
||||
always:
|
||||
- name: Pull out the logs
|
||||
synchronize:
|
||||
dest: "{{ artifacts }}"
|
||||
src: "/tmp/artifacts/./"
|
||||
mode: pull
|
||||
when: artifacts|default("") != ""
|
3
tests/roles/standard-test-scripts/vars/main.yml
Normal file
3
tests/roles/standard-test-scripts/vars/main.yml
Normal file
@ -0,0 +1,3 @@
|
||||
---
|
||||
tests: []
|
||||
files: []
|
12
tests/roles/standard-test-source/README.md
Normal file
12
tests/roles/standard-test-source/README.md
Normal file
@ -0,0 +1,12 @@
|
||||
# Ansible role for Upstream source tarball tests
|
||||
|
||||
Put this role in your tests.yml playbook. The playbook
|
||||
will extract the upstream source tarball as described in
|
||||
the package spec file into a test/source/ directory. You
|
||||
can then use or execute files (usually tests) from the
|
||||
upstream sources in your playbook.
|
||||
|
||||
You can redefine the following variables:
|
||||
|
||||
* srcdir: A directory to extract sources into. This defaults
|
||||
to {{ playbook_dir }}/source/
|
2
tests/roles/standard-test-source/defaults/main.yml
Normal file
2
tests/roles/standard-test-source/defaults/main.yml
Normal file
@ -0,0 +1,2 @@
|
||||
---
|
||||
artifacts: "{{ lookup('env', 'TEST_ARTIFACTS') | default('./artifacts', true) }}"
|
30
tests/roles/standard-test-source/tasks/main.yml
Normal file
30
tests/roles/standard-test-source/tasks/main.yml
Normal file
@ -0,0 +1,30 @@
|
||||
---
|
||||
- name: Add executor host
|
||||
add_host:
|
||||
name: executor
|
||||
ansible_connection: local
|
||||
ansible_ssh_host: 127.0.0.1
|
||||
ansible_ssh_connection: local
|
||||
|
||||
- name: Extract package source code
|
||||
delegate_to: executor
|
||||
block:
|
||||
- name: Gather facts
|
||||
setup:
|
||||
delegate_facts: True
|
||||
|
||||
- name: Install requirements
|
||||
package: name={{item}} state=present
|
||||
with_items:
|
||||
- fedpkg
|
||||
|
||||
# The dist doesn't actually matter here
|
||||
- name: Download sources, extract, and strip leading path
|
||||
shell: |
|
||||
shopt -s dotglob
|
||||
set -e
|
||||
rm -rf {{ srcdir }}
|
||||
fedpkg --release=master prep --builddir={{ srcdir }}
|
||||
mv {{ srcdir }}/*/* {{ srcdir }}
|
||||
args:
|
||||
chdir: "{{playbook_dir}}/.."
|
2
tests/roles/standard-test-source/vars/main.yml
Normal file
2
tests/roles/standard-test-source/vars/main.yml
Normal file
@ -0,0 +1,2 @@
|
||||
---
|
||||
srcdir: "{{ playbook_dir }}/source"
|
20
tests/tests.yml
Normal file
20
tests/tests.yml
Normal file
@ -0,0 +1,20 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
roles:
|
||||
- role: standard-test-source
|
||||
tags:
|
||||
- always
|
||||
|
||||
- role: standard-test-overlay
|
||||
tags:
|
||||
- atomic
|
||||
packages:
|
||||
- cockpit-ws
|
||||
- cockpit-dashboard
|
||||
|
||||
- role: standard-test-scripts
|
||||
tags:
|
||||
- atomic
|
||||
- classic
|
||||
tests:
|
||||
- ./source/tools/debian/tests/smoke
|
Loading…
Reference in New Issue
Block a user