Add odu tests and enable k8s oru test 08/9608/1
authoraravind.est <aravindhan.a@est.tech>
Thu, 10 Nov 2022 18:20:49 +0000 (18:20 +0000)
committeraravind.est <aravindhan.a@est.tech>
Mon, 14 Nov 2022 10:53:31 +0000 (10:53 +0000)
Issue-ID: NONRTRIC-723
Signed-off-by: aravind.est <aravindhan.a@est.tech>
Change-Id: I00297498489405777e6eeb50b1d40990f39e1154

smo-install/helm-override/pythonsdk-tests/onap-override.yaml
smo-install/test/pythonsdk/src/orantests/conftest.py
smo-install/test/pythonsdk/src/orantests/resources/cl-test-helm-chart/odu-app-1.0.0.tgz [new file with mode: 0755]
smo-install/test/pythonsdk/src/orantests/resources/cl-test-helm-chart/odu-app-ics-version-1.0.0.tgz [new file with mode: 0755]
smo-install/test/pythonsdk/src/orantests/resources/cl-test-helm-chart/oru-app-1.0.0.tgz [new file with mode: 0755]
smo-install/test/pythonsdk/src/orantests/test_cl_k8s.py [moved from smo-install/test/pythonsdk/src/orantests/disable_test_cl_k8s.py with 61% similarity]

index d66ea9f..0dc5aa3 100644 (file)
@@ -290,6 +290,14 @@ policy:
     enabled: true
   policy-clamp-ac-k8s-ppnt:
     enabled: true
     enabled: true
   policy-clamp-ac-k8s-ppnt:
     enabled: true
+    image: onap/policy-clamp-ac-k8s-ppnt:6.3.0
+    repoList:
+      helm:
+        repos:
+          - repoName: chartmuseum
+            address: http://test-chartmuseum.test:8080
+        protocols:
+          - http
   policy-gui:
     enabled: false
   policy-nexus:
   policy-gui:
     enabled: false
   policy-nexus:
index dd4e469..9723a6d 100644 (file)
@@ -102,7 +102,7 @@ def pytest_sessionstart():
     wait(lambda: policy_component_ready(), sleep_seconds=settings.POLICY_CHECK_RETRY, timeout_seconds=settings.POLICY_CHECK_TIMEOUT, waiting_for="Policy to be ready")
     wait(lambda: sdnc_component_ready(), sleep_seconds=settings.SDNC_CHECK_RETRY, timeout_seconds=settings.SDNC_CHECK_TIMEOUT, waiting_for="SDNC to be ready")
     # disable for now, until policy/clamp issue has been fixed
     wait(lambda: policy_component_ready(), sleep_seconds=settings.POLICY_CHECK_RETRY, timeout_seconds=settings.POLICY_CHECK_TIMEOUT, waiting_for="Policy to be ready")
     wait(lambda: sdnc_component_ready(), sleep_seconds=settings.SDNC_CHECK_RETRY, timeout_seconds=settings.SDNC_CHECK_TIMEOUT, waiting_for="SDNC to be ready")
     # disable for now, until policy/clamp issue has been fixed
-    ##wait(lambda: clamp_component_ready(), sleep_seconds=settings.CLAMP_CHECK_RETRY, timeout_seconds=settings.CLAMP_CHECK_TIMEOUT, waiting_for="Clamp to be ready")
+    wait(lambda: clamp_component_ready(), sleep_seconds=settings.CLAMP_CHECK_RETRY, timeout_seconds=settings.CLAMP_CHECK_TIMEOUT, waiting_for="Clamp to be ready")
 
     ## Just kill any simulators that could already be runnin
     network_sims.stop_network_simulators()
 
     ## Just kill any simulators that could already be runnin
     network_sims.stop_network_simulators()
