Skip to content

Commit

Permalink
ci: Try to debug CI error
Browse files Browse the repository at this point in the history
  • Loading branch information
jneo8 committed Oct 23, 2023
1 parent 746e227 commit 4934f20
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 44 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@ jobs:
tox-version: "<4"

func:
uses: canonical/bootstack-actions/.github/workflows/func.yaml@v2
uses: jneo8/bootstack-actions/.github/workflows/func.yaml@v3
needs: lint-unit
strategy:
fail-fast: false
matrix:
include:
- juju-channel: "2.9/stable"
command: "make functional"
- juju-channel: "3.1/stable"
command: "make functional31"
with:
Expand Down
12 changes: 1 addition & 11 deletions tests/functional/bundle.yaml.j2
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
# Test basic deployment:
# ubuntu:juju-info <-> grafana-agent:juju-info
# ubuntu:juju-info <-> hardware-observer:general-info
# grafana-agent:cos-agent <-> hardware-observer:cos-agent

series: {{ series }}

machines:
"0":

applications:
ubuntu:
charm: ubuntu
num_units: 1
to:
- "0"
grafana-agent:
charm: grafana-agent
channel: edge # FIXME: currently no stable release
channel: edge
hardware-observer:
charm: {{ charm }}

Expand Down
78 changes: 48 additions & 30 deletions tests/functional/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
# See LICENSE file for licensing details.

import asyncio
import inspect
import logging
import os
from enum import Enum
from pathlib import Path

Expand All @@ -21,6 +23,12 @@
TIMEOUT = 600


def get_this_script_dir() -> Path:
filename = inspect.getframeinfo(inspect.currentframe()).filename # type: ignore[arg-type]
path = os.path.dirname(os.path.abspath(filename))
return Path(path)


class AppStatus(str, Enum):
"""Various workload status messages for the app."""

Expand All @@ -43,40 +51,50 @@ async def test_build_and_deploy(ops_test: OpsTest, series, sync_helper):
charm = await ops_test.build_charm(".")
assert charm, "Charm was not built successfully."

await asyncio.gather(
ops_test.model.deploy(
ops_test.render_bundle(
"tests/functional/bundle.yaml.j2",
charm=charm,
series=series,
resources={
"storcli-deb": "empty-resource",
"perccli-deb": "empty-resource",
"sas2ircu-bin": "empty-resource",
"sas3ircu-bin": "empty-resource",
},
)
),
ops_test.model.wait_for_idle(
apps=[APP_NAME],
status="blocked",
timeout=TIMEOUT,
),
ops_test.model.wait_for_idle(
apps=[GRAFANA_AGENT_APP_NAME],
status="blocked",
timeout=TIMEOUT,
),
ops_test.model.wait_for_idle(
apps=[PRINCIPAL_APP_NAME],
status="active",
raise_on_blocked=True,
timeout=TIMEOUT,
),
bundle_template_path = get_this_script_dir() / "bundle.yaml.j2"

logger.info("Rendering bundle %s", bundle_template_path)
bundle = ops_test.render_bundle(
bundle_template_path,
charm=charm,
series=series,
resources={
"storcli-deb": "empty-resource",
"perccli-deb": "empty-resource",
"sas2ircu-bin": "empty-resource",
"sas3ircu-bin": "empty-resource",
},
)
with open(bundle, "r") as f:
print(f.read())

await ops_test.model.deploy("ubuntu"),
await ops_test.model.deploy(bundle),
await ops_test.model.wait_for_idle(
apps=[PRINCIPAL_APP_NAME],
status="active",
raise_on_blocked=True,
timeout=TIMEOUT,
)
await ops_test.model.wait_for_idle(
apps=[GRAFANA_AGENT_APP_NAME],
status="blocked",
timeout=TIMEOUT,
)
await ops_test.model.wait_for_idle(
apps=[APP_NAME],
status="blocked",
timeout=TIMEOUT,
)

for unit in ops_test.model.applications[GRAFANA_AGENT_APP_NAME].units:
logger.debug(unit.workload_status_message)
logger.debug(unit.workload_status)

# Test initial workload status
for unit in ops_test.model.applications[APP_NAME].units:
logger.debug(unit.workload_status_message)
logger.debug(unit.workload_status)
assert AppStatus.MISSING_RESOURCES not in unit.workload_status_message
assert unit.workload_status_message == AppStatus.MISSING_RELATION

Expand Down

0 comments on commit 4934f20

Please sign in to comment.