aboutsummaryrefslogtreecommitdiffstats
path: root/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/libraries/VesHvContainersUtilsLibrary.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/csit/tests/dcaegen2-collectors-hv-ves/testcases/libraries/VesHvContainersUtilsLibrary.py')
-rw-r--r--test/csit/tests/dcaegen2-collectors-hv-ves/testcases/libraries/VesHvContainersUtilsLibrary.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/libraries/VesHvContainersUtilsLibrary.py b/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/libraries/VesHvContainersUtilsLibrary.py
new file mode 100644
index 000000000..4db04612e
--- /dev/null
+++ b/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/libraries/VesHvContainersUtilsLibrary.py
@@ -0,0 +1,34 @@
+from time import time
+
+from robot.api import logger
+import os.path
+
+LOCALHOST = "localhost"
+
+
+class VesHvContainersUtilsLibrary:
+
+ def get_consul_api_access_url(self, method, image_name, port):
+ return self.create_url(
+ method,
+ self.get_instance_address(image_name, port)
+ )
+
+ def get_dcae_app_api_access_url(self, method, image_name, port):
+ return self.create_url(
+ method,
+ self.get_instance_address(image_name, port)
+ )
+
+ def get_instance_address(self, image_name, port):
+ if is_running_inside_docker():
+ return image_name + ":" + port
+ else:
+ logger.info("File `/.dockerenv` not found. Assuming local environment and using localhost.")
+ return LOCALHOST + ":" + port
+
+ def create_url(self, method, host_address):
+ return method + host_address
+
+def is_running_inside_docker():
+ return os.path.isfile("/.dockerenv")