Skip to content

Commit

Permalink
test: add custom partitions to edge-raw-image test case
Browse files Browse the repository at this point in the history
  • Loading branch information
mcattamoredhat committed Jan 31, 2024
1 parent db0e6c9 commit 512d13c
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 1 deletion.
19 changes: 19 additions & 0 deletions test/cases/ostree-ami-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ OSTREE_OSNAME=redhat
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)
Expand Down Expand Up @@ -93,10 +94,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}"
Expand Down Expand Up @@ -611,6 +614,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"

Expand Down Expand Up @@ -880,6 +897,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

Expand Down Expand Up @@ -1058,6 +1076,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

Expand Down
23 changes: 23 additions & 0 deletions test/cases/ostree-raw-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -478,6 +481,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"

Expand Down Expand Up @@ -590,6 +609,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

Expand Down Expand Up @@ -758,6 +778,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
Expand Down Expand Up @@ -864,6 +885,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

Expand Down Expand Up @@ -1056,6 +1078,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

Expand Down
19 changes: 19 additions & 0 deletions test/cases/ostree-vsphere.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,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)
Expand Down Expand Up @@ -110,10 +111,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}"
Expand Down Expand Up @@ -455,6 +458,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"

Expand Down Expand Up @@ -543,6 +560,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

Expand Down Expand Up @@ -677,6 +695,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
Expand Down
35 changes: 34 additions & 1 deletion test/data/ansible/check_ostree.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 512d13c

Please sign in to comment.