diff --git a/smo-install/test/pythonsdk/src/orantests/resources/cl-test-helm-chart/odu-app-1.0.0.tgz b/smo-install/test/pythonsdk/src/orantests/resources/cl-test-helm-chart/odu-app-1.0.0.tgz
new file mode 100755 (executable)
index 0000000..b82abf2
Binary files /dev/null and b/smo-install/test/pythonsdk/src/orantests/resources/cl-test-helm-chart/odu-app-1.0.0.tgz differ
diff --git a/smo-install/test/pythonsdk/src/orantests/resources/cl-test-helm-chart/odu-app-ics-version-1.0.0.tgz b/smo-install/test/pythonsdk/src/orantests/resources/cl-test-helm-chart/odu-app-ics-version-1.0.0.tgz
new file mode 100755 (executable)
index 0000000..b78e502
Binary files /dev/null and b/smo-install/test/pythonsdk/src/orantests/resources/cl-test-helm-chart/odu-app-ics-version-1.0.0.tgz differ
diff --git a/smo-install/test/pythonsdk/src/orantests/resources/cl-test-helm-chart/oru-app-1.0.0.tgz b/smo-install/test/pythonsdk/src/orantests/resources/cl-test-helm-chart/oru-app-1.0.0.tgz
new file mode 100755 (executable)
index 0000000..387a7a2
Binary files /dev/null and b/smo-install/test/pythonsdk/src/orantests/resources/cl-test-helm-chart/oru-app-1.0.0.tgz differ
@@ -42,20 +42,19 @@ dname = os.path.dirname(abspath)
 os.chdir(dname)
 
 logging.config.dictConfig(settings.LOG_CONFIG)
 os.chdir(dname)
 
 logging.config.dictConfig(settings.LOG_CONFIG)
-logger = logging.getLogger("test Control Loops for O-RU Fronthaul Recovery usecase - Clamp K8S usecase")
+logger = logging.getLogger("test Control Loops for Clamp K8S usecase")
 clcommissioning_utils = ClCommissioningUtils()
 clamp = ClampToscaTemplate(settings.CLAMP_BASICAUTH)
 
 chartmuseum_port = "8080"
 clcommissioning_utils = ClCommissioningUtils()
 clamp = ClampToscaTemplate(settings.CLAMP_BASICAUTH)
 
 chartmuseum_port = "8080"
-chart_version = "1.0.0"
-chart_name = "oru-app"
-release_name = "oru-app"
 usecase_name = "script_usecase"
 usecase_name = "script_usecase"
+chartmuseum_ip = "http://test-chartmuseum.test:8080"
+global app_name
 
 
-@pytest.fixture(scope="module", autouse=True)
-def setup_simulators():
+@pytest.fixture(autouse=True)
+def setup_simulators(request):
     """Prepare the test environment before the executing the tests."""
     """Prepare the test environment before the executing the tests."""
-    logger.info("Test class setup for Closed Loop tests")
+    logger.info("Test class setup for Closed Loop tests of %s", request.node.name)
 
     deploy_chartmuseum()
 
 
     deploy_chartmuseum()
 
@@ -73,13 +72,13 @@ def setup_simulators():
     result = check_output(cmd, shell=True).decode('utf-8')
     if result == '':
         logger.info("Failed to update the K8s pod repo")
     result = check_output(cmd, shell=True).decode('utf-8')
     if result == '':
         logger.info("Failed to update the K8s pod repo")
-    logger.info("Test Session setup completed successfully")
+    logger.info("Test Session setup completed successfully for %s", request.node.name)
 
     ### Cleanup code
     yield
     # Finish and delete the cl instance
     clcommissioning_utils.clean_instance(usecase_name)
 
     ### Cleanup code
     yield
     # Finish and delete the cl instance
     clcommissioning_utils.clean_instance(usecase_name)
-    wait(lambda: is_oru_app_down(), sleep_seconds=5, timeout_seconds=60, waiting_for="Oru app is down")
+    wait(lambda: is_rapp_down(app_name), sleep_seconds=5, timeout_seconds=60, waiting_for="Rapp is down")
     # Remove the remote repo to Clamp k8s pod
     cmd = f"kubectl exec -it -n onap {k8s_pod} -- sh -c \"helm repo remove chartmuseum\""
     check_output(cmd, shell=True).decode('utf-8')
     # Remove the remote repo to Clamp k8s pod
     cmd = f"kubectl exec -it -n onap {k8s_pod} -- sh -c \"helm repo remove chartmuseum\""
     check_output(cmd, shell=True).decode('utf-8')
@@ -88,7 +87,7 @@ def setup_simulators():
     cmd = "helm repo remove test"
     check_output(cmd, shell=True).decode('utf-8')
     time.sleep(10)
     cmd = "helm repo remove test"
     check_output(cmd, shell=True).decode('utf-8')
     time.sleep(10)
