Skip to content

Commit

Permalink
Add kubernetes engine test
Browse files Browse the repository at this point in the history
  • Loading branch information
312hzeng committed Nov 13, 2023
1 parent 5a43dfc commit 8b4a141
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/kubernetes_engine_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Kubernetes Engine Test
on:
push:
path:
- acto/kubernetes_engine/**
jobs:
KubernetesEngineTest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.20.5'
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
make
- name: Install Kind
run: |
go install sigs.k8s.io/kind@v0.20.0
- 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
- name: Run KubernetesEngineTest
run: |
pytest -m "kubernetes_engine"
47 changes: 47 additions & 0 deletions acto/kubernetes_engine/test_kubernetes_engines.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import os

import pytest

from acto.kubernetes_engine.base import KubernetesEngine
from acto.kubernetes_engine.kind import Kind

from . import minikube as minikube

# class TestKubernetesEngines():
# kind_cluster = kind.Kind(acto_namespace=0)

kind_cluster = Kind(acto_namespace=0)
minikube_cluster = minikube.Minikube(acto_namespace=0)

testcases = [(kind_cluster,3, "v1.27.3"), (minikube_cluster, 3, "v1.27.4")]

@pytest.mark.kubernetes_engine
@pytest.mark.parametrize('cluster_instance,num_nodes,version', testcases)
def test_kubernetes_engines(cluster_instance: KubernetesEngine, num_nodes, version):
configPath = os.path.join(os.path.expanduser('~'), '.kube/test-config')
name = "test-cluster"
# num_nodes = 3
# version = "v1.27.4"

cluster_instance.configure_cluster(num_nodes, version)
print(
f"Creating cluster {name} with {num_nodes} nodes, version {version}, configPath {configPath}")
cluster_instance.create_cluster(name, configPath)

node_list = cluster_instance.get_node_list(name)
assert len(node_list) == num_nodes

cluster_instance.delete_cluster(name, configPath)
with pytest.raises(RuntimeError):
# expect to raise RuntimeError
# get_node_list should raise RuntimeError when cluster is not found
cluster_instance.get_node_list(name)


# def test_minikube_load_image():
# num_nodes = 3
# name = "hz"
# version = "v1.27.4"
# cluster = minikube.Minikube(acto_namespace = 0, num_nodes=num_nodes, version=version)
# # cluster.create_cluster(name, "/users/hzeng21/.kube/config2")
# cluster.load_images("/users/hzeng21/.kube/sleepy.tar", name=name)
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
markers =
local: mark a test to run on a local machine
singleBugReproduction: mark a test to run e2e regressions on a pull request
kubernetes_engine: mark a test for cluster set up

0 comments on commit 8b4a141

Please sign in to comment.