301 lines
10 KiB
YAML
301 lines
10 KiB
YAML
---
|
|
- hosts: ostree_guest
|
|
become: no
|
|
vars:
|
|
workspace: "{{ lookup('env', 'WORKSPACE') }}"
|
|
total_counter: "0"
|
|
failed_counter: "0"
|
|
|
|
tasks:
|
|
# case: check ostree commit correctly updated
|
|
- name: get deployed ostree commit
|
|
command: rpm-ostree status --json
|
|
register: result_commit
|
|
|
|
- name: make a json result
|
|
set_fact:
|
|
deploy_commit: "{{ result_commit.stdout | from_json | json_query('deployments[0].checksum') }}"
|
|
|
|
- name: check commit deployed and built
|
|
block:
|
|
- assert:
|
|
that:
|
|
- deploy_commit == ostree_commit
|
|
fail_msg: "deployed ostree commit is not commit built by osbuild-composer"
|
|
success_msg: "successful building and deployment"
|
|
always:
|
|
- set_fact:
|
|
total_counter: "{{ total_counter | int + 1 }}"
|
|
rescue:
|
|
- name: failed count + 1
|
|
set_fact:
|
|
failed_counter: "{{ failed_counter | int + 1 }}"
|
|
|
|
# case from bug: https://bugzilla.redhat.com/show_bug.cgi?id=1848453
|
|
- name: check ostree-remount status
|
|
command: systemctl is-active ostree-remount.service
|
|
register: result_remount
|
|
|
|
- name: ostree-remount should be started
|
|
block:
|
|
- assert:
|
|
that:
|
|
- result_remount.stdout == "active"
|
|
fail_msg: "ostree-remount is not started by default"
|
|
success_msg: "starting ostree-remount successful"
|
|
always:
|
|
- set_fact:
|
|
total_counter: "{{ total_counter | int + 1 }}"
|
|
rescue:
|
|
- name: failed count + 1
|
|
set_fact:
|
|
failed_counter: "{{ failed_counter | int + 1 }}"
|
|
|
|
# case: check /sysroot moutn point
|
|
- name: check /sysroot mount point
|
|
command: findmnt -r -o SOURCE -n /sysroot
|
|
register: result_sysroot_mount_point
|
|
|
|
- name: /sysroot should be mounted on /dev/vda2
|
|
block:
|
|
- assert:
|
|
that:
|
|
- result_sysroot_mount_point.stdout == "/dev/vda2"
|
|
fail_msg: "/var does not mount on /dev/vda2"
|
|
success_msg: "/var mounts on /dev/vda2"
|
|
always:
|
|
- set_fact:
|
|
total_counter: "{{ total_counter | int + 1 }}"
|
|
rescue:
|
|
- name: failed count + 1
|
|
set_fact:
|
|
failed_counter: "{{ failed_counter | int + 1 }}"
|
|
|
|
# case: check /sysroot mount status
|
|
- name: check /sysroot mount status
|
|
shell: findmnt -r -o OPTIONS -n /sysroot | awk -F "," '{print $1}'
|
|
register: result_sysroot_mount_status
|
|
|
|
- name: /sysroot should be mount with rw permission
|
|
block:
|
|
- assert:
|
|
that:
|
|
- result_sysroot_mount_status.stdout == "rw"
|
|
fail_msg: "/sysroot is not mounted with rw permission"
|
|
success_msg: "/sysroot is mounted with rw permission"
|
|
always:
|
|
- set_fact:
|
|
total_counter: "{{ total_counter | int + 1 }}"
|
|
rescue:
|
|
- name: failed count + 1
|
|
set_fact:
|
|
failed_counter: "{{ failed_counter | int + 1 }}"
|
|
|
|
# case: check /var mount point
|
|
- name: check /var mount point
|
|
command: findmnt -r -o SOURCE -n /var
|
|
register: result_var_mount_point
|
|
|
|
- name: "/var should be mounted on /dev/vda2[/ostree/deploy/{{ image_type }}/var]"
|
|
block:
|
|
- assert:
|
|
that:
|
|
- result_var_mount_point.stdout == "/dev/vda2[/ostree/deploy/{{ image_type }}/var]"
|
|
fail_msg: "/var does not mount on /dev/vda2[/ostree/deploy/{{ image_type }}/var]"
|
|
success_msg: "/var mounts on /dev/vda2[/ostree/deploy/{{ image_type }}/var]"
|
|
always:
|
|
- set_fact:
|
|
total_counter: "{{ total_counter | int + 1 }}"
|
|
rescue:
|
|
- name: failed count + 1
|
|
set_fact:
|
|
failed_counter: "{{ failed_counter | int + 1 }}"
|
|
|
|
# case: check /var mount status
|
|
- name: check /var mount status
|
|
shell: findmnt -r -o OPTIONS -n /var | awk -F "," '{print $1}'
|
|
register: result_var_mount_status
|
|
|
|
- name: /var should be mount with rw permission
|
|
block:
|
|
- assert:
|
|
that:
|
|
- result_var_mount_status.stdout == "rw"
|
|
fail_msg: "/var is not mounted with rw permission"
|
|
success_msg: "/var is mounted with rw permission"
|
|
always:
|
|
- set_fact:
|
|
total_counter: "{{ total_counter | int + 1 }}"
|
|
rescue:
|
|
- name: failed count + 1
|
|
set_fact:
|
|
failed_counter: "{{ failed_counter | int + 1 }}"
|
|
|
|
# case: check /usr mount point
|
|
- name: check /usr mount point
|
|
command: findmnt -r -o SOURCE -n /usr
|
|
register: result_usr_mount_point
|
|
|
|
- name: "/usr should be mounted on /dev/vda2[/ostree/deploy/{{ image_type }}/deploy/{{ deploy_commit }}.0/usr]"
|
|
block:
|
|
- assert:
|
|
that:
|
|
- result_usr_mount_point.stdout == "/dev/vda2[/ostree/deploy/{{ image_type }}/deploy/{{ deploy_commit }}.0/usr]"
|
|
fail_msg: "/usr does not mount on /dev/vda2[/ostree/deploy/{{ image_type }}/deploy/{{ deploy_commit }}.0/usr]"
|
|
success_msg: "/usr mounts on /dev/vda2[/ostree/deploy/{{ image_type }}/deploy/{{ deploy_commit }}.0/usr]"
|
|
always:
|
|
- set_fact:
|
|
total_counter: "{{ total_counter | int + 1 }}"
|
|
rescue:
|
|
- name: failed count + 1
|
|
set_fact:
|
|
failed_counter: "{{ failed_counter | int + 1 }}"
|
|
|
|
# case: check /usr mount status
|
|
- name: check /usr mount status
|
|
shell: findmnt -r -o OPTIONS -n /usr | awk -F "," '{print $1}'
|
|
register: result_usr_mount_status
|
|
|
|
- name: /usr should be mount with rw permission
|
|
block:
|
|
- assert:
|
|
that:
|
|
- result_usr_mount_status.stdout == "ro"
|
|
fail_msg: "/usr is not mounted with ro permission"
|
|
success_msg: "/usr is mounted with ro permission"
|
|
always:
|
|
- set_fact:
|
|
total_counter: "{{ total_counter | int + 1 }}"
|
|
rescue:
|
|
- name: failed count + 1
|
|
set_fact:
|
|
failed_counter: "{{ failed_counter | int + 1 }}"
|
|
|
|
- name: get the first 10 chars in commit hash
|
|
set_fact:
|
|
commit_log: "{{ deploy_commit[:11] }}"
|
|
|
|
# case: check wget installed after upgrade
|
|
- name: check installed package
|
|
shell: rpm -qa | sort
|
|
register: result_packages
|
|
|
|
- name: check wget installed
|
|
block:
|
|
- assert:
|
|
that:
|
|
- "'wget' in result_packages.stdout"
|
|
fail_msg: "wget not installed, ostree upgrade might be failed"
|
|
success_msg: "wget installed in ostree upgrade"
|
|
always:
|
|
- set_fact:
|
|
total_counter: "{{ total_counter | int + 1 }}"
|
|
rescue:
|
|
- name: failed count + 1
|
|
set_fact:
|
|
failed_counter: "{{ failed_counter | int + 1 }}"
|
|
|
|
- name: save installed package to log file
|
|
copy:
|
|
content: "{{ result_packages.stdout }}"
|
|
dest: "{{ workspace }}/{{ commit_log }}.installed.ostree.log"
|
|
delegate_to: localhost
|
|
|
|
# case: check ostree-remount mount log
|
|
- name: check ostree-remount mount log
|
|
command: journalctl -u ostree-remount
|
|
register: result_remount_jounalctl
|
|
|
|
- name: ostree-remount should remount /var and /sysroot
|
|
block:
|
|
- assert:
|
|
that:
|
|
- "'/sysroot' in result_remount_jounalctl.stdout"
|
|
- "'/var' in result_remount_jounalctl.stdout"
|
|
fail_msg: "/sysroot or /var are not remounted by ostree-remount"
|
|
success_msg: "/sysroot and /var are remount"
|
|
always:
|
|
- set_fact:
|
|
total_counter: "{{ total_counter | int + 1 }}"
|
|
rescue:
|
|
- name: failed count + 1
|
|
set_fact:
|
|
failed_counter: "{{ failed_counter | int + 1 }}"
|
|
|
|
# case: check dmesg error and failed log
|
|
- name: check dmesg output
|
|
command: dmesg
|
|
register: result_dmesg
|
|
|
|
- name: save dmesg output to log file
|
|
copy:
|
|
content: "{{ result_dmesg.stdout }}"
|
|
dest: "{{ workspace }}/{{ commit_log }}.dmesg.ostree.log"
|
|
delegate_to: localhost
|
|
|
|
- name: check dmesg error and fail log
|
|
shell: dmesg --notime | grep -i "error\|fail"
|
|
register: result_dmesg_error
|
|
|
|
- name: no more error or failed log
|
|
block:
|
|
- assert:
|
|
that:
|
|
- result_dmesg_error.stdout_lines | length == 2
|
|
- "'pcieport 0000:00:01.6: Failed to check link status' in result_dmesg_error.stdout"
|
|
- "'Error: Driver \\'pcspkr\\' is already registered, aborting' in result_dmesg_error.stdout"
|
|
fail_msg: "more or less error and failed log"
|
|
success_msg: "everything works as expected"
|
|
always:
|
|
- set_fact:
|
|
total_counter: "{{ total_counter | int + 1 }}"
|
|
rescue:
|
|
- name: failed count + 1
|
|
set_fact:
|
|
failed_counter: "{{ failed_counter | int + 1 }}"
|
|
when: ansible_facts['distribution'] == "RedHat"
|
|
|
|
- name: no more error or failed log
|
|
block:
|
|
- assert:
|
|
that:
|
|
- result_dmesg_error.stdout_lines | length == 2
|
|
- "'pcieport 0000:00:01.6: pciehp: Failed to check link status' in result_dmesg_error.stdout"
|
|
- "'RAS: Correctable Errors collector initialized' in result_dmesg_error.stdout"
|
|
fail_msg: "more or less error and failed log"
|
|
success_msg: "everything works as expected"
|
|
always:
|
|
- set_fact:
|
|
total_counter: "{{ total_counter | int + 1 }}"
|
|
rescue:
|
|
- name: failed count + 1
|
|
set_fact:
|
|
failed_counter: "{{ failed_counter | int + 1 }}"
|
|
when: ansible_facts['distribution'] == "Fedora"
|
|
|
|
# case: check running container with podman
|
|
- name: run ubi8 image
|
|
command: podman run ubi8-minimal:latest cat /etc/redhat-release
|
|
register: podman_result
|
|
|
|
- name: run container test
|
|
block:
|
|
- assert:
|
|
that:
|
|
- podman_result is succeeded
|
|
- "'Red Hat Enterprise Linux release' in podman_result.stdout"
|
|
fail_msg: "failed run container with podman"
|
|
success_msg: "running container with podman successed"
|
|
always:
|
|
- set_fact:
|
|
total_counter: "{{ total_counter | int + 1 }}"
|
|
rescue:
|
|
- name: failed count + 1
|
|
set_fact:
|
|
failed_counter: "{{ failed_counter | int + 1 }}"
|
|
|
|
- assert:
|
|
that:
|
|
- failed_counter == "0"
|
|
fail_msg: "Run {{ total_counter }} tests, but {{ failed_counter }} of them failed"
|
|
success_msg: "Totally {{ total_counter }} test passed"
|