Skip to content

Commit bbbb845

Browse files
Copilotdciangot
andauthored
feat: add CI workflow and mesh-env setup scripts for mesh network tests
Agent-Logs-Url: https://github.com/interlink-hq/vk-test-set/sessions/06bae7e2-b996-439f-a3be-804ba8bd7eb9 Co-authored-by: dciangot <4144326+dciangot@users.noreply.github.com>
1 parent 2bef780 commit bbbb845

6 files changed

Lines changed: 676 additions & 8 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: mesh-network-integration-tests
2+
3+
on:
4+
push: {}
5+
pull_request: {}
6+
7+
jobs:
8+
mesh-e2e:
9+
name: mesh-network-e2e
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Enable unprivileged user namespaces (required by Apptainer/Singularity)
19+
run: sudo sysctl -w kernel.unprivileged_userns_clone=1
20+
21+
- name: Set up mesh-network environment
22+
run: bash scripts/setup-mesh-env.sh
23+
24+
- name: Run mesh-network integration tests
25+
run: bash scripts/run-mesh-tests.sh
26+
27+
- name: Upload test logs
28+
if: always()
29+
uses: actions/upload-artifact@v4
30+
with:
31+
name: mesh-e2e-test-logs
32+
path: /tmp/interlink-mesh-*
33+
retention-days: 7
34+
if-no-files-found: ignore
35+
36+
- name: Cleanup
37+
if: always()
38+
run: bash scripts/cleanup-mesh-env.sh

scripts/cleanup-mesh-env.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/usr/bin/env bash
2+
# cleanup-mesh-env.sh — Tear down the mesh-network test environment created
3+
# by setup-mesh-env.sh.
4+
#
5+
# Usage:
6+
# bash scripts/cleanup-mesh-env.sh
7+
#
8+
# Optional:
9+
# REMOVE_TEST_DIR=1 also delete the temporary test directory
10+
11+
set -euo pipefail
12+
13+
echo "=== Cleaning up mesh-network test environment ==="
14+
15+
STATE_FILE="/tmp/interlink-mesh-dir.txt"
16+
17+
# Stop virtual kubelet
18+
if [[ -f "${STATE_FILE}" ]]; then
19+
TEST_DIR=$(cat "${STATE_FILE}")
20+
if [[ -f "${TEST_DIR}/vk.pid" ]]; then
21+
VK_PID=$(cat "${TEST_DIR}/vk.pid")
22+
echo "Stopping VK (PID ${VK_PID})..."
23+
kill "${VK_PID}" 2>/dev/null || true
24+
sleep 2
25+
kill -9 "${VK_PID}" 2>/dev/null || true
26+
fi
27+
fi
28+
29+
# Save Docker logs before stopping containers
30+
if [[ -f "${STATE_FILE}" ]]; then
31+
TEST_DIR=$(cat "${STATE_FILE}")
32+
echo "Saving container logs..."
33+
docker logs interlink-api > "${TEST_DIR}/interlink-api.log" 2>&1 || true
34+
docker logs interlink-plugin > "${TEST_DIR}/interlink-plugin.log" 2>&1 || true
35+
fi
36+
37+
# Remove Docker containers and network
38+
echo "Removing Docker containers..."
39+
docker stop interlink-api 2>/dev/null || true
40+
docker rm interlink-api 2>/dev/null || true
41+
docker stop interlink-plugin 2>/dev/null || true
42+
docker rm interlink-plugin 2>/dev/null || true
43+
docker network rm interlink-net 2>/dev/null || true
44+
45+
# Uninstall k3s
46+
echo "Uninstalling k3s..."
47+
if [[ -f /usr/local/bin/k3s-uninstall.sh ]]; then
48+
sudo /usr/local/bin/k3s-uninstall.sh 2>/dev/null || true
49+
else
50+
echo " k3s uninstall script not found, skipping."
51+
fi
52+
53+
# Optionally remove test directory
54+
if [[ -f "${STATE_FILE}" ]]; then
55+
TEST_DIR=$(cat "${STATE_FILE}")
56+
if [[ "${REMOVE_TEST_DIR:-0}" == "1" ]]; then
57+
echo "Removing ${TEST_DIR}..."
58+
rm -rf "${TEST_DIR}" 2>/dev/null || true
59+
rm -f "${STATE_FILE}"
60+
else
61+
echo "Preserving test directory for debugging: ${TEST_DIR}"
62+
echo "(set REMOVE_TEST_DIR=1 to delete it)"
63+
fi
64+
fi
65+
66+
echo "✓ Cleanup complete"

