Skip to content
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
52 changes: 25 additions & 27 deletions charm/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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(
Expand Down Expand Up @@ -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",
Expand Down
9 changes: 6 additions & 3 deletions charm/tests/integration/test_daisy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -33,16 +37,15 @@ 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)

check_config(juju, amqp, cassandra, swift, "daisy/0")


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)
Expand Down
9 changes: 6 additions & 3 deletions charm/tests/integration/test_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -33,16 +37,15 @@ 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)

check_config(juju, amqp, cassandra, swift, "errors/0")


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)
Expand Down
Loading