Skip to content

Commit

Permalink
Move test to new LB relation pattern and use edge charms
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsca committed Apr 29, 2021
1 parent 7ecdf4b commit 059414e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
7 changes: 5 additions & 2 deletions tests/data/bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@ machines:
services:
containerd:
charm: cs:~containers/containerd
channel: edge
resources: {}
easyrsa:
charm: cs:~containers/easyrsa
channel: edge
num_units: 1
resources:
easyrsa: 5
to:
- '1'
etcd:
charm: cs:~containers/etcd
channel: edge
num_units: 1
options:
channel: 3.4/stable
Expand All @@ -31,6 +34,7 @@ services:
- '0'
flannel:
charm: cs:~containers/flannel
channel: edge
resources:
flannel-amd64: 653
flannel-arm64: 650
Expand All @@ -54,6 +58,7 @@ services:
- '0'
kubernetes-worker:
charm: cs:~containers/kubernetes-worker
channel: edge
constraints: cores=4 mem=4G root-disk=16G
expose: true
num_units: 1
Expand All @@ -70,8 +75,6 @@ services:
to:
- '1'
relations:
- - kubernetes-master:kube-api-endpoint
- kubernetes-worker:kube-api-endpoint
- - kubernetes-master:kube-control
- kubernetes-worker:kube-control
- - kubernetes-master:certificates
Expand Down
28 changes: 19 additions & 9 deletions tests/integration/test_kubernetes_master_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,31 @@
log = logging.getLogger(__name__)


def _check_status_messages(ops_test):
""" Validate that the status messages are correct. """
expected_messages = {
"kubernetes-master": "Kubernetes master running.",
"kubernetes-worker": "Kubernetes worker running.",
}
for app, message in expected_messages.items():
for unit in ops_test.model.applications[app].units:
assert unit.workload_status_message == message


@pytest.mark.abort_on_fail
async def test_build_and_deploy(ops_test):
bundle = ops_test.render_bundle(
"tests/data/bundle.yaml", master_charm=await ops_test.build_charm(".")
)
await ops_test.model.deploy(bundle)
await ops_test.model.wait_for_idle(wait_for_active=True, timeout=60 * 60)
_check_status_messages(ops_test)


async def test_status_messages(ops_test):
""" Validate that the status messages are correct. """
expected_messages = {
"kubernetes-master": "Kubernetes master running.",
"kubernetes-worker": "Kubernetes worker running.",
}
for app, message in expected_messages.items():
for unit in ops_test.model.applications[app].units:
assert unit.workload_status_message == message
async def test_kube_api_endpoint(ops_test):
""" Validate that adding the kube-api-endpoint relation works """
await ops_test.model.add_relation(
"kubernetes-master:kube-api-endpoint", "kubernetes-worker:kube-api-endpoint"
)
await ops_test.model.wait_for_idle(wait_for_active=True, timeout=10 * 60)
_check_status_messages(ops_test)

0 comments on commit 059414e

Please sign in to comment.