mirror of
https://github.com/rancher/k3k.git
synced 2026-02-14 18:10:01 +00:00
159 lines
4.8 KiB
YAML
159 lines
4.8 KiB
YAML
name: Conformance Tests - Shared Mode
|
|
|
|
on:
|
|
schedule:
|
|
- cron: "0 1 * * *"
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
conformance:
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
type:
|
|
- parallel
|
|
- serial
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
|
with:
|
|
fetch-depth: 0
|
|
fetch-tags: true
|
|
|
|
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6
|
|
with:
|
|
go-version-file: go.mod
|
|
|
|
- name: Install helm
|
|
uses: azure/setup-helm@1a275c3b69536ee54be43f2070a358922e12c8d4 # v4.3.1
|
|
|
|
- name: Install hydrophone
|
|
run: go install sigs.k8s.io/hydrophone@latest
|
|
|
|
- name: Install k3d and kubectl
|
|
run: |
|
|
wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash
|
|
k3d version
|
|
|
|
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
|
|
|
|
- name: Setup Kubernetes (k3d)
|
|
env:
|
|
REPO_NAME: k3k-registry
|
|
REPO_PORT: 12345
|
|
run: |
|
|
echo "127.0.0.1 ${REPO_NAME}" | sudo tee -a /etc/hosts
|
|
|
|
k3d registry create ${REPO_NAME} --port ${REPO_PORT}
|
|
|
|
k3d cluster create k3k --servers 2 \
|
|
-p "30000-30010:30000-30010@server:0" \
|
|
--registry-use k3d-${REPO_NAME}:${REPO_PORT}
|
|
|
|
kubectl cluster-info
|
|
kubectl get nodes
|
|
|
|
- name: Setup K3k
|
|
env:
|
|
REPO: k3k-registry:12345
|
|
run: |
|
|
echo "127.0.0.1 k3k-registry" | sudo tee -a /etc/hosts
|
|
|
|
make build
|
|
make package
|
|
make push
|
|
|
|
# add k3kcli to $PATH
|
|
echo "${{ github.workspace }}/bin" >> $GITHUB_PATH
|
|
|
|
VERSION=$(make version)
|
|
k3d image import ${REPO}/k3k:${VERSION} -c k3k --verbose
|
|
k3d image import ${REPO}/k3k-kubelet:${VERSION} -c k3k --verbose
|
|
|
|
make install
|
|
|
|
echo "Wait for K3k controller to be available"
|
|
kubectl wait -n k3k-system pod --for condition=Ready -l "app.kubernetes.io/name=k3k" --timeout=5m
|
|
|
|
- name: Check k3kcli
|
|
run: k3kcli -v
|
|
|
|
- name: Create virtual cluster
|
|
run: |
|
|
kubectl create namespace k3k-mycluster
|
|
|
|
cat <<EOF | kubectl apply -f -
|
|
apiVersion: k3k.io/v1beta1
|
|
kind: Cluster
|
|
metadata:
|
|
name: mycluster
|
|
namespace: k3k-mycluster
|
|
spec:
|
|
mirrorHostNodes: true
|
|
tlsSANs:
|
|
- "127.0.0.1"
|
|
expose:
|
|
nodePort:
|
|
serverPort: 30001
|
|
EOF
|
|
|
|
echo "Wait for bootstrap secret to be available"
|
|
kubectl wait -n k3k-mycluster --for=create secret k3k-mycluster-bootstrap --timeout=5m
|
|
|
|
k3kcli kubeconfig generate --name mycluster
|
|
|
|
export KUBECONFIG=${{ github.workspace }}/k3k-mycluster-mycluster-kubeconfig.yaml
|
|
|
|
kubectl cluster-info
|
|
kubectl get nodes
|
|
kubectl get pods -A
|
|
|
|
- name: Run conformance tests (parallel)
|
|
if: matrix.type == 'parallel'
|
|
run: |
|
|
# Run conformance tests in parallel mode (skipping serial)
|
|
hydrophone --conformance --parallel 4 --skip='\[Serial\]' \
|
|
--kubeconfig ${{ github.workspace }}/k3k-mycluster-mycluster-kubeconfig.yaml \
|
|
--output-dir /tmp
|
|
|
|
- name: Run conformance tests (serial)
|
|
if: matrix.type == 'serial'
|
|
run: |
|
|
# Run serial conformance tests
|
|
hydrophone --focus='\[Serial\].*\[Conformance\]' \
|
|
--kubeconfig ${{ github.workspace }}/k3k-mycluster-mycluster-kubeconfig.yaml \
|
|
--output-dir /tmp
|
|
|
|
- name: Archive conformance logs
|
|
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
|
|
if: always()
|
|
with:
|
|
name: conformance-${{ matrix.type }}-logs
|
|
path: /tmp/e2e.log
|
|
|
|
- name: Job Summary
|
|
if: always()
|
|
run: |
|
|
echo '## 📊 Conformance Tests Results (${{ matrix.type }})' >> $GITHUB_STEP_SUMMARY
|
|
echo '| Passed | Failed | Pending | Skipped |' >> $GITHUB_STEP_SUMMARY
|
|
echo '|---|---|---|---|' >> $GITHUB_STEP_SUMMARY
|
|
|
|
RESULTS=$(tail -10 /tmp/e2e.log | grep -E "Passed .* Failed .* Pending .* Skipped" | cut -d '-' -f 3)
|
|
RESULTS=$(echo $RESULTS | grep -oE '[0-9]+' | xargs | sed 's/ / | /g')
|
|
echo "| $RESULTS |" >> $GITHUB_STEP_SUMMARY
|
|
|
|
# only include failed tests section if there are any
|
|
if grep -q '\[FAIL\]' /tmp/e2e.log; then
|
|
echo '' >> $GITHUB_STEP_SUMMARY
|
|
echo '### Failed Tests' >> $GITHUB_STEP_SUMMARY
|
|
echo '```' >> $GITHUB_STEP_SUMMARY
|
|
grep '\[FAIL\]' /tmp/e2e.log >> $GITHUB_STEP_SUMMARY
|
|
echo '```' >> $GITHUB_STEP_SUMMARY
|
|
fi
|