-
Notifications
You must be signed in to change notification settings - Fork 14
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
2 changed files
with
84 additions
and
22 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
12 changes: 4 additions & 8 deletions
12
tests/integration/test_opstest_add_k8s.py → tests/integration/test_add_k8s.py
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 |
---|---|---|
@@ -1,24 +1,20 @@ | ||
# test that pytest operator supports adding a k8s to an existing controller | ||
# This is a new k8s cloud created/managed by pytest-operator | ||
|
||
from kubernetes import config as k8s_config | ||
from kubernetes.client import Configuration | ||
from kubernetes.config.config_exception import ConfigException | ||
import pytest | ||
|
||
from pytest_operator.plugin import OpsTest | ||
|
||
|
||
async def test_add_k8s(ops_test: OpsTest): | ||
config = type.__call__(Configuration) | ||
try: | ||
k8s_config.load_config(client_configuration=config) | ||
k8s_cloud = await ops_test.add_k8s(skip_storage=False) | ||
except ConfigException: | ||
pytest.skip("No Kubernetes config found to add-k8s") | ||
k8s_cloud = await ops_test.add_k8s(config, skip_storage=True, storage_class=None) | ||
|
||
k8s_model = await ops_test.track_model( | ||
"secondary", cloud_name=k8s_cloud, keep=ops_test.ModelKeep.NEVER | ||
) | ||
with ops_test.model_context("secondary"): | ||
await k8s_model.deploy("coredns", trust=True) | ||
await k8s_model.wait_for_idle(apps=["coredns"], status="active") | ||
await k8s_model.deploy("grafana-k8s", trust=True) | ||
await k8s_model.wait_for_idle(apps=["grafana-k8s"], status="active") |