"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",
self.harness.update_relation_data(
mongodb_relation_id,
"mongodb/0",
- {"connection_string": "mongo://mongo:27017"},
+ {"connection_string": "mongodb://mongo:27017"},
)
# Initializing the prometheus relation
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")
"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",
self.harness.update_relation_data(
mongodb_relation_id,
"mongodb/0",
- {"connection_string": "mongo://mongo:27017"},
+ {"connection_string": "mongodb://mongo:27017"},
)
# Initializing the prometheus relation
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")
"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",
self.harness.update_relation_data(
mongodb_relation_id,
"mongodb/0",
- {"connection_string": "mongo://mongo:27017"},
+ {"connection_string": "mongodb://mongo:27017"},
)
# Initializing the prometheus relation
"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",
"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": [
self.harness.update_relation_data(
mongodb_relation_id,
"mongodb/0",
- {"connection_string": "mongo://mongo:27017"},
+ {"connection_string": "mongodb://mongo:27017"},
)
# Initializing the prometheus relation
"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",
"name": "nbi-ingress",
"annotations": {
"nginx.ingress.kubernetes.io/proxy-body-size": "0",
+ "nginx.ingress.kubernetes.io/backend-protocol": "HTTPS",
},
"spec": {
"rules": [
self.harness.update_relation_data(
mongodb_relation_id,
"mongodb/0",
- {"connection_string": "mongo://mongo:27017"},
+ {"connection_string": "mongodb://mongo:27017"},
)
# Initializing the prometheus relation
"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",
"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": {
self.harness.update_relation_data(
mongodb_relation_id,
"mongodb/0",
- {"connection_string": "mongo://mongo:27017"},
+ {"connection_string": "mongodb://mongo:27017"},
)
# Initializing the prometheus relation
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()
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()
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)
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()
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"})
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 = {
relation_state = {
"message_host": "kafka",
"message_port": 9090,
- "database_uri": "mongo://mongo",
+ "database_uri": "mongodb://mongo",
"prometheus_host": "prometheus",
"prometheus_port": 9082,
}
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",
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",
"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": {
"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"
"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": [
"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": [
relation_state = {
"message_host": "kafka",
"message_port": 9090,
- "database_uri": "mongo://mongo",
+ "database_uri": "mongodb://mongo",
"prometheus_host": "prometheus",
"prometheus_port": 9082,
}
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."""
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."""
relation_state = {
"message_host": "kafka",
"message_port": 9090,
- "database_uri": "mongo://mongo",
+ "database_uri": "mongodb://mongo",
"prometheus_host": "prometheus",
"prometheus_port": 9082,
}
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",