Fix minor typo in Dockerfiles
[osm/devops.git] / installers / charm / osm-update-db-operator / tests / integration / test_charm.py
1 # Copyright 2022 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 import base64
16 import logging
17 from pathlib import Path
18
19 import pytest
20 import yaml
21 from pytest_operator.plugin import OpsTest
22
23 logger = logging.getLogger(__name__)
24
25 METADATA = yaml.safe_load(Path("./metadata.yaml").read_text())
26
27
28 @pytest.mark.abort_on_fail
29 async def test_build_and_deploy(ops_test: OpsTest):
30 """Build the charm-under-test and deploy it together with related charms.
31
32 Assert on the unit status before any relations/configurations take place.
33 """
34 await ops_test.model.set_config({"update-status-hook-interval": "10s"})
35 # build and deploy charm from local source folder
36 charm = await ops_test.build_charm(".")
37 resources = {
38 "update-db-image": METADATA["resources"]["update-db-image"]["upstream-source"],
39 }
40 await ops_test.model.deploy(charm, resources=resources, application_name="update-db")
41 await ops_test.model.wait_for_idle(apps=["update-db"], status="active", timeout=1000)
42 assert ops_test.model.applications["update-db"].units[0].workload_status == "active"
43
44 await ops_test.model.set_config({"update-status-hook-interval": "60m"})
45
46
47 def base64_encode(phrase: str) -> str:
48 return base64.b64encode(phrase.encode("utf-8")).decode("utf-8")