Skip to content

Commit

Permalink
Deploy with the default resource when deploying with a local charm
Browse files Browse the repository at this point in the history
  • Loading branch information
addyess committed Sep 20, 2024
1 parent c2bc40e commit beca4c6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ header:
- 'charms/worker/k8s/lib/charms/k8s/**'
paths-ignore:
- 'charms/worker/k8s/lib/charms/**'
- 'tests/integration/data/*.tar.gz'
- '.github/**'
- '**/.gitkeep'
- '**/*.cfg'
Expand Down
10 changes: 7 additions & 3 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
from .helpers import get_unit_cidrs, is_deployed

log = logging.getLogger(__name__)
TEST_DATA = Path(__file__).parent / "data"
DEFAULT_SNAP_INSTALLATION = TEST_DATA / "default-snap-installation.tar.gz"


def pytest_addoption(parser: pytest.Parser):
Expand Down Expand Up @@ -183,6 +185,7 @@ def switch(self, name: str, path: Optional[Path] = None, channel: Optional[str]
if path:
app["charm"] = str(path.resolve())
app["channel"] = None
app["resources"] = {"snap-installation": DEFAULT_SNAP_INSTALLATION}
if channel:
app["charm"] = name
app["channel"] = channel
Expand Down Expand Up @@ -220,7 +223,7 @@ async def cloud_proxied(ops_test: OpsTest):
assert ops_test.model, "Model must be present"
controller = await ops_test.model.get_controller()
controller_model = await controller.get_model("controller")
proxy_config_file = Path(__file__).parent / "data" / "static-proxy-config.yaml"
proxy_config_file = TEST_DATA / "static-proxy-config.yaml"
proxy_configs = yaml.safe_load(proxy_config_file.read_text())
local_no_proxy = await get_unit_cidrs(controller_model, "controller", 0)
no_proxy = {*proxy_configs["juju-no-proxy"], *local_no_proxy}
Expand Down Expand Up @@ -296,7 +299,7 @@ async def kubernetes_cluster(request: pytest.FixtureRequest, ops_test: OpsTest):
bundle_marker = request.node.get_closest_marker("bundle_file")
if bundle_marker:
bundle_file = bundle_marker.args[0]
bundle_path = Path(__file__).parent / "data" / bundle_file
bundle_path = TEST_DATA / bundle_file
model = "main"

with ops_test.model_context(model) as the_model:
Expand Down Expand Up @@ -346,7 +349,8 @@ async def _refresh(app_name: str):
app_name: Name of the application to refresh
"""
app: Application = model.applications[app_name]
await app.refresh(path=switch_to_path[app_name])
resources = {"snap-installation": DEFAULT_SNAP_INSTALLATION}
await app.refresh(path=switch_to_path[app_name], resources=resources)

await asyncio.gather(*[_refresh(app) for app in switch_to_path])
await model.wait_for_idle(
Expand Down

0 comments on commit beca4c6

Please sign in to comment.