Skip to content

Commit

Permalink
test: update for minimal raw new xz format
Browse files Browse the repository at this point in the history
  • Loading branch information
henrywang authored and ondrejbudai committed Jul 21, 2023
1 parent 3bbcc8a commit 8ba6487
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 12 deletions.
49 changes: 38 additions & 11 deletions test/cases/minimal-raw.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ source /usr/libexec/tests/osbuild-composer/shared_lib.sh
# Provision the software under test.
/usr/libexec/osbuild-composer-test/provision.sh none

# Start firewalld
greenprint "Start firewalld"
sudo systemctl enable --now firewalld

# Start libvirtd and test it.
greenprint "🚀 Starting libvirt daemon"
sudo systemctl start libvirtd
Expand All @@ -24,7 +28,7 @@ sudo tee /tmp/integration.xml > /dev/null << EOF
<port start='1024' end='65535'/>
</nat>
</forward>
<bridge name='integration' stp='on' delay='0'/>
<bridge name='integration' zone='trusted' stp='on' delay='0'/>
<mac address='52:54:00:36:46:ef'/>
<ip address='192.168.100.1' netmask='255.255.255.0'>
<dhcp>
Expand Down Expand Up @@ -57,7 +61,8 @@ TEST_UUID=$(uuidgen)
IMAGE_KEY="minimal-raw-${TEST_UUID}"
UEFI_GUEST_ADDRESS=192.168.100.51
MINIMAL_RAW_TYPE=minimal-raw
MINIMAL_RAW_FILENAME=raw.img
MINIMAL_RAW_DECOMPRESSED=raw.img
MINIMAL_RAW_FILENAME=raw.img.xz
BOOT_ARGS="uefi"

# Set up temporary files.
Expand All @@ -73,12 +78,33 @@ SSH_KEY=${SSH_DATA_DIR}/id_rsa
SSH_KEY_PUB=$(cat "${SSH_KEY}".pub)
EDGE_USER_PASSWORD=foobar

if [[ $ID != fedora ]]; then
echo "unsupported distro: ${ID}-${VERSION_ID}"
exit 1
fi

OS_VARIANT="fedora-unknown"
case "${ID}-${VERSION_ID}" in
"rhel-8.9")
OS_VARIANT="rhel8-unknown"
;;
"rhel-9.3")
OS_VARIANT="rhel9-unknown"
;;
"centos-8")
OS_VARIANT="centos-stream8"
;;
"centos-9")
OS_VARIANT="centos-stream9"
BOOT_ARGS="uefi,firmware.feature0.name=secure-boot,firmware.feature0.enabled=no"
;;
"fedora-37")
OS_VARIANT="fedora37"
;;
"fedora-38")
OS_VARIANT="fedora-unknown"
;;
"fedora-39")
OS_VARIANT="fedora-rawhide"
;;
*)
echo "unsupported distro: ${ID}-${VERSION_ID}"
exit 1;;
esac

