diff --git a/.github/workflows/integration_tests.yaml b/.github/workflows/integration_tests.yaml index 3934236bf..165452290 100644 --- a/.github/workflows/integration_tests.yaml +++ b/.github/workflows/integration_tests.yaml @@ -13,7 +13,7 @@ jobs: pre-run-script: scripts/pre-integration-test.sh provider: lxd test-tox-env: integration-juju2.9 - modules: '["test_charm_fork_repo", "test_charm_no_runner", "test_charm_scheduled_events", "test_charm_one_runner", "test_charm_metrics", "test_self_hosted_runner"]' + modules: '["test_charm_fork_repo", "test_charm_no_runner", "test_charm_scheduled_events", "test_charm_one_runner", "test_charm_metrics", "test_self_hosted_runner", "test_charm_with_proxy"]' integration-tests-juju3: name: Integration test with juju 3.1 uses: canonical/operator-workflows/.github/workflows/integration_test.yaml@main @@ -23,4 +23,4 @@ jobs: pre-run-script: scripts/pre-integration-test.sh provider: lxd test-tox-env: integration-juju3.1 - modules: '["test_charm_fork_repo", "test_charm_no_runner", "test_charm_scheduled_events", "test_charm_one_runner", "test_charm_metrics", "test_self_hosted_runner"]' + modules: '["test_charm_fork_repo", "test_charm_no_runner", "test_charm_scheduled_events", "test_charm_one_runner", "test_charm_metrics", "test_self_hosted_runner", "test_charm_with_proxy"]' diff --git a/tests/integration/test_charm_one_runner.py b/tests/integration/test_charm_one_runner.py index e60ef4f31..dcc033b4d 100644 --- a/tests/integration/test_charm_one_runner.py +++ b/tests/integration/test_charm_one_runner.py @@ -10,7 +10,6 @@ from charm import GithubRunnerCharm from tests.integration.helpers import ( assert_resource_lxd_profile, - ensure_charm_has_runner, get_runner_names, reconcile, run_in_lxd_instance, @@ -50,35 +49,6 @@ async def test_network_access(app: Application) -> None: assert stdout is None -@pytest.mark.asyncio -@pytest.mark.abort_on_fail -async def test_usage_of_aproxy(model: Model, app_no_runner: Application, squid_proxy: str) -> None: - """ - arrange: A working application with one runner using aproxy configured for a proxy server. - act: Run curl in the runner. - assert: The aproxy log contains the request. - """ - app = app_no_runner # Rename to make it clear that the app will contain a runner. - unit = app.units[0] - - await app.set_config({"aproxy-address": squid_proxy}) - await ensure_charm_has_runner(app, model) - - names = await get_runner_names(unit) - assert names - runner_name = names[0] - - return_code, stdout = await run_in_lxd_instance(unit, runner_name, "curl http://canonical.com") - assert return_code == 0 - - return_code, stdout = await run_in_lxd_instance( - unit, runner_name, "snap logs aproxy.aproxy -n=all" - ) - assert return_code == 0 - assert stdout is not None - assert "canonical.com" in stdout - - @pytest.mark.asyncio @pytest.mark.abort_on_fail async def test_flush_runner_and_resource_config(app: Application) -> None: diff --git a/tests/integration/test_charm_with_proxy.py b/tests/integration/test_charm_with_proxy.py new file mode 100644 index 000000000..0b968303c --- /dev/null +++ b/tests/integration/test_charm_with_proxy.py @@ -0,0 +1,42 @@ +# Copyright 2023 Canonical Ltd. +# See LICENSE file for licensing details. + +"""Test the usage of a proxy server.""" +import pytest +from juju.application import Application +from juju.model import Model + +from tests.integration.helpers import ( + ensure_charm_has_runner, + get_runner_names, + run_in_lxd_instance, +) + + +@pytest.mark.asyncio +@pytest.mark.abort_on_fail +async def test_usage_of_aproxy(model: Model, app_no_runner: Application, squid_proxy: str) -> None: + """ + arrange: A working application with one runner using aproxy configured for a proxy server. + act: Run curl in the runner. + assert: The aproxy log contains the request. + """ + app = app_no_runner # Rename to make it clear that the app will contain a runner. + unit = app.units[0] + + await app.set_config({"aproxy-address": squid_proxy}) + await ensure_charm_has_runner(app, model) + + names = await get_runner_names(unit) + assert names + runner_name = names[0] + + return_code, stdout = await run_in_lxd_instance(unit, runner_name, "curl http://canonical.com") + assert return_code == 0 + + return_code, stdout = await run_in_lxd_instance( + unit, runner_name, "snap logs aproxy.aproxy -n=all" + ) + assert return_code == 0 + assert stdout is not None + assert "canonical.com" in stdout