-    logger.info("Test Session cleanup done")
+    logger.info("Test Session cleanup done for %s", request.node.name)
 
 
 def deploy_chartmuseum():
 
 
 def deploy_chartmuseum():
@@ -107,6 +106,10 @@ def deploy_chartmuseum():
     chartmuseum_url = subprocess.run("kubectl get services -n test | grep test-chartmuseum | awk '{print $3}'", shell=True, check=True, stdout=subprocess.PIPE).stdout.decode('utf-8').strip()+":8080"
     cmd = f"curl -X POST --data-binary @{dname}/resources/cl-test-helm-chart/oru-app-1.0.0.tgz http://{chartmuseum_url}/api/charts"
     check_output(cmd, shell=True).decode('utf-8')
     chartmuseum_url = subprocess.run("kubectl get services -n test | grep test-chartmuseum | awk '{print $3}'", shell=True, check=True, stdout=subprocess.PIPE).stdout.decode('utf-8').strip()+":8080"
     cmd = f"curl -X POST --data-binary @{dname}/resources/cl-test-helm-chart/oru-app-1.0.0.tgz http://{chartmuseum_url}/api/charts"
     check_output(cmd, shell=True).decode('utf-8')
+    cmd = f"curl -X POST --data-binary @{dname}/resources/cl-test-helm-chart/odu-app-1.0.0.tgz http://{chartmuseum_url}/api/charts"
+    check_output(cmd, shell=True).decode('utf-8')
+    cmd = f"curl -X POST --data-binary @{dname}/resources/cl-test-helm-chart/odu-app-ics-version-1.0.0.tgz http://{chartmuseum_url}/api/charts"
+    check_output(cmd, shell=True).decode('utf-8')
 
 
 def is_chartmuseum_up() -> bool:
 
 
 def is_chartmuseum_up() -> bool:
@@ -121,35 +124,69 @@ def is_chartmuseum_up() -> bool:
     return True
 
 
     return True
 
 
-def is_oru_app_up() -> bool:
-    """Check if the oru-app is up."""
-    cmd = "kubectl get pods -n nonrtric | grep oru-app | wc -l"
+def is_rapp_up(appname) -> bool:
+    """Check if the rapp is up."""
+    cmd = "kubectl get pods -n nonrtric | grep " + appname + " | wc -l"
     result = check_output(cmd, shell=True).decode('utf-8')
     result = check_output(cmd, shell=True).decode('utf-8')
-    logger.info("Checking if oru-app is up :%s", result)
+    logger.info("Checking if %s is up :%s", appname, result)
     if int(result) == 1:
     if int(result) == 1:
-        logger.info("ORU-APP is Up")
+        logger.info("%s is Up", appname.upper())
         return True
         return True
-    logger.info("ORU-APP is Down")
+    logger.info("%s is Down", appname.upper())
     return False
 
     return False
 
-def is_oru_app_down() -> bool:
-    """Check if the oru-app is down."""
-    cmd = "kubectl get pods -n nonrtric | grep oru-app | wc -l"
+def is_rapp_down(appname) -> bool:
+    """Check if the rapp is down."""
+    cmd = "kubectl get pods -n nonrtric | grep " + appname + " | wc -l"
     result = check_output(cmd, shell=True).decode('utf-8')
     result = check_output(cmd, shell=True).decode('utf-8')
-    logger.info("Checking if oru-app is down :%s", result)
+    logger.info("Checking if %s is down :%s", appname, result)
     if int(result) == 0:
     if int(result) == 0:
-        logger.info("ORU-APP is Down")
+        logger.info("%s is Down", appname.upper())
         return True
         return True
-    logger.info("ORU-APP is Up")
+    logger.info("%s is Up", appname.upper())
     return False
 
 def test_cl_oru_app_deploy():
     return False
 
 def test_cl_oru_app_deploy():
+    chart_version = "1.0.0"
+    chart_name = "oru-app"
+    release_name = "oru-app"
+    global app_name
+    app_name = chart_name
     """The Closed Loop O-RU Fronthaul Recovery usecase Apex version."""
     logger.info("Upload tosca to commissioning")
     """The Closed Loop O-RU Fronthaul Recovery usecase Apex version."""
     logger.info("Upload tosca to commissioning")
