Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: move rhel for edge rhel9.5 test to testing-farm #4240

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .fmf/version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
173 changes: 16 additions & 157 deletions test/cases/ostree-simplified-installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ set -euo pipefail
source /etc/os-release
ARCH=$(uname -m)

# In case port 8081 is already in use
sudo dnf install -y lsof
if lsof -nP -iTCP -sTCP:LISTEN|grep 8081; then
sudo fuser -k 8081/tcp
fi

# Provision the software under test.
/usr/libexec/osbuild-composer-test/provision.sh none

Expand Down Expand Up @@ -108,7 +114,7 @@ INSTALLER_TYPE=edge-simplified-installer
INSTALLER_FILENAME=simplified-installer.iso
MEMORY=2048
BOOT_ARGS="uefi"
REF_PREFIX="rhel-edge"
# REF_PREFIX="rhel-edge"

# Set up temporary files.
TEMPDIR=$(mktemp -d)
Expand Down Expand Up @@ -139,12 +145,12 @@ EDGE_USER_PASSWORD_SHA512=$(openssl passwd -6 -stdin <<< "${EDGE_USER_PASSWORD:-
case "${ID}-${VERSION_ID}" in
"rhel-8"* )
OSTREE_REF="rhel/8/${ARCH}/edge"
PARENT_REF="rhel/8/${ARCH}/edge"
# PARENT_REF="rhel/8/${ARCH}/edge"
OS_VARIANT="rhel8-unknown"
;;
"rhel-9"* )
OSTREE_REF="rhel/9/${ARCH}/edge"
PARENT_REF="rhel/9/${ARCH}/edge"
# PARENT_REF="rhel/9/${ARCH}/edge"
OS_VARIANT="rhel9-unknown"
SYSROOT_RO="true"
ANSIBLE_USER=fdouser
Expand All @@ -155,13 +161,13 @@ case "${ID}-${VERSION_ID}" in
;;
"centos-8")
OSTREE_REF="centos/8/${ARCH}/edge"
PARENT_REF="centos/8/${ARCH}/edge"
# PARENT_REF="centos/8/${ARCH}/edge"
OS_VARIANT="centos8"
KERNEL_RT_PKG="kernel-rt-core"
;;
"centos-9")
OSTREE_REF="centos/9/${ARCH}/edge"
PARENT_REF="centos/9/${ARCH}/edge"
# PARENT_REF="centos/9/${ARCH}/edge"
OS_VARIANT="centos-stream9"
BOOT_ARGS="uefi,firmware.feature0.name=secure-boot,firmware.feature0.enabled=no"
SYSROOT_RO="true"
Expand Down Expand Up @@ -478,7 +484,7 @@ build_image simplified_iso_without_fdo "${INSTALLER_TYPE}" "${PROD_REPO_URL}/"
greenprint "📥 Downloading the simplified_iso_without_fdo image"
sudo composer-cli compose image "${COMPOSE_ID}" > /dev/null
ISO_FILENAME="${COMPOSE_ID}-${INSTALLER_FILENAME}"
sudo cp "${ISO_FILENAME}" /var/lib/libvirt/images
sudo mv "${ISO_FILENAME}" /var/lib/libvirt/images

