-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(e2e-testing): Add end-to-end test pipeline (#43)
- Loading branch information
1 parent
a32b880
commit 1b10a91
Showing
1 changed file
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
--- | ||
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | ||
name: Test E2E | ||
|
||
on: | ||
# Manual Trigger | ||
workflow_dispatch: {} | ||
|
||
# Run on any PR that changes this pipeline or that should ultimately trigger a release when merged | ||
pull_request: | ||
paths: | ||
- ".github/workflows/test.yaml" | ||
- "go.mod" | ||
- "go.sum" | ||
- "**/**.go" | ||
|
||
env: | ||
KUBECONFIG_DIR: ./configs/ | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | ||
|
||
- name: Build `kube-switcher` | ||
run: go build -o kube-switcher | ||
|
||
- name: Install `minikube` | ||
run: | | ||
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 | ||
sudo install minikube-linux-amd64 /usr/local/bin/minikube && rm minikube-linux-amd64 | ||
- name: Set Up Kubernetes Clusters | ||
run: | | ||
KUBECONFIG=./configs/cluster1.yaml minikube start -p test-cluster-1 & | ||
KUBECONFIG=./configs/cluster2.yaml minikube start -p test-cluster-2 & | ||
wait | ||
- name: Switch context to test-cluster-1 | ||
run: ./kube-switcher context test-cluster-1 | ||
|
||
- name: Validate the cluster has switched to test-cluster-1 by listing nodes | ||
run: | | ||
kubectl get nodes | grep "test-cluster-1" || { echo "Error: test-cluster-1 not found in node list!" >&2; exit 1; } | ||
- name: Check that no pods are found in the default namespace | ||
run: | | ||
kubectl get pods --namespace=default 2>&1 | grep "No resources found" || { echo "Error: Pods found in default namespace!" >&2; exit 1; } | ||
- name: Switch to the kube-system namespace | ||
run: ./kube-switcher namespace kube-system | ||
|
||
- name: Validate that kube-system namespace is selected and kube-apiserver is running | ||
run: | | ||
kubectl get pods --namespace=kube-system | grep "kube-apiserver" || { echo "Error: kube-apiserver not found in kube-system!" >&2; exit 1; } | ||
- name: Switch back to the default namespace | ||
run: ./kube-switcher namespace default | ||
|
||
- name: Check that no pods are found again in the default namespace | ||
run: | | ||
kubectl get pods --namespace=default 2>&1 | grep "No resources found" || { echo "Error: Pods found in default namespace!" >&2; exit 1; } | ||
- name: Switch context to test-cluster-2 | ||
run: ./kube-switcher context test-cluster-2 | ||
|
||
- name: Validate the cluster has switched to test-cluster-2 by listing nodes | ||
run: | | ||
kubectl get nodes | grep "test-cluster-2" || { echo "Error: test-cluster-2 not found in node list!" >&2; exit 1; } |