aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xagl-test23
-rw-r--r--plugins/agl_test_base.py25
-rw-r--r--plugins/agl_test_utils.py9
3 files changed, 57 insertions, 0 deletions
diff --git a/agl-test b/agl-test
index 1d2909a..866121f 100755
--- a/agl-test
+++ b/agl-test
@@ -26,6 +26,27 @@ then
fi
echo "STRESS_LEVEL: $STRESS_LEVEL"
+# default logging mode is default
+if [[ ! $LOG_MODE ]]
+then
+ export LOG_MODE="default"
+fi
+
+case $LOG_MODE in
+ "default")
+ ;;
+ "slim")
+ ;;
+ "clear")
+ ;;
+ *)
+ echo "Unrecognized LOG_MODE, setting to default..."
+ export LOG_MODE="default"
+ ;;
+esac
+
+echo "LOG_MODE: $LOG_MODE"
+
# default test without dangerous marker
moption="-m "
if [[ $* =~ ${moption} ]]
@@ -36,3 +57,5 @@ else
fi
python3 -c "import plugins.agl_test_report as report; report.generate_total_summary_files('${current_time}')"
+
+python3 -c "import plugins.agl_test_utils as utils; utils.rm_all_tmp()"
diff --git a/plugins/agl_test_base.py b/plugins/agl_test_base.py
index b30f841..1491f64 100644
--- a/plugins/agl_test_base.py
+++ b/plugins/agl_test_base.py
@@ -1,6 +1,8 @@
import pytest
import os
import json
+import pathlib
+import shutil
import plugins.agl_test_utils as utils
import plugins.agl_test_conf as conf
@@ -111,6 +113,9 @@ class AGLBaseTest:
#Write json data to html
report.change_json_to_html(self.name)
+ #Clean temp files and folders
+ self.clean_self_tmp()
+
def precheck(self):
return True;
@@ -133,3 +138,23 @@ class AGLBaseTest:
test_suites[self.name] = test_info
json.dump(test_suites,f)
f.close()
+
+ def prepare_local_log_mode(self):
+ # Get env 'LOG_MODE'
+ env_dist=os.environ
+ local_log_mode = str(env_dist.get("LOG_MODE"))
+ return local_log_mode
+
+ def clean_self_tmp(self):
+ path = self.get_temp_logdir()
+ log_mode = self.prepare_local_log_mode()
+ if log_mode == "slim" or log_mode == "clear":
+ # leave <path>/log and report.json as essential
+ folderObj = pathlib.Path(path)
+ for element in folderObj.iterdir():
+ if element.name != "log" and element.name != "report.json":
+ # check delete_file_path file type
+ if element.is_file():
+ element.unlink()
+ elif element.is_dir():
+ shutil.rmtree(path)
diff --git a/plugins/agl_test_utils.py b/plugins/agl_test_utils.py
index b1204a0..e2799f1 100644
--- a/plugins/agl_test_utils.py
+++ b/plugins/agl_test_utils.py
@@ -1,3 +1,5 @@
+import os
+import shutil
import subprocess
from plugins.agl_test_conf import REPORT_LOGS_DIR
@@ -29,3 +31,10 @@ def printe(msg):
def printd(msg):
# TODO
print("==== DEBUG: " + msg)
+
+# delete entire temp log folder
+def rm_all_tmp():
+ env_dist=os.environ
+ mode = str(env_dist.get("LOG_MODE"))
+ if mode == "clear":
+ shutil.rmtree(TMP_LOGS_DIR)