Skip to content

feat: add e2e integration test for env apply local #7

feat: add e2e integration test for env apply local

feat: add e2e integration test for env apply local #7

Workflow file for this run

name: E2E
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
jobs:
e2e:
runs-on: ubuntu-latest
timeout-minutes: 40
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Build ocpctl
run: go build -o ocpctl .
- name: Apply local environment
run: ./ocpctl env apply local --timeout 15m
- name: Wait for onboarding cluster
timeout-minutes: 5
run: |
until kind get clusters 2>/dev/null | grep -q "^local-onboarding$"; do
echo "Waiting for local-onboarding cluster..."
sleep 10
done
- name: Get onboarding kubeconfig
run: |
kind get kubeconfig --name local-onboarding > /tmp/onboarding.kubeconfig
echo "KUBECONFIG=/tmp/onboarding.kubeconfig" >> "$GITHUB_ENV"
- name: Wait for ControlPlane CRD
timeout-minutes: 2
run: |
kubectl wait --for=condition=Established \
crd/controlplanes.core.open-control-plane.io \
--timeout=120s
- name: Create ControlPlane
run: |
kubectl apply -f - <<'EOF'
apiVersion: core.open-control-plane.io/v2alpha1
kind: ControlPlane
metadata:
name: test
namespace: default
spec:
iam: {}
EOF
- name: Wait for ControlPlane to be ready
timeout-minutes: 5
run: |
DEADLINE=$((SECONDS + 300))
while [ $SECONDS -lt $DEADLINE ]; do
TOTAL=$(kubectl get cp test -n default \
-o jsonpath='{.status.conditions}' 2>/dev/null | jq 'length // 0')
READY=$(kubectl get cp test -n default \
-o jsonpath='{.status.conditions[*].status}' 2>/dev/null \
| tr ' ' '\n' | grep -c "^True$" || true)
echo "ControlPlane conditions: ${READY:-0}/${TOTAL:-0} True"
if [ "${TOTAL:-0}" -gt 0 ] && [ "${READY:-0}" -eq "${TOTAL:-0}" ]; then
echo "ControlPlane is ready"
break
fi
sleep 10
done
if [ "${READY:-0}" -ne "${TOTAL:-0}" ] || [ "${TOTAL:-0}" -eq 0 ]; then
echo "Timed out waiting for ControlPlane to be ready"
kubectl describe cp test -n default || true
exit 1
fi
- name: Find MCP kind cluster
run: |
MCP_CLUSTER=$(kind get clusters 2>/dev/null \
| grep -v "^local-platform$" | grep -v "^local-onboarding$" | head -1)
echo "MCP cluster: ${MCP_CLUSTER}"
echo "MCP_CLUSTER=${MCP_CLUSTER}" >> "$GITHUB_ENV"
[ -n "$MCP_CLUSTER" ] || { echo "No MCP kind cluster found"; exit 1; }
- name: Verify MCP cluster pods are ready
run: |
kind get kubeconfig --name "$MCP_CLUSTER" > /tmp/mcp.kubeconfig
kubectl wait --for=condition=Ready pods --all --all-namespaces \
--timeout=120s --kubeconfig /tmp/mcp.kubeconfig
- name: Cleanup
if: always()
run: ./ocpctl env delete local || true