From a29aa5aefb0bec3c4c486dc3c86f19ce4498de53 Mon Sep 17 00:00:00 2001 From: justinsb Date: Sat, 31 Aug 2024 07:05:45 -0400 Subject: [PATCH] tests: capture logs etc as github artifacts We use the ARTIFACTS idea from prow, should be compatible. --- .github/workflows/e2e.yml | 7 +++ tests/e2e/scenarios/bare-metal/dump-artifacts | 45 ++++++++++++------- 2 files changed, 37 insertions(+), 15 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 79ea64754aa1a..710929a37fd06 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -29,3 +29,10 @@ jobs: working-directory: ${{ env.GOPATH }}/src/k8s.io/kops run: | tests/e2e/scenarios/bare-metal/run-test + env: + ARTIFACTS: /tmp/artifacts + - name: Archive production artifacts + uses: actions/upload-artifact@v4 + with: + name: artifacts + path: /tmp/artifacts/ diff --git a/tests/e2e/scenarios/bare-metal/dump-artifacts b/tests/e2e/scenarios/bare-metal/dump-artifacts index 88c34585729b3..a91824d9e7484 100755 --- a/tests/e2e/scenarios/bare-metal/dump-artifacts +++ b/tests/e2e/scenarios/bare-metal/dump-artifacts @@ -22,18 +22,33 @@ set -o xtrace REPO_ROOT=$(git rev-parse --show-toplevel) cd ${REPO_ROOT} -ip route || true - -ip link || true - -ip addr || true - -sudo iptables --list-rules || true -sudo iptables -t nat --list-rules || true - - -journalctl --no-pager --user -xeu qemu-dhcp.service || true -journalctl --no-pager --user -xeu qemu-storage.service || true -journalctl --no-pager --user -xeu qemu-vm0.service || true -journalctl --no-pager --user -xeu qemu-vm1.service || true -journalctl --no-pager --user -xeu qemu-vm2.service || true +if [[ -z "${ARTIFACTS:-}" ]]; then + echo "ARTIFACTS is not set; skipping dump-artifacts" + exit 0 +fi + +mkdir -p ${ARTIFACTS}/networking/ +ip route 2>&1 > ${ARTIFACTS}/networking/ip-route || true + +ip link 2>&1 > ${ARTIFACTS}/networking/ip-link || true + +ip addr 2>&1 > ${ARTIFACTS}/networking/ip-addr || true + +sudo iptables --list-rules 2>&1 > ${ARTIFACTS}/networking/iptables-rules || true +sudo iptables -t nat --list-rules 2>&1 > ${ARTIFACTS}/networking/iptables-nat-rules || true + +mkdir -p ${ARTIFACTS}/logs/ +journalctl --no-pager --user -xeu qemu-dhcp.service 2>&1 > ${ARTIFACTS}/logs/qemu-dhcp.service || true +journalctl --no-pager --user -xeu qemu-storage.service 2>&1 > ${ARTIFACTS}/logs/qemu-storage.service || true +journalctl --no-pager --user -xeu qemu-vm0.service 2>&1 > ${ARTIFACTS}/logs/qemu-vm0.service || true +journalctl --no-pager --user -xeu qemu-vm1.service 2>&1 > ${ARTIFACTS}/logs/qemu-vm1.service || true +journalctl --no-pager --user -xeu qemu-vm2.service 2>&1 > ${ARTIFACTS}/logs/qemu-vm2.service || true + +# TODO: Replace this with toolbox dump +mkdir -p ${ARTIFACTS}/vms/ +for vm in 0 1 2; do + ip="10.123.45.1${vm}" + vm_name="vm${vm}" + mkdir -p ${ARTIFACTS}/vms/${vm_name}/logs/ + scp -o StrictHostKeyChecking=accept-new -i ${REPO_ROOT}/.build/.ssh/id_ed25519 root@10.123.45.10:/var/log/etcd* ${ARTIFACTS}/vms/${vm_name}/logs/ || true +done