-
Notifications
You must be signed in to change notification settings - Fork 6
/
test_charms.py
65 lines (51 loc) · 2.03 KB
/
test_charms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import logging
from pathlib import Path
import pytest
import yaml
from pytest_operator.plugin import OpsTest
log = logging.getLogger(__name__)
TC_METADATA = yaml.safe_load(Path("charms/tensorboard-controller/metadata.yaml").read_text())
TWA_METADATA = yaml.safe_load(Path("charms/tensorboards-web-app/metadata.yaml").read_text())
@pytest.mark.abort_on_fail
async def test_build_and_deploy_with_relations(ops_test: OpsTest):
tensorboard_controller = await ops_test.build_charm("charms/tensorboard-controller")
tensorboards_web_app = await ops_test.build_charm("charms/tensorboards-web-app")
image_path = TC_METADATA["resources"]["tensorboard-controller-image"]["upstream-source"]
resources = {"tensorboard-controller-image": image_path}
await ops_test.model.deploy(
entity_url=tensorboard_controller,
resources=resources,
trust=True,
)
istio_gateway = "istio-ingressgateway"
istio_pilot = "istio-pilot"
tc_app_name = TC_METADATA["name"]
twa_name = TWA_METADATA["name"]
await ops_test.model.deploy(
entity_url="istio-gateway",
application_name=istio_gateway,
channel="latest/edge",
config={"kind": "ingress"},
trust=True,
)
await ops_test.model.deploy(
istio_pilot,
channel="latest/edge",
config={"default-gateway": "test-gateway"},
trust=True,
)
await ops_test.model.add_relation(
istio_pilot,
istio_gateway,
)
await ops_test.model.add_relation(f"{istio_pilot}:gateway-info", f"{tc_app_name}:gateway-info")
image_path = TWA_METADATA["resources"]["tensorboards-web-app-image"]["upstream-source"]
resources = {"tensorboards-web-app-image": image_path}
await ops_test.model.deploy(
entity_url=tensorboards_web_app,
resources=resources,
trust=True,
)
await ops_test.model.add_relation(f"{istio_pilot}:ingress", f"{twa_name}:ingress")
# Wait for everything to deploy
await ops_test.model.wait_for_idle(status="active", timeout=60 * 5)