Fix bad path of the logs in the reporting page 16/113916/3
authormrichomme <morgan.richomme@orange.com>
Thu, 15 Oct 2020 12:57:37 +0000 (14:57 +0200)
committermrichomme <morgan.richomme@orange.com>
Thu, 15 Oct 2020 14:27:50 +0000 (16:27 +0200)
Issue-ID: TEST-270

Signed-off-by: mrichomme <morgan.richomme@orange.com>
Change-Id: Ief03cf6916b417fb0c80c5086ffe8e73f3865329
Signed-off-by: mrichomme <morgan.richomme@orange.com>
README.md
run_basicvm_nomulticloud.py
src/onaptests/configuration/settings.py
src/onaptests/steps/reports_collection.py

index 097967d..dc833e0 100644 (file)
--- a/README.md
+++ b/README.md
@@ -37,7 +37,9 @@ See ubuntu16test as example
 
 - Set global settings configuration files with all required input datas
   including the dynamic forwarding port for ssh tunnel in
-  src/onaptests/configuration/settings.py
+  src/onaptests/configuration/settings.py. You can customize the path for your
+  logs and reporting the page. Note that the reporting page assumes that the
+  logs are put in the same directory than the html page (relative path).
 
 - Set OpenStack configuration: there are 2 ways to provide the cloud information
   If you got the clouds.yaml, you need to reference your cloud with the env
index 9ebefb8..a2e9cfd 100644 (file)
@@ -1,5 +1,6 @@
 import logging.config
 import time
+import onaptests.utils.exceptions as onap_test_exceptions
 from onapsdk.configuration import settings
 from onaptests.steps.instantiate.vf_module_ala_carte import YamlTemplateVfModuleAlaCarteInstantiateStep
 
@@ -13,11 +14,24 @@ if __name__ == "__main__":
 
     basic_vm_instantiate = YamlTemplateVfModuleAlaCarteInstantiateStep(
         cleanup=settings.CLEANUP_FLAG)
-    basic_vm_instantiate.execute()
-    if settings.CLEANUP_FLAG:
-        time.sleep(settings.CLEANUP_ACTIVITY_TIMER)
-        try:
+    try:
+        basic_vm_instantiate.execute()
+        if settings.CLEANUP_FLAG:
+            time.sleep(settings.CLEANUP_ACTIVITY_TIMER)
             basic_vm_instantiate.cleanup()
-        except ValueError as error:
-            logger.info("service instance deleted as expected {0}".format(error))
+    except onap_test_exceptions.TestConfigurationException:
+        logger.error("Basic VM configuration error")
+    except onap_test_exceptions.ServiceInstantiateException:
+        logger.error("Basic VM instantiation error")
+    except onap_test_exceptions.ServiceCleanupException:
+        logger.error("Basic VM instance cleanup error")
+    except onap_test_exceptions.VnfInstantiateException:
+        logger.error("Basic VM Vnf instantiation error")
+    except onap_test_exceptions.VnfCleanupException:
+        logger.error("Basic VM Vnf instance cleanup error")
+    except onap_test_exceptions.VfModuleInstantiateException:
+        logger.error("Basic VM Module instantiation error")
+    except onap_test_exceptions.VfModuleCleanupException:
+        logger.error("Basic VM Module cleanup error")
+
     basic_vm_instantiate.reports_collection.generate_report()
index 3339082..745dc08 100644 (file)
@@ -28,7 +28,7 @@ LOG_CONFIG = {
             "level": "DEBUG",
             "class": "logging.FileHandler",
             "formatter": "default",
-            "filename": "./pythonsdk.debug.log",
+            "filename": "/tmp/pythonsdk.debug.log",
             "mode": "w"
         }
     },
index bcb199f..3c1dfb6 100644 (file)
@@ -36,7 +36,7 @@ class ReportsCollection:
 
     def generate_report(self) -> None:
         step_list = self.report
-        failing_steps = []
+        failing_steps = {}
         for step,status in step_list.items():
             if 'FAIL' in status:
                 failing_steps[step] = status
@@ -51,7 +51,6 @@ class ReportsCollection:
         except NameError:
             components = ""
 
-        log_path = settings.LOG_CONFIG['handlers']['file']['filename']
         jinja_env = Environment(
             autoescape=select_autoescape(['html']),
             loader=FileSystemLoader(sys.path[-1] + '/onaptests/templates/reporting'))
@@ -62,5 +61,5 @@ class ReportsCollection:
             usecase=usecase,
             details=details,
             components=components,
-            log_path=log_path).dump(
+            log_path="./pythonsdk.debug.log").dump(
             settings.REPORTING_FILE_PATH)