Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

Adapt the 'rpm-ostree' test suite to continue on failure #404

Merged
merged 7 commits into from
Jun 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ inventory*
# ignore test artifacts
*bdsf_archive.yml
*journal
*.log
5 changes: 5 additions & 0 deletions roles/ostree_admin_status/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
# vim: set ft=ansible:
#
allow_duplicates: true

5 changes: 5 additions & 0 deletions roles/ostree_admin_status/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
# vim: set ft=ansible:
#
- name: Check 'ostree admin status'
command: ostree admin status
12 changes: 12 additions & 0 deletions tests/improved-sanity-test/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@
- journal_fatal_msgs
- rhcos

# https://bugzilla.redhat.com/show_bug.cgi?id=1571264
- role: ostree_admin_status
tags:
- ostree_admin_status
- rhcos

# Check RPM signatures
- role: rpm_signature_verify
tags:
Expand Down Expand Up @@ -539,6 +545,12 @@
- journal_fatal_msgs
- rhcos

# https://bugzilla.redhat.com/show_bug.cgi?id=1571264
- role: ostree_admin_status
tags:
- ostree_admin_status_again
- rhcos

# We remove any subscriptions after the upgrade to verify that
# 'rpm-ostree status' with the 'unconfigured-state' field present.
# https://bugzilla.redhat.com/show_bug.cgi?id=1421867
Expand Down
8 changes: 8 additions & 0 deletions tests/rpm-ostree/cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# vim: set ft=ansible:
#
- import_role:
name: docker_remove_all

- import_role:
name: rpm_ostree_cleanup_all
58 changes: 58 additions & 0 deletions tests/rpm-ostree/cleanup_pending.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
# vim: set ft=ansible:
#
- import_role:
name: rpm_ostree_status

# Get the parent of the deployed commit, which we will use as HEAD-1
# in case the remote gets updated while testing
- name: Get parent of deployed commit
command: ostree rev-parse {{ ros_booted['checksum'] }}^
register: orp

# the rpm_ostree_status above sets the ros_booted variable used below
- name: Set current commit version and refspec
set_fact:
head_csum: "{{ ros_booted['checksum'] }}"
hmo_csum: "{{ orp.stdout }}"
refspec: "{{ ros_booted['origin'] }}"

- name: Deploy HEAD-1 checksum
command: rpm-ostree deploy {{ hmo_csum }}
register: ros_deploy
retries: 5
delay: 60
until: ros_deploy|success

# verify pending deployment info
- import_role:
name: rpm_ostree_status_verify
vars:
num_deployments: 2
deployment: 0
expected:
booted: false
checksum: "{{ hmo_csum }}"

# verify current deployment info
- import_role:
name: rpm_ostree_status_verify
vars:
num_deployments: 2
deployment: 1
expected:
booted: true
checksum: "{{ head_csum }}"

- name: Delete pending deployment
command: rpm-ostree cleanup -p

# verify origin deployment is still there and not deleted
- import_role:
name: rpm_ostree_status_verify
vars:
num_deployments: 1
deployment: 0
expected:
booted: true
checksum: "{{ head_csum }}"
171 changes: 171 additions & 0 deletions tests/rpm-ostree/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
---
# vim: set ft=ansible:
#
# Only run this test on Fedora and CentOS Atomic Host Continuous
# RHEL Atomic Host and CentOS do not have compose abilities enabled
- when: >
ansible_distribution == "Fedora" or
ansible_distribution == "CentOSDev"
block:
- name: Set base dir
set_fact:
base_dir: '/var/srv'

- name: Set common facts
set_fact:
compose_pkg: 'wget'
cache_dir: '{{ base_dir }}/cache'
repo_dir: '{{ base_dir }}/repo'

- name: Set Fedora facts
when: ansible_distribution == "Fedora"
set_fact:
repo_url: 'https://pagure.io/fedora-atomic.git'
repo_name: 'fedora-atomic'
json_file: 'fedora-atomic-host-base.json'

- name: Set CentOS Continuous facts
when: ansible_distribution == "CentOSDev"
set_fact:
repo_url: 'https://github.com/CentOS/sig-atomic-buildscripts.git'
repo_name: 'centos'
base_json: 'centos-atomic-host.json'
json_file: 'centos-atomic-host-continuous.json'

- name: Wipe base dir
file:
state: 'absent'
path: '{{ base_dir }}/'

# CentOS Atomic Host runs out of space in the root partition when
# creating a tree and rebasing to it so the root partition needs
# to be increased
- name: Resize partition for CentOS
when: ansible_distribution == "CentOSDev"
import_role:
name: resize_lv
vars:
rl_lvname: 'root'
rl_lvsize: '6'

- name: Clone fedora 27 repo
when: ansible_distribution == "Fedora"
command: >
docker run -v {{ base_dir }}:{{ base_dir }}:z
docker.io/miabbott/aht-tools /bin/bash -c
"git clone {{ repo_url }} {{ base_dir }}/{{ repo_name }};
cd {{ base_dir }}/{{ repo_name }}; git checkout f27"

