From c145b8a39c3b337b764dc05965e16cea50791bf8 Mon Sep 17 00:00:00 2001 From: Pablo Acevedo Montserrat Date: Tue, 11 Jul 2023 12:46:12 +0200 Subject: [PATCH 1/4] USHIFT-1423: Remove execution of e2e and cncf tests from metal --- ...hift-microshift-e2e-metal-tests-commands.sh | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/ci-operator/step-registry/openshift/microshift/e2e/metal-tests/openshift-microshift-e2e-metal-tests-commands.sh b/ci-operator/step-registry/openshift/microshift/e2e/metal-tests/openshift-microshift-e2e-metal-tests-commands.sh index 682ee2d04aaf5..4a6d7438c4809 100644 --- a/ci-operator/step-registry/openshift/microshift/e2e/metal-tests/openshift-microshift-e2e-metal-tests-commands.sh +++ b/ci-operator/step-registry/openshift/microshift/e2e/metal-tests/openshift-microshift-e2e-metal-tests-commands.sh @@ -174,21 +174,3 @@ cd /microshift/test || true if [ -f ./bin/ci_phase_test.sh ]; then ./bin/ci_phase_test.sh fi - -# VM mapping -# e2e: vm0 -# cncf: vm1, vm2 -trap print_test_output EXIT -run_e2e &> /tmp/run_e2e_test.log & -run_cncf &> /tmp/run_cncf_test.log & - -FAIL=0 -for job in $(jobs -p) ; do - echo "Waiting for job: $job" - wait "$job" || ((FAIL+=1)) -done - -if [ "$FAIL" != "0" ]; then - echo "Tests failed. Check junit for details" - exit 1 -fi From e3af910b878dcfcbf8071e8ca953a1147e8bf6d4 Mon Sep 17 00:00:00 2001 From: Pablo Acevedo Montserrat Date: Tue, 11 Jul 2023 12:46:57 +0200 Subject: [PATCH 2/4] USHIFT-1423: Remove dead code --- ...ift-microshift-e2e-metal-tests-commands.sh | 147 ------------------ 1 file changed, 147 deletions(-) diff --git a/ci-operator/step-registry/openshift/microshift/e2e/metal-tests/openshift-microshift-e2e-metal-tests-commands.sh b/ci-operator/step-registry/openshift/microshift/e2e/metal-tests/openshift-microshift-e2e-metal-tests-commands.sh index 4a6d7438c4809..17c9b2d3b8261 100644 --- a/ci-operator/step-registry/openshift/microshift/e2e/metal-tests/openshift-microshift-e2e-metal-tests-commands.sh +++ b/ci-operator/step-registry/openshift/microshift/e2e/metal-tests/openshift-microshift-e2e-metal-tests-commands.sh @@ -19,153 +19,6 @@ Host ${IP_ADDRESS} EOF chmod 0600 "${HOME}/.ssh/config" -# Print test output on exit -print_test_output() { - echo "##### START TEST OUTPUT #####" - - for log in /tmp/run_*_test.log ; do - echo "##### OUTPUT OF ${log} TEST #####" - cat "${log}" - done - - echo "##### FINISH TEST OUTPUT #####" -} - -# Bash e2e tests -run_e2e() { - local -r VM_IP="${IP_ADDRESS}" - local -r VM_PORT="$(cat "${SHARED_DIR}"/vm_ssh_port_0)" - local -r VM_USER="$(cat "${SHARED_DIR}"/vm_user_0)" - - cat << EOF >/tmp/e2e.yaml -USHIFT_HOST: ${VM_IP} -USHIFT_USER: ${VM_USER} -SSH_PRIV_KEY: ${CLUSTER_PROFILE_DIR}/ssh-privatekey -SSH_PORT: ${VM_PORT} -EOF - /microshift/test/run.sh -o "${ARTIFACT_DIR}/e2e" -i /tmp/e2e.yaml -v /tmp/venv /microshift/test/suites-ostree/backup-restore.robot -} - -# Bash CNCF Tests -# See https://github.com/openshift/microshift/blob/main/docs/multinode/setup.md -run_cncf() { - local -r PRI_HOST="$(cat "${SHARED_DIR}"/vm_ssh_host_1)" - local -r PRI_ADDR="$(cat "${SHARED_DIR}"/vm_int_ip_1)" - local -r PRI_PORT="$(cat "${SHARED_DIR}"/vm_ssh_port_1)" - local -r PRI_USER="$(cat "${SHARED_DIR}"/vm_user_1)" - - local -r SEC_HOST="$(cat "${SHARED_DIR}"/vm_ssh_host_2)" - local -r SEC_ADDR="$(cat "${SHARED_DIR}"/vm_int_ip_2)" - local -r SEC_PORT="$(cat "${SHARED_DIR}"/vm_ssh_port_2)" - local -r SEC_USER="$(cat "${SHARED_DIR}"/vm_user_2)" - - local -r SSH_CMD="ssh -i ${CLUSTER_PROFILE_DIR}/ssh-privatekey" - local -r SCP_CMD="scp -i ${CLUSTER_PROFILE_DIR}/ssh-privatekey" - - local -r RUN_SCRIPT=/tmp/run_cncf.sh - local -r KUBECONFIG=/tmp/kubeconfig-cncf - - cd /microshift/ - # Configure the primary host - ${SCP_CMD} -P "${PRI_PORT}" ./scripts/multinode/configure-pri.sh "${PRI_USER}@${IP_ADDRESS}:" - ${SSH_CMD} -p "${PRI_PORT}" "${PRI_USER}@${IP_ADDRESS}" \ - ./configure-pri.sh "${PRI_HOST}" "${PRI_ADDR}" "${SEC_HOST}" "${SEC_ADDR}" - - # Copy the kubelet configuration from the primary to the secondary host in two steps - ${SCP_CMD} -P "${PRI_PORT}" \ - "${PRI_USER}@${IP_ADDRESS}:/home/redhat/kubelet-${SEC_HOST}".{key,crt} \ - "${PRI_USER}@${IP_ADDRESS}:/home/redhat/kubeconfig-${PRI_HOST}" \ - /tmp/ - ${SCP_CMD} -P "${SEC_PORT}" \ - "/tmp/kubelet-${SEC_HOST}".{key,crt} \ - "/tmp/kubeconfig-${PRI_HOST}" \ - "${SEC_USER}@${IP_ADDRESS}": - - # Configure the secondary host - ${SCP_CMD} -P "${SEC_PORT}" ./scripts/multinode/configure-sec.sh "${SEC_USER}@${IP_ADDRESS}:" - ${SSH_CMD} -p "${SEC_PORT}" "${SEC_USER}@${IP_ADDRESS}" \ - ./configure-sec.sh "${PRI_HOST}" "${PRI_ADDR}" "${SEC_HOST}" "${SEC_ADDR}" - - cat < "${RUN_SCRIPT}" -#!/bin/bash -set -xeuo pipefail - -cd \${HOME}/microshift - -# Resolve primary host name locally -echo "${PRI_ADDR} ${PRI_HOST}" | sudo tee -a /etc/hosts &>/dev/null - -export KUBECONFIG="${KUBECONFIG}" -oc get pods -A -o wide - -# Wait up to 5m until both nodes are ready -NREADY=1 -for _ in \$(seq 1 30) ; do - NREADY=\$(oc get nodes --no-headers | awk '\$2=="Ready" {print \$1}' | wc -l) - [ "\${NREADY}" = 2 ] && break - sleep 10 -done -oc get nodes -o wide -[ "\${NREADY}" != 2 ] && exit 1 - -# Configure cluster prerequisites -oc adm policy add-scc-to-group privileged system:authenticated system:serviceaccounts -oc adm policy add-scc-to-group anyuid system:authenticated system:serviceaccounts - -# Install the tests -sudo dnf install -y golang -go install github.com/vmware-tanzu/sonobuoy@latest - -# Run the tests -~/go/bin/sonobuoy run \ - --mode=certified-conformance \ - --dns-namespace=openshift-dns \ - --dns-pod-labels=dns.operator.openshift.io/daemonset-dns=default - -# Wait for up to 1m until tests start -WAIT_FAILURE=true -for _ in \$(seq 1 30) ; do - if ~/go/bin/sonobuoy status --json | jq '.status' &>/dev/null ; then - WAIT_FAILURE=false - break - fi - sleep 2 -done - -# Exit with error on wait failure -\$WAIT_FAILURE && exit 1 - -# Wait until test complete (exit as soon as one of the tests failed) -TEST_FAILURE=false -while [ "\$(~/go/bin/sonobuoy status --json | jq -r '.status')" = "running" ] ; do - ~/go/bin/sonobuoy status --json | jq '.plugins[] | select(.plugin=="e2e") | .progress' - if [ "\$(~/go/bin/sonobuoy status --json | jq -r '.plugins[] | select(.plugin=="e2e") | .progress.failed')" != "null" ] ; then - TEST_FAILURE=true - break - fi - sleep 60 -done - -# Exit with error on test failure -\$TEST_FAILURE && exit 1 -# Normal exit -exit 0 -EOF - - # Download the kubeconfig from the primary host - ${SCP_CMD} -P "${PRI_PORT}" "${PRI_USER}@${IP_ADDRESS}:/home/redhat/kubeconfig-${PRI_HOST}" "${KUBECONFIG}" - cat "${KUBECONFIG}" - - # Copy and run the script, waiting up to 2h for it to complete - chmod +x "${RUN_SCRIPT}" - scp "${RUN_SCRIPT}" "${KUBECONFIG}" "${INSTANCE_PREFIX}:/tmp" - timeout 120m ssh "${INSTANCE_PREFIX}" "${RUN_SCRIPT}" -} - -###################################################################### -# If more tests are to be run in parallel the code should go in here # -###################################################################### - trap 'scp -r ${INSTANCE_PREFIX}:/home/${HOST_USER}/microshift/_output/test-images/scenario-info ${ARTIFACT_DIR}' EXIT # Run the scenario tests, if the phase script exists From d04afb3d150d8ebc8b43d1a29c6eb93c6269a87b Mon Sep 17 00:00:00 2001 From: Pablo Acevedo Montserrat Date: Tue, 11 Jul 2023 12:48:17 +0200 Subject: [PATCH 3/4] USHIFT-1423: Remove build phase for cncf and old e2e on metal --- .../openshift-microshift-infra-iso-build-commands.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ci-operator/step-registry/openshift/microshift/infra/iso-build/openshift-microshift-infra-iso-build-commands.sh b/ci-operator/step-registry/openshift/microshift/infra/iso-build/openshift-microshift-infra-iso-build-commands.sh index bdacb45221b77..04fa866e08fcd 100644 --- a/ci-operator/step-registry/openshift/microshift/infra/iso-build/openshift-microshift-infra-iso-build-commands.sh +++ b/ci-operator/step-registry/openshift/microshift/infra/iso-build/openshift-microshift-infra-iso-build-commands.sh @@ -31,8 +31,6 @@ if ! sudo subscription-manager status >&/dev/null; then fi chmod 0755 ~ -mkdir ~/rpms -tar -xf /tmp/rpms.tar -C ~/rpms tar -xf /tmp/microshift.tgz -C ~ cp /tmp/ssh-publickey ~/.ssh/id_rsa.pub @@ -46,15 +44,12 @@ cp /tmp/pull-secret "\${PULL_SECRET}" cd ~/microshift ./test/bin/ci_phase_iso_build.sh - -./scripts/image-builder/build.sh -pull_secret_file "\${PULL_SECRET}" -microshift_rpms ~/rpms -authorized_keys_file ~/.ssh/id_rsa.pub -open_firewall_ports 6443:tcp EOF chmod +x /tmp/iso.sh tar czf /tmp/microshift.tgz /microshift scp \ - /rpms.tar \ /tmp/iso.sh \ /var/run/rhsm/subscription-manager-org \ /var/run/rhsm/subscription-manager-act-key \ From a71a93c50ec1c847ab61210c0e669987dd6b0e8a Mon Sep 17 00:00:00 2001 From: Pablo Acevedo Montserrat Date: Tue, 11 Jul 2023 12:50:02 +0200 Subject: [PATCH 4/4] USHIFT-1423: Remove boot phase for cncf and old e2e on metal --- ...hift-microshift-infra-iso-boot-commands.sh | 106 +----------------- 1 file changed, 1 insertion(+), 105 deletions(-) diff --git a/ci-operator/step-registry/openshift/microshift/infra/iso-boot/openshift-microshift-infra-iso-boot-commands.sh b/ci-operator/step-registry/openshift/microshift/infra/iso-boot/openshift-microshift-infra-iso-boot-commands.sh index 4b240d3a93e5f..850eb598eff8d 100644 --- a/ci-operator/step-registry/openshift/microshift/infra/iso-boot/openshift-microshift-infra-iso-boot-commands.sh +++ b/ci-operator/step-registry/openshift/microshift/infra/iso-boot/openshift-microshift-infra-iso-boot-commands.sh @@ -26,110 +26,6 @@ Host ${IP_ADDRESS} EOF chmod 0600 "${HOME}/.ssh/config" -# Number of VMs to create. -# This will change over time as we add more tests. -NUM_VMS=3 -echo "${NUM_VMS}" > "${SHARED_DIR}/num_vms" - -# Run the boot VM loop -# TODO: run the boot.sh script in parallel -# Note that 'dnf' command fails when in parallel, so it needs to be put in -# critical section in the scripts/image-builder/create-vm.sh script -for (( i=0; i /tmp/boot.sh -#!/bin/bash -set -xeuo pipefail - -cd ~/microshift - -ISO_FILE=\$(find ~/microshift/_output/image-builder -name "*.iso") -sudo bash -c " \ - cd /var/lib/libvirt/images/ && \ - virt-install \ - --name ${VM_NAME} \ - --vcpus 2 \ - --memory 3072 \ - --disk path=./${VM_NAME}.qcow2,size=20 \ - --network network=default,model=virtio \ - --events on_reboot=restart \ - --cdrom "\${ISO_FILE}" \ - --noautoconsole \ - --wait \ -" - -VM_IP=\$(./scripts/devenv-builder/manage-vm.sh ip -n ${VM_NAME}) -timeout 8m bash -c "until ssh -oStrictHostKeyChecking=accept-new redhat@\${VM_IP} 'echo hello'; do sleep 5; done" - -cat << EOF2 > /tmp/config.yaml -apiServer: - subjectAltNames: - - "${IP_ADDRESS}" -EOF2 - -scp /tmp/config.yaml "redhat@\${VM_IP}":/tmp/ -set +e -ssh "redhat@\${VM_IP}" "sudo mv /tmp/config.yaml /etc/microshift/config.yaml && sudo reboot" -set -e -EOF - - chmod +x /tmp/boot.sh - scp /tmp/boot.sh "${INSTANCE_PREFIX}:/tmp" - ssh "${INSTANCE_PREFIX}" "/tmp/boot.sh" -done - -# Run the wait VM loop -for (( i=0; i /tmp/wait.sh -#!/bin/bash -set -xeuo pipefail - -cd ~/microshift -VM_IP=\$(./scripts/devenv-builder/manage-vm.sh ip -n ${VM_NAME}) - -timeout 8m bash -c "until ssh redhat@\${VM_IP} hostname; do sleep 5; done" -timeout 8m bash -c "date; until ssh redhat@\${VM_IP} \"sudo systemctl status greenboot-healthcheck | grep 'active (exited)'\"; do sleep 5; done; date" - -# Setup external access with port forwarding to allow running commands and tests from the CI container. -sudo /sbin/iptables -I FORWARD -o virbr0 -p tcp -d \${VM_IP} --dport 6443 -j ACCEPT -sudo /sbin/iptables -t nat -I PREROUTING -p tcp --dport "${API_EXTERNAL_PORT}" -j DNAT --to \${VM_IP}:6443 -sudo /sbin/iptables -I FORWARD -o virbr0 -p tcp -d \${VM_IP} --dport 22 -j ACCEPT -sudo /sbin/iptables -t nat -I PREROUTING -p tcp --dport "${SSH_EXTERNAL_PORT}" -j DNAT --to \${VM_IP}:22 -EOF - - chmod +x /tmp/wait.sh - scp /tmp/wait.sh "${INSTANCE_PREFIX}:/tmp" - ssh "${INSTANCE_PREFIX}" "/tmp/wait.sh" -done - -# Save the name, ip, port, user, etc. information about the VMs -for (( i=0; i "${SHARED_DIR}/kubeconfig_${i}" - sed -i "s,:6443,:${API_EXTERNAL_PORT}," "${SHARED_DIR}/kubeconfig_${i}" - - # shellcheck disable=SC2029 - ssh "${INSTANCE_PREFIX}" \ - "microshift/scripts/devenv-builder/manage-vm.sh ip -n ${VM_NAME}" > "${SHARED_DIR}/vm_int_ip_${i}" - - echo "${VM_NAME}" > "${SHARED_DIR}/vm_ssh_host_${i}" - echo "${SSH_EXTERNAL_PORT}" > "${SHARED_DIR}/vm_ssh_port_${i}" - echo "redhat" > "${SHARED_DIR}/vm_user_${i}" -done - # Install the settings for the scenario runner. The ssh keys have # already been copied into place in the iso-build step. SETTINGS_FILE="${SHARED_DIR}/scenario_settings.sh" @@ -143,4 +39,4 @@ scp "${SETTINGS_FILE}" "${INSTANCE_PREFIX}:/home/${HOST_USER}/microshift/test/" trap 'scp -r ${INSTANCE_PREFIX}:/home/${HOST_USER}/microshift/_output/test-images/scenario-info ${ARTIFACT_DIR}' EXIT # Run the in-repo ci phase script to create the VMs for the test scenarios. -ssh "${INSTANCE_PREFIX}" "/home/${HOST_USER}/microshift/test/bin/ci_phase_iso_boot.sh ${API_EXTERNAL_PORT} ${SSH_EXTERNAL_PORT} ${LB_EXTERNAL_BASE_PORT}" +ssh "${INSTANCE_PREFIX}" "/home/${HOST_USER}/microshift/test/bin/ci_phase_iso_boot.sh ${SSH_EXTERNAL_BASE_PORT} ${API_EXTERNAL_BASE_PORT} ${LB_EXTERNAL_BASE_PORT}"