From: sousaedu Date: Tue, 17 Nov 2020 14:30:47 +0000 (+0000) Subject: Updating unit tests for NBI charm X-Git-Tag: release-v9.0-start~38 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F98%2F9998%2F3;p=osm%2Fdevops.git Updating unit tests for NBI charm Change-Id: I21f92498364691c225164faa580788e07e133f47 Signed-off-by: sousaedu --- diff --git a/installers/charm/nbi/src/charm.py b/installers/charm/nbi/src/charm.py index 7ef9d59e..3970a33d 100755 --- a/installers/charm/nbi/src/charm.py +++ b/installers/charm/nbi/src/charm.py @@ -32,7 +32,7 @@ from oci_image import OCIImageResource, OCIImageResourceError from pod_spec import make_pod_spec -LOGGER = logging.getLogger(__name__) +logger = logging.getLogger(__name__) NBI_PORT = 9999 @@ -130,8 +130,10 @@ class NbiCharm(CharmBase): Args: event (EventBase): Kafka relation event. """ - message_host = event.relation.data[event.unit].get("host") - message_port = event.relation.data[event.unit].get("port") + data_loc = event.unit if event.unit else event.app + + message_host = event.relation.data[data_loc].get("host") + message_port = event.relation.data[data_loc].get("port") if ( message_host @@ -161,7 +163,9 @@ class NbiCharm(CharmBase): Args: event (EventBase): DB relation event. """ - database_uri = event.relation.data[event.unit].get("connection_string") + data_loc = event.unit if event.unit else event.app + + database_uri = event.relation.data[data_loc].get("connection_string") if database_uri and self.state.database_uri != database_uri: self.state.database_uri = database_uri @@ -182,17 +186,19 @@ class NbiCharm(CharmBase): Args: event (EventBase): Keystone relation event. """ - keystone_host = event.relation.data[event.unit].get("host") - keystone_port = event.relation.data[event.unit].get("port") - keystone_user_domain_name = event.relation.data[event.unit].get( + data_loc = event.unit if event.unit else event.app + + keystone_host = event.relation.data[data_loc].get("host") + keystone_port = event.relation.data[data_loc].get("port") + keystone_user_domain_name = event.relation.data[data_loc].get( "user_domain_name" ) - keystone_project_domain_name = event.relation.data[event.unit].get( + keystone_project_domain_name = event.relation.data[data_loc].get( "project_domain_name" ) - keystone_username = event.relation.data[event.unit].get("username") - keystone_password = event.relation.data[event.unit].get("password") - keystone_service = event.relation.data[event.unit].get("service") + keystone_username = event.relation.data[data_loc].get("username") + keystone_password = event.relation.data[data_loc].get("password") + keystone_service = event.relation.data[data_loc].get("service") if ( keystone_host @@ -243,8 +249,10 @@ class NbiCharm(CharmBase): Args: event (EventBase): Prometheus relation event. """ - prometheus_host = event.relation.data[event.unit].get("hostname") - prometheus_port = event.relation.data[event.unit].get("port") + data_loc = event.unit if event.unit else event.app + + prometheus_host = event.relation.data[data_loc].get("hostname") + prometheus_port = event.relation.data[data_loc].get("port") if ( prometheus_host @@ -367,7 +375,7 @@ class NbiCharm(CharmBase): self.port, ) except ValidationError as exc: - LOGGER.exception("Config/Relation data validation error") + logger.exception("Config/Relation data validation error") self.unit.status = BlockedStatus(str(exc)) return diff --git a/installers/charm/nbi/src/pod_spec.py b/installers/charm/nbi/src/pod_spec.py index 105e8779..68915ded 100644 --- a/installers/charm/nbi/src/pod_spec.py +++ b/installers/charm/nbi/src/pod_spec.py @@ -28,7 +28,6 @@ from pydantic import ( IPvAnyNetwork, PositiveInt, validator, - ValidationError, ) from typing import Any, Dict, List, Optional from urllib.parse import urlparse @@ -78,7 +77,7 @@ class RelationData(BaseModel): message_host: str message_port: PositiveInt - database_uri: constr(regex=r"^(mongo://)") + database_uri: constr(regex=r"^(mongodb://)") prometheus_host: str prometheus_port: PositiveInt keystone: bool diff --git a/installers/charm/nbi/tests/test_charm.py b/installers/charm/nbi/tests/test_charm.py index d1d24135..0df8e836 100644 --- a/installers/charm/nbi/tests/test_charm.py +++ b/installers/charm/nbi/tests/test_charm.py @@ -100,12 +100,12 @@ class TestCharm(unittest.TestCase): "OSMNBI_MESSAGE_DRIVER": "kafka", "OSMNBI_MESSAGE_PORT": 9092, "OSMNBI_DATABASE_DRIVER": "mongo", - "OSMNBI_DATABASE_URI": "mongo://mongo:27017", + "OSMNBI_DATABASE_URI": "mongodb://mongo:27017", "OSMNBI_DATABASE_COMMONKEY": "osm", "OSMNBI_STORAGE_DRIVER": "mongo", "OSMNBI_STORAGE_PATH": "/app/storage", "OSMNBI_STORAGE_COLLECTION": "files", - "OSMNBI_STORAGE_URI": "mongo://mongo:27017", + "OSMNBI_STORAGE_URI": "mongodb://mongo:27017", "OSMNBI_PROMETHEUS_HOST": "prometheus", "OSMNBI_PROMETHEUS_PORT": 9090, "OSMNBI_LOG_LEVEL": "INFO", @@ -144,7 +144,7 @@ class TestCharm(unittest.TestCase): self.harness.update_relation_data( mongodb_relation_id, "mongodb/0", - {"connection_string": "mongo://mongo:27017"}, + {"connection_string": "mongodb://mongo:27017"}, ) # Initializing the prometheus relation @@ -161,7 +161,7 @@ class TestCharm(unittest.TestCase): self.assertEqual(self.harness.charm.state.message_port, 9092) # Checking if mongodb data is stored - self.assertEqual(self.harness.charm.state.database_uri, "mongo://mongo:27017") + self.assertEqual(self.harness.charm.state.database_uri, "mongodb://mongo:27017") # Checking if prometheus data is stored self.assertEqual(self.harness.charm.state.prometheus_host, "prometheus") @@ -198,12 +198,12 @@ class TestCharm(unittest.TestCase): "OSMNBI_MESSAGE_DRIVER": "kafka", "OSMNBI_MESSAGE_PORT": 9092, "OSMNBI_DATABASE_DRIVER": "mongo", - "OSMNBI_DATABASE_URI": "mongo://mongo:27017", + "OSMNBI_DATABASE_URI": "mongodb://mongo:27017", "OSMNBI_DATABASE_COMMONKEY": "osm", "OSMNBI_STORAGE_DRIVER": "mongo", "OSMNBI_STORAGE_PATH": "/app/storage", "OSMNBI_STORAGE_COLLECTION": "files", - "OSMNBI_STORAGE_URI": "mongo://mongo:27017", + "OSMNBI_STORAGE_URI": "mongodb://mongo:27017", "OSMNBI_PROMETHEUS_HOST": "prometheus", "OSMNBI_PROMETHEUS_PORT": 9090, "OSMNBI_LOG_LEVEL": "INFO", @@ -260,7 +260,7 @@ class TestCharm(unittest.TestCase): self.harness.update_relation_data( mongodb_relation_id, "mongodb/0", - {"connection_string": "mongo://mongo:27017"}, + {"connection_string": "mongodb://mongo:27017"}, ) # Initializing the prometheus relation @@ -294,7 +294,7 @@ class TestCharm(unittest.TestCase): self.assertEqual(self.harness.charm.state.message_port, 9092) # Checking if mongodb data is stored - self.assertEqual(self.harness.charm.state.database_uri, "mongo://mongo:27017") + self.assertEqual(self.harness.charm.state.database_uri, "mongodb://mongo:27017") # Checking if prometheus data is stored self.assertEqual(self.harness.charm.state.prometheus_host, "prometheus") @@ -342,12 +342,12 @@ class TestCharm(unittest.TestCase): "OSMNBI_MESSAGE_DRIVER": "kafka", "OSMNBI_MESSAGE_PORT": 9092, "OSMNBI_DATABASE_DRIVER": "mongo", - "OSMNBI_DATABASE_URI": "mongo://mongo:27017", + "OSMNBI_DATABASE_URI": "mongodb://mongo:27017", "OSMNBI_DATABASE_COMMONKEY": "osm", "OSMNBI_STORAGE_DRIVER": "mongo", "OSMNBI_STORAGE_PATH": "/app/storage", "OSMNBI_STORAGE_COLLECTION": "files", - "OSMNBI_STORAGE_URI": "mongo://mongo:27017", + "OSMNBI_STORAGE_URI": "mongodb://mongo:27017", "OSMNBI_PROMETHEUS_HOST": "prometheus", "OSMNBI_PROMETHEUS_PORT": 9090, "OSMNBI_LOG_LEVEL": "INFO", @@ -375,7 +375,7 @@ class TestCharm(unittest.TestCase): self.harness.update_relation_data( mongodb_relation_id, "mongodb/0", - {"connection_string": "mongo://mongo:27017"}, + {"connection_string": "mongodb://mongo:27017"}, ) # Initializing the prometheus relation @@ -417,12 +417,12 @@ class TestCharm(unittest.TestCase): "OSMNBI_MESSAGE_DRIVER": "kafka", "OSMNBI_MESSAGE_PORT": 9092, "OSMNBI_DATABASE_DRIVER": "mongo", - "OSMNBI_DATABASE_URI": "mongo://mongo:27017", + "OSMNBI_DATABASE_URI": "mongodb://mongo:27017", "OSMNBI_DATABASE_COMMONKEY": "osm", "OSMNBI_STORAGE_DRIVER": "mongo", "OSMNBI_STORAGE_PATH": "/app/storage", "OSMNBI_STORAGE_COLLECTION": "files", - "OSMNBI_STORAGE_URI": "mongo://mongo:27017", + "OSMNBI_STORAGE_URI": "mongodb://mongo:27017", "OSMNBI_PROMETHEUS_HOST": "prometheus", "OSMNBI_PROMETHEUS_PORT": 9090, "OSMNBI_LOG_LEVEL": "INFO", @@ -437,6 +437,7 @@ class TestCharm(unittest.TestCase): "annotations": { "nginx.ingress.kubernetes.io/proxy-body-size": "0", "nginx.ingress.kubernetes.io/ssl-redirect": "false", + "nginx.ingress.kubernetes.io/backend-protocol": "HTTPS", }, "spec": { "rules": [ @@ -476,7 +477,7 @@ class TestCharm(unittest.TestCase): self.harness.update_relation_data( mongodb_relation_id, "mongodb/0", - {"connection_string": "mongo://mongo:27017"}, + {"connection_string": "mongodb://mongo:27017"}, ) # Initializing the prometheus relation @@ -518,12 +519,12 @@ class TestCharm(unittest.TestCase): "OSMNBI_MESSAGE_DRIVER": "kafka", "OSMNBI_MESSAGE_PORT": 9092, "OSMNBI_DATABASE_DRIVER": "mongo", - "OSMNBI_DATABASE_URI": "mongo://mongo:27017", + "OSMNBI_DATABASE_URI": "mongodb://mongo:27017", "OSMNBI_DATABASE_COMMONKEY": "osm", "OSMNBI_STORAGE_DRIVER": "mongo", "OSMNBI_STORAGE_PATH": "/app/storage", "OSMNBI_STORAGE_COLLECTION": "files", - "OSMNBI_STORAGE_URI": "mongo://mongo:27017", + "OSMNBI_STORAGE_URI": "mongodb://mongo:27017", "OSMNBI_PROMETHEUS_HOST": "prometheus", "OSMNBI_PROMETHEUS_PORT": 9090, "OSMNBI_LOG_LEVEL": "INFO", @@ -537,6 +538,7 @@ class TestCharm(unittest.TestCase): "name": "nbi-ingress", "annotations": { "nginx.ingress.kubernetes.io/proxy-body-size": "0", + "nginx.ingress.kubernetes.io/backend-protocol": "HTTPS", }, "spec": { "rules": [ @@ -577,7 +579,7 @@ class TestCharm(unittest.TestCase): self.harness.update_relation_data( mongodb_relation_id, "mongodb/0", - {"connection_string": "mongo://mongo:27017"}, + {"connection_string": "mongodb://mongo:27017"}, ) # Initializing the prometheus relation @@ -621,12 +623,12 @@ class TestCharm(unittest.TestCase): "OSMNBI_MESSAGE_DRIVER": "kafka", "OSMNBI_MESSAGE_PORT": 9092, "OSMNBI_DATABASE_DRIVER": "mongo", - "OSMNBI_DATABASE_URI": "mongo://mongo:27017", + "OSMNBI_DATABASE_URI": "mongodb://mongo:27017", "OSMNBI_DATABASE_COMMONKEY": "osm", "OSMNBI_STORAGE_DRIVER": "mongo", "OSMNBI_STORAGE_PATH": "/app/storage", "OSMNBI_STORAGE_COLLECTION": "files", - "OSMNBI_STORAGE_URI": "mongo://mongo:27017", + "OSMNBI_STORAGE_URI": "mongodb://mongo:27017", "OSMNBI_PROMETHEUS_HOST": "prometheus", "OSMNBI_PROMETHEUS_PORT": 9090, "OSMNBI_LOG_LEVEL": "INFO", @@ -640,6 +642,7 @@ class TestCharm(unittest.TestCase): "name": "nbi-ingress", "annotations": { "nginx.ingress.kubernetes.io/proxy-body-size": "0", + "nginx.ingress.kubernetes.io/backend-protocol": "HTTPS", "nginx.ingress.kubernetes.io/whitelist-source-range": "0.0.0.0/0", }, "spec": { @@ -681,7 +684,7 @@ class TestCharm(unittest.TestCase): self.harness.update_relation_data( mongodb_relation_id, "mongodb/0", - {"connection_string": "mongo://mongo:27017"}, + {"connection_string": "mongodb://mongo:27017"}, ) # Initializing the prometheus relation @@ -705,7 +708,7 @@ class TestCharm(unittest.TestCase): self.assertDictEqual(expected_result, pod_spec) - def test_on_kafka_relation_changed(self) -> NoReturn: + def test_on_kafka_unit_relation_changed(self) -> NoReturn: """Test to see if kafka relation is updated.""" self.harness.charm.on.start.emit() @@ -735,7 +738,37 @@ class TestCharm(unittest.TestCase): self.assertNotIn("keystone", self.harness.charm.unit.status.message) self.assertTrue(self.harness.charm.unit.status.message.endswith(" relations")) - def test_on_mongodb_relation_changed(self) -> NoReturn: + def test_on_kafka_app_relation_changed(self) -> NoReturn: + """Test to see if kafka relation is updated.""" + self.harness.charm.on.start.emit() + + self.assertIsNone(self.harness.charm.state.message_host) + self.assertIsNone(self.harness.charm.state.message_port) + + relation_id = self.harness.add_relation("kafka", "kafka") + self.harness.add_relation_unit(relation_id, "kafka/0") + self.harness.update_relation_data( + relation_id, "kafka", {"host": "kafka", "port": 9092} + ) + + self.assertEqual(self.harness.charm.state.message_host, "kafka") + self.assertEqual(self.harness.charm.state.message_port, 9092) + + # Verifying status + self.assertIsInstance(self.harness.charm.unit.status, BlockedStatus) + + # Verifying status message + self.assertGreater(len(self.harness.charm.unit.status.message), 0) + self.assertTrue( + self.harness.charm.unit.status.message.startswith("Waiting for ") + ) + self.assertNotIn("kafka", self.harness.charm.unit.status.message) + self.assertIn("mongodb", self.harness.charm.unit.status.message) + self.assertIn("prometheus", self.harness.charm.unit.status.message) + self.assertNotIn("keystone", self.harness.charm.unit.status.message) + self.assertTrue(self.harness.charm.unit.status.message.endswith(" relations")) + + def test_on_mongodb_unit_relation_changed(self) -> NoReturn: """Test to see if mongodb relation is updated.""" self.harness.charm.on.start.emit() @@ -744,10 +777,10 @@ class TestCharm(unittest.TestCase): relation_id = self.harness.add_relation("mongodb", "mongodb") self.harness.add_relation_unit(relation_id, "mongodb/0") self.harness.update_relation_data( - relation_id, "mongodb/0", {"connection_string": "mongo://mongo:27017"} + relation_id, "mongodb/0", {"connection_string": "mongodb://mongo:27017"} ) - self.assertEqual(self.harness.charm.state.database_uri, "mongo://mongo:27017") + self.assertEqual(self.harness.charm.state.database_uri, "mongodb://mongo:27017") # Verifying status self.assertIsInstance(self.harness.charm.unit.status, BlockedStatus) @@ -763,7 +796,35 @@ class TestCharm(unittest.TestCase): self.assertNotIn("keystone", self.harness.charm.unit.status.message) self.assertTrue(self.harness.charm.unit.status.message.endswith(" relations")) - def test_on_prometheus_relation_changed(self) -> NoReturn: + def test_on_mongodb_app_relation_changed(self) -> NoReturn: + """Test to see if mongodb relation is updated.""" + self.harness.charm.on.start.emit() + + self.assertIsNone(self.harness.charm.state.database_uri) + + relation_id = self.harness.add_relation("mongodb", "mongodb") + self.harness.add_relation_unit(relation_id, "mongodb/0") + self.harness.update_relation_data( + relation_id, "mongodb", {"connection_string": "mongodb://mongo:27017"} + ) + + self.assertEqual(self.harness.charm.state.database_uri, "mongodb://mongo:27017") + + # Verifying status + self.assertIsInstance(self.harness.charm.unit.status, BlockedStatus) + + # Verifying status message + self.assertGreater(len(self.harness.charm.unit.status.message), 0) + self.assertTrue( + self.harness.charm.unit.status.message.startswith("Waiting for ") + ) + self.assertIn("kafka", self.harness.charm.unit.status.message) + self.assertNotIn("mongodb", self.harness.charm.unit.status.message) + self.assertIn("prometheus", self.harness.charm.unit.status.message) + self.assertNotIn("keystone", self.harness.charm.unit.status.message) + self.assertTrue(self.harness.charm.unit.status.message.endswith(" relations")) + + def test_on_prometheus_unit_relation_changed(self) -> NoReturn: """Test to see if prometheus relation is updated.""" self.harness.charm.on.start.emit() @@ -793,7 +854,37 @@ class TestCharm(unittest.TestCase): self.assertNotIn("keystone", self.harness.charm.unit.status.message) self.assertTrue(self.harness.charm.unit.status.message.endswith(" relations")) - def test_on_keystone_relation_changed(self) -> NoReturn: + def test_on_prometheus_app_relation_changed(self) -> NoReturn: + """Test to see if prometheus relation is updated.""" + self.harness.charm.on.start.emit() + + self.assertIsNone(self.harness.charm.state.prometheus_host) + self.assertIsNone(self.harness.charm.state.prometheus_port) + + relation_id = self.harness.add_relation("prometheus", "prometheus") + self.harness.add_relation_unit(relation_id, "prometheus/0") + self.harness.update_relation_data( + relation_id, "prometheus", {"hostname": "prometheus", "port": 9090} + ) + + self.assertEqual(self.harness.charm.state.prometheus_host, "prometheus") + self.assertEqual(self.harness.charm.state.prometheus_port, 9090) + + # Verifying status + self.assertIsInstance(self.harness.charm.unit.status, BlockedStatus) + + # Verifying status message + self.assertGreater(len(self.harness.charm.unit.status.message), 0) + self.assertTrue( + self.harness.charm.unit.status.message.startswith("Waiting for ") + ) + self.assertIn("kafka", self.harness.charm.unit.status.message) + self.assertIn("mongodb", self.harness.charm.unit.status.message) + self.assertNotIn("prometheus", self.harness.charm.unit.status.message) + self.assertNotIn("keystone", self.harness.charm.unit.status.message) + self.assertTrue(self.harness.charm.unit.status.message.endswith(" relations")) + + def test_on_keystone_unit_relation_changed(self) -> NoReturn: """Test to see if keystone relation is updated.""" self.harness.update_config({"auth_backend": "keystone"}) @@ -847,6 +938,60 @@ class TestCharm(unittest.TestCase): self.assertNotIn("keystone", self.harness.charm.unit.status.message) self.assertTrue(self.harness.charm.unit.status.message.endswith(" relations")) + def test_on_keystone_app_relation_changed(self) -> NoReturn: + """Test to see if keystone relation is updated.""" + self.harness.update_config({"auth_backend": "keystone"}) + + self.harness.charm.on.start.emit() + + self.assertIsNone(self.harness.charm.state.keystone_host) + self.assertIsNone(self.harness.charm.state.keystone_port) + self.assertIsNone(self.harness.charm.state.keystone_user_domain_name) + self.assertIsNone(self.harness.charm.state.keystone_project_domain_name) + self.assertIsNone(self.harness.charm.state.keystone_username) + self.assertIsNone(self.harness.charm.state.keystone_password) + self.assertIsNone(self.harness.charm.state.keystone_service) + + relation_id = self.harness.add_relation("keystone", "keystone") + self.harness.add_relation_unit(relation_id, "keystone/0") + self.harness.update_relation_data( + relation_id, + "keystone", + { + "host": "keystone", + "port": 5000, + "user_domain_name": "default", + "project_domain_name": "default", + "username": "nbi", + "password": "nbi", + "service": "service", + }, + ) + + self.assertEqual(self.harness.charm.state.keystone_host, "keystone") + self.assertEqual(self.harness.charm.state.keystone_port, 5000) + self.assertEqual(self.harness.charm.state.keystone_user_domain_name, "default") + self.assertEqual( + self.harness.charm.state.keystone_project_domain_name, "default" + ) + self.assertEqual(self.harness.charm.state.keystone_username, "nbi") + self.assertEqual(self.harness.charm.state.keystone_password, "nbi") + self.assertEqual(self.harness.charm.state.keystone_service, "service") + + # Verifying status + self.assertIsInstance(self.harness.charm.unit.status, BlockedStatus) + + # Verifying status message + self.assertGreater(len(self.harness.charm.unit.status.message), 0) + self.assertTrue( + self.harness.charm.unit.status.message.startswith("Waiting for ") + ) + self.assertIn("kafka", self.harness.charm.unit.status.message) + self.assertIn("mongodb", self.harness.charm.unit.status.message) + self.assertIn("prometheus", self.harness.charm.unit.status.message) + self.assertNotIn("keystone", self.harness.charm.unit.status.message) + self.assertTrue(self.harness.charm.unit.status.message.endswith(" relations")) + def test_publish_nbi_info(self) -> NoReturn: """Test to see if nbi relation is updated.""" expected_result = { diff --git a/installers/charm/nbi/tests/test_pod_spec.py b/installers/charm/nbi/tests/test_pod_spec.py index 7be45915..7cf586ce 100644 --- a/installers/charm/nbi/tests/test_pod_spec.py +++ b/installers/charm/nbi/tests/test_pod_spec.py @@ -57,7 +57,7 @@ class TestPodSpec(unittest.TestCase): relation_state = { "message_host": "kafka", "message_port": 9090, - "database_uri": "mongo://mongo", + "database_uri": "mongodb://mongo", "prometheus_host": "prometheus", "prometheus_port": 9082, } @@ -97,7 +97,7 @@ class TestPodSpec(unittest.TestCase): relation_state = { "message_host": "kafka", "message_port": 9090, - "database_uri": "mongo://mongo", + "database_uri": "mongodb://mongo", "prometheus_host": "prometheus", "prometheus_port": 9082, "keystone_host": "keystone", @@ -159,7 +159,7 @@ class TestPodSpec(unittest.TestCase): relation_state = { "message_host": "kafka", "message_port": 9090, - "database_uri": "mongo://mongo", + "database_uri": "mongodb://mongo", "prometheus_host": "prometheus", "prometheus_port": 9082, "keystone_host": "keystone", @@ -205,6 +205,7 @@ class TestPodSpec(unittest.TestCase): "name": f"{app_name}-ingress", "annotations": { "nginx.ingress.kubernetes.io/proxy-body-size": f"{config['max_file_size']}", + "nginx.ingress.kubernetes.io/backend-protocol": "HTTPS", "nginx.ingress.kubernetes.io/ssl-redirect": "false", }, "spec": { @@ -249,6 +250,7 @@ class TestPodSpec(unittest.TestCase): "name": f"{app_name}-ingress", "annotations": { "nginx.ingress.kubernetes.io/proxy-body-size": f"{config['max_file_size']}", + "nginx.ingress.kubernetes.io/backend-protocol": "HTTPS", "nginx.ingress.kubernetes.io/ssl-redirect": "false", "nginx.ingress.kubernetes.io/whitelist-source-range": config[ "ingress_whitelist_source_range" @@ -297,6 +299,7 @@ class TestPodSpec(unittest.TestCase): "name": f"{app_name}-ingress", "annotations": { "nginx.ingress.kubernetes.io/proxy-body-size": f"{config['max_file_size']}", + "nginx.ingress.kubernetes.io/backend-protocol": "HTTPS", }, "spec": { "rules": [ @@ -342,6 +345,7 @@ class TestPodSpec(unittest.TestCase): "name": f"{app_name}-ingress", "annotations": { "nginx.ingress.kubernetes.io/proxy-body-size": f"{config['max_file_size']}", + "nginx.ingress.kubernetes.io/backend-protocol": "HTTPS", }, "spec": { "rules": [ @@ -432,7 +436,7 @@ class TestPodSpec(unittest.TestCase): relation_state = { "message_host": "kafka", "message_port": 9090, - "database_uri": "mongo://mongo", + "database_uri": "mongodb://mongo", "prometheus_host": "prometheus", "prometheus_port": 9082, } @@ -452,17 +456,15 @@ class TestPodSpec(unittest.TestCase): relation_state = { "message_host": "kafka", "message_port": 9090, - "database_uri": "mongo://mongo", + "database_uri": "mongodb://mongo", "prometheus_host": "prometheus", "prometheus_port": 9082, } app_name = "nbi" port = 9999 - with self.assertRaises(ValidationError) as exc: - pod_spec.make_pod_spec( - image_info, config, relation_state, app_name, port - ) + with self.assertRaises(ValidationError): + pod_spec.make_pod_spec(image_info, config, relation_state, app_name, port) def test_make_pod_spec_without_relation_state(self) -> NoReturn: """Testing make pod spec without relation_state.""" @@ -478,10 +480,8 @@ class TestPodSpec(unittest.TestCase): app_name = "nbi" port = 9999 - with self.assertRaises(ValidationError) as exc: - pod_spec.make_pod_spec( - image_info, config, relation_state, app_name, port - ) + with self.assertRaises(ValidationError): + pod_spec.make_pod_spec(image_info, config, relation_state, app_name, port) def test_make_pod_spec(self) -> NoReturn: """Testing make pod spec.""" @@ -496,7 +496,7 @@ class TestPodSpec(unittest.TestCase): relation_state = { "message_host": "kafka", "message_port": 9090, - "database_uri": "mongo://mongo", + "database_uri": "mongodb://mongo", "prometheus_host": "prometheus", "prometheus_port": 9082, } @@ -562,7 +562,7 @@ class TestPodSpec(unittest.TestCase): relation_state = { "message_host": "kafka", "message_port": 9090, - "database_uri": "mongo://mongo", + "database_uri": "mongodb://mongo", "prometheus_host": "prometheus", "prometheus_port": 9082, "keystone_host": "keystone",