Skip to content

Commit

Permalink
fix: juju 3.1 compatible cos stack (#70)
Browse files Browse the repository at this point in the history
* fix: juju 2.9 compatible cos stack

* fix: use model

* fix: cos stack revisions to juju 2.9 compatible

* fix: juju lib version to 2.9 compatible libs

* chore: add json schema pkg dep for ingress lib

* chore: remove jsonschema dependency that cannot be built by charmcraft

* fix: update updated juju lib syntax

* fix: juju 3.1 based jenkins

* chore: use strict microk8s for juju 3.1

* chore: update microk8s group to snap mk8s group

* test: fix jenkins auto update test fix for juju 3.1

* ci: update microk8s version
  • Loading branch information
yanksyoon authored Nov 28, 2023
1 parent 3e4c253 commit 2f48e63
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 32 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/integration_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ jobs:
uses: canonical/operator-workflows/.github/workflows/integration_test.yaml@main
secrets: inherit
with:
channel: 1.28-strict/stable
extra-arguments: |
--kube-config ${GITHUB_WORKSPACE}/kube-config
modules: '["test_jenkins.py", "test_k8s_agent.py", "test_machine_agent.py", "test_plugins.py", "test_proxy.py", "test_cos.py"]'
pre-run-script: |
-c "sudo microk8s config > ${GITHUB_WORKSPACE}/kube-config
chmod +x tests/integration/pre_run_script.sh
./tests/integration/pre_run_script.sh"
extra-arguments: |
--kube-config ${GITHUB_WORKSPACE}/kube-config
modules: '["test_jenkins.py", "test_k8s_agent.py", "test_machine_agent.py", "test_plugins.py", "test_proxy.py", "test_cos.py"]'

juju-channel: 3.1/stable
34 changes: 17 additions & 17 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ async def jenkins_k8s_agents_fixture(

yield agent_app

await model.remove_application(agent_app.name, block_until_done=True, force=True)
await model.remove_application(agent_app.name, block_until_done=True)


@pytest_asyncio.fixture(scope="function", name="k8s_agent_related_app")
Expand Down Expand Up @@ -474,7 +474,7 @@ async def jenkins_with_proxy_fixture(
async with ops_test.fast_forward(fast_interval="5h"):
yield application

await model_with_proxy.remove_application(application.name, force=True, block_until_done=True)
await model_with_proxy.remove_application(application.name, block_until_done=True)


@pytest_asyncio.fixture(scope="module", name="proxy_jenkins_unit_ip")
Expand Down Expand Up @@ -589,14 +589,14 @@ async def ldap_server_ip_fixture(


@pytest_asyncio.fixture(scope="module", name="prometheus_related")
async def prometheus_related_fixture(application: Application):
async def prometheus_related_fixture(application: Application, model: Model):
"""The prometheus-k8s application related to Jenkins via metrics-endpoint relation."""
prometheus = await application.model.deploy("prometheus-k8s", channel="1.0/stable", trust=True)
await application.model.wait_for_idle(
prometheus = await model.deploy("prometheus-k8s", channel="1.0/stable", trust=True)
await model.wait_for_idle(
status="active", apps=[prometheus.name], raise_on_error=False, timeout=30 * 60
)
await application.model.add_relation(f"{application.name}:metrics-endpoint", prometheus.name)
await application.model.wait_for_idle(
await model.add_relation(f"{application.name}:metrics-endpoint", prometheus.name)
await model.wait_for_idle(
status="active",
apps=[prometheus.name, application.name],
timeout=20 * 60,
Expand All @@ -607,14 +607,14 @@ async def prometheus_related_fixture(application: Application):


@pytest_asyncio.fixture(scope="module", name="loki_related")
async def loki_related_fixture(application: Application):
async def loki_related_fixture(application: Application, model: Model):
"""The loki-k8s application related to Jenkins via logging relation."""
loki = await application.model.deploy("loki-k8s", channel="1.0/stable", trust=True)
await application.model.wait_for_idle(
loki = await model.deploy("loki-k8s", channel="1.0/stable", trust=True)
await model.wait_for_idle(
status="active", apps=[loki.name], raise_on_error=False, timeout=30 * 60
)
await application.model.add_relation(f"{application.name}:logging", loki.name)
await application.model.wait_for_idle(
await model.add_relation(f"{application.name}:logging", loki.name)
await model.wait_for_idle(
status="active",
apps=[loki.name, application.name],
timeout=20 * 60,
Expand All @@ -625,14 +625,14 @@ async def loki_related_fixture(application: Application):


@pytest_asyncio.fixture(scope="module", name="grafana_related")
async def grafana_related_fixture(application: Application):
async def grafana_related_fixture(application: Application, model: Model):
"""The grafana-k8s application related to Jenkins via grafana-dashboard relation."""
grafana = await application.model.deploy("grafana-k8s", channel="1.0/stable", trust=True)
await application.model.wait_for_idle(
grafana = await model.deploy("grafana-k8s", channel="1.0/stable", trust=True)
await model.wait_for_idle(
status="active", apps=[grafana.name], raise_on_error=False, timeout=30 * 60
)
await application.model.add_relation(f"{application.name}:grafana-dashboard", grafana.name)
await application.model.wait_for_idle(
await model.add_relation(f"{application.name}:grafana-dashboard", grafana.name)
await model.wait_for_idle(
status="active",
apps=[grafana.name, application.name],
timeout=20 * 60,
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/pre_run_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ TESTING_MODEL="$(juju switch)"

# lxd should be install and init by a previous step in integration test action.
echo "bootstrapping lxd juju controller"
sg microk8s -c "microk8s status --wait-ready"
sg microk8s -c "juju bootstrap localhost localhost"
sg snap_microk8s -c "microk8s status --wait-ready"
sg snap_microk8s -c "juju bootstrap localhost localhost"

echo "Switching to testing model"
sg microk8s -c "juju switch $TESTING_MODEL"
sg snap_microk8s -c "juju switch $TESTING_MODEL"
14 changes: 7 additions & 7 deletions tests/integration/test_jenkins.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ async def test_jenkins_automatic_update_out_of_range(
"""
extra_plugin = "oic-auth"
await install_plugins(ops_test, unit_web_client.unit, unit_web_client.client, (extra_plugin,))
ret_code, _, stderr = await ops_test.juju(
"run",
"--unit",
unit_web_client.unit.name,
"--",
f"{' '.join(libfaketime_env)} {' '.join(update_status_env)} ./dispatch",
action: Action = await unit_web_client.unit.run(
f"-- {' '.join(libfaketime_env)} {' '.join(update_status_env)} ./dispatch"
)
assert not ret_code, f"Failed to execute update-status-hook, {stderr}"
await action.wait()
assert (
action.status == "completed"
), f"Failed to execute update-status-hook, {action.data['message']}"

assert unit_web_client.client.has_plugin(
extra_plugin
), "additionally installed plugin cleanedup."
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ commands =
description = Run integration tests
deps =
pytest
juju==3.0.4
juju>=3,<4
ops
pytest-operator
pytest-asyncio
Expand Down

0 comments on commit 2f48e63

Please sign in to comment.