1 # Copyright 2021 Canonical Ltd.
3 # Licensed under the Apache License, Version 2.0 (the "License"); you may
4 # not use this file except in compliance with the License. You may obtain
5 # a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 # License for the specific language governing permissions and limitations
15 # For those usages not covered by the Apache License, Version 2.0 please
16 # contact: legal@canonical.com
20 from pathlib
import Path
24 from pytest_operator
.plugin
import OpsTest
26 logger
= logging
.getLogger(__name__
)
28 METADATA
= yaml
.safe_load(Path("./metadata.yaml").read_text())
31 @pytest.mark
.abort_on_fail
32 async def test_build_and_deploy(ops_test
: OpsTest
):
33 """Build the charm-under-test and deploy it together with related charms.
35 Assert on the unit status before any relations/configurations take place.
37 await ops_test
.model
.set_config({"update-status-hook-interval": "10s"})
38 await ops_test
.model
.deploy("charmed-osm-mariadb-k8s", application_name
="mariadb-k8s")
39 # build and deploy charm from local source folder
40 charm
= await ops_test
.build_charm(".")
42 "keystone-image": METADATA
["resources"]["keystone-image"]["upstream-source"],
44 await ops_test
.model
.deploy(charm
, resources
=resources
, application_name
="keystone")
45 await ops_test
.model
.add_relation("keystone:db", "mariadb-k8s:mysql")
46 await ops_test
.model
.wait_for_idle(
47 apps
=["keystone", "mariadb-k8s"], status
="active", timeout
=1000
49 assert ops_test
.model
.applications
["keystone"].units
[0].workload_status
== "active"
51 await ops_test
.model
.set_config({"update-status-hook-interval": "60m"})