From babe0456986c0f9cab3c9416f34536d6c398e580 Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Wed, 15 May 2024 09:56:49 +0300 Subject: [PATCH 01/42] 3897880:PDR black list tests (initial steps) --- .github/workflows/pdr_plugin_ci_workflow.yml | 24 ++++++++++++++++++++ plugins/requirements.txt | 0 2 files changed, 24 insertions(+) create mode 100644 .github/workflows/pdr_plugin_ci_workflow.yml create mode 100644 plugins/requirements.txt diff --git a/.github/workflows/pdr_plugin_ci_workflow.yml b/.github/workflows/pdr_plugin_ci_workflow.yml new file mode 100644 index 000000000..fded0b46f --- /dev/null +++ b/.github/workflows/pdr_plugin_ci_workflow.yml @@ -0,0 +1,24 @@ +name: PDR Plugin CI Workflow + +on: + push: + paths: + - 'plugins/pdr_deterministic_plugin/**' +jobs: + pylint: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@main + + - name: Set up Python + uses: actions/setup-python@main + with: + python-version: 3.9 + + - name: Install dependencies + run: | + pip install -r plugins/pdr_deterministic_plugin/requirements.txt + pip install pylint + - name: Run PyLint + run: pylint --rcfile=plugins/pdr_deterministic_plugin/.pylintrc plugins/pdr_deterministic_plugin \ No newline at end of file diff --git a/plugins/requirements.txt b/plugins/requirements.txt new file mode 100644 index 000000000..e69de29bb From 5dee6464de83987109c642d084c8680067bf3d2c Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Wed, 15 May 2024 14:20:53 +0300 Subject: [PATCH 02/42] Pylint test --- plugins/pdr_deterministic_plugin/.pylintrc | 17 +++++++++++++++++ plugins/requirements.txt | 11 +++++++++++ 2 files changed, 28 insertions(+) create mode 100644 plugins/pdr_deterministic_plugin/.pylintrc diff --git a/plugins/pdr_deterministic_plugin/.pylintrc b/plugins/pdr_deterministic_plugin/.pylintrc new file mode 100644 index 000000000..4eda3a070 --- /dev/null +++ b/plugins/pdr_deterministic_plugin/.pylintrc @@ -0,0 +1,17 @@ +[MASTER] +init-hook="import os, sys; sys.path.append(os.path.join(os.getcwd(), 'plugins', 'pdr_deterministic_plugin', 'src')); sys.path.append(os.path.join(os.getcwd(), 'utils'))" + +[MAIN] +max-public-methods=100 + +[DESIGN] +max-attributes=10 + +[MESSAGES CONTROL] +disable=missing-module-docstring,missing-function-docstring,fixme + +[FORMAT] +max-line-length=140 + +[BASIC] +min-public-methods=0 diff --git a/plugins/requirements.txt b/plugins/requirements.txt index e69de29bb..105e91cca 100644 --- a/plugins/requirements.txt +++ b/plugins/requirements.txt @@ -0,0 +1,11 @@ +requests +configparser +flask +flask_restful +twisted +tzlocal<3.0 +jsonschema +pandas +numpy +prometheus_client +msgpack From c6aa08a6d85c156cf3fcb362da800bf8e8650810 Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Wed, 15 May 2024 14:49:47 +0300 Subject: [PATCH 03/42] Fix for requirements file location --- plugins/{ => pdr_deterministic_plugin}/requirements.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename plugins/{ => pdr_deterministic_plugin}/requirements.txt (100%) diff --git a/plugins/requirements.txt b/plugins/pdr_deterministic_plugin/requirements.txt similarity index 100% rename from plugins/requirements.txt rename to plugins/pdr_deterministic_plugin/requirements.txt From ee3564ad16cd8fc4db404336a4b8e586cb3898ff Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Wed, 15 May 2024 14:57:00 +0300 Subject: [PATCH 04/42] Added missing empty file --- plugins/pdr_deterministic_plugin/__init__.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 plugins/pdr_deterministic_plugin/__init__.py diff --git a/plugins/pdr_deterministic_plugin/__init__.py b/plugins/pdr_deterministic_plugin/__init__.py new file mode 100644 index 000000000..26680606e --- /dev/null +++ b/plugins/pdr_deterministic_plugin/__init__.py @@ -0,0 +1,11 @@ +# +# Copyright © 2013-2024 NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. +# +# This software product is a proprietary product of Nvidia Corporation and its affiliates +# (the "Company") and all right, title, and interest in and to the software +# product, including all associated intellectual property rights, are and +# shall remain exclusively with the Company. +# +# This software product is governed by the End User License Agreement +# provided with the software product. +# From 9451c9bb7d48224bb6251e56a45aa1d4c9891b2b Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Wed, 15 May 2024 16:13:15 +0300 Subject: [PATCH 05/42] First simple pytest test --- .github/workflows/pdr_plugin_ci_workflow.yml | 7 ++++- .../tests/exclude_list_tests.py | 26 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py diff --git a/.github/workflows/pdr_plugin_ci_workflow.yml b/.github/workflows/pdr_plugin_ci_workflow.yml index fded0b46f..7e98265f8 100644 --- a/.github/workflows/pdr_plugin_ci_workflow.yml +++ b/.github/workflows/pdr_plugin_ci_workflow.yml @@ -20,5 +20,10 @@ jobs: run: | pip install -r plugins/pdr_deterministic_plugin/requirements.txt pip install pylint + pip install pytest pytest-cov + - name: Run PyLint - run: pylint --rcfile=plugins/pdr_deterministic_plugin/.pylintrc plugins/pdr_deterministic_plugin \ No newline at end of file + run: pylint --rcfile=plugins/pdr_deterministic_plugin/.pylintrc plugins/pdr_deterministic_plugin + + - name: Test exclude list with pytest + run: pytest exclude_list_tests.py --doctest-modules --junitxml=junit/exclude_list_tests_results.xml --cov=com --cov-report=xml --cov-report=html \ No newline at end of file diff --git a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py new file mode 100644 index 000000000..0f504475a --- /dev/null +++ b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py @@ -0,0 +1,26 @@ +# +# Copyright © 2013-2024 NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. +# +# This software product is a proprietary product of Nvidia Corporation and its affiliates +# (the "Company") and all right, title, and interest in and to the software +# product, including all associated intellectual property rights, are and +# shall remain exclusively with the Company. +# +# This software product is governed by the End User License Agreement +# provided with the software product. +# + +#import pytest +from plugins.pdr_deterministic_plugin.ufm_sim_web_service.constants import PDRConstants as Constants +from plugins.pdr_deterministic_plugin.ufm_sim_web_service.exclude_list import ExcludeList +from plugins.pdr_deterministic_plugin.ufm_sim_web_service.isolation_algo import create_logger + +def test_get_from_empty_list(): + """ + Create exclude list and ensure its empty via its method + """ + + logger = create_logger(Constants.LOG_FILE) + exclude_list = ExcludeList(logger) + items = exclude_list.items() + assert not items From 1d7629f4eb4b96148f3c9a0cde07ec26057c9782 Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Wed, 15 May 2024 16:18:50 +0300 Subject: [PATCH 06/42] Test file path fix --- .github/workflows/pdr_plugin_ci_workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pdr_plugin_ci_workflow.yml b/.github/workflows/pdr_plugin_ci_workflow.yml index 7e98265f8..03cf24f45 100644 --- a/.github/workflows/pdr_plugin_ci_workflow.yml +++ b/.github/workflows/pdr_plugin_ci_workflow.yml @@ -26,4 +26,4 @@ jobs: run: pylint --rcfile=plugins/pdr_deterministic_plugin/.pylintrc plugins/pdr_deterministic_plugin - name: Test exclude list with pytest - run: pytest exclude_list_tests.py --doctest-modules --junitxml=junit/exclude_list_tests_results.xml --cov=com --cov-report=xml --cov-report=html \ No newline at end of file + run: pytest plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py --doctest-modules --junitxml=junit/exclude_list_tests_results.xml --cov=com --cov-report=xml --cov-report=html \ No newline at end of file From 389a353a1d4e659f8f049ab32128d3ddcc6137dc Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Wed, 15 May 2024 16:22:35 +0300 Subject: [PATCH 07/42] Minor fix --- .github/workflows/pdr_plugin_ci_workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pdr_plugin_ci_workflow.yml b/.github/workflows/pdr_plugin_ci_workflow.yml index 03cf24f45..c28cb31e5 100644 --- a/.github/workflows/pdr_plugin_ci_workflow.yml +++ b/.github/workflows/pdr_plugin_ci_workflow.yml @@ -26,4 +26,4 @@ jobs: run: pylint --rcfile=plugins/pdr_deterministic_plugin/.pylintrc plugins/pdr_deterministic_plugin - name: Test exclude list with pytest - run: pytest plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py --doctest-modules --junitxml=junit/exclude_list_tests_results.xml --cov=com --cov-report=xml --cov-report=html \ No newline at end of file + run: pytest plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py --doctest-modules --junitxml=junit/exclude_list_tests_results.xml --cov=com --cov-report=xml --cov-report=html From 5bf6458d14451e5cbaedeae7ef8c50e815321fb9 Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Wed, 15 May 2024 16:27:06 +0300 Subject: [PATCH 08/42] Minor fix --- plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py index 0f504475a..c4e91b29f 100644 --- a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py +++ b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py @@ -15,11 +15,10 @@ from plugins.pdr_deterministic_plugin.ufm_sim_web_service.exclude_list import ExcludeList from plugins.pdr_deterministic_plugin.ufm_sim_web_service.isolation_algo import create_logger -def test_get_from_empty_list(): +def test_get_from_empty_exclude_list(): """ Create exclude list and ensure its empty via its method """ - logger = create_logger(Constants.LOG_FILE) exclude_list = ExcludeList(logger) items = exclude_list.items() From 0b34f10c2a75d63fdb4e367220f89280c6b22337 Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Wed, 15 May 2024 17:39:26 +0300 Subject: [PATCH 09/42] Import paths --- .../pdr_deterministic_plugin/tests/exclude_list_tests.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py index c4e91b29f..150c704f4 100644 --- a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py +++ b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py @@ -11,9 +11,9 @@ # #import pytest -from plugins.pdr_deterministic_plugin.ufm_sim_web_service.constants import PDRConstants as Constants -from plugins.pdr_deterministic_plugin.ufm_sim_web_service.exclude_list import ExcludeList -from plugins.pdr_deterministic_plugin.ufm_sim_web_service.isolation_algo import create_logger +from constants import PDRConstants as Constants +from exclude_list import ExcludeList +from isolation_algo import create_logger def test_get_from_empty_exclude_list(): """ @@ -23,3 +23,6 @@ def test_get_from_empty_exclude_list(): exclude_list = ExcludeList(logger) items = exclude_list.items() assert not items + +if __name__ == '__main__': + test_get_from_empty_exclude_list() From d57b663c1536455d0a61366f2818e5f9ebbe845b Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Wed, 15 May 2024 17:53:52 +0300 Subject: [PATCH 10/42] Fix --- .github/workflows/pdr_plugin_ci_workflow.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pdr_plugin_ci_workflow.yml b/.github/workflows/pdr_plugin_ci_workflow.yml index c28cb31e5..78e616909 100644 --- a/.github/workflows/pdr_plugin_ci_workflow.yml +++ b/.github/workflows/pdr_plugin_ci_workflow.yml @@ -5,8 +5,12 @@ on: paths: - 'plugins/pdr_deterministic_plugin/**' jobs: - pylint: + build: runs-on: ubuntu-latest + + environment: + PYTHONPATH: 'plugins/pdr_deterministic_plugin/ufm_sim_web_service' + steps: - name: Checkout code uses: actions/checkout@main From f3d08b2780e171074fcfcb57a0a655614b073283 Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Wed, 15 May 2024 17:57:03 +0300 Subject: [PATCH 11/42] Fix --- .github/workflows/pdr_plugin_ci_workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pdr_plugin_ci_workflow.yml b/.github/workflows/pdr_plugin_ci_workflow.yml index 78e616909..6d5dea086 100644 --- a/.github/workflows/pdr_plugin_ci_workflow.yml +++ b/.github/workflows/pdr_plugin_ci_workflow.yml @@ -8,7 +8,7 @@ jobs: build: runs-on: ubuntu-latest - environment: + env: PYTHONPATH: 'plugins/pdr_deterministic_plugin/ufm_sim_web_service' steps: From 056af80fae8de19b5094a984c33b05984ea9094f Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Wed, 15 May 2024 18:10:05 +0300 Subject: [PATCH 12/42] Fix 3 --- plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py index 150c704f4..dffdd942e 100644 --- a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py +++ b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py @@ -19,6 +19,7 @@ def test_get_from_empty_exclude_list(): """ Create exclude list and ensure its empty via its method """ + print("Test 1") logger = create_logger(Constants.LOG_FILE) exclude_list = ExcludeList(logger) items = exclude_list.items() From b874461e113d5891452e5c9433483abbabb5ef51 Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Wed, 15 May 2024 18:17:33 +0300 Subject: [PATCH 13/42] Fix 4 --- .github/workflows/pdr_plugin_ci_workflow.yml | 2 +- plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pdr_plugin_ci_workflow.yml b/.github/workflows/pdr_plugin_ci_workflow.yml index 6d5dea086..f8e92be6e 100644 --- a/.github/workflows/pdr_plugin_ci_workflow.yml +++ b/.github/workflows/pdr_plugin_ci_workflow.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest env: - PYTHONPATH: 'plugins/pdr_deterministic_plugin/ufm_sim_web_service' + PYTHONPATH: '.:plugins/pdr_deterministic_plugin/ufm_sim_web_service' steps: - name: Checkout code diff --git a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py index dffdd942e..5528c7bbe 100644 --- a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py +++ b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py @@ -19,7 +19,7 @@ def test_get_from_empty_exclude_list(): """ Create exclude list and ensure its empty via its method """ - print("Test 1") + print("Test 2") logger = create_logger(Constants.LOG_FILE) exclude_list = ExcludeList(logger) items = exclude_list.items() From 319365179d3d55948141400aeb19c1ff4209c424 Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Wed, 15 May 2024 18:32:57 +0300 Subject: [PATCH 14/42] Fix 5 --- .github/workflows/pdr_plugin_ci_workflow.yml | 2 +- plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pdr_plugin_ci_workflow.yml b/.github/workflows/pdr_plugin_ci_workflow.yml index f8e92be6e..4b8627509 100644 --- a/.github/workflows/pdr_plugin_ci_workflow.yml +++ b/.github/workflows/pdr_plugin_ci_workflow.yml @@ -30,4 +30,4 @@ jobs: run: pylint --rcfile=plugins/pdr_deterministic_plugin/.pylintrc plugins/pdr_deterministic_plugin - name: Test exclude list with pytest - run: pytest plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py --doctest-modules --junitxml=junit/exclude_list_tests_results.xml --cov=com --cov-report=xml --cov-report=html + run: sudo pytest plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py --doctest-modules --junitxml=junit/exclude_list_tests_results.xml --cov=com --cov-report=xml --cov-report=html diff --git a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py index 5528c7bbe..6d664ce4f 100644 --- a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py +++ b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py @@ -19,7 +19,7 @@ def test_get_from_empty_exclude_list(): """ Create exclude list and ensure its empty via its method """ - print("Test 2") + print("Test 3") logger = create_logger(Constants.LOG_FILE) exclude_list = ExcludeList(logger) items = exclude_list.items() From e9a4617c426ad1cf9723f3a8bbe2c6e5b188a1f7 Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Wed, 15 May 2024 19:13:56 +0300 Subject: [PATCH 15/42] Fix 6 --- .../tests/exclude_list_tests.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py index 6d664ce4f..73fabfcda 100644 --- a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py +++ b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py @@ -10,6 +10,9 @@ # provided with the software product. # +import os +import tempfile + #import pytest from constants import PDRConstants as Constants from exclude_list import ExcludeList @@ -19,8 +22,12 @@ def test_get_from_empty_exclude_list(): """ Create exclude list and ensure its empty via its method """ - print("Test 3") - logger = create_logger(Constants.LOG_FILE) + print("Test 4") + + filename = os.path.basename(Constants.LOG_FILE) + lod_file = os.path.join(tempfile.gettempdir(), filename) + + logger = create_logger(lod_file) exclude_list = ExcludeList(logger) items = exclude_list.items() assert not items From 7199f4b501b53e51dd4778e710dde3a2ada816ef Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Wed, 15 May 2024 19:17:20 +0300 Subject: [PATCH 16/42] Fix 7 --- .github/workflows/pdr_plugin_ci_workflow.yml | 2 +- plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pdr_plugin_ci_workflow.yml b/.github/workflows/pdr_plugin_ci_workflow.yml index 4b8627509..f8e92be6e 100644 --- a/.github/workflows/pdr_plugin_ci_workflow.yml +++ b/.github/workflows/pdr_plugin_ci_workflow.yml @@ -30,4 +30,4 @@ jobs: run: pylint --rcfile=plugins/pdr_deterministic_plugin/.pylintrc plugins/pdr_deterministic_plugin - name: Test exclude list with pytest - run: sudo pytest plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py --doctest-modules --junitxml=junit/exclude_list_tests_results.xml --cov=com --cov-report=xml --cov-report=html + run: pytest plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py --doctest-modules --junitxml=junit/exclude_list_tests_results.xml --cov=com --cov-report=xml --cov-report=html diff --git a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py index 73fabfcda..cb96887cf 100644 --- a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py +++ b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py @@ -22,7 +22,7 @@ def test_get_from_empty_exclude_list(): """ Create exclude list and ensure its empty via its method """ - print("Test 4") + print("Test 5") filename = os.path.basename(Constants.LOG_FILE) lod_file = os.path.join(tempfile.gettempdir(), filename) From 2b8d6f0279e3435061a9140256ddb5b910b69cce Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Wed, 15 May 2024 19:28:54 +0300 Subject: [PATCH 17/42] Fix 8 --- .../tests/exclude_list_tests.py | 6 +++--- .../ufm_sim_web_service/isolation_algo.py | 19 +++++++++---------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py index cb96887cf..d87a13b58 100644 --- a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py +++ b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py @@ -24,10 +24,10 @@ def test_get_from_empty_exclude_list(): """ print("Test 5") - filename = os.path.basename(Constants.LOG_FILE) - lod_file = os.path.join(tempfile.gettempdir(), filename) + log_name = os.path.basename(Constants.LOG_FILE) + log_path = os.path.join(tempfile.gettempdir(), log_name) - logger = create_logger(lod_file) + logger = create_logger(log_path) exclude_list = ExcludeList(logger) items = exclude_list.items() assert not items diff --git a/plugins/pdr_deterministic_plugin/ufm_sim_web_service/isolation_algo.py b/plugins/pdr_deterministic_plugin/ufm_sim_web_service/isolation_algo.py index 58350b4f5..b5272c5d5 100644 --- a/plugins/pdr_deterministic_plugin/ufm_sim_web_service/isolation_algo.py +++ b/plugins/pdr_deterministic_plugin/ufm_sim_web_service/isolation_algo.py @@ -26,27 +26,26 @@ from utils.utils import Utils -def create_logger(file): +def create_logger(log_file): """ create a logger to put all the data of the server action :param file: name of the file :return: """ - format_str = "%(asctime)-15s UFM-PDR_deterministic-plugin-{0} Machine: {1} %(levelname)-7s: %(message)s".format(file,'localhost') - log_name = Constants.LOG_FILE - if not os.path.exists(log_name): - os.makedirs('/'.join(log_name.split('/')[:-1]), exist_ok=True) - logger = logging.getLogger(log_name) + format_str = "%(asctime)-15s UFM-PDR_deterministic-plugin-{0} Machine: {1} %(levelname)-7s: %(message)s".format(log_file,'localhost') + if not os.path.exists(log_file): + os.makedirs('/'.join(log_file.split('/')[:-1]), exist_ok=True) + logger = logging.getLogger(log_file) logging_level = logging.getLevelName(Constants.log_level) \ if isinstance(Constants.log_level, str) else Constants.log_level logging.basicConfig(format=format_str,level=logging_level) - rotateHandler = RotatingFileHandler(log_name,maxBytes=Constants.log_file_max_size, + rotate_handler = RotatingFileHandler(log_file,maxBytes=Constants.log_file_max_size, backupCount=Constants.log_file_backup_count) - rotateHandler.setLevel(Constants.log_level) - rotateHandler.setFormatter(logging.Formatter(format_str)) - logger.addHandler(rotateHandler) + rotate_handler.setLevel(Constants.log_level) + rotate_handler.setFormatter(logging.Formatter(format_str)) + logger.addHandler(rotate_handler) return logger From fc2fca11b25e5ef1c498fee2cd9bfb8c3bb532ed Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Thu, 16 May 2024 14:11:29 +0300 Subject: [PATCH 18/42] Test ExcludeList class methods directly --- .../tests/exclude_list_tests.py | 75 ++++++++++++++++--- 1 file changed, 65 insertions(+), 10 deletions(-) diff --git a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py index d87a13b58..67b5b1172 100644 --- a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py +++ b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py @@ -12,25 +12,80 @@ import os import tempfile - -#import pytest +import time +import pytest from constants import PDRConstants as Constants -from exclude_list import ExcludeList +from exclude_list import ExcludeList, ExcludeListItem from isolation_algo import create_logger -def test_get_from_empty_exclude_list(): +def get_logger(): """ - Create exclude list and ensure its empty via its method + Return logger associated with log file in temporary directory """ - print("Test 5") - log_name = os.path.basename(Constants.LOG_FILE) log_path = os.path.join(tempfile.gettempdir(), log_name) + return create_logger(log_path) + +pytest.mark.run(order=0) +def test_exclude_list_class_methods(): + """ + Create exclude list and ensure its empty via its method + """ + # Create exclude list and ensure it's - logger = create_logger(log_path) - exclude_list = ExcludeList(logger) + exclude_list = ExcludeList(get_logger()) items = exclude_list.items() assert not items + # Add ports to excluded list + excluded_ports = [ + ExcludeListItem("0123456789aaabbb_1", 0), # Add forever + ExcludeListItem("9876543210cccddd_2", 30), # Add for 30 seconds + ExcludeListItem("3456789012eeefff_3", 0) # Add forever + ] + for port in excluded_ports: + exclude_list.add(port.port_name, port.ttl_seconds) + + # Test excluded list size + items = exclude_list.items() + assert items and len(items) == len(excluded_ports) + + # Test 'contains' method + for port in excluded_ports: + assert exclude_list.contains(port.port_name) + + # Test excluded list content + for (index, item) in enumerate(items): + assert item.port_name == excluded_ports[index].port_name + assert item.ttl_seconds == excluded_ports[index].ttl_seconds + + # Test auto-remove of second port after TTL is expired + auto_remove_port = excluded_ports[1] + time.sleep(auto_remove_port.ttl_seconds + 1) + assert not exclude_list.contains(auto_remove_port.port_name) + + # Test excluded list size + items = exclude_list.items() + assert items and len(items) == (len(excluded_ports) - 1) + + # Test excluded list content + for port in excluded_ports: + if port.port_name != auto_remove_port.port_name: + assert exclude_list.contains(port.port_name) + + # Test forced remove of third port + remove_port = excluded_ports[2] + exclude_list.remove(port.port_name) + assert not exclude_list.contains(remove_port.port_name) + + # Test excluded list size + items = exclude_list.items() + assert items and len(items) == (len(excluded_ports) - 2) + + # Test excluded list content + for port in excluded_ports: + if port.port_name != remove_port.port_name and port.port_name != auto_remove_port.port_name: + assert exclude_list.contains(port.port_name) + if __name__ == '__main__': - test_get_from_empty_exclude_list() + test_exclude_list_class_methods() From 26070aa286e143208d8645164d761e495352c47a Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Thu, 16 May 2024 15:05:06 +0300 Subject: [PATCH 19/42] Initial REST API test and generated requirements file --- .../pdr_deterministic_plugin/requirements.txt | 18 ++++----- .../tests/exclude_list_tests.py | 40 +++++++++++++++---- 2 files changed, 40 insertions(+), 18 deletions(-) diff --git a/plugins/pdr_deterministic_plugin/requirements.txt b/plugins/pdr_deterministic_plugin/requirements.txt index 105e91cca..e245b0634 100644 --- a/plugins/pdr_deterministic_plugin/requirements.txt +++ b/plugins/pdr_deterministic_plugin/requirements.txt @@ -1,11 +1,7 @@ -requests -configparser -flask -flask_restful -twisted -tzlocal<3.0 -jsonschema -pandas -numpy -prometheus_client -msgpack +Flask==3.0.3 +numpy==1.26.4 +pandas==2.2.2 +pytest==8.2.0 +Requests==2.31.0 +Twisted==22.1.0 +utils==1.0.2 diff --git a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py index 67b5b1172..3d44ced8d 100644 --- a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py +++ b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py @@ -10,10 +10,13 @@ # provided with the software product. # +import http +import json import os import tempfile import time import pytest +import requests from constants import PDRConstants as Constants from exclude_list import ExcludeList, ExcludeListItem from isolation_algo import create_logger @@ -29,20 +32,20 @@ def get_logger(): pytest.mark.run(order=0) def test_exclude_list_class_methods(): """ - Create exclude list and ensure its empty via its method + Test exclude list class methods by direct calls """ - # Create exclude list and ensure it's + excluded_ports = [ + ExcludeListItem("0123456789aaabbb_1", 0), # Add forever + ExcludeListItem("9876543210cccddd_2", 30), # Add for 30 seconds + ExcludeListItem("3456789012eeefff_3", 0) # Add forever + ] + # Create exclude list and ensure it's empty exclude_list = ExcludeList(get_logger()) items = exclude_list.items() assert not items # Add ports to excluded list - excluded_ports = [ - ExcludeListItem("0123456789aaabbb_1", 0), # Add forever - ExcludeListItem("9876543210cccddd_2", 30), # Add for 30 seconds - ExcludeListItem("3456789012eeefff_3", 0) # Add forever - ] for port in excluded_ports: exclude_list.add(port.port_name, port.ttl_seconds) @@ -87,5 +90,28 @@ def test_exclude_list_class_methods(): if port.port_name != remove_port.port_name and port.port_name != auto_remove_port.port_name: assert exclude_list.contains(port.port_name) +pytest.mark.run(order=1) +def test_exclude_list_rest_api(): + """ + Test exclude list inside plugin via REST API + """ + url = "http://127.0.0.1:8977/excluded" + + excluded_ports = [ + ExcludeListItem("0123456789aaabbb_1", 0), # Add forever + ExcludeListItem("9876543210cccddd_2", 30), # Add for 30 seconds + ExcludeListItem("3456789012eeefff_3", 0) # Add forever + ] + + # Prepare data for PUT HTTP request + data = [] + for port in excluded_ports: + data.append([port.port_name, port.ttl_seconds]) + + # Add ports to excluded list + response = requests.put(url, data=json.dumps(data), headers={'Content-Type': 'application/json'}, timeout=5, auth = None, verify = False) + assert response.status_code == http.client.OK + if __name__ == '__main__': test_exclude_list_class_methods() + test_exclude_list_rest_api() From 4d94359aa3444b4ce4fbfeb07dd60ba99698d775 Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Thu, 16 May 2024 15:12:49 +0300 Subject: [PATCH 20/42] Rollback for requirements file --- .../pdr_deterministic_plugin/requirements.txt | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/plugins/pdr_deterministic_plugin/requirements.txt b/plugins/pdr_deterministic_plugin/requirements.txt index e245b0634..105e91cca 100644 --- a/plugins/pdr_deterministic_plugin/requirements.txt +++ b/plugins/pdr_deterministic_plugin/requirements.txt @@ -1,7 +1,11 @@ -Flask==3.0.3 -numpy==1.26.4 -pandas==2.2.2 -pytest==8.2.0 -Requests==2.31.0 -Twisted==22.1.0 -utils==1.0.2 +requests +configparser +flask +flask_restful +twisted +tzlocal<3.0 +jsonschema +pandas +numpy +prometheus_client +msgpack From 270298922e92952e5c6557143e7920405a335ca4 Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Thu, 16 May 2024 15:38:59 +0300 Subject: [PATCH 21/42] Disable REST API test --- .../pdr_deterministic_plugin/tests/exclude_list_tests.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py index 3d44ced8d..fc566f3ba 100644 --- a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py +++ b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py @@ -90,8 +90,8 @@ def test_exclude_list_class_methods(): if port.port_name != remove_port.port_name and port.port_name != auto_remove_port.port_name: assert exclude_list.contains(port.port_name) -pytest.mark.run(order=1) -def test_exclude_list_rest_api(): +#pytest.mark.run(order=1) +def no_test_exclude_list_rest_api(): """ Test exclude list inside plugin via REST API """ @@ -114,4 +114,4 @@ def test_exclude_list_rest_api(): if __name__ == '__main__': test_exclude_list_class_methods() - test_exclude_list_rest_api() + #test_exclude_list_rest_api() From 2110e43730d9353fd94c11fe8db9f71f128e8b1e Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Thu, 16 May 2024 16:17:00 +0300 Subject: [PATCH 22/42] Experimental --- .github/workflows/pdr_plugin_ci_workflow.yml | 40 +++++++++++++++++++ .../tests/exclude_list_tests.py | 2 + 2 files changed, 42 insertions(+) diff --git a/.github/workflows/pdr_plugin_ci_workflow.yml b/.github/workflows/pdr_plugin_ci_workflow.yml index f8e92be6e..877f37ff5 100644 --- a/.github/workflows/pdr_plugin_ci_workflow.yml +++ b/.github/workflows/pdr_plugin_ci_workflow.yml @@ -5,6 +5,46 @@ on: paths: - 'plugins/pdr_deterministic_plugin/**' jobs: + ufm-pdr-deterministic-plugin: + runs-on: ubuntu-latest + + env: + plugin_dir: pdr_deterministic_plugin + plugin_name: ufm-plugin-pdr_deterministic + DOCKER_CLI_EXPERIMENTAL: enabled + + steps: + - name: Build Plugin + run: | + cd plugins/$plugin_dir/build + bash -x ./docker_build.sh latest / + ls -l / + cp /ufm-plugin* /auto/UFM/tmp/${JOB_NAME}/${BUILD_ID}/ + + - name: remove plugin if exists on the location + run: | + env + bash -x plugins/pdr_deterministic_plugin/.ci/do_remove_plugin.sh + + - name: Install the new plugin on Server + run: | + env + pwd + export PASSWORD=$PASSWORD + bash -x plugins/pdr_deterministic_plugin/.ci/do_install_plugin_server.sh + + - name: load plugin + run: | + bash -x plugins/pdr_deterministic_plugin/.ci/do_load_plugin.sh + + - name: add plugin + run: | + bash -x plugins/pdr_deterministic_plugin/.ci/do_add_plugin.sh + + - name: remove plugin end + run: | + bash -x plugins/pdr_deterministic_plugin/.ci/do_remove_plugin.sh + build: runs-on: ubuntu-latest diff --git a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py index fc566f3ba..412640905 100644 --- a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py +++ b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py @@ -21,6 +21,8 @@ from exclude_list import ExcludeList, ExcludeListItem from isolation_algo import create_logger +# Comment just for trigger the test (1) + def get_logger(): """ Return logger associated with log file in temporary directory From aad96f7e3b7575e7353eebef1c3c05ecc74156e2 Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Thu, 16 May 2024 16:31:29 +0300 Subject: [PATCH 23/42] Rollback experimental --- .github/workflows/pdr_plugin_ci_workflow.yml | 40 ------------------- .../tests/exclude_list_tests.py | 2 - 2 files changed, 42 deletions(-) diff --git a/.github/workflows/pdr_plugin_ci_workflow.yml b/.github/workflows/pdr_plugin_ci_workflow.yml index 877f37ff5..f8e92be6e 100644 --- a/.github/workflows/pdr_plugin_ci_workflow.yml +++ b/.github/workflows/pdr_plugin_ci_workflow.yml @@ -5,46 +5,6 @@ on: paths: - 'plugins/pdr_deterministic_plugin/**' jobs: - ufm-pdr-deterministic-plugin: - runs-on: ubuntu-latest - - env: - plugin_dir: pdr_deterministic_plugin - plugin_name: ufm-plugin-pdr_deterministic - DOCKER_CLI_EXPERIMENTAL: enabled - - steps: - - name: Build Plugin - run: | - cd plugins/$plugin_dir/build - bash -x ./docker_build.sh latest / - ls -l / - cp /ufm-plugin* /auto/UFM/tmp/${JOB_NAME}/${BUILD_ID}/ - - - name: remove plugin if exists on the location - run: | - env - bash -x plugins/pdr_deterministic_plugin/.ci/do_remove_plugin.sh - - - name: Install the new plugin on Server - run: | - env - pwd - export PASSWORD=$PASSWORD - bash -x plugins/pdr_deterministic_plugin/.ci/do_install_plugin_server.sh - - - name: load plugin - run: | - bash -x plugins/pdr_deterministic_plugin/.ci/do_load_plugin.sh - - - name: add plugin - run: | - bash -x plugins/pdr_deterministic_plugin/.ci/do_add_plugin.sh - - - name: remove plugin end - run: | - bash -x plugins/pdr_deterministic_plugin/.ci/do_remove_plugin.sh - build: runs-on: ubuntu-latest diff --git a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py index 412640905..fc566f3ba 100644 --- a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py +++ b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py @@ -21,8 +21,6 @@ from exclude_list import ExcludeList, ExcludeListItem from isolation_algo import create_logger -# Comment just for trigger the test (1) - def get_logger(): """ Return logger associated with log file in temporary directory From e15b99b53f9872173d0ad989110ea39f07ba6fd2 Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Thu, 16 May 2024 19:31:56 +0300 Subject: [PATCH 24/42] Experiment with standalone plugin --- .github/workflows/pdr_plugin_ci_workflow.yml | 13 ++++++++++++- .../tests/exclude_list_tests.py | 6 +++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pdr_plugin_ci_workflow.yml b/.github/workflows/pdr_plugin_ci_workflow.yml index f8e92be6e..fd345ae2f 100644 --- a/.github/workflows/pdr_plugin_ci_workflow.yml +++ b/.github/workflows/pdr_plugin_ci_workflow.yml @@ -28,6 +28,17 @@ jobs: - name: Run PyLint run: pylint --rcfile=plugins/pdr_deterministic_plugin/.pylintrc plugins/pdr_deterministic_plugin + + - name: Run single plugin instance on background as standalone + run: | + kill -9 isolation_algo.py + sleep 10 + nohup python plugins/pdr_deterministic_plugin/ufm_sim_web_service/isolation_algo.py > /dev/null 2>&1 & - name: Test exclude list with pytest - run: pytest plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py --doctest-modules --junitxml=junit/exclude_list_tests_results.xml --cov=com --cov-report=xml --cov-report=html + run: pytest plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py #--doctest-modules --junitxml=junit/exclude_list_tests_results.xml --cov=com --cov-report=xml --cov-report=html + + - name: Kill plugin process + run: | + kill -9 isolation_algo.py + sleep 10 diff --git a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py index fc566f3ba..3d44ced8d 100644 --- a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py +++ b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py @@ -90,8 +90,8 @@ def test_exclude_list_class_methods(): if port.port_name != remove_port.port_name and port.port_name != auto_remove_port.port_name: assert exclude_list.contains(port.port_name) -#pytest.mark.run(order=1) -def no_test_exclude_list_rest_api(): +pytest.mark.run(order=1) +def test_exclude_list_rest_api(): """ Test exclude list inside plugin via REST API """ @@ -114,4 +114,4 @@ def no_test_exclude_list_rest_api(): if __name__ == '__main__': test_exclude_list_class_methods() - #test_exclude_list_rest_api() + test_exclude_list_rest_api() From f405f1d8073d7116db6cd894ea31179b205d46ff Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Thu, 16 May 2024 19:39:37 +0300 Subject: [PATCH 25/42] Experiment with standalone plugin --- .github/workflows/pdr_plugin_ci_workflow.yml | 4 ++-- plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pdr_plugin_ci_workflow.yml b/.github/workflows/pdr_plugin_ci_workflow.yml index fd345ae2f..7b2476ac2 100644 --- a/.github/workflows/pdr_plugin_ci_workflow.yml +++ b/.github/workflows/pdr_plugin_ci_workflow.yml @@ -31,7 +31,7 @@ jobs: - name: Run single plugin instance on background as standalone run: | - kill -9 isolation_algo.py + pkill -9 -f isolation_algo.py sleep 10 nohup python plugins/pdr_deterministic_plugin/ufm_sim_web_service/isolation_algo.py > /dev/null 2>&1 & @@ -40,5 +40,5 @@ jobs: - name: Kill plugin process run: | - kill -9 isolation_algo.py + pkill -9 -f isolation_algo.py sleep 10 diff --git a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py index 3d44ced8d..a12c78af0 100644 --- a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py +++ b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py @@ -21,6 +21,8 @@ from exclude_list import ExcludeList, ExcludeListItem from isolation_algo import create_logger +# Temp + def get_logger(): """ Return logger associated with log file in temporary directory From e6cd666a12329a1994282e8fc506099eb7a75d3c Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Thu, 16 May 2024 19:53:03 +0300 Subject: [PATCH 26/42] Experiment with standalone plugin --- .github/workflows/pdr_plugin_ci_workflow.yml | 2 ++ plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pdr_plugin_ci_workflow.yml b/.github/workflows/pdr_plugin_ci_workflow.yml index 7b2476ac2..fefb4d05e 100644 --- a/.github/workflows/pdr_plugin_ci_workflow.yml +++ b/.github/workflows/pdr_plugin_ci_workflow.yml @@ -31,6 +31,8 @@ jobs: - name: Run single plugin instance on background as standalone run: | + cp -r utils plugins/pdr_deterministic_plugin/ufm_sim_web_service + cp -r utils plugins/pdr_deterministic_plugin/ pkill -9 -f isolation_algo.py sleep 10 nohup python plugins/pdr_deterministic_plugin/ufm_sim_web_service/isolation_algo.py > /dev/null 2>&1 & diff --git a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py index a12c78af0..2cc78d19b 100644 --- a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py +++ b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py @@ -21,7 +21,7 @@ from exclude_list import ExcludeList, ExcludeListItem from isolation_algo import create_logger -# Temp +# Temp 1 def get_logger(): """ From 7aee83f59c8243a3723b956dadab5505066e4222 Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Thu, 16 May 2024 19:57:03 +0300 Subject: [PATCH 27/42] Experiment with standalone plugin --- .github/workflows/pdr_plugin_ci_workflow.yml | 6 +++--- .../pdr_deterministic_plugin/tests/exclude_list_tests.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pdr_plugin_ci_workflow.yml b/.github/workflows/pdr_plugin_ci_workflow.yml index fefb4d05e..bed70f5ef 100644 --- a/.github/workflows/pdr_plugin_ci_workflow.yml +++ b/.github/workflows/pdr_plugin_ci_workflow.yml @@ -31,11 +31,11 @@ jobs: - name: Run single plugin instance on background as standalone run: | - cp -r utils plugins/pdr_deterministic_plugin/ufm_sim_web_service - cp -r utils plugins/pdr_deterministic_plugin/ + cp -r ./utils plugins/pdr_deterministic_plugin/ufm_sim_web_service + cp -r ./utils plugins/pdr_deterministic_plugin/ pkill -9 -f isolation_algo.py sleep 10 - nohup python plugins/pdr_deterministic_plugin/ufm_sim_web_service/isolation_algo.py > /dev/null 2>&1 & +# nohup python plugins/pdr_deterministic_plugin/ufm_sim_web_service/isolation_algo.py > /dev/null 2>&1 & - name: Test exclude list with pytest run: pytest plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py #--doctest-modules --junitxml=junit/exclude_list_tests_results.xml --cov=com --cov-report=xml --cov-report=html diff --git a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py index 2cc78d19b..e11d2893f 100644 --- a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py +++ b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py @@ -21,7 +21,7 @@ from exclude_list import ExcludeList, ExcludeListItem from isolation_algo import create_logger -# Temp 1 +# Temp 2 def get_logger(): """ From 6ed1bcc701c0eee66839bec290d4dfc2ba35a367 Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Thu, 16 May 2024 20:01:11 +0300 Subject: [PATCH 28/42] Experiment with standalone plugin --- .github/workflows/pdr_plugin_ci_workflow.yml | 5 +++-- plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pdr_plugin_ci_workflow.yml b/.github/workflows/pdr_plugin_ci_workflow.yml index bed70f5ef..802e52ac7 100644 --- a/.github/workflows/pdr_plugin_ci_workflow.yml +++ b/.github/workflows/pdr_plugin_ci_workflow.yml @@ -31,10 +31,11 @@ jobs: - name: Run single plugin instance on background as standalone run: | - cp -r ./utils plugins/pdr_deterministic_plugin/ufm_sim_web_service - cp -r ./utils plugins/pdr_deterministic_plugin/ + #cp -r ./utils plugins/pdr_deterministic_plugin/ufm_sim_web_service + #cp -r ./utils plugins/pdr_deterministic_plugin/ pkill -9 -f isolation_algo.py sleep 10 + python plugins/pdr_deterministic_plugin/ufm_sim_web_service/isolation_algo.py # nohup python plugins/pdr_deterministic_plugin/ufm_sim_web_service/isolation_algo.py > /dev/null 2>&1 & - name: Test exclude list with pytest diff --git a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py index e11d2893f..0308abdaa 100644 --- a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py +++ b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py @@ -21,7 +21,7 @@ from exclude_list import ExcludeList, ExcludeListItem from isolation_algo import create_logger -# Temp 2 +# Temp 3 def get_logger(): """ From 8d9ce72303fbdc658b4227d88f5411a276410e3a Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Thu, 16 May 2024 20:03:33 +0300 Subject: [PATCH 29/42] Experiment with standalone plugin --- .github/workflows/pdr_plugin_ci_workflow.yml | 8 ++++---- .../pdr_deterministic_plugin/tests/exclude_list_tests.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pdr_plugin_ci_workflow.yml b/.github/workflows/pdr_plugin_ci_workflow.yml index 802e52ac7..6e74e72bc 100644 --- a/.github/workflows/pdr_plugin_ci_workflow.yml +++ b/.github/workflows/pdr_plugin_ci_workflow.yml @@ -31,11 +31,11 @@ jobs: - name: Run single plugin instance on background as standalone run: | - #cp -r ./utils plugins/pdr_deterministic_plugin/ufm_sim_web_service - #cp -r ./utils plugins/pdr_deterministic_plugin/ - pkill -9 -f isolation_algo.py - sleep 10 python plugins/pdr_deterministic_plugin/ufm_sim_web_service/isolation_algo.py +# pkill -9 -f isolation_algo.py +# sleep 10 +# cp -r ./utils plugins/pdr_deterministic_plugin/ufm_sim_web_service +# cp -r ./utils plugins/pdr_deterministic_plugin/ # nohup python plugins/pdr_deterministic_plugin/ufm_sim_web_service/isolation_algo.py > /dev/null 2>&1 & - name: Test exclude list with pytest diff --git a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py index 0308abdaa..27247658f 100644 --- a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py +++ b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py @@ -21,7 +21,7 @@ from exclude_list import ExcludeList, ExcludeListItem from isolation_algo import create_logger -# Temp 3 +# Temp 4 def get_logger(): """ From 031da8173183c9032fa505f567a66834eac3003b Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Sun, 19 May 2024 08:25:30 +0300 Subject: [PATCH 30/42] Temp: full simulation --- .github/workflows/pdr_plugin_ci_workflow.yml | 4 +++- .../.pytest/run_simulation_pytest.sh | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh diff --git a/.github/workflows/pdr_plugin_ci_workflow.yml b/.github/workflows/pdr_plugin_ci_workflow.yml index 6e74e72bc..2f985e242 100644 --- a/.github/workflows/pdr_plugin_ci_workflow.yml +++ b/.github/workflows/pdr_plugin_ci_workflow.yml @@ -31,7 +31,9 @@ jobs: - name: Run single plugin instance on background as standalone run: | - python plugins/pdr_deterministic_plugin/ufm_sim_web_service/isolation_algo.py + bash plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh +# cp -f plugins/pdr_deterministic_plugin/build/config/pdr_deterministic.conf /config/ +# python plugins/pdr_deterministic_plugin/ufm_sim_web_service/isolation_algo.py # pkill -9 -f isolation_algo.py # sleep 10 # cp -r ./utils plugins/pdr_deterministic_plugin/ufm_sim_web_service diff --git a/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh b/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh new file mode 100644 index 000000000..10930cd97 --- /dev/null +++ b/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh @@ -0,0 +1,12 @@ +#!/bin/bash -x + +CONFIG_FILE="/config/pdr_deterministic.conf" +cp -f plugins/pdr_deterministic_plugin/build/config/pdr_deterministic.conf "$CONFIG_FILE" +sed -i -e 's/\nTEST_MODE=True\n//g' "$CONFIG_FILE" +echo -e '\n[Common]\nTEST_MODE=True\n' >> "$CONFIG_FILE" +sed -i -e 's/DRY_RUN=False/DRY_RUN=True/g' "$CONFIG_FILE" +sed -i -e 's/INTERVAL=300/INTERVAL=10/g' "$CONFIG_FILE" +sed -i -e 's/CONFIGURED_TEMP_CHECK=False/CONFIGURED_TEMP_CHECK=True/g' "$CONFIG_FILE" +sed -i -e 's/DEISOLATE_CONSIDER_TIME=5/DEISOLATE_CONSIDER_TIME=1/g' "$CONFIG_FILE" + +python plugins/pdr_deterministic_plugin/ufm_sim_web_service/isolation_algo.py \ No newline at end of file From c0faf9e4043d29119eb7146b3331d391e7564f48 Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Sun, 19 May 2024 08:29:13 +0300 Subject: [PATCH 31/42] Temp: full simulation --- .../pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh b/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh index 10930cd97..e63ef322c 100644 --- a/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh +++ b/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh @@ -1,5 +1,5 @@ #!/bin/bash -x - +mkdir -p /config CONFIG_FILE="/config/pdr_deterministic.conf" cp -f plugins/pdr_deterministic_plugin/build/config/pdr_deterministic.conf "$CONFIG_FILE" sed -i -e 's/\nTEST_MODE=True\n//g' "$CONFIG_FILE" From 7ffef77c402f5e0b3b848ee39ac076436c585a74 Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Sun, 19 May 2024 08:33:32 +0300 Subject: [PATCH 32/42] Temp: full simulation --- .../pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh b/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh index e63ef322c..cb1550b15 100644 --- a/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh +++ b/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh @@ -1,5 +1,5 @@ #!/bin/bash -x -mkdir -p /config +sudo mkdir -p /config CONFIG_FILE="/config/pdr_deterministic.conf" cp -f plugins/pdr_deterministic_plugin/build/config/pdr_deterministic.conf "$CONFIG_FILE" sed -i -e 's/\nTEST_MODE=True\n//g' "$CONFIG_FILE" From ead0b0893761188599121b8914e3e64dc7a1a067 Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Sun, 19 May 2024 08:36:31 +0300 Subject: [PATCH 33/42] Temp: full simulation --- .../pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh b/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh index cb1550b15..66a3b6b26 100644 --- a/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh +++ b/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh @@ -1,7 +1,7 @@ #!/bin/bash -x -sudo mkdir -p /config CONFIG_FILE="/config/pdr_deterministic.conf" -cp -f plugins/pdr_deterministic_plugin/build/config/pdr_deterministic.conf "$CONFIG_FILE" +sudo mkdir -p /config +sudo cp -f plugins/pdr_deterministic_plugin/build/config/pdr_deterministic.conf "$CONFIG_FILE" sed -i -e 's/\nTEST_MODE=True\n//g' "$CONFIG_FILE" echo -e '\n[Common]\nTEST_MODE=True\n' >> "$CONFIG_FILE" sed -i -e 's/DRY_RUN=False/DRY_RUN=True/g' "$CONFIG_FILE" From 995d0d2389741554a5d958789b9044a33d8d45a7 Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Sun, 19 May 2024 08:39:09 +0300 Subject: [PATCH 34/42] Temp: full simulation --- .github/workflows/pdr_plugin_ci_workflow.yml | 2 +- .../pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pdr_plugin_ci_workflow.yml b/.github/workflows/pdr_plugin_ci_workflow.yml index 2f985e242..cf6a280f6 100644 --- a/.github/workflows/pdr_plugin_ci_workflow.yml +++ b/.github/workflows/pdr_plugin_ci_workflow.yml @@ -31,7 +31,7 @@ jobs: - name: Run single plugin instance on background as standalone run: | - bash plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh + sudo bash plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh # cp -f plugins/pdr_deterministic_plugin/build/config/pdr_deterministic.conf /config/ # python plugins/pdr_deterministic_plugin/ufm_sim_web_service/isolation_algo.py # pkill -9 -f isolation_algo.py diff --git a/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh b/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh index 66a3b6b26..1a8cd52d4 100644 --- a/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh +++ b/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh @@ -1,7 +1,7 @@ #!/bin/bash -x CONFIG_FILE="/config/pdr_deterministic.conf" -sudo mkdir -p /config -sudo cp -f plugins/pdr_deterministic_plugin/build/config/pdr_deterministic.conf "$CONFIG_FILE" +mkdir -p /config +cp -f plugins/pdr_deterministic_plugin/build/config/pdr_deterministic.conf "$CONFIG_FILE" sed -i -e 's/\nTEST_MODE=True\n//g' "$CONFIG_FILE" echo -e '\n[Common]\nTEST_MODE=True\n' >> "$CONFIG_FILE" sed -i -e 's/DRY_RUN=False/DRY_RUN=True/g' "$CONFIG_FILE" From 0bb237443bf4d532a821106ffc15a2a099cd5ed7 Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Sun, 19 May 2024 08:47:48 +0300 Subject: [PATCH 35/42] Temp: full simulation --- .../pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh b/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh index 1a8cd52d4..7714cedf0 100644 --- a/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh +++ b/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh @@ -1,4 +1,7 @@ #!/bin/bash -x + +pip install -r requirements.txt + CONFIG_FILE="/config/pdr_deterministic.conf" mkdir -p /config cp -f plugins/pdr_deterministic_plugin/build/config/pdr_deterministic.conf "$CONFIG_FILE" From 8e5920aae373ea668895fbe463543050b9cf2d89 Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Sun, 19 May 2024 08:50:18 +0300 Subject: [PATCH 36/42] Temp: full simulation --- .../pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh b/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh index 7714cedf0..b4ffdc004 100644 --- a/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh +++ b/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh @@ -1,6 +1,6 @@ #!/bin/bash -x -pip install -r requirements.txt +pip install -r plugins/pdr_deterministic_plugin/requirements.txt CONFIG_FILE="/config/pdr_deterministic.conf" mkdir -p /config From bc9d5d4d42eed5645fecafc18ca0e6ba69583c24 Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Sun, 19 May 2024 08:59:14 +0300 Subject: [PATCH 37/42] Temp: full simulation --- .github/workflows/pdr_plugin_ci_workflow.yml | 3 ++- .../.pytest/run_simulation_pytest.sh | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pdr_plugin_ci_workflow.yml b/.github/workflows/pdr_plugin_ci_workflow.yml index cf6a280f6..243127832 100644 --- a/.github/workflows/pdr_plugin_ci_workflow.yml +++ b/.github/workflows/pdr_plugin_ci_workflow.yml @@ -7,7 +7,8 @@ on: jobs: build: runs-on: ubuntu-latest - + timeout-minutes: 3 + env: PYTHONPATH: '.:plugins/pdr_deterministic_plugin/ufm_sim_web_service' diff --git a/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh b/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh index b4ffdc004..e06034b52 100644 --- a/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh +++ b/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh @@ -1,10 +1,12 @@ #!/bin/bash -x -pip install -r plugins/pdr_deterministic_plugin/requirements.txt +PLUGIN_DIR="plugins/pdr_deterministic_plugin" +pip install -r $PLUGIN_DIR/requirements.txt +cp -r utils $PLUGIN_DIR/ufm_sim_web_service CONFIG_FILE="/config/pdr_deterministic.conf" mkdir -p /config -cp -f plugins/pdr_deterministic_plugin/build/config/pdr_deterministic.conf "$CONFIG_FILE" +cp -f $PLUGIN_DIR/build/config/pdr_deterministic.conf "$CONFIG_FILE" sed -i -e 's/\nTEST_MODE=True\n//g' "$CONFIG_FILE" echo -e '\n[Common]\nTEST_MODE=True\n' >> "$CONFIG_FILE" sed -i -e 's/DRY_RUN=False/DRY_RUN=True/g' "$CONFIG_FILE" @@ -12,4 +14,4 @@ sed -i -e 's/INTERVAL=300/INTERVAL=10/g' "$CONFIG_FILE" sed -i -e 's/CONFIGURED_TEMP_CHECK=False/CONFIGURED_TEMP_CHECK=True/g' "$CONFIG_FILE" sed -i -e 's/DEISOLATE_CONSIDER_TIME=5/DEISOLATE_CONSIDER_TIME=1/g' "$CONFIG_FILE" -python plugins/pdr_deterministic_plugin/ufm_sim_web_service/isolation_algo.py \ No newline at end of file +python $PLUGIN_DIR/ufm_sim_web_service/isolation_algo.py \ No newline at end of file From 547d87ca2a13170f7753810047f0bbda63591c20 Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Sun, 19 May 2024 09:20:26 +0300 Subject: [PATCH 38/42] Temp: full simulation --- .github/workflows/pdr_plugin_ci_workflow.yml | 2 +- .../.pytest/run_simulation_pytest.sh | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pdr_plugin_ci_workflow.yml b/.github/workflows/pdr_plugin_ci_workflow.yml index 243127832..ebc282212 100644 --- a/.github/workflows/pdr_plugin_ci_workflow.yml +++ b/.github/workflows/pdr_plugin_ci_workflow.yml @@ -7,7 +7,7 @@ on: jobs: build: runs-on: ubuntu-latest - timeout-minutes: 3 + timeout-minutes: 5 env: PYTHONPATH: '.:plugins/pdr_deterministic_plugin/ufm_sim_web_service' diff --git a/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh b/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh index e06034b52..dd227ed84 100644 --- a/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh +++ b/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh @@ -14,4 +14,10 @@ sed -i -e 's/INTERVAL=300/INTERVAL=10/g' "$CONFIG_FILE" sed -i -e 's/CONFIGURED_TEMP_CHECK=False/CONFIGURED_TEMP_CHECK=True/g' "$CONFIG_FILE" sed -i -e 's/DEISOLATE_CONSIDER_TIME=5/DEISOLATE_CONSIDER_TIME=1/g' "$CONFIG_FILE" -python $PLUGIN_DIR/ufm_sim_web_service/isolation_algo.py \ No newline at end of file +echo "Starting 'isolation_algo.py'" +python $PLUGIN_DIR/ufm_sim_web_service/isolation_algo.py & +echo "Started 'isolation_algo.py'" +sleep 180 +echo "Terminating 'isolation_algo.py'" +pkill -9 -f isolation_algo.py +echo "Terminated 'isolation_algo.py'" \ No newline at end of file From 5854493b307182248ec3684b5b157ad2c6f3ce12 Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Sun, 19 May 2024 09:29:54 +0300 Subject: [PATCH 39/42] Temp: full simulation --- .../pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh b/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh index dd227ed84..2a03c761d 100644 --- a/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh +++ b/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh @@ -20,4 +20,5 @@ echo "Started 'isolation_algo.py'" sleep 180 echo "Terminating 'isolation_algo.py'" pkill -9 -f isolation_algo.py -echo "Terminated 'isolation_algo.py'" \ No newline at end of file +echo "Terminated 'isolation_algo.py'" +exit 1 \ No newline at end of file From cfa8bb8a786bedda235a47abb09f07afb8e6efb1 Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Sun, 19 May 2024 10:15:25 +0300 Subject: [PATCH 40/42] Temp: full simulation --- .github/workflows/pdr_plugin_ci_workflow.yml | 2 +- .../.pytest/run_simulation_pytest.sh | 5 ++--- .../pdr_deterministic_plugin/tests/exclude_list_tests.py | 6 +++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pdr_plugin_ci_workflow.yml b/.github/workflows/pdr_plugin_ci_workflow.yml index ebc282212..924bb43be 100644 --- a/.github/workflows/pdr_plugin_ci_workflow.yml +++ b/.github/workflows/pdr_plugin_ci_workflow.yml @@ -7,7 +7,7 @@ on: jobs: build: runs-on: ubuntu-latest - timeout-minutes: 5 + timeout-minutes: 10 env: PYTHONPATH: '.:plugins/pdr_deterministic_plugin/ufm_sim_web_service' diff --git a/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh b/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh index 2a03c761d..ca581d91d 100644 --- a/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh +++ b/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh @@ -16,9 +16,8 @@ sed -i -e 's/DEISOLATE_CONSIDER_TIME=5/DEISOLATE_CONSIDER_TIME=1/g' "$CONFIG_FIL echo "Starting 'isolation_algo.py'" python $PLUGIN_DIR/ufm_sim_web_service/isolation_algo.py & -echo "Started 'isolation_algo.py'" -sleep 180 +echo "Starting 'simulation_telemetry.py'" +python $PLUGIN_DIR/tests/simulation_telemetry.py echo "Terminating 'isolation_algo.py'" pkill -9 -f isolation_algo.py echo "Terminated 'isolation_algo.py'" -exit 1 \ No newline at end of file diff --git a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py index 27247658f..95ea2504e 100644 --- a/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py +++ b/plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py @@ -92,8 +92,8 @@ def test_exclude_list_class_methods(): if port.port_name != remove_port.port_name and port.port_name != auto_remove_port.port_name: assert exclude_list.contains(port.port_name) -pytest.mark.run(order=1) -def test_exclude_list_rest_api(): +#pytest.mark.run(order=1) +def no_test_exclude_list_rest_api(): """ Test exclude list inside plugin via REST API """ @@ -116,4 +116,4 @@ def test_exclude_list_rest_api(): if __name__ == '__main__': test_exclude_list_class_methods() - test_exclude_list_rest_api() + #test_exclude_list_rest_api() From 9ecf0aa976dbbb111c3a3813ef6f201e14a55e72 Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Sun, 19 May 2024 10:35:34 +0300 Subject: [PATCH 41/42] Temp: full simulation --- .github/workflows/pdr_plugin_ci_workflow.yml | 2 +- .../pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pdr_plugin_ci_workflow.yml b/.github/workflows/pdr_plugin_ci_workflow.yml index 924bb43be..d2d440e68 100644 --- a/.github/workflows/pdr_plugin_ci_workflow.yml +++ b/.github/workflows/pdr_plugin_ci_workflow.yml @@ -46,5 +46,5 @@ jobs: - name: Kill plugin process run: | - pkill -9 -f isolation_algo.py + pkill -9 -f isolation_algo.py 2>/dev/null || true sleep 10 diff --git a/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh b/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh index ca581d91d..002c6213e 100644 --- a/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh +++ b/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh @@ -19,5 +19,5 @@ python $PLUGIN_DIR/ufm_sim_web_service/isolation_algo.py & echo "Starting 'simulation_telemetry.py'" python $PLUGIN_DIR/tests/simulation_telemetry.py echo "Terminating 'isolation_algo.py'" -pkill -9 -f isolation_algo.py +pkill -9 -f isolation_algo.py 2>/dev/null || true echo "Terminated 'isolation_algo.py'" From ff1829a3b0313d6596d814c884e4995b31c9909b Mon Sep 17 00:00:00 2001 From: Vitaly Gavensky Date: Sun, 19 May 2024 11:19:41 +0300 Subject: [PATCH 42/42] Temp: full simulation --- .../.pytest/run_simulation_pytest.sh | 1 - .../ufm_sim_web_service/isolation_mgr.py | 10 ++++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh b/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh index 002c6213e..ddf4c2be0 100644 --- a/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh +++ b/plugins/pdr_deterministic_plugin/.pytest/run_simulation_pytest.sh @@ -20,4 +20,3 @@ echo "Starting 'simulation_telemetry.py'" python $PLUGIN_DIR/tests/simulation_telemetry.py echo "Terminating 'isolation_algo.py'" pkill -9 -f isolation_algo.py 2>/dev/null || true -echo "Terminated 'isolation_algo.py'" diff --git a/plugins/pdr_deterministic_plugin/ufm_sim_web_service/isolation_mgr.py b/plugins/pdr_deterministic_plugin/ufm_sim_web_service/isolation_mgr.py index 8ebde143c..c8dc606e9 100644 --- a/plugins/pdr_deterministic_plugin/ufm_sim_web_service/isolation_mgr.py +++ b/plugins/pdr_deterministic_plugin/ufm_sim_web_service/isolation_mgr.py @@ -314,7 +314,8 @@ def eval_isolation(self, port_name, cause): log_message = f"Isolated port: {port_name} cause: {cause}. dry_run: {self.dry_run}" self.logger.warning(log_message) - self.ufm_client.send_event(log_message, event_id=Constants.EXTERNAL_EVENT_ALERT, external_event_name="Isolating Port") + if not self.test_mode: + self.ufm_client.send_event(log_message, event_id=Constants.EXTERNAL_EVENT_ALERT, external_event_name="Isolating Port") def eval_deisolate(self, port_name): @@ -372,8 +373,9 @@ def eval_deisolate(self, port_name): self.ports_states.pop(port_name) log_message = f"Deisolated port: {port_name}. dry_run: {self.dry_run}" self.logger.warning(log_message) - self.ufm_client.send_event(log_message, event_id=Constants.EXTERNAL_EVENT_NOTICE, external_event_name="Deisolating Port") - + if not self.test_mode: + self.ufm_client.send_event(log_message, event_id=Constants.EXTERNAL_EVENT_NOTICE, external_event_name="Deisolating Port") + def get_rate(self, port_obj, counter_name, new_val, timestamp): """ Calculate the rate of the counter @@ -901,7 +903,7 @@ def main_flow(self): self.logger.warning(event_msg) if not self.test_mode: self.ufm_client.send_event(event_msg, event_id=Constants.EXTERNAL_EVENT_ALERT, external_event_name="Skipping isolation") - + # deal with reported new issues else: for issue in issues.values():