# Clean compose and blueprints.
greenprint "🧹 Clean up simplified_iso_without_fdo blueprint and compose"
Expand Down Expand Up @@ -578,6 +584,7 @@ if [[ $(sudo virsh domstate "${IMAGE_KEY}-simplified_iso_without_fdo") == "runni
fi
sudo virsh undefine "${IMAGE_KEY}-simplified_iso_without_fdo" --nvram
sudo virsh vol-delete --pool images "$LIBVIRT_IMAGE_PATH"
sudo rm -fr "/var/lib/libvirt/images/${ISO_FILENAME}"

########################################################################
##
Expand Down Expand Up @@ -829,7 +836,7 @@ build_image fdosshkey "${INSTALLER_TYPE}" "${PROD_REPO_URL}"
greenprint "📥 Downloading the fdosshkey image"
sudo composer-cli compose image "${COMPOSE_ID}" > /dev/null
ISO_FILENAME="${COMPOSE_ID}-${INSTALLER_FILENAME}"
sudo cp "${ISO_FILENAME}" /var/lib/libvirt/images
sudo mv "${ISO_FILENAME}" /var/lib/libvirt/images

# Clean compose and blueprints.
greenprint "🧹 Clean up fdosshkey blueprint and compose"
Expand Down Expand Up @@ -946,162 +953,14 @@ sudo ansible-playbook -v -i "${TEMPDIR}"/inventory \
/usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0
check_result

##################################################################
##
## Build rebased ostree repo
##
##################################################################
tee "$BLUEPRINT_FILE" > /dev/null << EOF
name = "rebase"
description = "An rebase rhel-edge container image"
version = "0.0.2"
modules = []
groups = []

[[packages]]
name = "python3"
version = "*"

[[packages]]
name = "sssd"
version = "*"

[[packages]]
name = "wget"
version = "*"

[customizations.kernel]
name = "${KERNEL_RT_PKG}"

[[customizations.user]]
name = "admin"
description = "Administrator account"
password = "${EDGE_USER_PASSWORD_SHA512}"
home = "/home/admin/"
groups = ["wheel"]
EOF

greenprint "📄 rebase blueprint"
cat "$BLUEPRINT_FILE"

# Prepare the blueprint for the compose.
greenprint "📋 Preparing rebase blueprint"
sudo composer-cli blueprints push "$BLUEPRINT_FILE"
sudo composer-cli blueprints depsolve rebase

# Build upgrade image.
OSTREE_REF="test/redhat/x/${ARCH}/edge"
build_image rebase "$CONTAINER_TYPE" "$PROD_REPO_URL" "$PARENT_REF"

# Download the image
greenprint "📥 Downloading the rebase image"
sudo composer-cli compose image "${COMPOSE_ID}" > /dev/null

# Delete installation rhel-edge container and its image
greenprint "🧹 Delete installation rhel-edge container and its image"
# Remove rhel-edge container if exists
sudo podman ps -q --filter name=rhel-edge --format "{{.ID}}" | sudo xargs --no-run-if-empty podman rm -f
# Remove container image if exists
sudo podman images --filter "dangling=true" --format "{{.ID}}" | sudo xargs --no-run-if-empty podman rmi -f

# Deal with stage repo container
greenprint "🗜 Extracting image"
IMAGE_FILENAME="${COMPOSE_ID}-${CONTAINER_FILENAME}"
sudo podman pull "oci-archive:${IMAGE_FILENAME}"
sudo podman images
# Clear image file
sudo rm -f "$IMAGE_FILENAME"

# Run edge stage repo
greenprint "🛰 Running edge stage repo"
# Get image id to run image
EDGE_IMAGE_ID=$(sudo podman images --filter "dangling=true" --format "{{.ID}}")
sudo podman run -d --name rhel-edge --network edge --ip "$STAGE_REPO_ADDRESS" "$EDGE_IMAGE_ID"
# Wait for container to be running
until [ "$(sudo podman inspect -f '{{.State.Running}}' rhel-edge)" == "true" ]; do
sleep 1;
done;

# Pull rebase commit to prod mirror
greenprint "⛓ Pull rebase commit to prod mirror"
sudo ostree --repo="$PROD_REPO" pull --mirror edge-stage "$OSTREE_REF"

# Get ostree commit value.
greenprint "🕹 Get ostree rebase commit value"
REBASE_HASH=$(curl "${PROD_REPO_URL}/refs/heads/${OSTREE_REF}")

# Clean compose and blueprints.
greenprint "🧽 Clean up rebase blueprint and compose"
sudo composer-cli compose delete "${COMPOSE_ID}" > /dev/null
sudo composer-cli blueprints delete rebase > /dev/null

greenprint "🗳 Rebase ostree image/commit"
sudo ssh "${SSH_OPTIONS[@]}" -i "${SSH_KEY}" admin@${EDGE_GUEST_ADDRESS} "echo '${EDGE_USER_PASSWORD}' |sudo -S rpm-ostree rebase ${REF_PREFIX}:${OSTREE_REF}"
sudo ssh "${SSH_OPTIONS[@]}" -i "${SSH_KEY}" admin@${EDGE_GUEST_ADDRESS} "echo '${EDGE_USER_PASSWORD}' |nohup sudo -S systemctl reboot &>/dev/null & exit"

# Sleep 10 seconds here to make sure vm restarted already
sleep 10

# Check for ssh ready to go.
greenprint "🛃 Checking for SSH is ready to go"
# shellcheck disable=SC2034 # Unused variables left for readability
for _ in $(seq 0 30); do
RESULTS="$(wait_for_ssh_up $EDGE_GUEST_ADDRESS)"
if [[ $RESULTS == 1 ]]; then
echo "SSH is ready now! 🥳"
break
fi
sleep 10
done

# Check ostree rebase result
check_result

# Add instance IP address into /etc/ansible/hosts
sudo tee "${TEMPDIR}"/inventory > /dev/null << EOF
[ostree_guest]
${EDGE_GUEST_ADDRESS}

[ostree_guest:vars]
ansible_python_interpreter=/usr/bin/python3
ansible_user=${ANSIBLE_USER}
ansible_private_key_file=${SSH_KEY}
ansible_ssh_common_args="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
ansible_become=yes
ansible_become_method=sudo
ansible_become_pass=${EDGE_USER_PASSWORD}
EOF

# Test IoT/Edge OS
sudo ansible-playbook -v -i "${TEMPDIR}"/inventory \
-e image_type=rhel-edge \
-e ostree_commit="${REBASE_HASH}" \
-e skip_rollback_test="true" \
-e edge_type=edge-simplified-installer \
-e fdo_credential="true" \
-e sysroot_ro="$SYSROOT_RO" \
-e mfg_guest_int_name="${MFG_GUEST_INT_NAME}" \
-e fips="${FIPS}" \
/usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0

check_result

# Clean up VM
greenprint "🧹 Clean up VM"
if [[ $(sudo virsh domstate "${IMAGE_KEY}-fdosshkey") == "running" ]]; then
sudo virsh destroy "${IMAGE_KEY}-fdosshkey"
fi
sudo virsh undefine "${IMAGE_KEY}-fdosshkey" --nvram
sudo virsh vol-delete --pool images "$LIBVIRT_IMAGE_PATH"

# Re configure OSTREE_REF because it's change to "test/redhat/x/${ARCH}/edge" by above rebase test
if [[ "$ID" == fedora ]]; then
OSTREE_REF="${ID}/${VERSION_ID}/${ARCH}/iot"
elif [[ "$VERSION_ID" == 8* ]]; then
OSTREE_REF="${ID}/8/${ARCH}/edge"
else
OSTREE_REF="${ID}/9/${ARCH}/edge"
fi
sudo rm -fr "/var/lib/libvirt/images/${ISO_FILENAME}"

##################################################################
##
Expand Down Expand Up @@ -1162,7 +1021,7 @@ build_image fdorootcert "${INSTALLER_TYPE}" "${PROD_REPO_URL}/"
greenprint "📥 Downloading the fdorootcert image"
sudo composer-cli compose image "${COMPOSE_ID}" > /dev/null
ISO_FILENAME="${COMPOSE_ID}-${INSTALLER_FILENAME}"
sudo cp "${ISO_FILENAME}" /var/lib/libvirt/images
sudo mv "${ISO_FILENAME}" /var/lib/libvirt/images

# Clean compose and blueprints.
greenprint "🧹 Clean up fdorootcert blueprint and compose"
Expand Down
2 changes: 1 addition & 1 deletion test/cases/ostree-vsphere.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ EDGE_USER_PASSWORD_SHA512=$(openssl passwd -6 -stdin <<< "${EDGE_USER_PASSWORD}"

DATACENTER_70="Datacenter7.0"
DATASTORE_70="datastore-80"
DATACENTER_70_POOL="/Datacenter7.0/host/Automation/Resources"
DATACENTER_70_POOL="/Datacenter7.0/host/Edge/Resources"
# Workdaround for creating rhel9 and centos9 on dc67, change guest_id to 8
case "${ID}-${VERSION_ID}" in
"rhel-9"* )
Expand Down
12 changes: 6 additions & 6 deletions test/data/ansible/check-minimal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,25 @@
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"

- name: add RHEL 9.4 BaseOS repository
- name: add RHEL 9.5 BaseOS repository
yum_repository:
name: baseos
description: RHEL repository
baseurl: "http://{{ download_node }}/rhel-9/nightly/RHEL-9/latest-RHEL-9.4.0/compose/BaseOS/{{ ansible_facts['architecture'] }}/os/"
baseurl: "http://{{ download_node }}/rhel-9/nightly/RHEL-9/latest-RHEL-9.5.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.4', '==')
when: ansible_facts['distribution'] == 'RedHat' and ansible_facts ['distribution_version'] is version('9.5', '==')

- name: add RHEL 9.4 AppStream repository
- name: add RHEL 9.5 AppStream repository
yum_repository:
name: appstream
description: RHEL repository
baseurl: "http://{{ download_node }}/rhel-9/nightly/RHEL-9/latest-RHEL-9.4.0/compose/AppStream/{{ ansible_facts['architecture'] }}/os/"
baseurl: "http://{{ download_node }}/rhel-9/nightly/RHEL-9/latest-RHEL-9.5.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.4', '==')
when: ansible_facts['distribution'] == 'RedHat' and ansible_facts ['distribution_version'] is version('9.5', '==')

- name: add RHEL 8.10 BaseOS repository
yum_repository:
Expand Down
Loading
Loading