X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=installers%2Fcharm%2Fnbi%2Ftests%2Ftest_charm.py;h=59a27fb735f4827ffddc8c5ccb85936b78c294ec;hb=refs%2Fchanges%2F85%2F13185%2F2;hp=116c06bc4bb3f95efd2613f3bfc90ca947f88268;hpb=996a5604c7d31f3758503b08a426f1f40619b17b;p=osm%2Fdevops.git diff --git a/installers/charm/nbi/tests/test_charm.py b/installers/charm/nbi/tests/test_charm.py index 116c06bc..59a27fb7 100644 --- a/installers/charm/nbi/tests/test_charm.py +++ b/installers/charm/nbi/tests/test_charm.py @@ -155,16 +155,79 @@ class TestCharm(unittest.TestCase): # Verifying status self.assertIsInstance(self.harness.charm.unit.status, BlockedStatus) + def test_config_liveness_probe_with_relations( + self, + ) -> NoReturn: + "Test configuration of liveness probe with relations" + self.initialize_nbi_with_keystone() + self.config_liveness_probe() + # Verifying status + self.assertIsInstance(self.harness.charm.unit.status, ActiveStatus) + + def test_wrong_config_liveness_probe_with_relations( + self, + ) -> NoReturn: + "Test wrong configuration of liveness probe with relations" + self.initialize_nbi_with_keystone() + self.wrong_config_liveness_probe() + # Verifying status + self.assertIsInstance(self.harness.charm.unit.status, BlockedStatus) + + def test_config_readiness_probe_with_relations( + self, + ) -> NoReturn: + "Test configuration of readiness probe with relations" + self.initialize_nbi_with_keystone() + self.config_readiness_probe() + # Verifying status + self.assertIsInstance(self.harness.charm.unit.status, ActiveStatus) + + def test_wrong_config_readiness_probe_with_relations( + self, + ) -> NoReturn: + "Test wrong configuration of readiness probe with relations" + self.initialize_nbi_with_keystone() + self.wrong_config_readiness_probe() + # Verifying status + self.assertIsInstance(self.harness.charm.unit.status, BlockedStatus) + def initialize_kafka_relation(self): kafka_relation_id = self.harness.add_relation("kafka", "kafka") self.harness.add_relation_unit(kafka_relation_id, "kafka/0") self.harness.update_relation_data( - kafka_relation_id, "kafka/0", {"host": "kafka", "port": 9092} + kafka_relation_id, "kafka", {"host": "kafka", "port": 9092} ) def initialize_mongo_config(self): self.harness.update_config({"mongodb_uri": "mongodb://mongo:27017"}) + def initialize_nbi_with_keystone(self): + self.harness.update_config({"auth_backend": "keystone"}) + self.initialize_kafka_relation() + self.initialize_mongo_relation() + self.initialize_prometheus_relation() + self.initialize_keystone_relation() + + def config_liveness_probe(self): + self.harness.update_config( + {"tcpsocket_liveness_probe": '{"initial_delay_seconds": 10}'} + ) + + def wrong_config_liveness_probe(self): + self.harness.update_config( + {"tcpsocket_liveness_probe": "{initial_delay_seconds: 10}"} + ) + + def wrong_config_readiness_probe(self): + self.harness.update_config( + {"tcpsocket_readiness_probe": "{initial_delay_seconds: 10}"} + ) + + def config_readiness_probe(self): + self.harness.update_config( + {"tcpsocket_readiness_probe": '{"initial_delay_seconds": 10}'} + ) + def initialize_mongo_relation(self): mongodb_relation_id = self.harness.add_relation("mongodb", "mongodb") self.harness.add_relation_unit(mongodb_relation_id, "mongodb/0")