Skip to content

Commit

Permalink
add test case for iot-simplified-installer
Browse files Browse the repository at this point in the history
  • Loading branch information
schutzbot authored and yih-redhat committed Oct 8, 2023
1 parent 98c50e3 commit 35900a0
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 18 deletions.
67 changes: 51 additions & 16 deletions test/cases/ostree-simplified-installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ KERNEL_RT_PKG="kernel-rt"
SYSROOT_RO="false"
ANSIBLE_USER="admin"
FDO_USER_ONBOARDING="false"
IMAGE_TYPE=redhat

case "${ID}-${VERSION_ID}" in
"rhel-8"* )
Expand Down Expand Up @@ -160,6 +161,18 @@ case "${ID}-${VERSION_ID}" in
sudo setenforce 0
getenforce
;;
fedora-*)
OSTREE_REF="fedora/${VERSION_ID}/${ARCH}/iot"
PARENT_REF="fedora/${VERSION_ID}/${ARCH}/iot"
OS_VARIANT="fedora-unknown"
CONTAINER_TYPE="iot-container"
INSTALLER_TYPE="iot-simplified-installer"
REF_PREFIX="fedora-iot"
SYSROOT_RO="true"
IMAGE_TYPE="fedora"
ANSIBLE_USER=fdouser
FDO_USER_ONBOARDING="true"
;;
*)
redprint "unsupported distro: ${ID}-${VERSION_ID}"
exit 1;;
Expand All @@ -173,8 +186,15 @@ if [[ "$FDO_USER_ONBOARDING" == "true" ]]; then
fdouser ALL=(ALL) NOPASSWD: ALL
EOF
sudo /usr/local/bin/yq -iy '.service_info.files |= [{path: "/etc/sudoers.d/fdouser", source_path: "/tmp/fdouser"}]' /etc/fdo/aio/configs/serviceinfo_api_server.yml
sudo systemctl restart fdo-aio
fi

# Fedora iot-simplified-installer uses /dev/vda3, https://github.com/osbuild/osbuild-composer/issues/3527
if [[ "${ID}" == "fedora" ]]; then
echo "Change vda4 to vda3 for fedora in serviceinfo config file"
sudo sed -i 's/vda4/vda3/' /etc/fdo/aio/configs/serviceinfo_api_server.yml
fi
sudo systemctl restart fdo-aio

# Wait for fdo server to be running
until [ "$(curl -X POST http://${FDO_SERVER_ADDRESS}:8080/ping)" == "pong" ]; do
sleep 1;
Expand Down Expand Up @@ -367,9 +387,6 @@ version = "*"
name = "sssd"
version = "*"
[customizations.kernel]
name = "${KERNEL_RT_PKG}"
[[customizations.user]]
name = "admin"
description = "Administrator account"
Expand All @@ -379,6 +396,14 @@ home = "/home/admin/"
groups = ["wheel"]
EOF

# Fedora does not have kernel-rt
if [[ "$ID" != "fedora" ]]; then
tee -a "$BLUEPRINT_FILE" >> /dev/null << EOF
[customizations.kernel]
name = "${KERNEL_RT_PKG}"
EOF
fi

greenprint "📄 container blueprint"
cat "$BLUEPRINT_FILE"

Expand Down Expand Up @@ -541,7 +566,7 @@ EOF

# Test IoT/Edge OS
sudo ansible-playbook -v -i "${TEMPDIR}"/inventory \
-e image_type=redhat \
-e image_type=${IMAGE_TYPE} \
-e ostree_commit="${INSTALL_HASH}" \
-e skip_rollback_test="true" \
-e edge_type=edge-simplified-installer \
Expand Down Expand Up @@ -713,7 +738,7 @@ EOF

# Test IoT/Edge OS
sudo ansible-playbook -v -i "${TEMPDIR}"/inventory \
-e image_type=redhat \
-e image_type=${IMAGE_TYPE} \
-e ostree_commit="${INSTALL_HASH}" \
-e skip_rollback_test="true" \
-e edge_type=edge-simplified-installer \
Expand Down Expand Up @@ -883,7 +908,7 @@ fi

# Test IoT/Edge OS
sudo ansible-playbook -v -i "${TEMPDIR}"/inventory \
-e image_type=redhat \
-e image_type=${IMAGE_TYPE} \
-e ostree_commit="${INSTALL_HASH}" \
-e skip_rollback_test="true" \
-e edge_type=edge-simplified-installer \
Expand Down Expand Up @@ -916,9 +941,6 @@ version = "*"
name = "wget"
version = "*"
[customizations.kernel]
name = "${KERNEL_RT_PKG}"
[[customizations.user]]
name = "admin"
description = "Administrator account"
Expand All @@ -927,6 +949,14 @@ home = "/home/admin/"
groups = ["wheel"]
EOF