- name: Clone sig-atomic-buildscripts repo
when: ansible_distribution == "CentOSDev"
command: >
docker run -v {{ base_dir }}:{{ base_dir }}:z
docker.io/miabbott/aht-tools /bin/bash -c
"git clone {{ repo_url }} {{ base_dir }}/{{ repo_name }};
cd {{ base_dir }}/{{ repo_name }};"

- name: Create repo + cache directory
file:
path: '{{ item }}'
state: directory
mode: 0755
with_items:
- '{{ repo_dir }}'
- '{{ cache_dir }}'

- name: Initialize repo directory
command: ostree --repo=repo init --mode=archive-z2
args:
chdir: '{{ base_dir }}'

# base_json is required because the CAHC json file uses the centos
# atomic host base json which contains the package list that needs
# to be modified
- name: Modify base package json for CAHC
when: base_json is defined
lineinfile:
dest: '{{ base_dir }}/{{ repo_name }}/{{ base_json }}'
state: present
insertafter: '"docker",$'
line: ' "{{ compose_pkg }}",'

- name: Modify base package json for Fedora
when: base_json is undefined
lineinfile:
dest: '{{ base_dir }}/{{ repo_name }}/{{ json_file }}'
state: present
insertafter: '"docker",$'
line: ' "{{ compose_pkg }}",'

- name: Compose new tree
command: >
rpm-ostree compose tree
--cachedir={{ cache_dir }}
--repo={{ repo_dir }}
{{ base_dir }}/{{ repo_name }}/{{ json_file }}
register: rct_output

- name: Set refspec and commit id
set_fact:
rct_refspec: "{{ rct_output.stdout | regex_search(regexp, '\\1') }}"
rct_commit_id: "{{ rct_output.stdout | regex_search(regexp, '\\2') }}"
vars:
regexp: '(.*)\s=>\s(.*)'

# Fire the http server and forget about it using the async option
# This http server will die when the system is rebooted after rebase
- name: Start http server and keep it running
command: python -m SimpleHTTPServer 80
args:
chdir: '{{ base_dir }}'
async: 1000
poll: 0
tags:
- start

- name: Wait for port 80 to be open
wait_for:
port: 80
delay: 5
timeout: 60

- import_role:
name: rpm_ostree_rebase
vars:
ror_refspec: '{{ rct_refspec[0] }}'
ror_remote_name: local
ror_remote_url: http://localhost:80/repo

- import_role:
name: reboot

- import_role:
name: rpm_ostree_status

- name: Fail if booted commit is incorrect
when:
- rct_commit_id[0] != booted_checksum
fail:
msg: |
Expected: booted commit is {{ rct_commit_id[0] }}
Actual: booted commit is {{ booted_checksum }}
vars:
booted_checksum: '{{ ros_booted["checksum"] }}'

# use the rpm_ostree_install_verify to ensure compose_pkg was part
# of the compose but do not check that it is layered
- import_role:
name: rpm_ostree_install_verify
vars:
roiv_package_name: '{{ compose_pkg }}'
roiv_binary_name: '{{ compose_pkg }}'
roiv_status_check: false

- import_role:
name: rpm_ostree_rollback

- import_role:
name: reboot

- name: Clean up deployments
command: rpm-ostree cleanup -rpmb
69 changes: 69 additions & 0 deletions tests/rpm-ostree/deploy_commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
# vim: set ft=ansible:
#
- import_role:
name: rpm_ostree_status

# Get the parent of the deployed commit, which we will use as HEAD-1
# in case the remote gets updated while testing
- name: Get parent of deployed commit
command: ostree rev-parse {{ ros_booted['checksum'] }}^
register: orp

# the rpm_ostree_status above sets the ros_booted variable used below
- name: Set current commit version and refspec
set_fact:
head_csum: "{{ ros_booted['checksum'] }}"
hmo_csum: "{{ orp.stdout }}"
refspec: "{{ ros_booted['origin'] }}"

- name: Deploy HEAD-1
command: rpm-ostree deploy {{ hmo_csum }}
register: ros_deploy
retries: 5
delay: 60
until: ros_deploy|success

# reboot
- import_role:
name: reboot

# verify booted checksum
- import_role:
name: rpm_ostree_status_verify
vars:
num_deployments: 2
deployment: 0
expected:
booted: true
checksum: "{{ hmo_csum }}"

- name: Rollback to HEAD
import_role:
name: rpm_ostree_rollback

# reboot
- import_role:
name: reboot

# verify HEAD checksum is booted
- import_role:
name: rpm_ostree_status_verify
vars:
num_deployments: 2
deployment: 0
expected:
booted: true
checksum: "{{ head_csum }}"

- name: Cleanup rollback
command: rpm-ostree cleanup -r

# verify rollback cleanup
- import_role:
name: rpm_ostree_status_verify
vars:
num_deployments: 1
deployment: 0
expected:
checksum: "{{ head_csum }}"
Loading