From e90886e69c733afaff93d231caaec0e958fea23a Mon Sep 17 00:00:00 2001 From: Mario Cattamo Date: Mon, 8 Jan 2024 18:27:59 +0100 Subject: [PATCH] test: add custom partitions to raw image --- test/cases/ostree-ami-image.sh | 19 +++++++ test/cases/ostree-raw-image.sh | 23 +++++++++ test/cases/ostree-simplified-installer.sh | 63 +++++++++++++++++++++++ test/cases/ostree-vsphere.sh | 19 +++++++ test/data/ansible/check_ostree.yaml | 35 ++++++++++++- 5 files changed, 158 insertions(+), 1 deletion(-) diff --git a/test/cases/ostree-ami-image.sh b/test/cases/ostree-ami-image.sh index b27a88d8703..13e55eb9e1f 100755 --- a/test/cases/ostree-ami-image.sh +++ b/test/cases/ostree-ami-image.sh @@ -73,6 +73,7 @@ OSTREE_OSNAME=rhel-edge BUCKET_NAME="composer-ci-${TEST_UUID}" BUCKET_URL="s3://${BUCKET_NAME}" OBJECT_URL="http://${BUCKET_NAME}.s3.${AWS_DEFAULT_REGION}.amazonaws.com" +CUSTOM_FS_LVS="false" # Set up temporary files. TEMPDIR=$(mktemp -d) @@ -100,10 +101,12 @@ case "${ID}-${VERSION_ID}" in "rhel-9."*) OSTREE_REF="rhel/9/${ARCH}/edge" SYSROOT_RO="true" + CUSTOM_FS_LVS="true" ;; "centos-9") OSTREE_REF="centos/9/${ARCH}/edge" SYSROOT_RO="true" + CUSTOM_FS_LVS="true" ;; *) redprint "unsupported distro: ${ID}-${VERSION_ID}" @@ -615,6 +618,20 @@ groups = ["wheel"] url = "${OBJECT_URL}/config.ign" EOF +if [[ "${CUSTOM_FS_LVS}" == "true" ]]; then + tee -a "$BLUEPRINT_FILE" > /dev/null << EOF +[[customizations.filesystem]] +mountpoint = "/foo/bar" +size=2147483648 +[[customizations.filesystem]] +mountpoint = "/foo" +size=8589934592 +[[customizations.filesystem]] +mountpoint = "/var/myfiles" +size= "1 GiB" +EOF +fi + greenprint "📄 aws ami blueprint" cat "$BLUEPRINT_FILE" @@ -884,6 +901,7 @@ sudo ansible-playbook -v -i "${TEMPDIR}"/inventory \ -e ostree_commit="${INSTALL_HASH}" \ -e sysroot_ro="$SYSROOT_RO" \ -e fips="${FIPS}" \ + -e custom_fs_lvs="${CUSTOM_FS_LVS}" \ /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 check_result @@ -1062,6 +1080,7 @@ sudo ansible-playbook -v -i "${TEMPDIR}"/inventory \ -e ostree_commit="${UPGRADE_HASH}" \ -e sysroot_ro="$SYSROOT_RO" \ -e fips="${FIPS}" \ + -e custom_fs_lvs="${CUSTOM_FS_LVS}" \ /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 check_result diff --git a/test/cases/ostree-raw-image.sh b/test/cases/ostree-raw-image.sh index d1187e007d0..a08a80ac1d2 100755 --- a/test/cases/ostree-raw-image.sh +++ b/test/cases/ostree-raw-image.sh @@ -103,6 +103,7 @@ KERNEL_RT_PKG="kernel-rt" # Set up variables. SYSROOT_RO="false" CUSTOM_DIRS_FILES="false" +CUSTOM_FS_LVS="false" # Set FIPS variable default FIPS="${FIPS:-false}" @@ -121,6 +122,7 @@ case "${ID}-${VERSION_ID}" in PARENT_REF="rhel/9/${ARCH}/edge" OS_VARIANT="rhel9-unknown" SYSROOT_RO="true" + CUSTOM_FS_LVS="true" ;; "centos-8") OSTREE_REF="centos/8/${ARCH}/edge" @@ -134,6 +136,7 @@ case "${ID}-${VERSION_ID}" in OS_VARIANT="centos-stream9" BOOT_ARGS="uefi,firmware.feature0.name=secure-boot,firmware.feature0.enabled=no" SYSROOT_RO="true" + CUSTOM_FS_LVS="true" ;; "fedora-"*) CONTAINER_TYPE=iot-container @@ -475,6 +478,22 @@ enabled = ["custom.service"] EOF fi +if [[ "${CUSTOM_FS_LVS}" == "true" ]]; then + tee -a "$BLUEPRINT_FILE" > /dev/null << EOF +[[customizations.filesystem]] +mountpoint = "/foo/bar" +size=2147483648 + +[[customizations.filesystem]] +mountpoint = "/foo" +size=8589934592 + +[[customizations.filesystem]] +mountpoint = "/var/myfiles" +size= "1 GiB" +EOF +fi + greenprint "📄 raw image blueprint" cat "$BLUEPRINT_FILE" @@ -587,6 +606,7 @@ EOF -e sysroot_ro="$SYSROOT_RO" \ -e test_custom_dirs_files="$CUSTOM_DIRS_FILES" \ -e fips="${FIPS}" \ + -e custom_fs_lvs="${CUSTOM_FS_LVS}" \ /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 check_result @@ -755,6 +775,7 @@ EOF -e sysroot_ro="$SYSROOT_RO" \ -e test_custom_dirs_files="$CUSTOM_DIRS_FILES" \ -e fips="${FIPS}" \ + -e custom_fs_lvs="${CUSTOM_FS_LVS}" \ /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 check_result @@ -861,6 +882,7 @@ sudo ansible-playbook -v -i "${TEMPDIR}"/inventory \ -e sysroot_ro="$SYSROOT_RO" \ -e test_custom_dirs_files="$CUSTOM_DIRS_FILES" \ -e fips="${FIPS}" \ + -e custom_fs_lvs="${CUSTOM_FS_LVS}" \ /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 check_result @@ -1053,6 +1075,7 @@ sudo ansible-playbook -v -i "${TEMPDIR}"/inventory \ -e sysroot_ro="$SYSROOT_RO" \ -e test_custom_dirs_files="$CUSTOM_DIRS_FILES" \ -e fips="${FIPS}" \ + -e custom_fs_lvs="${CUSTOM_FS_LVS}" \ /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 check_result diff --git a/test/cases/ostree-simplified-installer.sh b/test/cases/ostree-simplified-installer.sh index 80805ae5ade..9c2cb111a1f 100755 --- a/test/cases/ostree-simplified-installer.sh +++ b/test/cases/ostree-simplified-installer.sh @@ -115,6 +115,7 @@ INSTALLER_FILENAME=simplified-installer.iso MEMORY=2048 BOOT_ARGS="uefi" # REF_PREFIX="rhel-edge" +CUSTOM_FS_LVS="false" # Set up temporary files. TEMPDIR=$(mktemp -d) @@ -155,6 +156,7 @@ case "${ID}-${VERSION_ID}" in SYSROOT_RO="true" ANSIBLE_USER=fdouser FDO_USER_ONBOARDING="true" + CUSTOM_FS_LVS="true" # workaround selinux bug https://bugzilla.redhat.com/show_bug.cgi?id=2026795 sudo setenforce 0 getenforce @@ -173,6 +175,7 @@ case "${ID}-${VERSION_ID}" in SYSROOT_RO="true" ANSIBLE_USER=fdouser FDO_USER_ONBOARDING="true" + CUSTOM_FS_LVS="true" # workaround selinux bug https://bugzilla.redhat.com/show_bug.cgi?id=2026795 sudo setenforce 0 getenforce @@ -469,6 +472,20 @@ fips = ${FIPS} EOF fi +if [[ "${CUSTOM_FS_LVS}" == "true" ]]; then + tee -a "$BLUEPRINT_FILE" > /dev/null << EOF +[[customizations.filesystem]] +mountpoint = "/foo/bar" +size=2147483648 +[[customizations.filesystem]] +mountpoint = "/foo" +size=8589934592 +[[customizations.filesystem]] +mountpoint = "/var/myfiles" +size= "1 GiB" +EOF +fi + greenprint "📄 simplified_iso_without_fdo blueprint" cat "$BLUEPRINT_FILE" @@ -575,6 +592,7 @@ sudo ansible-playbook -v -i "${TEMPDIR}"/inventory \ -e fdo_credential="false" \ -e sysroot_ro="$SYSROOT_RO" \ -e fips="${FIPS}" \ + -e custom_fs_lvs="${CUSTOM_FS_LVS}" \ /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 check_result @@ -636,6 +654,19 @@ append = "enforcing=0" EOF fi +if [[ "${CUSTOM_FS_LVS}" == "true" ]]; then + tee -a "$BLUEPRINT_FILE" > /dev/null << EOF +[[customizations.filesystem]] +mountpoint = "/foo/bar" +size=2147483648 +[[customizations.filesystem]] +mountpoint = "/foo" +size=8589934592 +[[customizations.filesystem]] +mountpoint = "/var/myfiles" +size= "1 GiB" +EOF +fi greenprint "📄 installer blueprint" cat "$BLUEPRINT_FILE" @@ -764,6 +795,7 @@ sudo ansible-playbook -v -i "${TEMPDIR}"/inventory \ -e sysroot_ro="$SYSROOT_RO" \ -e mfg_guest_int_name="${MFG_GUEST_INT_NAME}" \ -e fips="${FIPS}" \ + -e custom_fs_lvs="${CUSTOM_FS_LVS}" \ /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 check_result @@ -821,6 +853,20 @@ append = "enforcing=0" EOF fi +if [[ "${CUSTOM_FS_LVS}" == "true" ]]; then + tee -a "$BLUEPRINT_FILE" > /dev/null << EOF +[[customizations.filesystem]] +mountpoint = "/foo/bar" +size=2147483648 +[[customizations.filesystem]] +mountpoint = "/foo" +size=8589934592 +[[customizations.filesystem]] +mountpoint = "/var/myfiles" +size= "1 GiB" +EOF +fi + greenprint "📄 fdosshkey blueprint" cat "$BLUEPRINT_FILE" @@ -950,6 +996,7 @@ sudo ansible-playbook -v -i "${TEMPDIR}"/inventory \ -e sysroot_ro="$SYSROOT_RO" \ -e mfg_guest_int_name="${MFG_GUEST_INT_NAME}" \ -e fips="${FIPS}" \ + -e custom_fs_lvs="${CUSTOM_FS_LVS}" \ /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 check_result @@ -1006,6 +1053,20 @@ append = "enforcing=0" EOF fi +if [[ "${CUSTOM_FS_LVS}" == "true" ]]; then + tee -a "$BLUEPRINT_FILE" > /dev/null << EOF +[[customizations.filesystem]] +mountpoint = "/foo/bar" +size=2147483648 +[[customizations.filesystem]] +mountpoint = "/foo" +size=8589934592 +[[customizations.filesystem]] +mountpoint = "/var/myfiles" +size= "1 GiB" +EOF +fi + greenprint "📄 fdosshkey blueprint" cat "$BLUEPRINT_FILE" @@ -1116,6 +1177,7 @@ sudo ansible-playbook -v -i "${TEMPDIR}"/inventory \ -e sysroot_ro="$SYSROOT_RO" \ -e mfg_guest_int_name="${MFG_GUEST_INT_NAME}" \ -e fips="${FIPS}" \ + -e custom_fs_lvs="${CUSTOM_FS_LVS}" \ /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 check_result @@ -1259,6 +1321,7 @@ sudo ansible-playbook -v -i "${TEMPDIR}"/inventory \ -e sysroot_ro="$SYSROOT_RO" \ -e mfg_guest_int_name="${MFG_GUEST_INT_NAME}" \ -e fips="${FIPS}" \ + -e custom_fs_lvs="${CUSTOM_FS_LVS}" \ /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 check_result diff --git a/test/cases/ostree-vsphere.sh b/test/cases/ostree-vsphere.sh index 959ea17da0e..8886967ba32 100755 --- a/test/cases/ostree-vsphere.sh +++ b/test/cases/ostree-vsphere.sh @@ -80,6 +80,7 @@ CONTAINER_TYPE=edge-container CONTAINER_FILENAME=container.tar VSPHERE_IMAGE_TYPE=edge-vsphere VSPHERE_FILENAME=image.vmdk +CUSTOM_FS_LVS="false" # Set up temporary files. TEMPDIR=$(mktemp -d) @@ -118,10 +119,12 @@ case "${ID}-${VERSION_ID}" in "rhel-9"* ) OSTREE_REF="rhel/9/${ARCH}/edge" GUEST_ID_DC70="rhel9_64Guest" + CUSTOM_FS_LVS="true" ;; "centos-9") OSTREE_REF="centos/9/${ARCH}/edge" GUEST_ID_DC70="centos9_64Guest" + CUSTOM_FS_LVS="true" ;; *) echo "unsupported distro: ${ID}-${VERSION_ID}" @@ -460,6 +463,20 @@ groups = ["wheel"] url = "${IGNITION_SERVER_URL}/config.ign" EOF +if [[ "${CUSTOM_FS_LVS}" == "true" ]]; then + tee -a "$BLUEPRINT_FILE" > /dev/null << EOF +[[customizations.filesystem]] +mountpoint = "/foo/bar" +size=2147483648 +[[customizations.filesystem]] +mountpoint = "/foo" +size=8589934592 +[[customizations.filesystem]] +mountpoint = "/var/myfiles" +size= "1 GiB" +EOF +fi + greenprint "📄 vmdk blueprint" cat "$BLUEPRINT_FILE" @@ -548,6 +565,7 @@ sudo ansible-playbook -v -i "${TEMPDIR}"/inventory \ -e fdo_credential="false" \ -e sysroot_ro="$SYSROOT_RO" \ -e fips="${FIPS}" \ + -e custom_fs_lvs="${CUSTOM_FS_LVS}" \ /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 check_result @@ -682,6 +700,7 @@ sudo ansible-playbook -v -i "${TEMPDIR}"/inventory \ -e fdo_credential="false" \ -e sysroot_ro="$SYSROOT_RO" \ -e fips="${FIPS}" \ + -e custom_fs_lvs="${CUSTOM_FS_LVS}" \ /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 check_result diff --git a/test/data/ansible/check_ostree.yaml b/test/data/ansible/check_ostree.yaml index d82ed3a4e96..fab2fc26f61 100644 --- a/test/data/ansible/check_ostree.yaml +++ b/test/data/ansible/check_ostree.yaml @@ -14,6 +14,7 @@ test_custom_dirs_files: "false" sysroot_ro: "false" fips: "false" + custom_fs_lvs: "false" tasks: # current target host's IP address @@ -261,7 +262,7 @@ # case: check pv size - name: check pv size - shell: pvs --reportformat json | jq .report[0].pv[0].pv_size -r + shell: pvs --reportformat json --units g | jq .report[0].pv[0].pv_size -r | sed "s/\.[0-9]\+g//g" become: yes register: result_pv_size when: "'/dev/mapper/rootvg-rootlv' in result_sysroot_source.stdout" @@ -303,6 +304,38 @@ when: - "'/dev/mapper/rootvg-rootlv' in result_sysroot_source.stdout" - fdo_credential == "false" + - custom_fs_lvs == "false" + + # check logical volumes + - name: check logical volumes + shell: lvdisplay -a + become: yes + register: result_custom_lvs + when: + - "'/dev/mapper/rootvg-rootlv' in result_sysroot_source.stdout" + - custom_fs_lvs == "true" + + - name: "check that custom partitions are present" + block: + - assert: + that: + - "'var_myfileslv' in result_custom_lvs.stdout" + - "'foolv' in result_custom_lvs.stdout" + - "'foo_barlv' in result_custom_lvs.stdout" + fail_msg: "There are custom partitions missing" + success_msg: "Custom partitions present in filesystem" + always: + - set_fact: + total_counter: "{{ total_counter | int + 1 }}" + rescue: + - name: failed count + 1 + set_fact: + failed_counter: "{{ failed_counter | int + 1 }}" + when: + - "'/dev/mapper/rootvg-rootlv' in result_sysroot_source.stdout" + - fdo_credential == "false" + - custom_fs_lvs == "true" + # case: check /sysroot lv size - name: check sysroot lv size