# Fedora does not have kernel-rt
if [[ "$ID" != "fedora" ]]; then
tee -a "$BLUEPRINT_FILE" >> /dev/null << EOF
[customizations.kernel]
name = "${KERNEL_RT_PKG}"
EOF
fi

greenprint "📄 rebase blueprint"
cat "$BLUEPRINT_FILE"

Expand Down Expand Up @@ -1020,7 +1050,7 @@ EOF

# Test IoT/Edge OS
sudo ansible-playbook -v -i "${TEMPDIR}"/inventory \
-e image_type=redhat \
-e image_type=${IMAGE_TYPE} \
-e ostree_commit="${REBASE_HASH}" \
-e skip_rollback_test="true" \
-e edge_type=edge-simplified-installer \
Expand Down Expand Up @@ -1179,7 +1209,7 @@ EOF

# Test IoT/Edge OS
sudo ansible-playbook -v -i "${TEMPDIR}"/inventory \
-e image_type=redhat \
-e image_type=${IMAGE_TYPE} \
-e ostree_commit="${INSTALL_HASH}" \
-e skip_rollback_test="true" \
-e edge_type=edge-simplified-installer \
Expand Down Expand Up @@ -1215,9 +1245,6 @@ version = "*"
name = "wget"
version = "*"
[customizations.kernel]
name = "${KERNEL_RT_PKG}"
[[customizations.user]]
name = "admin"
description = "Administrator account"
Expand All @@ -1226,6 +1253,14 @@ home = "/home/admin/"
groups = ["wheel"]
EOF

# Fedora does not have kernel-rt
if [[ "$ID" != "fedora" ]]; then
tee -a "$BLUEPRINT_FILE" >> /dev/null << EOF
[customizations.kernel]
name = "${KERNEL_RT_PKG}"
EOF
fi

greenprint "📄 upgrade blueprint"
cat "$BLUEPRINT_FILE"

Expand Down Expand Up @@ -1320,7 +1355,7 @@ EOF

# Test IoT/Edge OS
sudo ansible-playbook -v -i "${TEMPDIR}"/inventory \
-e image_type=redhat \
-e image_type=${IMAGE_TYPE} \
-e ostree_commit="${UPGRADE_HASH}" \
-e skip_rollback_test="true" \
-e edge_type=edge-simplified-installer \
Expand Down
47 changes: 45 additions & 2 deletions test/data/ansible/check_ostree.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
ignition: "false"
test_custom_dirs_files: "false"
sysroot_ro: "false"
image_type: "none"

tasks:
# current target host's IP address
Expand Down Expand Up @@ -267,6 +268,27 @@
when:
- "'/dev/mapper/rootvg-rootlv' in result_sysroot_source.stdout"
- fdo_credential == "true"
- image_type == "redhat"

# on fedora, it grows to 18.49G
- name: "pv size should bigger than 18G for simplified installer"
block:
- assert:
that:
- "'18' in result_pv_size.stdout"
fail_msg: "pv size is not bigger than 18G"
success_msg: "pv size is bigger than 18G"
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 == "true"
- image_type == "fedora"

# raw image does not have coreos-installer to grow fs to 19G
- name: "pv size should keep at 9G for raw image"
Expand Down Expand Up @@ -307,7 +329,28 @@
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
when: "'/dev/mapper/rootvg-rootlv' in result_sysroot_source.stdout"
when:
- "'/dev/mapper/rootvg-rootlv' in result_sysroot_source.stdout"
- image_type == "redhat"

# lv size on fedora is 7.8G, https://github.com/osbuild/osbuild-composer/issues/3529
- name: "/sysroot lv size should be 7.8G on fedora"
block:
- assert:
that:
- "'7.8G' in result_sysroot_lv_size.stdout"
fail_msg: "lv size is not 7.8G"
success_msg: "lv size is 7.8G"
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"
- image_type == "fedora"

# case: check /sysroot mount status
- name: check /sysroot mount status
Expand Down Expand Up @@ -1096,4 +1139,4 @@
that:
- failed_counter == "0"
fail_msg: "Run {{ total_counter }} tests, but {{ failed_counter }} of them failed"
success_msg: "Totally {{ total_counter }} test passed"
success_msg: "Totally {{ total_counter }} test passed"

0 comments on commit 35900a0

Please sign in to comment.