-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
80 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,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" |
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,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) |
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