# Get the compose log.
get_compose_log () {
Expand Down Expand Up @@ -239,11 +265,12 @@ build_image minimal-raw "${MINIMAL_RAW_TYPE}"
# Download the image
greenprint "📥 Downloading the minimal-raw image"
sudo composer-cli compose image "${COMPOSE_ID}" > /dev/null
MINIMAL_RAW_FILENAME="${COMPOSE_ID}-${MINIMAL_RAW_FILENAME}"

greenprint "Extracting and converting the raw image to a qcow2 file"
MINIMAL_RAW_FILENAME="${COMPOSE_ID}-${MINIMAL_RAW_FILENAME}"
sudo xz -d "${MINIMAL_RAW_FILENAME}"
LIBVIRT_IMAGE_PATH_UEFI=/var/lib/libvirt/images/"${IMAGE_KEY}-uefi.qcow2"
sudo qemu-img convert -f raw "$MINIMAL_RAW_FILENAME" -O qcow2 "$LIBVIRT_IMAGE_PATH_UEFI"
sudo qemu-img convert -f raw "${COMPOSE_ID}-${MINIMAL_RAW_DECOMPRESSED}" -O qcow2 "$LIBVIRT_IMAGE_PATH_UEFI"
# Remove raw file
sudo rm -f "$MINIMAL_RAW_FILENAME"

Expand Down Expand Up @@ -309,7 +336,7 @@ ansible_become_pass=${EDGE_USER_PASSWORD}
EOF

# Test IoT/Edge OS
sudo ansible-playbook -v -i "${TEMPDIR}"/inventory /usr/share/tests/osbuild-composer/ansible/check-minimal.yaml || RESULTS=0
sudo ansible-playbook -v -i "${TEMPDIR}"/inventory -e download_node="$DOWNLOAD_NODE" /usr/share/tests/osbuild-composer/ansible/check-minimal.yaml || RESULTS=0
check_result

# Final success clean up
Expand Down
55 changes: 54 additions & 1 deletion test/data/ansible/check-minimal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
vars:
total_counter: "0"
failed_counter: "0"
download_node: ""

tasks:
# current target host's IP address
Expand Down Expand Up @@ -57,6 +58,58 @@
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"

- name: enable persistent logging for the systemd journal
file:
path: /var/log/journal
state: directory
become: yes
when: ansible_facts['distribution'] == 'RedHat' or ansible_facts['distribution'] == 'CentOS'

- name: enable persistent logging on RHEL 9 and CS9 only
command: journalctl --flush
become: yes
when: ansible_facts['distribution_version'] == "9.3" or ansible_facts['distribution_version'] == "9"

- name: add RHEL 9.3 BaseOS repository
yum_repository:
name: baseos
description: RHEL repository
baseurl: "http://{{ download_node }}/rhel-9/nightly/RHEL-9/latest-RHEL-9.3.0/compose/BaseOS/{{ ansible_facts['architecture'] }}/os/"
gpgcheck: no
file: rhel_repo
become: yes
when: ansible_facts['distribution'] == 'RedHat' and ansible_facts ['distribution_version'] is version('9.3', '==')

- name: add RHEL 9.3 AppStream repository
yum_repository:
name: appstream
description: RHEL repository
baseurl: "http://{{ download_node }}/rhel-9/nightly/RHEL-9/latest-RHEL-9.3.0/compose/AppStream/{{ ansible_facts['architecture'] }}/os/"
gpgcheck: no
file: rhel_repo
become: yes
when: ansible_facts['distribution'] == 'RedHat' and ansible_facts ['distribution_version'] is version('9.3', '==')

- name: add RHEL 8.9 BaseOS repository
yum_repository:
name: baseos
description: RHEL repository
baseurl: "http://{{ download_node }}/rhel-8/nightly/RHEL-8/latest-RHEL-8.9.0/compose/BaseOS/{{ ansible_facts['architecture'] }}/os/"
gpgcheck: no
file: rhel_repo
become: yes
when: ansible_facts['distribution'] == 'RedHat' and ansible_facts ['distribution_version'] is version('8.9', '==')

- name: add RHEL 8.9 AppStream repository
yum_repository:
name: appstream
description: RHEL repository
baseurl: "http://{{ download_node }}/rhel-8/nightly/RHEL-8/latest-RHEL-8.9.0/compose/AppStream/{{ ansible_facts['architecture'] }}/os/"
gpgcheck: no
file: rhel_repo
become: yes
when: ansible_facts['distribution'] == 'RedHat' and ansible_facts ['distribution_version'] is version('8.9', '==')

- name: install podman
dnf:
name:
Expand Down Expand Up @@ -157,7 +210,7 @@
- name: check journald has persistent logging
block:
- name: list boots
shell: journalctl --list-boots
shell: journalctl --list-boots -q
register: result_list_boots

- assert:
Expand Down

0 comments on commit 8ba6487

Please sign in to comment.