Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add kubernetes engine test #283

Merged
merged 1 commit into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/[email protected]
- 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")]

@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
Loading