Add Keystone charm
[osm/devops.git] / installers / charm / osm-keystone / tests / integration / test_charm.py
1 # Copyright 2021 Canonical Ltd.
2 #
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
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
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
13 # under the License.
14 #
15 # For those usages not covered by the Apache License, Version 2.0 please
16 # contact: legal@canonical.com
17 #
18
19 import logging
20 from pathlib import Path
21
22 import pytest
23 import yaml
24 from pytest_operator.plugin import OpsTest
25
26 logger = logging.getLogger(__name__)
27
28 METADATA = yaml.safe_load(Path("./metadata.yaml").read_text())
29
30
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.
34
35 Assert on the unit status before any relations/configurations take place.
36 """
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(".")
41 resources = {
42 "keystone-image": METADATA["resources"]["keystone-image"]["upstream-source"],
43 }
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
48 )
49 assert ops_test.model.applications["keystone"].units[0].workload_status == "active"
50
51 await ops_test.model.set_config({"update-status-hook-interval": "60m"})