scripts/run-mesh-tests.sh

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#!/usr/bin/env bash
2+
# run-mesh-tests.sh — Run the vk-test-set integration tests against the
3+
# mesh-network environment set up by setup-mesh-env.sh.
4+
#
5+
# Usage:
6+
# bash scripts/run-mesh-tests.sh
7+
#
8+
# Requires setup-mesh-env.sh to have been run first.
9+
10+
set -euo pipefail
11+
12+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13+
REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
14+
15+
# Read test directory written by setup-mesh-env.sh
16+
STATE_FILE="/tmp/interlink-mesh-dir.txt"
17+
if [[ ! -f "${STATE_FILE}" ]]; then
18+
echo "ERROR: state file ${STATE_FILE} not found. Run setup-mesh-env.sh first."
19+
exit 1
20+
fi
21+
TEST_DIR=$(cat "${STATE_FILE}")
22+
23+
echo "=== Running vk-test-set mesh integration tests ==="
24+
echo "TEST_DIR: ${TEST_DIR}"
25+
26+
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
27+
WILDCARD_DNS=$(cat "${TEST_DIR}/wildcard-dns.txt" 2>/dev/null || echo "")
28+
29+
echo "Cluster status:"
30+
kubectl get nodes
31+
kubectl get pods -A --field-selector="metadata.namespace!=kube-system" 2>/dev/null | head -20 || true
32+
33+
# Wait for the virtual-kubelet node to be Ready
34+
echo "Waiting for virtual-kubelet node..."
35+
for i in {1..30}; do
36+
kubectl get node virtual-kubelet &>/dev/null && break
37+
echo " ($i/30) waiting..."
38+
sleep 5
39+
done
40+
kubectl wait --for=condition=Ready node/virtual-kubelet --timeout=120s || {
41+
echo "ERROR: virtual-kubelet node not Ready"
42+
kubectl describe node virtual-kubelet || true
43+
tail -50 "${TEST_DIR}/vk.log" || true
44+
exit 1
45+
}
46+
echo "✓ virtual-kubelet is Ready"
47+
48+
# ---------------------------------------------------------------------------
49+
# Write test configuration
50+
# ---------------------------------------------------------------------------
51+
cat > "${REPO_ROOT}/vktest_config_mesh.yaml" <<EOF
52+
target_nodes:
53+
- virtual-kubelet
54+
55+
required_namespaces:
56+
- default
57+
- kube-system
58+
- interlink
59+
60+
timeout_multiplier: 3.0
61+
62+
values:
63+
namespace: interlink
64+
65+
annotations: {}
66+
67+
tolerations:
68+
- key: virtual-node.interlink/no-schedule
69+
operator: Exists
70+
effect: NoSchedule
71+
EOF
72+
73+
# ---------------------------------------------------------------------------
74+
# Set up Python venv and install vk-test-set
75+
# ---------------------------------------------------------------------------
76+
echo "Installing vk-test-set..."
77+
python3 -m venv "${TEST_DIR}/.venv"
78+
source "${TEST_DIR}/.venv/bin/activate"
79+
pip install -q -e "${REPO_ROOT}/"
80+
echo "✓ vk-test-set installed"
81+
82+
# ---------------------------------------------------------------------------
83+
# Run the tests — focus on mesh-network template plus smoke tests
84+
# ---------------------------------------------------------------------------
85+
echo ""
86+
echo "========================================="
87+
echo "Running integration tests..."
88+
echo "WildcardDNS: ${WILDCARD_DNS}"
89+
echo "========================================="
90+
91+
cd "${REPO_ROOT}"
92+
VKTEST_CONFIG="${REPO_ROOT}/vktest_config_mesh.yaml" \
93+
pytest -v \
94+
-k "not rclone and not limits and not stress and not multi-init" \
95+
2>&1 | tee "${TEST_DIR}/test-results.log"
96+
TEST_EXIT=${PIPESTATUS[0]}
97+
98+
echo "========================================="
99+
if [[ "${TEST_EXIT}" -eq 0 ]]; then
100+
echo "✓ All tests passed"
101+
else
102+
echo "✗ Tests failed (exit ${TEST_EXIT})"
103+
echo "Logs:"
104+
echo " Test results : ${TEST_DIR}/test-results.log"
105+
echo " VK log : ${TEST_DIR}/vk.log"
106+
echo " API logs : docker logs interlink-api"
107+
echo " Plugin logs : docker logs interlink-plugin"
108+
fi
109+
110+
exit "${TEST_EXIT}"

0 commit comments

Comments
 (0)