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

Fix deploy bundle tests #1046

Merged
merged 1 commit into from
Apr 30, 2024
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
13 changes: 5 additions & 8 deletions tests/bundle/bundle.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
series: jammy
applications:
grafana:
charm: "grafana"
channel: stable
num_units: 1
prometheus:
charm: "prometheus"
channel: stable
juju-qa-test:
charm: "juju-qa-test"
num_units: 1
nrpe:
charm: "nrpe"
relations:
- ["prometheus:grafana-source", "grafana:grafana-source"]
- ["nrpe:general-info", "juju-qa-test:juju-info"]
13 changes: 5 additions & 8 deletions tests/bundle/mini-bundle.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
series: jammy
applications:
grafana:
charm: "grafana"
channel: stable
num_units: 1
prometheus:
charm: "prometheus"
channel: stable
juju-qa-test:
charm: "juju-qa-test"
num_units: 1
nrpe:
charm: "nrpe"
relations:
- ["prometheus:grafana-source", "grafana:grafana-source"]
- ["nrpe:general-info", "juju-qa-test:juju-info"]
13 changes: 5 additions & 8 deletions tests/integration/bundle/bundle.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
series: jammy
applications:
grafana:
charm: "grafana"
channel: stable
num_units: 1
prometheus:
charm: "prometheus"
channel: stable
juju-qa-test:
charm: "juju-qa-test"
num_units: 1
nrpe:
charm: "nrpe"
test:
charm: "./tests/integration/charm"
relations:
- ["prometheus:grafana-source", "grafana:grafana-source"]
- ["nrpe:general-info", "juju-qa-test:juju-info"]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
description: An overlay for test multi-overlay
applications:
ntp:
nrpe:
memcached:
charm: "memcached"
channel: stable
Expand All @@ -10,6 +10,6 @@ description: Another overlay for test multi-overlay
applications:
memcached:
mysql:
charm: "prometheus"
channel: stable
num_units: 1
charm: "mysql"
channel: candidate
num_units: 1
12 changes: 4 additions & 8 deletions tests/integration/bundle/test-overlays/test-overlay.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
description: An overlay for tests
applications:
ntp:
ghost:
charm: "prometheus"
channel: stable
num_units: 1
nrpe:
mysql:
charm: "prometheus"
channel: stable
num_units: 1
charm: "mysql"
channel: candidate
num_units: 1
31 changes: 14 additions & 17 deletions tests/integration/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ async def test_deploy_local_bundle_dir():
async with base.CleanModel() as model:
await model.deploy(str(bundle_path))

app1 = model.applications.get('grafana')
app2 = model.applications.get('prometheus')
app1 = model.applications.get('juju-qa-test')
app2 = model.applications.get('nrpe')
with open("/tmp/output", "w") as writer:
writer.write(str(bundle_path) + "\n")
for (k, v) in model.applications.items():
Expand All @@ -66,8 +66,8 @@ async def test_deploy_local_bundle_file():
async with base.CleanModel() as model:
await model.deploy(str(mini_bundle_file_path))

app1 = model.applications.get('grafana')
app2 = model.applications.get('prometheus')
app1 = model.applications.get('juju-qa-test')
app2 = model.applications.get('nrpe')
assert app1 and app2
await model.block_until(lambda: (len(app1.units) == 1 and
len(app2.units) == 1),
Expand Down Expand Up @@ -272,27 +272,21 @@ async def test_deploy_local_bundle_with_overlay_multi():
# this bundle deploys mysql and ghost apps and relates them,
# but the overlay attached removes ghost, so
assert 'mysql' in model.applications
assert 'ghost' not in model.applications


@base.bootstrapped
@pytest.mark.asyncio
async def test_deploy_bundle_with_overlay_as_argument():
async with base.CleanModel() as model:
overlay_path = OVERLAYS_DIR / 'test-overlay.yaml'
bundle_path = TESTS_DIR / "bundle" / "bundle.yaml"

await model.deploy('juju-qa-bundle-test', overlays=[overlay_path])
# juju-qa-bundle-test installs the applications
# - juju-qa-test
# - juju-qa-test-focal
# - ntp
# - ntp-focal
await model.deploy(bundle_path, overlays=[overlay_path])

# our overlay requests to remove ntp and add ghost and mysql
# our overlay requests to remove ntp and add mysql
# and relate them, so
assert 'juju-qa-test' in model.applications
assert 'ntp' not in model.applications
assert 'ghost' in model.applications
assert 'nrpe' not in model.applications
assert 'mysql' in model.applications


Expand All @@ -301,9 +295,12 @@ async def test_deploy_bundle_with_overlay_as_argument():
async def test_deploy_bundle_with_multi_overlay_as_argument():
async with base.CleanModel() as model:
overlay_path = OVERLAYS_DIR / 'test-multi-overlay.yaml'
bundle_path = TESTS_DIR / "bundle" / "bundle.yaml"

await model.deploy(bundle_path, overlays=[overlay_path])

await model.deploy('juju-qa-bundle-test', overlays=[overlay_path])
assert 'ntp' not in model.applications
assert 'juju-qa-test' in model.applications
assert 'nrpe' not in model.applications
assert 'memcached' not in model.applications
assert 'mysql' in model.applications

Expand All @@ -321,7 +318,7 @@ async def test_deploy_bundle_with_multiple_overlays_with_include_files():
assert 'influxdb' not in model.applications
assert 'test' not in model.applications
assert 'memcached' not in model.applications
assert 'grafana' in model.applications
assert 'juju-qa-test' in model.applications


@base.bootstrapped
Expand Down
Loading