aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorpawel.denst <pawel.denst@external.t-mobile.pl>2023-05-10 10:50:58 +0000
committerpawel.denst <pawel.denst@external.t-mobile.pl>2023-05-30 22:36:16 +0000
commitea72aa01e864b6ddf3145d51d060077da00526d3 (patch)
tree249c7516e5e76e1b2e1453d2bd0e946956738c61 /src
parent4299fadeddffd2d24eb672fb26e6fa7cc141899f (diff)
ONAP Python SDK tests should generate JSON artifact (next to HTML)
Generation of report file in JSON format Issue-ID: INT-2235 Signed-off-by: pawel.denst <pawel.denst@external.t-mobile.pl> Signed-off-by: Lukasz Rajewski <lukasz.rajewski@t-mobile.pl> Change-Id: Ib99a0cb8bf317633e19a4a2e1c41d611a3b9f343
Diffstat (limited to 'src')
-rw-r--r--src/onaptests/configuration/settings.py4
-rw-r--r--src/onaptests/steps/reports_collection.py20
2 files changed, 22 insertions, 2 deletions
diff --git a/src/onaptests/configuration/settings.py b/src/onaptests/configuration/settings.py
index 74bc840..436e82c 100644
--- a/src/onaptests/configuration/settings.py
+++ b/src/onaptests/configuration/settings.py
@@ -40,7 +40,9 @@ LOG_CONFIG = {
CLEANUP_FLAG = False
SDC_CLEANUP = False
-REPORTING_FILE_PATH = "/tmp/reporting.html"
+REPORTING_FILE_DIRECTORY = "/tmp/"
+HTML_REPORTING_FILE_NAME = "reporting.html"
+JSON_REPORTING_FILE_NAME = "reporting.json"
K8S_REGION_TYPE = "k8s"
TILLER_HOST = "localhost"
K8S_CONFIG = None # None means it will use default config (~/.kube/config)
diff --git a/src/onaptests/steps/reports_collection.py b/src/onaptests/steps/reports_collection.py
index 4b7f79b..0e5076f 100644
--- a/src/onaptests/steps/reports_collection.py
+++ b/src/onaptests/steps/reports_collection.py
@@ -1,5 +1,7 @@
from dataclasses import dataclass
from enum import Enum
+import json
+from pathlib import Path
from typing import List
from jinja2 import Environment, FileSystemLoader, select_autoescape
from onapsdk.configuration import settings
@@ -83,4 +85,20 @@ class ReportsCollection:
details=details,
components=components,
log_path="./pythonsdk.debug.log").dump(
- settings.REPORTING_FILE_PATH)
+ str(Path(settings.REPORTING_FILE_DIRECTORY).joinpath(settings.HTML_REPORTING_FILE_NAME)))
+
+ report_dict = {
+ 'usecase': usecase,
+ 'details': details,
+ 'components': components,
+ 'steps': [
+ {
+ 'description': step_report.step_description,
+ 'status': step_report.step_execution_status.value,
+ 'duration': step_report.step_execution_duration
+ }
+ for step_report in reversed(self.report)
+ ]
+ }
+ with (Path(settings.REPORTING_FILE_DIRECTORY).joinpath(settings.JSON_REPORTING_FILE_NAME)).open('w') as file:
+ json.dump(report_dict, file, indent=4) \ No newline at end of file