-    chartmuseum_ip = subprocess.run("kubectl get services -n test | grep test-chartmuseum | awk '{print $3}'", shell=True, check=True, stdout=subprocess.PIPE).stdout.decode('utf-8').strip()+":8080"
     commissioning_payload = jinja_env().get_template("commission_k8s.json.j2").render(chartmuseumIp=chartmuseum_ip, chartmuseumPort=chartmuseum_port, chartVersion=chart_version, chartName=chart_name, releaseName=release_name)
     instance_payload = jinja_env().get_template("create_instance_k8s.json.j2").render(chartmuseumIp=chartmuseum_ip, chartmuseumPort=chartmuseum_port, chartVersion=chart_version, chartName=chart_name, releaseName=release_name, instanceName=usecase_name)
     assert clcommissioning_utils.create_instance(usecase_name, commissioning_payload, instance_payload) is True
 
     logger.info("Check if oru-app is up")
     commissioning_payload = jinja_env().get_template("commission_k8s.json.j2").render(chartmuseumIp=chartmuseum_ip, chartmuseumPort=chartmuseum_port, chartVersion=chart_version, chartName=chart_name, releaseName=release_name)
     instance_payload = jinja_env().get_template("create_instance_k8s.json.j2").render(chartmuseumIp=chartmuseum_ip, chartmuseumPort=chartmuseum_port, chartVersion=chart_version, chartName=chart_name, releaseName=release_name, instanceName=usecase_name)
     assert clcommissioning_utils.create_instance(usecase_name, commissioning_payload, instance_payload) is True
 
     logger.info("Check if oru-app is up")
-    wait(lambda: is_oru_app_up(), sleep_seconds=5, timeout_seconds=60, waiting_for="Oru app to be up")
+    wait(lambda: is_rapp_up(chart_name), sleep_seconds=5, timeout_seconds=300, waiting_for="Oru app to be up")
+
+def test_cl_odu_app_smo_deploy():
+    chart_version = "1.0.0"
+    chart_name = "odu-app"
+    release_name = "odu-app"
+    global app_name
+    app_name = chart_name
+    """The O-DU Slice Assurance SMO Version use case."""
+    logger.info("Upload tosca to commissioning")
+    commissioning_payload = jinja_env().get_template("commission_k8s.json.j2").render(chartmuseumIp=chartmuseum_ip, chartmuseumPort=chartmuseum_port, chartVersion=chart_version, chartName=chart_name, releaseName=release_name)
+    instance_payload = jinja_env().get_template("create_instance_k8s.json.j2").render(chartmuseumIp=chartmuseum_ip, chartmuseumPort=chartmuseum_port, chartVersion=chart_version, chartName=chart_name, releaseName=release_name, instanceName=usecase_name)
+    assert clcommissioning_utils.create_instance(usecase_name, commissioning_payload, instance_payload) is True
+
+    logger.info("Check if odu-app smo version is up")
+    wait(lambda: is_rapp_up(chart_name), sleep_seconds=5, timeout_seconds=300, waiting_for="Odu app smo version to be up")
+
+def test_cl_odu_app_ics_deploy():
+    chart_version = "1.0.0"
+    chart_name = "odu-app-ics-version"
+    release_name = "odu-app-ics-version"
+    global app_name
+    app_name = chart_name
+    """The O-DU Slice Assurance ICS Version use case."""
+    logger.info("Upload tosca to commissioning")
+    commissioning_payload = jinja_env().get_template("commission_k8s.json.j2").render(chartmuseumIp=chartmuseum_ip, chartmuseumPort=chartmuseum_port, chartVersion=chart_version, chartName=chart_name, releaseName=release_name)
+    instance_payload = jinja_env().get_template("create_instance_k8s.json.j2").render(chartmuseumIp=chartmuseum_ip, chartmuseumPort=chartmuseum_port, chartVersion=chart_version, chartName=chart_name, releaseName=release_name, instanceName=usecase_name)
+    assert clcommissioning_utils.create_instance(usecase_name, commissioning_payload, instance_payload) is True
+
+    logger.info("Check if odu-app ics version is up")
+    wait(lambda: is_rapp_up(chart_name), sleep_seconds=5, timeout_seconds=300, waiting_for="Odu app ics version to be up")