diff --git a/charm/tests/conftest.py b/charm/tests/conftest.py index 1f6c327..4c33309 100644 --- a/charm/tests/conftest.py +++ b/charm/tests/conftest.py @@ -59,14 +59,36 @@ def services(juju: jubilant.Juju) -> None: juju.deploy("rabbitmq-server") juju.deploy(charm="ubuntu", app="swift") + # Swift is ready first + juju.wait(lambda status: jubilant.all_active(status, "swift"), timeout=600) + juju.exec("sudo", "apt-get", "install", "-Uy", "docker.io", unit="swift/0") + juju.exec( + "docker", + "run", + "--name", + "swift", + "--network", + "host", + "--rm", + "-d", + "docker.io/openstackswift/saio", + unit="swift/0", + ) -@pytest.fixture -def cassandra(juju: jubilant.Juju, services) -> dict[str, str]: + # Then comes RabbitMQ + juju.wait(lambda status: jubilant.all_active(status, "rabbitmq-server"), timeout=600) + # Useful to push arbitrary messages in test cases. + juju.exec("sudo", "apt-get", "install", "-y", "amqp-tools", unit="rabbitmq-server/0") + + # Make sure everything is ready juju.wait( - lambda status: jubilant.all_active(status, "cassandra"), + lambda status: jubilant.all_active(status, "cassandra", "rabbitmq-server", "swift"), timeout=900, ) + +@pytest.fixture +def cassandra(juju: jubilant.Juju, services) -> dict[str, str]: # Get Cassandra credentials task = juju.exec("cat", "/home/ubuntu/.cassandra/cqlshrc", unit="cassandra/0") logger.info("Cassandra config: " + task.stdout) @@ -81,16 +103,9 @@ def cassandra(juju: jubilant.Juju, services) -> dict[str, str]: @pytest.fixture def amqp(juju: jubilant.Juju, services) -> dict[str, str]: - juju.wait( - lambda status: jubilant.all_active(status, "rabbitmq-server"), - timeout=600, - ) amqp_host = juju.status().get_units("rabbitmq-server")["rabbitmq-server/0"].public_address logger.info("RabbitMQ address: " + amqp_host) - # Useful to push arbitrary messages in test cases. - juju.exec("sudo", "apt-get", "install", "-y", "amqp-tools", unit="rabbitmq-server/0") - # Set up rabbitmq test user juju.exec("sudo", "rabbitmqctl", "add_user", "test", "test", unit="rabbitmq-server/0") juju.exec( @@ -118,26 +133,9 @@ def amqp(juju: jubilant.Juju, services) -> dict[str, str]: @pytest.fixture def swift(juju: jubilant.Juju, services) -> dict[str, str]: - juju.wait( - lambda status: jubilant.all_active(status, "swift"), - timeout=600, - ) swift_host = juju.status().get_units("swift")["swift/0"].public_address logger.info("swift address: " + swift_host) - juju.exec("sudo", "apt-get", "install", "-Uy", "docker.io", unit="swift/0") - juju.exec( - "docker", - "run", - "--name", - "swift", - "--network", - "host", - "--rm", - "-d", - "docker.io/openstackswift/saio", - unit="swift/0", - ) return { "auth_url": f"http://{swift_host}:8080/auth/v1.0", "username": "test:tester", diff --git a/charm/tests/integration/test_daisy.py b/charm/tests/integration/test_daisy.py index dffc1e7..619d867 100644 --- a/charm/tests/integration/test_daisy.py +++ b/charm/tests/integration/test_daisy.py @@ -21,6 +21,10 @@ def test_deploy( error_tracker_config: str, charm_path: str, ): + """ + Deploy everything at once, but don't integrate anything. This is just to + speed up CI by parallelizing deployment. + """ juju.deploy( charm=charm_path, app="daisy", @@ -33,6 +37,8 @@ def test_deploy( "enable_errors": False, }, ) + juju.deploy(HAPROXY, channel="2.8/edge", config={"external-hostname": "haproxy.internal"}) + juju.deploy(SSC, channel="1/edge") juju.wait(lambda status: jubilant.all_active(status, "daisy"), timeout=600) @@ -40,9 +46,6 @@ def test_deploy( def test_http(juju: jubilant.Juju): - juju.deploy(HAPROXY, channel="2.8/edge", config={"external-hostname": "haproxy.internal"}) - juju.deploy(SSC, channel="1/edge") - juju.integrate(HAPROXY + ":certificates", SSC + ":certificates") juju.integrate("daisy:route_daisy", HAPROXY) juju.wait(lambda status: jubilant.all_active(status, HAPROXY, SSC), timeout=1800) diff --git a/charm/tests/integration/test_errors.py b/charm/tests/integration/test_errors.py index ec97c56..aa90b73 100644 --- a/charm/tests/integration/test_errors.py +++ b/charm/tests/integration/test_errors.py @@ -21,6 +21,10 @@ def test_deploy( error_tracker_config: str, charm_path: str, ): + """ + Deploy everything at once, but don't integrate anything. This is just to + speed up CI by parallelizing deployment. + """ juju.deploy( charm=charm_path, app="errors", @@ -33,6 +37,8 @@ def test_deploy( "enable_errors": True, }, ) + juju.deploy(HAPROXY, channel="2.8/edge", config={"external-hostname": "haproxy.internal"}) + juju.deploy(SSC, channel="1/edge") juju.wait(lambda status: jubilant.all_active(status, "errors"), timeout=600) @@ -40,9 +46,6 @@ def test_deploy( def test_http(juju: jubilant.Juju): - juju.deploy(HAPROXY, channel="2.8/edge", config={"external-hostname": "haproxy.internal"}) - juju.deploy(SSC, channel="1/edge") - juju.integrate(HAPROXY + ":certificates", SSC + ":certificates") juju.integrate("errors:route_errors", HAPROXY) juju.wait(lambda status: jubilant.all_active(status, HAPROXY, SSC), timeout=1800)