aboutsummaryrefslogtreecommitdiffstats
path: root/src/onaptests/steps/simulator
diff options
context:
space:
mode:
authorMichal Jagiello <michal.jagiello@t-mobile.pl>2021-07-20 10:15:32 +0000
committerMichal Jagiello <michal.jagiello@t-mobile.pl>2021-11-08 17:17:21 +0000
commitaad04fa2a7e1c9d71f273d26da25436e5c6b779c (patch)
tree8b247e3c7d2bf22a9b6d50b764afba6946b5e746 /src/onaptests/steps/simulator
parent1a77bcd6eb5ab695a232004b88e5e59d9d9ff6a3 (diff)
[TEST] CDS resource-resolution test
Issue-ID: TEST-291 Signed-off-by: Michal Jagiello <michal.jagiello@t-mobile.pl> Change-Id: I5d9f55b67942c62f63e11282ef2383fe063d3137 (cherry picked from commit c31b7fb464fbb8bb0c7d8d2b3dc7b20f4a04cff5)
Diffstat (limited to 'src/onaptests/steps/simulator')
-rw-r--r--src/onaptests/steps/simulator/cds_mockserver.py62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/onaptests/steps/simulator/cds_mockserver.py b/src/onaptests/steps/simulator/cds_mockserver.py
new file mode 100644
index 0000000..6933fa0
--- /dev/null
+++ b/src/onaptests/steps/simulator/cds_mockserver.py
@@ -0,0 +1,62 @@
+# http://www.apache.org/licenses/LICENSE-2.0
+"""CDS mockserver registration module."""
+
+import time
+
+import requests
+from onapsdk.configuration import settings
+
+from onaptests.steps.base import BaseStep
+from onaptests.steps.instantiate.msb_k8s import CreateInstanceStep
+from onaptests.utils.exceptions import OnapTestException
+
+
+class CdsMockserverCnfConfigureStep(BaseStep):
+ """Configure cds mockserver expectations."""
+
+ def __init__(self, cleanup: bool = False) -> None:
+ """Initialize step.
+
+ Substeps:
+ - CreateInstanceStep.
+ """
+ super().__init__(cleanup=cleanup)
+ self.add_step(CreateInstanceStep(cleanup=cleanup))
+
+ @property
+ def description(self) -> str:
+ """Step description."""
+ return "Configure cds-mockserver."
+
+ @property
+ def component(self) -> str:
+ """Component name."""
+ return "Environment"
+
+ @BaseStep.store_state
+ def execute(self) -> None:
+ """Create mockserver expectations.
+
+ Use settings values:
+ - CDS_MOCKSERVER_EXPECTATIONS.
+ """
+ super().execute()
+ time.sleep(60) # Wait for mockserver
+ for expectation in settings.CDS_MOCKSERVER_EXPECTATIONS:
+ try:
+ response = requests.put(
+ "http://portal.api.simpledemo.onap.org:30726/mockserver/expectation",
+ json={
+ "httpRequest" : {
+ "method": expectation["method"],
+ "path": expectation["path"]
+ },
+ "httpResponse" : {
+ "body": expectation["response"]
+ }
+ }
+ )
+ response.raise_for_status()
+ except (requests.ConnectionError, requests.HTTPError) as http_error:
+ self._logger.debug(f"Can't register cds-mockserver expectation: {str(http_error)}")
+ raise OnapTestException("CDS mockserver not configured")