Fixing kafka_port validation in RO charm 90/10190/2
authorsousaedu <eduardo.sousa@canonical.com>
Mon, 18 Jan 2021 17:53:28 +0000 (17:53 +0000)
committerbeierlm <mark.beierl@canonical.com>
Tue, 19 Jan 2021 12:52:53 +0000 (13:52 +0100)
Change-Id: I5d7ea4ecd3f45e901d0da431e386580f5c49611c
Signed-off-by: sousaedu <eduardo.sousa@canonical.com>
installers/charm/ro/src/pod_spec.py
installers/charm/ro/tests/test_charm.py
installers/charm/ro/tests/test_pod_spec.py

index b54710c..6c91baf 100644 (file)
@@ -65,7 +65,7 @@ def _validate_data(
         "kafka_host": lambda value, _: (isinstance(value, str) and len(value) > 0)
         if config_data.get("enable_ng_ro", True)
         else True,
-        "kafka_port": lambda value, _: (isinstance(value, int) and value > 0)
+        "kafka_port": lambda value, _: (isinstance(value, str) and len(value) > 0)
         if config_data.get("enable_ng_ro", True)
         else True,
         "mongodb_connection_string": lambda value, _: (
index cdc384f..0aa9b7d 100644 (file)
@@ -91,7 +91,7 @@ class TestCharm(unittest.TestCase):
                         "OSMRO_LOG_LEVEL": "INFO",
                         "OSMRO_MESSAGE_DRIVER": "kafka",
                         "OSMRO_MESSAGE_HOST": "kafka",
-                        "OSMRO_MESSAGE_PORT": 9090,
+                        "OSMRO_MESSAGE_PORT": "9090",
                         "OSMRO_DATABASE_DRIVER": "mongo",
                         "OSMRO_DATABASE_URI": "mongodb://mongo",
                         "OSMRO_DATABASE_COMMONKEY": "osm",
@@ -139,7 +139,7 @@ class TestCharm(unittest.TestCase):
             "kafka/0",
             {
                 "host": "kafka",
-                "port": 9090,
+                "port": "9090",
             },
         )
 
index 2dc1104..e616242 100644 (file)
@@ -54,7 +54,7 @@ class TestPodSpec(unittest.TestCase):
         }
         relation_state = {
             "kafka_host": "kafka",
-            "kafka_port": 9090,
+            "kafka_port": "9090",
             "mongodb_connection_string": "mongodb://mongo",
         }
 
@@ -171,7 +171,7 @@ class TestPodSpec(unittest.TestCase):
         }
         relation_state = {
             "kafka_host": "kafka",
-            "kafka_port": 9090,
+            "kafka_port": "9090",
             "mongodb_connection_string": "mongodb://mongo",
         }
         app_name = "ro"