Skip to content

Commit

Permalink
Add new Go module to deploy VM for tests
Browse files Browse the repository at this point in the history
Signed-off-by: Huy Mai <[email protected]>
  • Loading branch information
mquhuy committed Jun 20, 2024
1 parent ebffc08 commit 7a90b0c
Show file tree
Hide file tree
Showing 10 changed files with 464 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Install libvirt
run: |
sudo apt-get update
sudo apt-get install -y libvirt-daemon-system qemu-kvm virt-manager
sudo apt-get install -y libvirt-daemon-system qemu-kvm virt-manager libvirt-dev
- name: Run BMO e2e Tests
env:
Expand All @@ -45,6 +45,7 @@ jobs:
sudo -s -u $USER --preserve-env bash ${{ github.workspace }}/hack/ci-e2e.sh
- name: Upload artifacts
if: {{ !cancelled() }}
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: artifacts-${{ inputs.bmc-protocol }}.tar.gz
Expand Down
27 changes: 27 additions & 0 deletions clean_bmcs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
#
# This script reads BMC information in a config file and prepare VMs
# whose info match those config
#
set -ex

REPO_ROOT=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
cd "${REPO_ROOT}"

virsh pool-destroy default || true
virsh pool-delete default || true
virsh pool-undefine default || true

CONFIG_FILE=$1
NETWORK=${2:-"baremetal-e2e"}

readarray -t BMCS < <(yq e -o=j -I=0 '.[]' "${CONFIG_FILE}")

for bmc in "${BMCS[@]}"; do
bootMacAddress=$(echo "${bmc}" | jq -r '.bootMacAddress')
ipAddress=$(echo "${bmc}" | jq -r '.ipAddress')
virsh -c qemu:///system net-update "${NETWORK}" delete ip-dhcp-host "<host mac='${bootMacAddress}' ip='${ipAddress}'/>" --live --config
done
"${REPO_ROOT}/tools/bmh_test/clean_local_bmh_test_setup.sh" "^bmo-e2e-"
rm -rf /tmp/bmo-e2e-*

6 changes: 5 additions & 1 deletion hack/ci-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ else
exit 1
fi

"${REPO_ROOT}/hack/create_bmcs.sh" "${E2E_BMCS_CONF_FILE}" baremetal-e2e
# "${REPO_ROOT}/hack/create_bmcs.sh" "${E2E_BMCS_CONF_FILE}" baremetal-e2e
pushd "${REPO_ROOT}/test/createVM" || exit 1
go run main.go --yaml-source-file "${E2E_BMCS_CONF_FILE}"
popd

# Image server variables
CIRROS_VERSION="0.6.2"
Expand All @@ -118,6 +121,7 @@ mkdir -p "${IMAGE_DIR}"
## Download disk images
wget --quiet -P "${IMAGE_DIR}/" https://artifactory.nordix.org/artifactory/metal3/images/iso/"${IMAGE_FILE}"
wget --quiet -P "${IMAGE_DIR}/" https://fastly-cdn.system-rescue.org/releases/11.00/systemrescue-11.00-amd64.iso
wget --quiet -P "${IMAGE_DIR}/" https://artifactory.nordix.org/artifactory/metal3/images/iso/minimal_linux_live-v2.iso

## Start the image server
docker run --name image-server-e2e -d \
Expand Down
4 changes: 4 additions & 0 deletions hack/clean-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ docker rm -f sushy-tools
rm -rf "${REPO_ROOT}/test/e2e/_artifacts"
rm -rf "${REPO_ROOT}"/artifacts-*
rm -rf "${REPO_ROOT}/test/e2e/images"

# Clear network
virsh -c qemu:///system net-destroy baremetal-e2e
virsh -c qemu:///system net-undefine baremetal-e2e
Loading

0 comments on commit 7a90b0c

Please sign in to comment.