From 9a4d3c5b8dc9c7697275cab38ee45b014dff9e55 Mon Sep 17 00:00:00 2001 From: Alex Shatov Date: Mon, 1 Apr 2019 11:32:06 -0400 Subject: 5.0.0 policy-handler - new PDP API or old PDP API - in R4 Dublin the policy-engine introduced a totally new API - policy-handler now has a startup option to either use the new PDP API or the old PDP API that was created-updated before the end of 2018 - see README.md and README_pdp_api_v0.md for instructions on how to setup the policy-handler running either with the new PDP API or the old (pdp_api_v0) PDP API - this is a massive refactoring that changed almost all the source files, but kept the old logic when using the old (pdp_api_v0) PDP API - all the code related to PDP API version is split into two subfolders = pdp_api/ contains the new PDP API source code = pdp_api_v0/ contains the old (2018) PDP API source code = pdp_client.py imports from either pdp_api or pdp_api_v0 = the rest of the code is only affected when it needs to branch the logic - logging to policy_handler.log now shows the path of the source file to allow tracing which PDP API is actually used - when the new PDP API is used, the policy-update flow is disabled = passive mode of operation = no web-socket = no periodic catch_up = no policy-filters = reduced web-API - only a single /policy_latest endpoint is available /policies_latest returns 404 /catch_up request is accepted, but ignored - on new PDP API: http /policy_latest returns the new data from the new PDP API with the following fields added by the policy-handler to keep other policy related parts intact in R4 (see pdp_api/policy_utils.py) = "policyName" = policy_id + "." + "policyVersion" + ".xml" = "policyVersion" = str("metadata"."policy-version") = "config" - is the renamed "properties" from the new PDP API response - unit tests are split into two subfolders as well = main/ for the new PDP API testing = pdp_api_v0/ for the old (2018) PDP API - removed the following line from the license text of changed files ECOMP is a trademark and service mark of AT&T Intellectual Property. - the new PDP API is expected to be extended and redesigned in R5 El Alto - on retiring the old PDP API - the intention is to be able to remove the pdp_api_v0/ subfolder and minimal related cleanup of the code that imports that as well as the cleanup of the config.py, etc. Change-Id: Ief9a2ae4541300308caaf97377f4ed051535dbe4 Signed-off-by: Alex Shatov Issue-ID: DCAEGEN2-1128 --- tests/conftest.py | 189 +- tests/etc_config.json | 47 + tests/main/__init__.py | 20 + tests/main/conftest.py | 56 + tests/main/mock_expected.py | 526 ++++++ tests/main/mock_policy_engine.py | 96 + tests/main/pdp_policies.json | 25 + tests/main/test_policy_rest.py | 47 + tests/main/test_policyhandler.py | 130 ++ tests/mock_config.json | 1 + tests/mock_deploy_handler.py | 15 +- tests/mock_expected.py | 3013 -------------------------------- tests/mock_policy_engine.py | 131 -- tests/mock_settings.py | 56 +- tests/mock_tracker.py | 72 +- tests/mock_websocket.py | 89 - tests/pdp_api_v0/__init__.py | 20 + tests/pdp_api_v0/conftest.py | 133 ++ tests/pdp_api_v0/mock_expected.py | 3012 +++++++++++++++++++++++++++++++ tests/pdp_api_v0/mock_policy_engine.py | 130 ++ tests/pdp_api_v0/mock_websocket.py | 90 + tests/pdp_api_v0/test_policy_rest.py | 47 + tests/pdp_api_v0/test_policyhandler.py | 280 +++ tests/pdp_api_v0/test_pz_catch_up.py | 107 ++ tests/pdp_api_v0/test_pz_pdp_boom.py | 255 +++ tests/pdp_api_v0/test_pz_ph_boom.py | 256 +++ tests/test_policy_rest.py | 47 - tests/test_policy_utils.py | 186 -- tests/test_policyhandler.py | 248 --- tests/test_pz_catch_up.py | 96 - tests/test_pz_pdp_boom.py | 226 --- tests/test_pz_ph_boom.py | 228 --- tests/test_step_timer.py | 209 --- tests/test_zzz_memory.py | 118 -- tests/utils/__init__.py | 20 + tests/utils/test_step_timer.py | 199 +++ tests/utils/test_utils.py | 181 ++ tests/utils/test_zzz_memory.py | 115 ++ 38 files changed, 5949 insertions(+), 4767 deletions(-) create mode 100644 tests/etc_config.json create mode 100644 tests/main/__init__.py create mode 100644 tests/main/conftest.py create mode 100644 tests/main/mock_expected.py create mode 100644 tests/main/mock_policy_engine.py create mode 100644 tests/main/pdp_policies.json create mode 100644 tests/main/test_policy_rest.py create mode 100644 tests/main/test_policyhandler.py delete mode 100644 tests/mock_expected.py delete mode 100644 tests/mock_policy_engine.py delete mode 100644 tests/mock_websocket.py create mode 100644 tests/pdp_api_v0/__init__.py create mode 100644 tests/pdp_api_v0/conftest.py create mode 100644 tests/pdp_api_v0/mock_expected.py create mode 100644 tests/pdp_api_v0/mock_policy_engine.py create mode 100644 tests/pdp_api_v0/mock_websocket.py create mode 100644 tests/pdp_api_v0/test_policy_rest.py create mode 100644 tests/pdp_api_v0/test_policyhandler.py create mode 100644 tests/pdp_api_v0/test_pz_catch_up.py create mode 100644 tests/pdp_api_v0/test_pz_pdp_boom.py create mode 100644 tests/pdp_api_v0/test_pz_ph_boom.py delete mode 100644 tests/test_policy_rest.py delete mode 100644 tests/test_policy_utils.py delete mode 100644 tests/test_policyhandler.py delete mode 100644 tests/test_pz_catch_up.py delete mode 100644 tests/test_pz_pdp_boom.py delete mode 100644 tests/test_pz_ph_boom.py delete mode 100644 tests/test_step_timer.py delete mode 100644 tests/test_zzz_memory.py create mode 100644 tests/utils/__init__.py create mode 100644 tests/utils/test_step_timer.py create mode 100644 tests/utils/test_utils.py create mode 100644 tests/utils/test_zzz_memory.py (limited to 'tests') diff --git a/tests/conftest.py b/tests/conftest.py index 0dcb2bb..c3f4100 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,5 +1,5 @@ # ============LICENSE_START======================================================= -# Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. +# Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,7 +14,6 @@ # limitations under the License. # ============LICENSE_END========================================================= # -# ECOMP is a trademark and service mark of AT&T Intellectual Property. """ startdard pytest file that contains the shared fixtures https://docs.pytest.org/en/latest/fixture.html @@ -29,61 +28,61 @@ from policyhandler.config import Config from policyhandler.deploy_handler import DeployHandler from policyhandler.discovery import DiscoveryClient from policyhandler.onap.audit import Audit -from policyhandler.policy_consts import CATCH_UP, POLICY_NAME, TARGET_ENTITY -from policyhandler.policy_receiver import PolicyReceiver -from policyhandler.policy_rest import PolicyRest +from policyhandler.policy_consts import CATCH_UP, TARGET_ENTITY +from policyhandler.utils import Utils from .mock_deploy_handler import MockDeploymentHandler -from .mock_policy_engine import MockPolicyEngine -from .mock_settings import Settings +from .mock_settings import MockSettings from .mock_tracker import MockHttpResponse, Tracker -from .mock_websocket import MockWebSocket + +_LOGGER = Utils.get_logger(__file__) + +_LOGGER.info("init MockSettings") +MockSettings.init() + +@pytest.fixture(scope="session", autouse=True) +def _auto_setup__global(): + """initialize the _auto_setup__global per the whole test session""" + _LOGGER.info("_auto_setup__global") + + yield _auto_setup__global + Tracker.log_all_tests() + _LOGGER.info("teardown _auto_setup__global") @pytest.fixture(autouse=True) def _auto_test_cycle(request): """log all the test starts and ends""" + module_name = request.module.__name__.replace(".", "/") if request.cls: - test_name = "%s::%s::%s" % (request.module.__name__, - request.cls.__name__, - request.function.__name__) + test_name = "%s.py::%s::%s" % (module_name, request.cls.__name__, + request.function.__name__) else: - test_name = "%s::%s" % (request.module.__name__, request.function.__name__) + test_name = "%s.py::%s" % (module_name, request.function.__name__) Tracker.reset(test_name) - if Settings.logger: - Settings.logger.info(">>>>>>> start %s", test_name) + _LOGGER.info("-"*75) + _LOGGER.info(">>>>>>> start [%s]: %s", len(Tracker.test_names), test_name) yield _auto_test_cycle - if Settings.logger: - Settings.logger.info(">>>>>>> tracked messages: %s", Tracker.to_string()) - Settings.logger.info(">>>>>>> ended %s", test_name) + _LOGGER.info(">>>>>>> tracked messages: %s", Tracker.to_string()) + _LOGGER.info(">>>>>>> %s[%s]: %s", Tracker.get_status(test_name), + len(Tracker.test_names), test_name) -@pytest.fixture(scope="session", autouse=True) -def _auto_setup_policy_engine(): - """initialize the mock-policy-engine per the whole test session""" - Settings.init() +@pytest.fixture() +def fix_cherrypy_engine_exit(monkeypatch): + """monkeyed cherrypy.engine.exit()""" + _LOGGER.info("setup fix_cherrypy_engine_exit") - Settings.logger.info("create _auto_setup_policy_engine") - MockPolicyEngine.init() - yield _auto_setup_policy_engine - Settings.logger.info("teardown _auto_setup_policy_engine") + def monkeyed_cherrypy_engine_exit(): + """monkeypatch for deploy_handler""" + _LOGGER.info("cherrypy_engine_exit()") + monkeypatch.setattr('policyhandler.web_server.cherrypy.engine.exit', + monkeyed_cherrypy_engine_exit) + yield fix_cherrypy_engine_exit + _LOGGER.info("teardown fix_cherrypy_engine_exit") -@pytest.fixture() -def fix_pdp_post(monkeypatch): - """monkeyed request /getConfig to PDP""" - def monkeyed_policy_rest_post(uri, json=None, **kwargs): - """monkeypatch for the POST to policy-engine""" - res_json = MockPolicyEngine.get_config(json.get(POLICY_NAME)) - return MockHttpResponse("post", uri, res_json, json=json, **kwargs) - - Settings.logger.info("setup fix_pdp_post") - PolicyRest._lazy_init() - monkeypatch.setattr('policyhandler.policy_rest.PolicyRest._requests_session.post', - monkeyed_policy_rest_post) - yield fix_pdp_post - Settings.logger.info("teardown fix_pdp_post") @pytest.fixture() def fix_deploy_handler(monkeypatch): @@ -98,7 +97,7 @@ def fix_deploy_handler(monkeypatch): return MockHttpResponse("get", uri, MockDeploymentHandler.get_deployed_policies(), **kwargs) - Settings.logger.info("setup fix_deploy_handler") + _LOGGER.info("setup fix_deploy_handler") audit = None if DeployHandler._lazy_inited is False: audit = Audit(req_message="fix_deploy_handler") @@ -112,78 +111,9 @@ def fix_deploy_handler(monkeypatch): yield fix_deploy_handler if audit: audit.audit_done("teardown") - Settings.logger.info("teardown fix_deploy_handler") - - -@pytest.fixture() -def fix_cherrypy_engine_exit(monkeypatch): - """monkeyed cherrypy.engine.exit()""" - Settings.logger.info("setup fix_cherrypy_engine_exit") - - def monkeyed_cherrypy_engine_exit(): - """monkeypatch for deploy_handler""" - Settings.logger.info("cherrypy_engine_exit()") - - monkeypatch.setattr('policyhandler.web_server.cherrypy.engine.exit', - monkeyed_cherrypy_engine_exit) - yield fix_cherrypy_engine_exit - Settings.logger.info("teardown fix_cherrypy_engine_exit") + _LOGGER.info("teardown fix_deploy_handler") -@pytest.fixture() -def fix_pdp_post_big(monkeypatch): - """monkeyed request /getConfig to PDP""" - def monkeyed_policy_rest_post(uri, **kwargs): - """monkeypatch for the POST to policy-engine""" - res_json = MockPolicyEngine.get_configs_all() - return MockHttpResponse("post", uri, res_json, **kwargs) - - Settings.logger.info("setup fix_pdp_post_big") - PolicyRest._lazy_init() - monkeypatch.setattr('policyhandler.policy_rest.PolicyRest._requests_session.post', - monkeyed_policy_rest_post) - yield fix_pdp_post_big - Settings.logger.info("teardown fix_pdp_post_big") - - -class MockException(Exception): - """mock exception""" - pass - - -@pytest.fixture() -def fix_pdp_post_boom(monkeypatch): - """monkeyed request /getConfig to PDP - exception""" - def monkeyed_policy_rest_post_boom(uri, **_): - """monkeypatch for the POST to policy-engine""" - raise MockException("fix_pdp_post_boom {}".format(uri)) - - Settings.logger.info("setup fix_pdp_post_boom") - PolicyRest._lazy_init() - monkeypatch.setattr('policyhandler.policy_rest.PolicyRest._requests_session.post', - monkeyed_policy_rest_post_boom) - yield fix_pdp_post_boom - Settings.logger.info("teardown fix_pdp_post_boom") - - -@pytest.fixture() -def fix_select_latest_policies_boom(monkeypatch): - """monkeyed exception""" - def monkeyed_boom(*args, **kwargs): - """monkeypatch for the select_latest_policies""" - raise MockException("monkeyed_boom") - - Settings.logger.info("setup fix_select_latest_policies_boom") - monkeypatch.setattr('policyhandler.policy_utils.PolicyUtils.select_latest_policies', - monkeyed_boom) - monkeypatch.setattr('policyhandler.policy_utils.PolicyUtils.select_latest_policy', - monkeyed_boom) - monkeypatch.setattr('policyhandler.policy_utils.PolicyUtils.extract_policy_id', - monkeyed_boom) - - yield fix_select_latest_policies_boom - Settings.logger.info("teardown fix_select_latest_policies_boom") - @pytest.fixture() def fix_discovery(monkeypatch): """monkeyed discovery request.get""" @@ -203,29 +133,28 @@ def fix_discovery(monkeypatch): elif uri == DiscoveryClient.CONSUL_KV_MASK.format( Config.consul_url, Config.system_name): res_json = [{"Value": base64.b64encode( - json.dumps(Settings.mock_config).encode()).decode("utf-8")}] + json.dumps(MockSettings.mock_config).encode()).decode("utf-8")}] return MockHttpResponse("get", uri, res_json) - Settings.logger.info("setup fix_discovery") + _LOGGER.info("setup fix_discovery") monkeypatch.setattr('policyhandler.discovery.requests.get', monkeyed_discovery) yield fix_discovery - Settings.logger.info("teardown fix_discovery") - + _LOGGER.info("teardown fix_discovery") @pytest.fixture(scope="module") def fix_auto_catch_up(): """increase the frequency of auto catch_up""" - Settings.logger.info("setup fix_auto_catch_up %s", json.dumps(Settings.mock_config)) - prev_config = copy.deepcopy(Settings.mock_config) - Settings.mock_config.get(Config.SERVICE_NAME_POLICY_HANDLER, {}) \ + _LOGGER.info("setup fix_auto_catch_up %s", json.dumps(MockSettings.mock_config)) + prev_config = copy.deepcopy(MockSettings.mock_config) + MockSettings.mock_config.get(Config.SERVICE_NAME_POLICY_HANDLER, {}) \ .get(CATCH_UP, {})[Config.TIMER_INTERVAL] = 5 - Settings.logger.info("fix_auto_catch_up %s", json.dumps(Settings.mock_config)) - Settings.rediscover_config() + _LOGGER.info("fix_auto_catch_up %s", json.dumps(MockSettings.mock_config)) + MockSettings.rediscover_config() yield fix_auto_catch_up - Settings.rediscover_config(prev_config) - Settings.logger.info("teardown fix_auto_catch_up") + MockSettings.rediscover_config(prev_config) + _LOGGER.info("teardown fix_auto_catch_up") @pytest.fixture() @@ -235,7 +164,7 @@ def fix_deploy_handler_413(monkeypatch): """monkeypatch for deploy_handler""" return MockHttpResponse( "put", uri, - {"server_instance_uuid": Settings.deploy_handler_instance_uuid}, + {"server_instance_uuid": MockSettings.deploy_handler_instance_uuid}, status_code=413, **kwargs ) @@ -244,7 +173,7 @@ def fix_deploy_handler_413(monkeypatch): return MockHttpResponse("get", uri, MockDeploymentHandler.get_deployed_policies(), **kwargs) - Settings.logger.info("setup fix_deploy_handler_413") + _LOGGER.info("setup fix_deploy_handler_413") audit = None if DeployHandler._lazy_inited is False: audit = Audit(req_message="fix_deploy_handler_413") @@ -258,7 +187,7 @@ def fix_deploy_handler_413(monkeypatch): yield fix_deploy_handler_413 if audit: audit.audit_done("teardown") - Settings.logger.info("teardown fix_deploy_handler_413") + _LOGGER.info("teardown fix_deploy_handler_413") @pytest.fixture() @@ -274,7 +203,7 @@ def fix_deploy_handler_404(monkeypatch): return MockHttpResponse("get", uri, MockDeploymentHandler.default_response(), **kwargs) - Settings.logger.info("setup fix_deploy_handler_404") + _LOGGER.info("setup fix_deploy_handler_404") audit = None if DeployHandler._lazy_inited is False: audit = Audit(req_message="fix_deploy_handler_404") @@ -288,12 +217,4 @@ def fix_deploy_handler_404(monkeypatch): yield fix_deploy_handler_404 if audit: audit.audit_done("teardown") - Settings.logger.info("teardown fix_deploy_handler_404") - -@pytest.fixture() -def fix_policy_receiver_websocket(monkeypatch): - """monkeyed websocket for policy_receiver""" - Settings.logger.info("setup fix_policy_receiver_websocket") - monkeypatch.setattr('policyhandler.policy_receiver.websocket', MockWebSocket) - yield fix_policy_receiver_websocket - Settings.logger.info("teardown fix_policy_receiver_websocket") + _LOGGER.info("teardown fix_deploy_handler_404") diff --git a/tests/etc_config.json b/tests/etc_config.json new file mode 100644 index 0000000..d7715b2 --- /dev/null +++ b/tests/etc_config.json @@ -0,0 +1,47 @@ +{ + "wservice_port" : 25577, + "consul_url" : "http://unit-test-consul:850000", + "consul_timeout_in_secs" : 60, + "pdp_api_version" : null, + "policy_handler" : { + "system" : "policy_handler", + "tls" : { + "cert_directory" : "etc/tls/certs/", + "cacert" : "att_internal_root.crt", + "private_key" : "key.pem", + "server_cert" : "cert.pem", + "server_ca_chain" : "ca_chain.pem" + } + }, + "logging" : { + "version": 1, + "disable_existing_loggers": false, + "formatters": { + "local": { + "format": "%(asctime)s.%(msecs)03d %(levelname)+8s %(threadName)s %(name)s.%(funcName)s: %(message)s", + "datefmt": "%Y%m%d_%H%M%S" + } + }, + "handlers": { + "file": { + "class": "logging.handlers.TimedRotatingFileHandler", + "formatter": "local", + "filename" : "logs/policy_handler.log", + "level": "DEBUG", + "when": "midnight", + "interval": 1, + "backupCount": 10, + "delay": true + } + }, + "loggers": { + "policy_handler" : { + "handlers": ["file"], + "propagate":false + } + }, + "root": { + "handlers": ["file"] + } + } +} \ No newline at end of file diff --git a/tests/main/__init__.py b/tests/main/__init__.py new file mode 100644 index 0000000..b8e4605 --- /dev/null +++ b/tests/main/__init__.py @@ -0,0 +1,20 @@ +# ================================================================================ +# Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# + + +# empty __init__.py so that pytest can add correct path to coverage report, -- per pytest +# best practice guideline diff --git a/tests/main/conftest.py b/tests/main/conftest.py new file mode 100644 index 0000000..c985380 --- /dev/null +++ b/tests/main/conftest.py @@ -0,0 +1,56 @@ +# ============LICENSE_START======================================================= +# Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +""" +startdard pytest file that contains the shared fixtures +https://docs.pytest.org/en/latest/fixture.html +""" + +import pytest + +from policyhandler import pdp_client +from policyhandler.pdp_api.pdp_consts import PDP_POLICY_ID, PDP_REQ_RESOURCE +from policyhandler.utils import Utils + +from ..mock_tracker import MockHttpResponse +from .mock_policy_engine import MockPolicyEngine + +_LOGGER = Utils.get_logger(__file__) + +@pytest.fixture(scope="session", autouse=True) +def _auto_setup_policy_engine(): + """initialize the mock-policy-engine per the whole test session""" + _LOGGER.info("create _auto_setup_policy_engine") + MockPolicyEngine.init() + yield _auto_setup_policy_engine + _LOGGER.info("teardown _auto_setup_policy_engine") + +@pytest.fixture() +def fix_pdp_post(monkeypatch): + """monkeyed request /decision/v1 to PDP""" + def monkeyed_policy_rest_post(uri, json=None, **kwargs): + """monkeypatch for the POST to policy-engine""" + policy_ids = json.get(PDP_REQ_RESOURCE, {}).get(PDP_POLICY_ID) + policy_id = policy_ids and policy_ids[0] + res_json = MockPolicyEngine.get_policy(policy_id) + return MockHttpResponse("post", uri, res_json, json=json, **kwargs) + + _LOGGER.info("setup fix_pdp_post") + pdp_client.PolicyRest._lazy_init() + monkeypatch.setattr('policyhandler.pdp_client.PolicyRest._requests_session.post', + monkeyed_policy_rest_post) + yield fix_pdp_post + _LOGGER.info("teardown fix_pdp_post") diff --git a/tests/main/mock_expected.py b/tests/main/mock_expected.py new file mode 100644 index 0000000..450394c --- /dev/null +++ b/tests/main/mock_expected.py @@ -0,0 +1,526 @@ +# ============LICENSE_START======================================================= +# Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +"""expected message history per test for pdp API 2019 and after""" + + +HISTORY_EXPECTED = { + "tests/main/test_policy_rest.py::test_get_policy_latest" : [ + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "ONAPComponent": "policy_handler", + "ONAPInstance": "*", + "ONAPName": "DCAE", + "action": "configure", + "resource": { + "policy-id": [ + "test_scope_prefix.pdp_desition_sit" + ] + } + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/decision/v1/" + }, + "res": "*", + "status_code": 200 + } + ], + "tests/main/test_policyhandler.py::WebServerTest::test_web_all_policies_latest": [ + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_.*" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + } + ], + "tests/main/test_policyhandler.py::WebServerTest::test_web_policies_latest": [ + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_amet.*" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + } + ], + "tests/main/test_policyhandler.py::WebServerTest::test_web_policy_latest": [ + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "ONAPComponent": "policy_handler", + "ONAPInstance": "*", + "ONAPName": "DCAE", + "action": "configure", + "resource": { + "policy-id": [ + "test_scope_prefix.pdp_desition_sit" + ] + } + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/decision/v1/" + }, + "res": "*", + "status_code": 200 + } + ], + "tests/main/test_policyhandler.py::WebServerTest::test_zzzzz_shutdown": [ + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_.*" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": { + "catch_up": True, + "latest_policies": { + "test_scope_prefix.Config_Lorem": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "0", + "policy_updated_to_ver": "1", + "updated_policy_id": "test_scope_prefix.Config_Lorem" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_Lorem.1.xml", + "policyVersion": "1", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_Lorem" + }, + "test_scope_prefix.Config_amet": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "4", + "policy_updated_to_ver": "5", + "updated_policy_id": "test_scope_prefix.Config_amet" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_amet.5.xml", + "policyVersion": "5", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_amet" + }, + "test_scope_prefix.Config_ametist": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "6", + "policy_updated_to_ver": "7", + "updated_policy_id": "test_scope_prefix.Config_ametist" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_ametist.7.xml", + "policyVersion": "7", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_ametist" + }, + "test_scope_prefix.Config_consectetur": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "5", + "policy_updated_to_ver": "6", + "updated_policy_id": "test_scope_prefix.Config_consectetur" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_consectetur.6.xml", + "policyVersion": "6", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_consectetur" + }, + "test_scope_prefix.Config_dolor": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "2", + "policy_updated_to_ver": "3", + "updated_policy_id": "test_scope_prefix.Config_dolor" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_dolor.3.xml", + "policyVersion": "3", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_dolor" + }, + "test_scope_prefix.Config_ipsum": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "1", + "policy_updated_to_ver": "2", + "updated_policy_id": "test_scope_prefix.Config_ipsum" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_ipsum.2.xml", + "policyVersion": "2", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_ipsum" + }, + "test_scope_prefix.Config_sit": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "3", + "policy_updated_to_ver": "4", + "updated_policy_id": "test_scope_prefix.Config_sit" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_sit.4.xml", + "policyVersion": "4", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_sit" + } + }, + "policy_filter_matches": { + "test_scope_prefix.Config_Lorem": {}, + "test_scope_prefix.Config_amet": {}, + "test_scope_prefix.Config_ametist": {}, + "test_scope_prefix.Config_consectetur": {}, + "test_scope_prefix.Config_dolor": {}, + "test_scope_prefix.Config_ipsum": {}, + "test_scope_prefix.Config_sit": {} + }, + "removed_policies": {} + }, + "method": "put", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_ipsum" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_sit" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_consectetur" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": { + "catch_up": False, + "latest_policies": { + "test_scope_prefix.Config_consectetur": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "5", + "policy_updated_to_ver": "6", + "updated_policy_id": "test_scope_prefix.Config_consectetur" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_consectetur.6.xml", + "policyVersion": "6", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_consectetur" + }, + "test_scope_prefix.Config_ipsum": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "1", + "policy_updated_to_ver": "2", + "updated_policy_id": "test_scope_prefix.Config_ipsum" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_ipsum.2.xml", + "policyVersion": "2", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_ipsum" + }, + "test_scope_prefix.Config_sit": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "3", + "policy_updated_to_ver": "4", + "updated_policy_id": "test_scope_prefix.Config_sit" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_sit.4.xml", + "policyVersion": "4", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_sit" + } + }, + "policy_filter_matches": { + "test_scope_prefix.Config_consectetur": {}, + "test_scope_prefix.Config_ipsum": {}, + "test_scope_prefix.Config_sit": {} + }, + "removed_policies": {} + }, + "method": "put", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + } + ] +} diff --git a/tests/main/mock_policy_engine.py b/tests/main/mock_policy_engine.py new file mode 100644 index 0000000..1bac045 --- /dev/null +++ b/tests/main/mock_policy_engine.py @@ -0,0 +1,96 @@ +# ============LICENSE_START======================================================= +# Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +"""mocking for the policy-engine - shared by many tests""" + +import copy +import json + +from policyhandler.pdp_api.pdp_consts import (PDP_METADATA, + PDP_POLICY_ID, + PDP_POLICY_VERSION, + PDP_POLICIES, PDP_PROPERTIES) +from policyhandler.pdp_api.policy_utils import PolicyUtils +from policyhandler.utils import Utils + +_LOGGER = Utils.get_logger(__file__) + + +class MockPolicyEngine(object): + """pretend this is the policy-engine""" + scope_prefix = "test_scope_prefix.pdp_desition_" + LOREM_IPSUM = """Lorem ipsum dolor sit amet consectetur ametist""".split() + LONG_TEXT = "0123456789" * 100 + _policies = {} + + _inited = False + + @staticmethod + def init(): + """init collection of policies: policy_version = policy_index + 1""" + if MockPolicyEngine._inited: + return + MockPolicyEngine._inited = True + + MockPolicyEngine._policies = dict( + (policy_id, MockPolicyEngine._create_policy_body(policy_id, policy_version)) + for policy_id, policy_version in + [(MockPolicyEngine.get_policy_id(policy_index), policy_index + 1) + for policy_index in range(1 + len(MockPolicyEngine.LOREM_IPSUM))] + ) + _LOGGER.info("_policies: %s", json.dumps(MockPolicyEngine._policies)) + + @staticmethod + def get_policy_id(policy_index): + """get the policy_id by policy_index""" + return (MockPolicyEngine.scope_prefix + + MockPolicyEngine.LOREM_IPSUM[ + policy_index % len(MockPolicyEngine.LOREM_IPSUM)]) + + @staticmethod + def get_policy(policy_id): + """find policy the way the policy-engine finds""" + if policy_id not in MockPolicyEngine._policies: + return {} + return {PDP_POLICIES: {policy_id: copy.deepcopy(MockPolicyEngine._policies[policy_id])}} + + @staticmethod + def gen_policy_latest(policy_index, version_offset=0): + """generate the policy response from policy-handler by policy_index = version - 1""" + policy_id = MockPolicyEngine.get_policy_id(policy_index) + policy = PolicyUtils.convert_to_policy( + MockPolicyEngine._create_policy_body(policy_id, policy_index + 1 - version_offset) + ) + return policy_id, policy + + @staticmethod + def _create_policy_body(policy_id, policy_version=1): + """returns a fake policy-body""" + return { + "type": "unit.test.type.policies", + "version": "1.0.0", + PDP_METADATA: { + PDP_POLICY_ID: policy_id, + PDP_POLICY_VERSION: policy_version, + "description": "description for {}".format(policy_id) + }, + PDP_PROPERTIES: { + "policy_updated_from_ver": (policy_version - 1), + "policy_updated_to_ver": policy_version, + "policy_hello": "world!", + "updated_policy_id": policy_id + } + } diff --git a/tests/main/pdp_policies.json b/tests/main/pdp_policies.json new file mode 100644 index 0000000..b7d0d9e --- /dev/null +++ b/tests/main/pdp_policies.json @@ -0,0 +1,25 @@ +{ + "policies": { + "onap.scaleout.tca": { + "type": "onap.policies.monitoring.cdap.tca.hi.lo.app", + "version": "1.0.0", + "metadata": { + "policy-id": "onap.scaleout.tca", + "policy-version": 1, + "description": "The scaleout policy for vDNS" + }, + "properties": { + "tca_policy": { + "domain": "measurementsForVfScaling", + "metricsPerEventName": [ + { + "eventName": "vLoadBalancer", + "controlLoopSchemaType": "VNF", + "policyScope": "type=configuration" + } + ] + } + } + } + } +} \ No newline at end of file diff --git a/tests/main/test_policy_rest.py b/tests/main/test_policy_rest.py new file mode 100644 index 0000000..964a21d --- /dev/null +++ b/tests/main/test_policy_rest.py @@ -0,0 +1,47 @@ +# ============LICENSE_START======================================================= +# Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +"""test policy_rest methods directly""" + +import json + +import pytest + +from policyhandler import pdp_client +from policyhandler.onap.audit import Audit +from policyhandler.utils import Utils + +from ..mock_tracker import Tracker +from .mock_policy_engine import MockPolicyEngine + +_LOGGER = Utils.get_logger(__file__) + +@pytest.mark.usefixtures("fix_pdp_post") +def test_get_policy_latest(): + """test /policy_latest/""" + policy_id, expected_policy = MockPolicyEngine.gen_policy_latest(3) + + audit = Audit(job_name="test_get_policy_latest", + req_message="get /policy_latest/{}".format(policy_id or "")) + + policy_latest = pdp_client.PolicyRest.get_latest_policy((audit, policy_id, None, None)) or {} + audit.audit_done(result=json.dumps(policy_latest)) + + _LOGGER.info("expected_policy: %s", json.dumps(expected_policy)) + _LOGGER.info("policy_latest: %s", json.dumps(policy_latest)) + assert Utils.are_the_same(policy_latest, expected_policy) + + Tracker.validate() diff --git a/tests/main/test_policyhandler.py b/tests/main/test_policyhandler.py new file mode 100644 index 0000000..73ab9ca --- /dev/null +++ b/tests/main/test_policyhandler.py @@ -0,0 +1,130 @@ +# ============LICENSE_START======================================================= +# Copyright (c) 2017-2019 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# + +"""test of the package for policy-handler of DCAE-Controller""" + +import json +import time +import uuid + +import cherrypy +import pytest +from cherrypy.test.helper import CPWebCase + +from policyhandler.config import Config +from policyhandler.onap.audit import REQUEST_X_ECOMP_REQUESTID, Audit +from policyhandler.pdp_api.pdp_consts import POLICY_NAME +from policyhandler.policy_consts import LATEST_POLICIES +from policyhandler.policy_receiver import PolicyReceiver +from policyhandler.utils import Utils +from policyhandler.web_server import _PolicyWeb + +from ..mock_tracker import Tracker +from .mock_policy_engine import MockPolicyEngine + +_LOGGER = Utils.get_logger(__file__) + + +@pytest.mark.usefixtures("fix_pdp_post", "fix_discovery") +class WebServerTest(CPWebCase): + """testing the web-server - runs tests in alphabetical order of method names""" + def setup_server(): + """setup the web-server""" + cherrypy.tree.mount(_PolicyWeb(), '/') + + setup_server = staticmethod(setup_server) + + def test_web_healthcheck(self): + """test /healthcheck""" + result = self.getPage("/healthcheck") + _LOGGER.info("healthcheck result: %s", result) + _LOGGER.info("got healthcheck: %s", self.body) + self.assertStatus('200 OK') + + Tracker.validate() + + def test_web_policy_latest(self): + """test /policy_latest/""" + policy_id, expected_policy = MockPolicyEngine.gen_policy_latest(3) + + self.getPage("/policy_latest/{0}".format(policy_id or "")) + self.assertStatus('200 OK') + + policy_latest = json.loads(self.body) + + _LOGGER.info("policy_latest: %s", self.body) + _LOGGER.info("expected_policy: %s", json.dumps(expected_policy)) + assert Utils.are_the_same(policy_latest, expected_policy) + + result = self.getPage("/healthcheck") + _LOGGER.info("healthcheck result: %s", result) + + Tracker.validate() + + @pytest.mark.usefixtures("fix_deploy_handler") + def test_web_all_policies_latest(self): + """test GET /policies_latest""" + + result = self.getPage("/policies_latest") + _LOGGER.info("result: %s", result) + _LOGGER.info("body: %s", self.body) + + self.assertStatus('404 Not Found') + + def test_web_policies_latest(self): + """test POST /policies_latest with policyName""" + body = json.dumps({"junk": "to-be-developed"}) + result = self.getPage("/policies_latest", method='POST', + body=body, + headers=[ + (REQUEST_X_ECOMP_REQUESTID, str(uuid.uuid4())), + ("Content-Type", "application/json"), + ('Content-Length', str(len(body))) + ]) + _LOGGER.info("result: %s", result) + _LOGGER.info("body: %s", self.body) + + self.assertStatus('404 Not Found') + + @pytest.mark.usefixtures( + "fix_deploy_handler", + "fix_cherrypy_engine_exit") + def test_zzzzz_shutdown(self): + """test shutdown""" + _LOGGER.info("start shutdown") + assert not PolicyReceiver.is_running() + audit = Audit(job_name="test_zzzzz_shutdown", req_message="start shutdown") + PolicyReceiver.run(audit) + + result = self.getPage("/healthcheck") + _LOGGER.info("healthcheck result: %s", result) + + WebServerTest.do_gc_test = False + _LOGGER.info("shutdown...") + audit.audit_done("shutdown") + result = self.getPage("/shutdown") + _LOGGER.info("shutdown result: %s", result) + self.assertStatus('200 OK') + _LOGGER.info("got shutdown: %s", self.body) + time.sleep(1) + assert not PolicyReceiver.is_running() + + if Config.is_pdp_api_default(): + _LOGGER.info("passive for new PDP API") + return + + Tracker.validate() diff --git a/tests/mock_config.json b/tests/mock_config.json index ef02a15..30e3251 100644 --- a/tests/mock_config.json +++ b/tests/mock_config.json @@ -13,6 +13,7 @@ }, "policy_engine" : { "url" : "https://unit-test-pdp-server:8081000", + "path_decision" : "/decision/v1/", "path_notifications" : "/pdp/notifications", "path_api" : "/pdp/api/", "headers" : { diff --git a/tests/mock_deploy_handler.py b/tests/mock_deploy_handler.py index ebbbfc7..cd8e791 100644 --- a/tests/mock_deploy_handler.py +++ b/tests/mock_deploy_handler.py @@ -1,5 +1,5 @@ # ============LICENSE_START======================================================= -# Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. +# Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,14 +14,13 @@ # limitations under the License. # ============LICENSE_END========================================================= # -# ECOMP is a trademark and service mark of AT&T Intellectual Property. """mocking for the deployment-handler - shared by many tests""" -from policyhandler.policy_consts import (POLICY_BODY, POLICY_ID, - POLICY_VERSION, POLICY_VERSIONS) +from policyhandler.pdp_api_v0.pdp_consts import POLICY_VERSION +from policyhandler.policy_consts import POLICY_BODY, POLICY_ID, POLICY_VERSIONS -from .mock_policy_engine import MockPolicyEngine -from .mock_settings import Settings +from .mock_settings import MockSettings +from .pdp_api_v0.mock_policy_engine import MockPolicyEngine2018 class MockDeploymentHandler(object): @@ -30,7 +29,7 @@ class MockDeploymentHandler(object): @staticmethod def default_response(): """generate the deployed policies message""" - return {"server_instance_uuid": Settings.deploy_handler_instance_uuid} + return {"server_instance_uuid": MockSettings.deploy_handler_instance_uuid} @staticmethod def get_deployed_policies(): @@ -42,7 +41,7 @@ class MockDeploymentHandler(object): POLICY_VERSIONS: {policy.get(POLICY_BODY, {}).get(POLICY_VERSION, "999"): True}, "pending_update": False}) for policy_id, policy in ( - MockPolicyEngine.gen_all_policies_latest(version_offset=1).items())) + MockPolicyEngine2018.gen_all_policies_latest(version_offset=1).items())) response["policies"] = policies return response diff --git a/tests/mock_expected.py b/tests/mock_expected.py deleted file mode 100644 index c10215d..0000000 --- a/tests/mock_expected.py +++ /dev/null @@ -1,3013 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= -# -# ECOMP is a trademark and service mark of AT&T Intellectual Property. -"""expected message history per test""" - - -HISTORY_EXPECTED = { - "tests.test_policy_rest::test_get_policy_latest" : [ - { - "request": { - "headers": { - "Accept": "application/json", - "Authorization": "Basic auth", - "ClientAuth": "Basic user", - "Content-Type": "application/json", - "Environment": "TEST", - "X-ECOMP-RequestID": "*" - }, - "json": { - "policyName": "test_scope_prefix.Config_sit" - }, - "method": "post", - "params": None, - "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" - }, - "res": "*", - "status_code": 200 - } - ], - "tests.test_policyhandler::WebServerTest::test_web_all_policies_latest": [ - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": None, - "method": "get", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "Accept": "application/json", - "Authorization": "Basic auth", - "ClientAuth": "Basic user", - "Content-Type": "application/json", - "Environment": "TEST", - "X-ECOMP-RequestID": "*" - }, - "json": { - "policyName": "test_scope_prefix.Config_.*" - }, - "method": "post", - "params": None, - "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" - }, - "res": "*", - "status_code": 200 - } - ], - "tests.test_policyhandler::WebServerTest::test_web_policies_latest": [ - { - "request": { - "headers": { - "Accept": "application/json", - "Authorization": "Basic auth", - "ClientAuth": "Basic user", - "Content-Type": "application/json", - "Environment": "TEST", - "X-ECOMP-RequestID": "*" - }, - "json": { - "policyName": "test_scope_prefix.Config_amet.*" - }, - "method": "post", - "params": None, - "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" - }, - "res": "*", - "status_code": 200 - } - ], - "tests.test_policyhandler::WebServerTest::test_web_policy_latest": [ - { - "request": { - "headers": { - "Accept": "application/json", - "Authorization": "Basic auth", - "ClientAuth": "Basic user", - "Content-Type": "application/json", - "Environment": "TEST", - "X-ECOMP-RequestID": "*" - }, - "json": { - "policyName": "test_scope_prefix.Config_sit" - }, - "method": "post", - "params": None, - "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" - }, - "res": "*", - "status_code": 200 - } - ], - "tests.test_policyhandler::WebServerTest::test_zzz_get_catch_up": [ - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": None, - "method": "get", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "Accept": "application/json", - "Authorization": "Basic auth", - "ClientAuth": "Basic user", - "Content-Type": "application/json", - "Environment": "TEST", - "X-ECOMP-RequestID": "*" - }, - "json": { - "policyName": "test_scope_prefix.Config_.*" - }, - "method": "post", - "params": None, - "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": { - "catch_up": True, - "latest_policies": { - "test_scope_prefix.Config_Lorem": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "0", - "policy_updated_to_ver": "1", - "updated_policy_id": "test_scope_prefix.Config_Lorem" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_Lorem.1.xml", - "policyVersion": "1", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_Lorem" - }, - "test_scope_prefix.Config_amet": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "4", - "policy_updated_to_ver": "5", - "updated_policy_id": "test_scope_prefix.Config_amet" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_amet.5.xml", - "policyVersion": "5", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_amet" - }, - "test_scope_prefix.Config_ametist": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "6", - "policy_updated_to_ver": "7", - "updated_policy_id": "test_scope_prefix.Config_ametist" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_ametist.7.xml", - "policyVersion": "7", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_ametist" - }, - "test_scope_prefix.Config_consectetur": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "5", - "policy_updated_to_ver": "6", - "updated_policy_id": "test_scope_prefix.Config_consectetur" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_consectetur.6.xml", - "policyVersion": "6", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_consectetur" - }, - "test_scope_prefix.Config_dolor": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "2", - "policy_updated_to_ver": "3", - "updated_policy_id": "test_scope_prefix.Config_dolor" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_dolor.3.xml", - "policyVersion": "3", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_dolor" - }, - "test_scope_prefix.Config_ipsum": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "1", - "policy_updated_to_ver": "2", - "updated_policy_id": "test_scope_prefix.Config_ipsum" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_ipsum.2.xml", - "policyVersion": "2", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_ipsum" - }, - "test_scope_prefix.Config_sit": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "3", - "policy_updated_to_ver": "4", - "updated_policy_id": "test_scope_prefix.Config_sit" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_sit.4.xml", - "policyVersion": "4", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_sit" - } - }, - "policy_filter_matches": { - "test_scope_prefix.Config_Lorem": {}, - "test_scope_prefix.Config_amet": {}, - "test_scope_prefix.Config_ametist": {}, - "test_scope_prefix.Config_consectetur": {}, - "test_scope_prefix.Config_dolor": {}, - "test_scope_prefix.Config_ipsum": {}, - "test_scope_prefix.Config_sit": {} - }, - "removed_policies": {} - }, - "method": "put", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": None, - "method": "get", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "Accept": "application/json", - "Authorization": "Basic auth", - "ClientAuth": "Basic user", - "Content-Type": "application/json", - "Environment": "TEST", - "X-ECOMP-RequestID": "*" - }, - "json": { - "policyName": "test_scope_prefix.Config_.*" - }, - "method": "post", - "params": None, - "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": { - "catch_up": True, - "latest_policies": { - "test_scope_prefix.Config_Lorem": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "0", - "policy_updated_to_ver": "1", - "updated_policy_id": "test_scope_prefix.Config_Lorem" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_Lorem.1.xml", - "policyVersion": "1", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_Lorem" - }, - "test_scope_prefix.Config_amet": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "4", - "policy_updated_to_ver": "5", - "updated_policy_id": "test_scope_prefix.Config_amet" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_amet.5.xml", - "policyVersion": "5", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_amet" - }, - "test_scope_prefix.Config_ametist": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "6", - "policy_updated_to_ver": "7", - "updated_policy_id": "test_scope_prefix.Config_ametist" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_ametist.7.xml", - "policyVersion": "7", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_ametist" - }, - "test_scope_prefix.Config_consectetur": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "5", - "policy_updated_to_ver": "6", - "updated_policy_id": "test_scope_prefix.Config_consectetur" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_consectetur.6.xml", - "policyVersion": "6", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_consectetur" - }, - "test_scope_prefix.Config_dolor": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "2", - "policy_updated_to_ver": "3", - "updated_policy_id": "test_scope_prefix.Config_dolor" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_dolor.3.xml", - "policyVersion": "3", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_dolor" - }, - "test_scope_prefix.Config_ipsum": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "1", - "policy_updated_to_ver": "2", - "updated_policy_id": "test_scope_prefix.Config_ipsum" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_ipsum.2.xml", - "policyVersion": "2", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_ipsum" - }, - "test_scope_prefix.Config_sit": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "3", - "policy_updated_to_ver": "4", - "updated_policy_id": "test_scope_prefix.Config_sit" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_sit.4.xml", - "policyVersion": "4", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_sit" - } - }, - "policy_filter_matches": { - "test_scope_prefix.Config_Lorem": {}, - "test_scope_prefix.Config_amet": {}, - "test_scope_prefix.Config_ametist": {}, - "test_scope_prefix.Config_consectetur": {}, - "test_scope_prefix.Config_dolor": {}, - "test_scope_prefix.Config_ipsum": {}, - "test_scope_prefix.Config_sit": {} - }, - "removed_policies": {} - }, - "method": "put", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - } - ], - "tests.test_policyhandler::WebServerTest::test_zzz_policy_updates_and_catch_ups": [ - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": None, - "method": "get", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "Accept": "application/json", - "Authorization": "Basic auth", - "ClientAuth": "Basic user", - "Content-Type": "application/json", - "Environment": "TEST", - "X-ECOMP-RequestID": "*" - }, - "json": { - "policyName": "test_scope_prefix.Config_.*" - }, - "method": "post", - "params": None, - "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": { - "catch_up": True, - "latest_policies": { - "test_scope_prefix.Config_Lorem": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "0", - "policy_updated_to_ver": "1", - "updated_policy_id": "test_scope_prefix.Config_Lorem" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_Lorem.1.xml", - "policyVersion": "1", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_Lorem" - }, - "test_scope_prefix.Config_amet": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "4", - "policy_updated_to_ver": "5", - "updated_policy_id": "test_scope_prefix.Config_amet" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_amet.5.xml", - "policyVersion": "5", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_amet" - }, - "test_scope_prefix.Config_ametist": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "6", - "policy_updated_to_ver": "7", - "updated_policy_id": "test_scope_prefix.Config_ametist" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_ametist.7.xml", - "policyVersion": "7", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_ametist" - }, - "test_scope_prefix.Config_consectetur": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "5", - "policy_updated_to_ver": "6", - "updated_policy_id": "test_scope_prefix.Config_consectetur" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_consectetur.6.xml", - "policyVersion": "6", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_consectetur" - }, - "test_scope_prefix.Config_dolor": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "2", - "policy_updated_to_ver": "3", - "updated_policy_id": "test_scope_prefix.Config_dolor" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_dolor.3.xml", - "policyVersion": "3", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_dolor" - }, - "test_scope_prefix.Config_ipsum": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "1", - "policy_updated_to_ver": "2", - "updated_policy_id": "test_scope_prefix.Config_ipsum" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_ipsum.2.xml", - "policyVersion": "2", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_ipsum" - }, - "test_scope_prefix.Config_sit": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "3", - "policy_updated_to_ver": "4", - "updated_policy_id": "test_scope_prefix.Config_sit" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_sit.4.xml", - "policyVersion": "4", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_sit" - } - }, - "policy_filter_matches": { - "test_scope_prefix.Config_Lorem": {}, - "test_scope_prefix.Config_amet": {}, - "test_scope_prefix.Config_ametist": {}, - "test_scope_prefix.Config_consectetur": {}, - "test_scope_prefix.Config_dolor": {}, - "test_scope_prefix.Config_ipsum": {}, - "test_scope_prefix.Config_sit": {} - }, - "removed_policies": {} - }, - "method": "put", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": None, - "method": "get", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "Accept": "application/json", - "Authorization": "Basic auth", - "ClientAuth": "Basic user", - "Content-Type": "application/json", - "Environment": "TEST", - "X-ECOMP-RequestID": "*" - }, - "json": { - "policyName": "test_scope_prefix.Config_ipsum" - }, - "method": "post", - "params": None, - "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "Accept": "application/json", - "Authorization": "Basic auth", - "ClientAuth": "Basic user", - "Content-Type": "application/json", - "Environment": "TEST", - "X-ECOMP-RequestID": "*" - }, - "json": { - "policyName": "test_scope_prefix.Config_sit" - }, - "method": "post", - "params": None, - "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "Accept": "application/json", - "Authorization": "Basic auth", - "ClientAuth": "Basic user", - "Content-Type": "application/json", - "Environment": "TEST", - "X-ECOMP-RequestID": "*" - }, - "json": { - "policyName": "test_scope_prefix.Config_consectetur" - }, - "method": "post", - "params": None, - "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": { - "catch_up": False, - "latest_policies": { - "test_scope_prefix.Config_consectetur": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "5", - "policy_updated_to_ver": "6", - "updated_policy_id": "test_scope_prefix.Config_consectetur" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_consectetur.6.xml", - "policyVersion": "6", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_consectetur" - }, - "test_scope_prefix.Config_ipsum": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "1", - "policy_updated_to_ver": "2", - "updated_policy_id": "test_scope_prefix.Config_ipsum" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_ipsum.2.xml", - "policyVersion": "2", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_ipsum" - }, - "test_scope_prefix.Config_sit": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "3", - "policy_updated_to_ver": "4", - "updated_policy_id": "test_scope_prefix.Config_sit" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_sit.4.xml", - "policyVersion": "4", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_sit" - } - }, - "policy_filter_matches": { - "test_scope_prefix.Config_consectetur": {}, - "test_scope_prefix.Config_ipsum": {}, - "test_scope_prefix.Config_sit": {} - }, - "removed_policies": {} - }, - "method": "put", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - } - ], - "tests.test_policyhandler::WebServerTest::test_zzzzz_shutdown": [ - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": None, - "method": "get", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "Accept": "application/json", - "Authorization": "Basic auth", - "ClientAuth": "Basic user", - "Content-Type": "application/json", - "Environment": "TEST", - "X-ECOMP-RequestID": "*" - }, - "json": { - "policyName": "test_scope_prefix.Config_.*" - }, - "method": "post", - "params": None, - "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": { - "catch_up": True, - "latest_policies": { - "test_scope_prefix.Config_Lorem": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "0", - "policy_updated_to_ver": "1", - "updated_policy_id": "test_scope_prefix.Config_Lorem" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_Lorem.1.xml", - "policyVersion": "1", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_Lorem" - }, - "test_scope_prefix.Config_amet": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "4", - "policy_updated_to_ver": "5", - "updated_policy_id": "test_scope_prefix.Config_amet" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_amet.5.xml", - "policyVersion": "5", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_amet" - }, - "test_scope_prefix.Config_ametist": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "6", - "policy_updated_to_ver": "7", - "updated_policy_id": "test_scope_prefix.Config_ametist" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_ametist.7.xml", - "policyVersion": "7", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_ametist" - }, - "test_scope_prefix.Config_consectetur": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "5", - "policy_updated_to_ver": "6", - "updated_policy_id": "test_scope_prefix.Config_consectetur" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_consectetur.6.xml", - "policyVersion": "6", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_consectetur" - }, - "test_scope_prefix.Config_dolor": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "2", - "policy_updated_to_ver": "3", - "updated_policy_id": "test_scope_prefix.Config_dolor" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_dolor.3.xml", - "policyVersion": "3", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_dolor" - }, - "test_scope_prefix.Config_ipsum": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "1", - "policy_updated_to_ver": "2", - "updated_policy_id": "test_scope_prefix.Config_ipsum" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_ipsum.2.xml", - "policyVersion": "2", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_ipsum" - }, - "test_scope_prefix.Config_sit": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "3", - "policy_updated_to_ver": "4", - "updated_policy_id": "test_scope_prefix.Config_sit" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_sit.4.xml", - "policyVersion": "4", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_sit" - } - }, - "policy_filter_matches": { - "test_scope_prefix.Config_Lorem": {}, - "test_scope_prefix.Config_amet": {}, - "test_scope_prefix.Config_ametist": {}, - "test_scope_prefix.Config_consectetur": {}, - "test_scope_prefix.Config_dolor": {}, - "test_scope_prefix.Config_ipsum": {}, - "test_scope_prefix.Config_sit": {} - }, - "removed_policies": {} - }, - "method": "put", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": None, - "method": "get", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "Accept": "application/json", - "Authorization": "Basic auth", - "ClientAuth": "Basic user", - "Content-Type": "application/json", - "Environment": "TEST", - "X-ECOMP-RequestID": "*" - }, - "json": { - "policyName": "test_scope_prefix.Config_ipsum" - }, - "method": "post", - "params": None, - "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "Accept": "application/json", - "Authorization": "Basic auth", - "ClientAuth": "Basic user", - "Content-Type": "application/json", - "Environment": "TEST", - "X-ECOMP-RequestID": "*" - }, - "json": { - "policyName": "test_scope_prefix.Config_sit" - }, - "method": "post", - "params": None, - "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "Accept": "application/json", - "Authorization": "Basic auth", - "ClientAuth": "Basic user", - "Content-Type": "application/json", - "Environment": "TEST", - "X-ECOMP-RequestID": "*" - }, - "json": { - "policyName": "test_scope_prefix.Config_consectetur" - }, - "method": "post", - "params": None, - "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": { - "catch_up": False, - "latest_policies": { - "test_scope_prefix.Config_consectetur": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "5", - "policy_updated_to_ver": "6", - "updated_policy_id": "test_scope_prefix.Config_consectetur" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_consectetur.6.xml", - "policyVersion": "6", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_consectetur" - }, - "test_scope_prefix.Config_ipsum": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "1", - "policy_updated_to_ver": "2", - "updated_policy_id": "test_scope_prefix.Config_ipsum" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_ipsum.2.xml", - "policyVersion": "2", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_ipsum" - }, - "test_scope_prefix.Config_sit": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "3", - "policy_updated_to_ver": "4", - "updated_policy_id": "test_scope_prefix.Config_sit" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_sit.4.xml", - "policyVersion": "4", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_sit" - } - }, - "policy_filter_matches": { - "test_scope_prefix.Config_consectetur": {}, - "test_scope_prefix.Config_ipsum": {}, - "test_scope_prefix.Config_sit": {} - }, - "removed_policies": {} - }, - "method": "put", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - } - ], - "tests.test_policyhandler::WebServerTest::test_zzz_catch_up_on_deploy_handler_changed": [ - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": None, - "method": "get", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "Accept": "application/json", - "Authorization": "Basic auth", - "ClientAuth": "Basic user", - "Content-Type": "application/json", - "Environment": "TEST", - "X-ECOMP-RequestID": "*" - }, - "json": { - "policyName": "test_scope_prefix.Config_.*" - }, - "method": "post", - "params": None, - "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": { - "catch_up": True, - "latest_policies": { - "test_scope_prefix.Config_Lorem": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "0", - "policy_updated_to_ver": "1", - "updated_policy_id": "test_scope_prefix.Config_Lorem" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_Lorem.1.xml", - "policyVersion": "1", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_Lorem" - }, - "test_scope_prefix.Config_amet": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "4", - "policy_updated_to_ver": "5", - "updated_policy_id": "test_scope_prefix.Config_amet" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_amet.5.xml", - "policyVersion": "5", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_amet" - }, - "test_scope_prefix.Config_ametist": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "6", - "policy_updated_to_ver": "7", - "updated_policy_id": "test_scope_prefix.Config_ametist" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_ametist.7.xml", - "policyVersion": "7", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_ametist" - }, - "test_scope_prefix.Config_consectetur": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "5", - "policy_updated_to_ver": "6", - "updated_policy_id": "test_scope_prefix.Config_consectetur" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_consectetur.6.xml", - "policyVersion": "6", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_consectetur" - }, - "test_scope_prefix.Config_dolor": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "2", - "policy_updated_to_ver": "3", - "updated_policy_id": "test_scope_prefix.Config_dolor" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_dolor.3.xml", - "policyVersion": "3", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_dolor" - }, - "test_scope_prefix.Config_ipsum": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "1", - "policy_updated_to_ver": "2", - "updated_policy_id": "test_scope_prefix.Config_ipsum" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_ipsum.2.xml", - "policyVersion": "2", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_ipsum" - }, - "test_scope_prefix.Config_sit": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "3", - "policy_updated_to_ver": "4", - "updated_policy_id": "test_scope_prefix.Config_sit" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_sit.4.xml", - "policyVersion": "4", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_sit" - } - }, - "policy_filter_matches": { - "test_scope_prefix.Config_Lorem": {}, - "test_scope_prefix.Config_amet": {}, - "test_scope_prefix.Config_ametist": {}, - "test_scope_prefix.Config_consectetur": {}, - "test_scope_prefix.Config_dolor": {}, - "test_scope_prefix.Config_ipsum": {}, - "test_scope_prefix.Config_sit": {} - }, - "removed_policies": {} - }, - "method": "put", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": None, - "method": "get", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "Accept": "application/json", - "Authorization": "Basic auth", - "ClientAuth": "Basic user", - "Content-Type": "application/json", - "Environment": "TEST", - "X-ECOMP-RequestID": "*" - }, - "json": { - "policyName": "test_scope_prefix.Config_ipsum" - }, - "method": "post", - "params": None, - "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": { - "catch_up": False, - "latest_policies": { - "test_scope_prefix.Config_ipsum": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "1", - "policy_updated_to_ver": "2", - "updated_policy_id": "test_scope_prefix.Config_ipsum" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_ipsum.2.xml", - "policyVersion": "2", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_ipsum" - } - }, - "policy_filter_matches": { - "test_scope_prefix.Config_ipsum": {} - }, - "removed_policies": {} - }, - "method": "put", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": None, - "method": "get", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "Accept": "application/json", - "Authorization": "Basic auth", - "ClientAuth": "Basic user", - "Content-Type": "application/json", - "Environment": "TEST", - "X-ECOMP-RequestID": "*" - }, - "json": { - "policyName": "test_scope_prefix.Config_dolor" - }, - "method": "post", - "params": None, - "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "Accept": "application/json", - "Authorization": "Basic auth", - "ClientAuth": "Basic user", - "Content-Type": "application/json", - "Environment": "TEST", - "X-ECOMP-RequestID": "*" - }, - "json": { - "policyName": "test_scope_prefix.Config_amet" - }, - "method": "post", - "params": None, - "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": { - "catch_up": False, - "latest_policies": { - "test_scope_prefix.Config_amet": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "4", - "policy_updated_to_ver": "5", - "updated_policy_id": "test_scope_prefix.Config_amet" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_amet.5.xml", - "policyVersion": "5", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_amet" - }, - "test_scope_prefix.Config_dolor": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "2", - "policy_updated_to_ver": "3", - "updated_policy_id": "test_scope_prefix.Config_dolor" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_dolor.3.xml", - "policyVersion": "3", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_dolor" - } - }, - "policy_filter_matches": { - "test_scope_prefix.Config_amet": {}, - "test_scope_prefix.Config_dolor": {} - }, - "removed_policies": {} - }, - "method": "put", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": None, - "method": "get", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "Accept": "application/json", - "Authorization": "Basic auth", - "ClientAuth": "Basic user", - "Content-Type": "application/json", - "Environment": "TEST", - "X-ECOMP-RequestID": "*" - }, - "json": { - "policyName": "test_scope_prefix.Config_.*" - }, - "method": "post", - "params": None, - "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": { - "catch_up": True, - "latest_policies": { - "test_scope_prefix.Config_Lorem": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "0", - "policy_updated_to_ver": "1", - "updated_policy_id": "test_scope_prefix.Config_Lorem" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_Lorem.1.xml", - "policyVersion": "1", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_Lorem" - }, - "test_scope_prefix.Config_amet": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "4", - "policy_updated_to_ver": "5", - "updated_policy_id": "test_scope_prefix.Config_amet" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_amet.5.xml", - "policyVersion": "5", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_amet" - }, - "test_scope_prefix.Config_ametist": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "6", - "policy_updated_to_ver": "7", - "updated_policy_id": "test_scope_prefix.Config_ametist" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_ametist.7.xml", - "policyVersion": "7", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_ametist" - }, - "test_scope_prefix.Config_consectetur": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "5", - "policy_updated_to_ver": "6", - "updated_policy_id": "test_scope_prefix.Config_consectetur" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_consectetur.6.xml", - "policyVersion": "6", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_consectetur" - }, - "test_scope_prefix.Config_dolor": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "2", - "policy_updated_to_ver": "3", - "updated_policy_id": "test_scope_prefix.Config_dolor" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_dolor.3.xml", - "policyVersion": "3", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_dolor" - }, - "test_scope_prefix.Config_ipsum": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "1", - "policy_updated_to_ver": "2", - "updated_policy_id": "test_scope_prefix.Config_ipsum" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_ipsum.2.xml", - "policyVersion": "2", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_ipsum" - }, - "test_scope_prefix.Config_sit": { - "policy_body": { - "config": { - "policy_hello": "world!", - "policy_updated_from_ver": "3", - "policy_updated_to_ver": "4", - "updated_policy_id": "test_scope_prefix.Config_sit" - }, - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_sit.4.xml", - "policyVersion": "4", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_sit" - } - }, - "policy_filter_matches": { - "test_scope_prefix.Config_Lorem": {}, - "test_scope_prefix.Config_amet": {}, - "test_scope_prefix.Config_ametist": {}, - "test_scope_prefix.Config_consectetur": {}, - "test_scope_prefix.Config_dolor": {}, - "test_scope_prefix.Config_ipsum": {}, - "test_scope_prefix.Config_sit": {} - }, - "removed_policies": {} - }, - "method": "put", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - } - ], - "tests.test_pz_catch_up::test_catch_up_failed_dh": [ - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": None, - "method": "get", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "Accept": "application/json", - "Authorization": "Basic auth", - "ClientAuth": "Basic user", - "Content-Type": "application/json", - "Environment": "TEST", - "X-ECOMP-RequestID": "*" - }, - "json": { - "policyName": "test_scope_prefix.Config_.*" - }, - "method": "post", - "params": None, - "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": { - "catch_up": True, - "latest_policies": { - "test_scope_prefix.Config_Lorem": { - "policy_body": { - "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_Lorem.1.xml", - "policyVersion": "1", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_Lorem" - }, - "test_scope_prefix.Config_amet": { - "policy_body": { - "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_amet.5.xml", - "policyVersion": "5", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_amet" - }, - "test_scope_prefix.Config_ametist": { - "policy_body": { - "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_ametist.7.xml", - "policyVersion": "7", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_ametist" - }, - "test_scope_prefix.Config_consectetur": { - "policy_body": { - "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_consectetur.6.xml", - "policyVersion": "6", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_consectetur" - }, - "test_scope_prefix.Config_dolor": { - "policy_body": { - "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_dolor.3.xml", - "policyVersion": "3", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_dolor" - }, - "test_scope_prefix.Config_ipsum": { - "policy_body": { - "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_ipsum.2.xml", - "policyVersion": "2", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_ipsum" - }, - "test_scope_prefix.Config_sit": { - "policy_body": { - "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_sit.4.xml", - "policyVersion": "4", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_sit" - } - }, - "policy_filter_matches": { - "test_scope_prefix.Config_Lorem": {}, - "test_scope_prefix.Config_amet": {}, - "test_scope_prefix.Config_ametist": {}, - "test_scope_prefix.Config_consectetur": {}, - "test_scope_prefix.Config_dolor": {}, - "test_scope_prefix.Config_ipsum": {}, - "test_scope_prefix.Config_sit": {} - }, - "removed_policies": {} - }, - "method": "put", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 413 - }, - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": None, - "method": "get", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "Accept": "application/json", - "Authorization": "Basic auth", - "ClientAuth": "Basic user", - "Content-Type": "application/json", - "Environment": "TEST", - "X-ECOMP-RequestID": "*" - }, - "json": { - "policyName": "test_scope_prefix.Config_.*" - }, - "method": "post", - "params": None, - "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": { - "catch_up": True, - "latest_policies": { - "test_scope_prefix.Config_Lorem": { - "policy_body": { - "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_Lorem.1.xml", - "policyVersion": "1", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_Lorem" - }, - "test_scope_prefix.Config_amet": { - "policy_body": { - "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_amet.5.xml", - "policyVersion": "5", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_amet" - }, - "test_scope_prefix.Config_ametist": { - "policy_body": { - "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_ametist.7.xml", - "policyVersion": "7", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_ametist" - }, - "test_scope_prefix.Config_consectetur": { - "policy_body": { - "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_consectetur.6.xml", - "policyVersion": "6", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_consectetur" - }, - "test_scope_prefix.Config_dolor": { - "policy_body": { - "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_dolor.3.xml", - "policyVersion": "3", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_dolor" - }, - "test_scope_prefix.Config_ipsum": { - "policy_body": { - "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_ipsum.2.xml", - "policyVersion": "2", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_ipsum" - }, - "test_scope_prefix.Config_sit": { - "policy_body": { - "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_sit.4.xml", - "policyVersion": "4", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_sit" - } - }, - "policy_filter_matches": { - "test_scope_prefix.Config_Lorem": {}, - "test_scope_prefix.Config_amet": {}, - "test_scope_prefix.Config_ametist": {}, - "test_scope_prefix.Config_consectetur": {}, - "test_scope_prefix.Config_dolor": {}, - "test_scope_prefix.Config_ipsum": {}, - "test_scope_prefix.Config_sit": {} - }, - "removed_policies": {} - }, - "method": "put", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 413 - }, - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": None, - "method": "get", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "Accept": "application/json", - "Authorization": "Basic auth", - "ClientAuth": "Basic user", - "Content-Type": "application/json", - "Environment": "TEST", - "X-ECOMP-RequestID": "*" - }, - "json": { - "policyName": "test_scope_prefix.Config_.*" - }, - "method": "post", - "params": None, - "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": { - "catch_up": True, - "latest_policies": { - "test_scope_prefix.Config_Lorem": { - "policy_body": { - "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_Lorem.1.xml", - "policyVersion": "1", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_Lorem" - }, - "test_scope_prefix.Config_amet": { - "policy_body": { - "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_amet.5.xml", - "policyVersion": "5", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_amet" - }, - "test_scope_prefix.Config_ametist": { - "policy_body": { - "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_ametist.7.xml", - "policyVersion": "7", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_ametist" - }, - "test_scope_prefix.Config_consectetur": { - "policy_body": { - "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_consectetur.6.xml", - "policyVersion": "6", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_consectetur" - }, - "test_scope_prefix.Config_dolor": { - "policy_body": { - "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_dolor.3.xml", - "policyVersion": "3", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_dolor" - }, - "test_scope_prefix.Config_ipsum": { - "policy_body": { - "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_ipsum.2.xml", - "policyVersion": "2", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_ipsum" - }, - "test_scope_prefix.Config_sit": { - "policy_body": { - "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", - "matchingConditions": { - "ConfigName": "alex_config_name", - "ONAPName": "DCAE" - }, - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "policyName": "test_scope_prefix.Config_sit.4.xml", - "policyVersion": "4", - "property": None, - "responseAttributes": {}, - "type": "JSON" - }, - "policy_id": "test_scope_prefix.Config_sit" - } - }, - "policy_filter_matches": { - "test_scope_prefix.Config_Lorem": {}, - "test_scope_prefix.Config_amet": {}, - "test_scope_prefix.Config_ametist": {}, - "test_scope_prefix.Config_consectetur": {}, - "test_scope_prefix.Config_dolor": {}, - "test_scope_prefix.Config_ipsum": {}, - "test_scope_prefix.Config_sit": {} - }, - "removed_policies": {} - }, - "method": "put", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 413 - } - ], - "tests.test_pz_catch_up::test_catch_up_dh_404": [ - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": None, - "method": "get", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": None, - "method": "get", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": None, - "method": "get", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - } - ], - "tests.test_pz_pdp_boom::WebServerPDPBoomTest::test_web_all_policies_latest": [ - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": None, - "method": "get", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - } - ], - "tests.test_pz_pdp_boom::WebServerPDPBoomTest::test_zzz_catch_up_on_deploy_handler_changed": [ - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": None, - "method": "get", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": None, - "method": "get", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": None, - "method": "get", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": None, - "method": "get", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - } - ], - "tests.test_pz_pdp_boom::WebServerPDPBoomTest::test_zzz_get_catch_up": [ - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": None, - "method": "get", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": None, - "method": "get", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - } - ], - "tests.test_pz_pdp_boom::WebServerPDPBoomTest::test_zzz_policy_updates_and_catch_ups": [ - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": None, - "method": "get", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": None, - "method": "get", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - } - ], - "tests.test_pz_pdp_boom::WebServerPDPBoomTest::test_zzzzz_shutdown": [ - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": None, - "method": "get", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": None, - "method": "get", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - } - ], - "tests.test_pz_ph_boom::WebServerInternalBoomTest::test_web_all_policies_latest": [ - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": None, - "method": "get", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "Accept": "application/json", - "Authorization": "Basic auth", - "ClientAuth": "Basic user", - "Content-Type": "application/json", - "Environment": "TEST", - "X-ECOMP-RequestID": "*" - }, - "json": { - "policyName": "test_scope_prefix.Config_.*" - }, - "method": "post", - "params": None, - "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" - }, - "res": "*", - "status_code": 200 - } - ], - "tests.test_pz_ph_boom::WebServerInternalBoomTest::test_web_policies_latest": [ - { - "request": { - "headers": { - "Accept": "application/json", - "Authorization": "Basic auth", - "ClientAuth": "Basic user", - "Content-Type": "application/json", - "Environment": "TEST", - "X-ECOMP-RequestID": "*" - }, - "json": { - "policyName": "test_scope_prefix.Config_amet.*" - }, - "method": "post", - "params": None, - "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" - }, - "res": "*", - "status_code": 200 - } - ], - "tests.test_pz_ph_boom::WebServerInternalBoomTest::test_web_policy_latest": [ - { - "request": { - "headers": { - "Accept": "application/json", - "Authorization": "Basic auth", - "ClientAuth": "Basic user", - "Content-Type": "application/json", - "Environment": "TEST", - "X-ECOMP-RequestID": "*" - }, - "json": { - "policyName": "test_scope_prefix.Config_sit" - }, - "method": "post", - "params": None, - "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" - }, - "res": "*", - "status_code": 200 - } - ], - "tests.test_pz_ph_boom::WebServerInternalBoomTest::test_zzz_catch_up_on_deploy_handler_changed": [ - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": None, - "method": "get", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "Accept": "application/json", - "Authorization": "Basic auth", - "ClientAuth": "Basic user", - "Content-Type": "application/json", - "Environment": "TEST", - "X-ECOMP-RequestID": "*" - }, - "json": { - "policyName": "test_scope_prefix.Config_.*" - }, - "method": "post", - "params": None, - "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" - }, - "res": "*", - "status_code": 200 - } - ], - "tests.test_pz_ph_boom::WebServerInternalBoomTest::test_zzz_get_catch_up": [ - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": None, - "method": "get", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "Accept": "application/json", - "Authorization": "Basic auth", - "ClientAuth": "Basic user", - "Content-Type": "application/json", - "Environment": "TEST", - "X-ECOMP-RequestID": "*" - }, - "json": { - "policyName": "test_scope_prefix.Config_.*" - }, - "method": "post", - "params": None, - "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": None, - "method": "get", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "Accept": "application/json", - "Authorization": "Basic auth", - "ClientAuth": "Basic user", - "Content-Type": "application/json", - "Environment": "TEST", - "X-ECOMP-RequestID": "*" - }, - "json": { - "policyName": "test_scope_prefix.Config_.*" - }, - "method": "post", - "params": None, - "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" - }, - "res": "*", - "status_code": 200 - } - ], - "tests.test_pz_ph_boom::WebServerInternalBoomTest::test_zzz_policy_updates_and_catch_ups": [ - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": None, - "method": "get", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "Accept": "application/json", - "Authorization": "Basic auth", - "ClientAuth": "Basic user", - "Content-Type": "application/json", - "Environment": "TEST", - "X-ECOMP-RequestID": "*" - }, - "json": { - "policyName": "test_scope_prefix.Config_.*" - }, - "method": "post", - "params": None, - "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" - }, - "res": "*", - "status_code": 200 - } - ], - "tests.test_pz_ph_boom::WebServerInternalBoomTest::test_zzzzz_shutdown": [ - { - "request": { - "headers": { - "X-ECOMP-RequestID": "*" - }, - "json": None, - "method": "get", - "params": { - "cfy_tenant_name": "default_tenant" - }, - "uri": "http://unit-test-deployment_handler:8188000/policy" - }, - "res": "*", - "status_code": 200 - }, - { - "request": { - "headers": { - "Accept": "application/json", - "Authorization": "Basic auth", - "ClientAuth": "Basic user", - "Content-Type": "application/json", - "Environment": "TEST", - "X-ECOMP-RequestID": "*" - }, - "json": { - "policyName": "test_scope_prefix.Config_.*" - }, - "method": "post", - "params": None, - "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" - }, - "res": "*", - "status_code": 200 - } - ] -} diff --git a/tests/mock_policy_engine.py b/tests/mock_policy_engine.py deleted file mode 100644 index d57d613..0000000 --- a/tests/mock_policy_engine.py +++ /dev/null @@ -1,131 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= -# -# ECOMP is a trademark and service mark of AT&T Intellectual Property. -"""mocking for the policy-engine - shared by many tests""" - -import copy -import json -import re - -from policyhandler.policy_consts import (POLICY_BODY, POLICY_CONFIG, POLICY_ID, - POLICY_NAME, POLICY_VERSION) -from policyhandler.policy_utils import PolicyUtils - -from .mock_settings import Settings - - -class MonkeyPolicyBody(object): - """policy body that policy-engine returns""" - @staticmethod - def create_policy_body(policy_id, policy_version=1): - """returns a fake policy-body""" - prev_ver = str(policy_version - 1) - this_ver = str(policy_version) - config = { - "policy_updated_from_ver": prev_ver, - "policy_updated_to_ver": this_ver, - "policy_hello": "world!", - "updated_policy_id": policy_id - } - return { - "policyConfigMessage": "Config Retrieved! ", - "policyConfigStatus": "CONFIG_RETRIEVED", - "type": "JSON", - POLICY_NAME: "{0}.{1}.xml".format(policy_id, this_ver), - POLICY_VERSION: this_ver, - POLICY_CONFIG: json.dumps(config, sort_keys=True), - "matchingConditions": { - "ONAPName": "DCAE", - "ConfigName": "alex_config_name" - }, - "responseAttributes": {}, - "property": None - } - - -class MockPolicyEngine(object): - """pretend this is the policy-engine""" - scope_prefix = "test_scope_prefix.Config_" - LOREM_IPSUM = """Lorem ipsum dolor sit amet consectetur ametist""".split() - LONG_TEXT = "0123456789" * 100 - _policies = [] - - _inited = False - - @staticmethod - def init(): - """init static vars""" - if MockPolicyEngine._inited: - return - MockPolicyEngine._inited = True - - MockPolicyEngine._policies = [ - MonkeyPolicyBody.create_policy_body( - MockPolicyEngine.scope_prefix + policy_id, policy_index + 1) - for policy_id in MockPolicyEngine.LOREM_IPSUM - for policy_index in range(1 + MockPolicyEngine.LOREM_IPSUM.index(policy_id))] - Settings.logger.info("MockPolicyEngine._policies: %s", - json.dumps(MockPolicyEngine._policies)) - - @staticmethod - def get_config(policy_name): - """find policy the way the policy-engine finds""" - if not policy_name: - return [] - return [copy.deepcopy(policy) - for policy in MockPolicyEngine._policies - if re.match(policy_name, policy[POLICY_NAME])] - - @staticmethod - def get_configs_all(): - """get all policies the way the policy-engine finds""" - policies = [copy.deepcopy(policy) - for policy in MockPolicyEngine._policies] - for policy in policies: - policy["config"] = MockPolicyEngine.LONG_TEXT - return policies - - @staticmethod - def get_policy_id(policy_index): - """get the policy_id by index""" - return (MockPolicyEngine.scope_prefix - + MockPolicyEngine.LOREM_IPSUM[ - policy_index % len(MockPolicyEngine.LOREM_IPSUM)]) - - @staticmethod - def gen_policy_latest(policy_index, version_offset=0): - """generate the policy response by policy_index = version - 1""" - policy_id = MockPolicyEngine.get_policy_id(policy_index) - policy = { - POLICY_ID: policy_id, - POLICY_BODY: MonkeyPolicyBody.create_policy_body( - policy_id, policy_index + 1 - version_offset) - } - return policy_id, PolicyUtils.parse_policy_config(policy) - - @staticmethod - def gen_all_policies_latest(version_offset=0): - """generate all latest policies""" - return dict(MockPolicyEngine.gen_policy_latest(policy_index, version_offset=version_offset) - for policy_index in range(len(MockPolicyEngine.LOREM_IPSUM))) - - @staticmethod - def gen_policies_latest(match_to_policy_name): - """generate all latest policies""" - return dict((k, v) - for k, v in MockPolicyEngine.gen_all_policies_latest().items() - if re.match(match_to_policy_name, k)) diff --git a/tests/mock_settings.py b/tests/mock_settings.py index 8dec8e5..9e99561 100644 --- a/tests/mock_settings.py +++ b/tests/mock_settings.py @@ -14,12 +14,12 @@ # limitations under the License. # ============LICENSE_END========================================================= # -# ECOMP is a trademark and service mark of AT&T Intellectual Property. """settings that are general to all tests""" import copy +import importlib import json -import logging +import os import sys import uuid from functools import wraps @@ -29,7 +29,9 @@ from policyhandler.config import Config from policyhandler.discovery import DiscoveryClient from policyhandler.onap.audit import Audit from policyhandler.service_activator import ServiceActivator +from policyhandler.utils import Utils +_LOGGER = Utils.get_logger(__file__) def _fix_discover_config(func): """the decorator""" @@ -38,7 +40,7 @@ def _fix_discover_config(func): def mocked_discover_get_value(*_): """monkeypatch for get from consul""" - return copy.deepcopy(Settings.mock_config) + return copy.deepcopy(MockSettings.mock_config) @wraps(func) def wrapper(*args, **kwargs): @@ -54,49 +56,65 @@ def _fix_discover_config(func): return func_result return wrapper -class Settings(object): +class MockSettings(object): """init all locals""" + PDP_API_VERSION = "PDP_API_VERSION" + OLD_PDP_API_VERSION = "pdp_api_v0" _loaded = False - logger = None mock_config = None deploy_handler_instance_uuid = str(uuid.uuid4()) @staticmethod def init(): """init configs""" - if Settings._loaded: - Settings.logger.info("testing policy_handler with config: %s", Config.discovered_config) + if MockSettings._loaded: + _LOGGER.info("testing policy_handler with config: %s", Config.discovered_config) return - Settings._loaded = True + MockSettings._loaded = True - Config.init_config() - - Config.consul_url = "http://unit-test-consul:850000" + Config.init_config("tests/etc_config.json") with open("tests/mock_config.json", 'r') as config_json: - Settings.mock_config = json.load(config_json) + MockSettings.mock_config = json.load(config_json) - Settings.logger = logging.getLogger("policy_handler.unit_test") - sys.stdout = LogWriter(Settings.logger.info) - sys.stderr = LogWriter(Settings.logger.error) + sys.stdout = LogWriter(_LOGGER.info) + sys.stderr = LogWriter(_LOGGER.error) print("print is expected to be in the log") - Settings.logger.info("========== run_policy_handler ==========") + _LOGGER.info("========== run_policy_handler ==========") Audit.init(Config.system_name, Config.LOGGER_CONFIG_FILE_PATH) - Settings.rediscover_config() + MockSettings.rediscover_config() @staticmethod @_fix_discover_config def rediscover_config(updated_config=None): """rediscover the config""" if updated_config is not None: - Settings.mock_config = copy.deepcopy(updated_config) + MockSettings.mock_config = copy.deepcopy(updated_config) audit = Audit(req_message="rediscover_config") Config.discover(audit) ServiceActivator.determine_mode_of_operation(audit) - Settings.logger.info("testing policy_handler with config: %s", Config.discovered_config) + _LOGGER.info("testing policy_handler with config: %s", Config.discovered_config) audit.audit_done(" -- started") + + @staticmethod + def setup_pdp_api(pdp_api_version=None): + """set the environment var for pdp_api""" + if Config._pdp_api_version == pdp_api_version: + _LOGGER.info("unchanged setup_pdp_api %s", pdp_api_version) + return + + _LOGGER.info("setup_pdp_api %s -> %s", Config._pdp_api_version, pdp_api_version) + + if pdp_api_version: + os.environ[MockSettings.PDP_API_VERSION] = pdp_api_version + elif MockSettings.PDP_API_VERSION in os.environ: + del os.environ[MockSettings.PDP_API_VERSION] + Config._pdp_api_version = pdp_api_version + + importlib.reload(importlib.import_module("policyhandler.pdp_client")) + _LOGGER.info("done setup_pdp_api %s", Config._pdp_api_version) diff --git a/tests/mock_tracker.py b/tests/mock_tracker.py index 4e69afd..a5fffd5 100644 --- a/tests/mock_tracker.py +++ b/tests/mock_tracker.py @@ -1,5 +1,5 @@ # ============LICENSE_START======================================================= -# Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. +# Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,19 +14,18 @@ # limitations under the License. # ============LICENSE_END========================================================= # -# ECOMP is a trademark and service mark of AT&T Intellectual Property. """record all the messages going outside policy-handler during testing""" import copy import json +from policyhandler.config import Config from policyhandler.onap.audit import REQUEST_X_ECOMP_REQUESTID -from policyhandler.policy_utils import Utils - -from .mock_expected import HISTORY_EXPECTED -from .mock_settings import Settings +from policyhandler.utils import Utils RESPONSE = "res" +PEP_INSTANCE = "ONAPInstance" +_LOGGER = Utils.get_logger(__file__) class _MockHttpRequestInResponse(object): """Mock http request in reponse object""" @@ -89,26 +88,61 @@ class Tracker(object): """record all the messages going outside policy-handler during testing""" test_name = None messages = [] + test_names = [] + validated_tests = {} + valid_tests = {} @staticmethod - def reset(test_name): + def reset(test_name=None): """remove all the messages from history""" Tracker.test_name = test_name Tracker.messages.clear() + Tracker.test_names.append(test_name) @staticmethod def track(message): """append the tracked message to the history""" message = copy.deepcopy(message) Tracker.messages.append(message) - if Settings.logger: - Settings.logger.info("tracked_message: %s", json.dumps(message, sort_keys=True)) + if _LOGGER: + _LOGGER.info("tracked_message: %s", json.dumps(message, sort_keys=True)) @staticmethod def to_string(): """stringify message history for logging""" return json.dumps(Tracker.messages, sort_keys=True) + @staticmethod + def get_status(test_name=None): + """get the status of validation""" + if Tracker.valid_tests.get(test_name): + return "success" + if Tracker.validated_tests.get(test_name): + return "failed" + if test_name in Tracker.test_names: + return "covered" + return "unknown" + + @staticmethod + def log_all_tests(): + """log the covered and not covered test names""" + _LOGGER.info("-"*75) + _LOGGER.info("tracked test_names[%s]", len(Tracker.test_names)) + for idx, test_name in enumerate(Tracker.test_names): + _LOGGER.info("%s[%s]: %s", Tracker.get_status(test_name), (idx + 1), test_name) + + _LOGGER.info("not tracked test_names listed in main.mock_expected") + from .main.mock_expected import HISTORY_EXPECTED as main_history + for test_name in main_history: + if test_name not in Tracker.test_names: + _LOGGER.info("untracked: %s", test_name) + + _LOGGER.info("not tracked test_names listed in pdp_api_v0.mock_expected") + from .pdp_api_v0.mock_expected import HISTORY_EXPECTED as pdp_api_v0_history + for test_name in pdp_api_v0_history: + if test_name not in Tracker.test_names: + _LOGGER.info("untracked: %s", test_name) + @staticmethod def _hide_volatiles(obj): """hides the volatile field values""" @@ -116,7 +150,7 @@ class Tracker(object): return obj for key, value in obj.items(): - if key in [REQUEST_X_ECOMP_REQUESTID, RESPONSE]: + if key in [REQUEST_X_ECOMP_REQUESTID, RESPONSE, PEP_INSTANCE]: obj[key] = "*" elif isinstance(value, dict): obj[key] = Tracker._hide_volatiles(value) @@ -126,13 +160,21 @@ class Tracker(object): @staticmethod def validate(): """validate that the message history is as expected""" - Settings.logger.info("Tracker.validate(%s)", Tracker.test_name) + _LOGGER.info("Tracker.validate(%s)", Tracker.test_name) messages = [Tracker._hide_volatiles(copy.deepcopy(message)) for message in Tracker.messages] - expected = HISTORY_EXPECTED.get(Tracker.test_name, []) + Tracker.validated_tests[Tracker.test_name] = True + + if Config.is_pdp_api_default(): + from .main.mock_expected import HISTORY_EXPECTED as main_history + expected = main_history.get(Tracker.test_name, []) + else: + from .pdp_api_v0.mock_expected import HISTORY_EXPECTED as pdp_api_v0_history + expected = pdp_api_v0_history.get(Tracker.test_name, []) - Settings.logger.info("messages: %s", json.dumps(messages, sort_keys=True)) - Settings.logger.info("expected: %s", json.dumps(expected, sort_keys=True)) + _LOGGER.info("messages: %s", json.dumps(messages, sort_keys=True)) + _LOGGER.info("expected: %s", json.dumps(expected, sort_keys=True)) assert Utils.are_the_same(messages, expected) - Settings.logger.info("history valid for Tracker.validate(%s)", Tracker.test_name) + _LOGGER.info("history valid for Tracker.validate(%s)", Tracker.test_name) + Tracker.valid_tests[Tracker.test_name] = True diff --git a/tests/mock_websocket.py b/tests/mock_websocket.py deleted file mode 100644 index ac64ed8..0000000 --- a/tests/mock_websocket.py +++ /dev/null @@ -1,89 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= -# -# ECOMP is a trademark and service mark of AT&T Intellectual Property. -"""mocking for the websocket - for testing of policy-engine""" - -import json -import time - -from policyhandler.policy_consts import POLICY_NAME -from policyhandler.policy_receiver import (LOADED_POLICIES, POLICY_VER, - REMOVED_POLICIES) - -from .mock_policy_engine import MockPolicyEngine -from .mock_settings import Settings - - -class MockWebSocket(object): - """Mock websocket""" - on_message = None - - @staticmethod - def send_notification(updated_indexes): - """fake notification through the web-socket""" - if not MockWebSocket.on_message: - return - message = { - LOADED_POLICIES: [ - {POLICY_NAME: "{0}.{1}.xml".format( - MockPolicyEngine.get_policy_id(policy_index), policy_index + 1), - POLICY_VER: str(policy_index + 1)} - for policy_index in updated_indexes or [] - ], - REMOVED_POLICIES : [] - } - message = json.dumps(message) - Settings.logger.info("send_notification: %s", message) - MockWebSocket.on_message(None, message) - - @staticmethod - def enableTrace(yes_no): - """ignore""" - pass - - class MockSocket(object): - """Mock websocket""" - def __init__(self): - self.connected = True - - class WebSocketApp(object): - """Mocked WebSocketApp""" - def __init__(self, web_socket_url, - on_open=None, on_message=None, on_close=None, on_error=None, on_pong=None): - self.web_socket_url = web_socket_url - self.on_open = on_open - self.on_message = MockWebSocket.on_message = on_message - self.on_close = on_close - self.on_error = on_error - self.on_pong = on_pong - self.sock = MockWebSocket.MockSocket() - Settings.logger.info("MockWebSocket for: %s", self.web_socket_url) - - def run_forever(self, sslopt=None): - """forever in the loop""" - Settings.logger.info("MockWebSocket run_forever with sslopt=%s...", - json.dumps(sslopt)) - counter = 0 - while self.sock.connected: - counter += 1 - Settings.logger.info("MockWebSocket sleep %s...", counter) - time.sleep(5) - Settings.logger.info("MockWebSocket exit %s", counter) - - def close(self): - """close socket""" - self.sock.connected = False diff --git a/tests/pdp_api_v0/__init__.py b/tests/pdp_api_v0/__init__.py new file mode 100644 index 0000000..b8e4605 --- /dev/null +++ b/tests/pdp_api_v0/__init__.py @@ -0,0 +1,20 @@ +# ================================================================================ +# Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# + + +# empty __init__.py so that pytest can add correct path to coverage report, -- per pytest +# best practice guideline diff --git a/tests/pdp_api_v0/conftest.py b/tests/pdp_api_v0/conftest.py new file mode 100644 index 0000000..07e566f --- /dev/null +++ b/tests/pdp_api_v0/conftest.py @@ -0,0 +1,133 @@ +# ============LICENSE_START======================================================= +# Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +""" +startdard pytest file that contains the shared fixtures +https://docs.pytest.org/en/latest/fixture.html +""" + +import pytest + +from policyhandler import pdp_client +from policyhandler.pdp_api_v0.pdp_consts import POLICY_NAME +from policyhandler.utils import Utils + +from ..mock_settings import MockSettings +from ..mock_tracker import MockHttpResponse +from .mock_policy_engine import MockPolicyEngine2018 +from .mock_websocket import MockWebSocket + +_LOGGER = Utils.get_logger(__file__) + +@pytest.fixture(scope="session", autouse=True) +def _auto_setup_policy_engine_pdp_api_v0(): + """initialize the mock-policy-engine_pdp_api_v0 per the whole test session""" + _LOGGER.info("create _auto_setup_policy_engine_pdp_api_v0") + MockPolicyEngine2018.init() + yield _auto_setup_policy_engine_pdp_api_v0 + _LOGGER.info("teardown _auto_setup_policy_engine_pdp_api_v0") + + +@pytest.fixture(scope="module") +def fix_pdp_api_v0(): + """test on the old (pdp_api_v0) pdp API""" + _LOGGER.info("setup fix_pdp_api_v0 %s", MockSettings.OLD_PDP_API_VERSION) + MockSettings.setup_pdp_api(MockSettings.OLD_PDP_API_VERSION) + + yield fix_pdp_api_v0 + MockSettings.setup_pdp_api() + _LOGGER.info("teardown fix_pdp_api_v0 %s", MockSettings.OLD_PDP_API_VERSION) + +@pytest.fixture() +def fix_pdp_post(monkeypatch): + """monkeyed request /getConfig to PDP""" + def monkeyed_policy_rest_post(uri, json=None, **kwargs): + """monkeypatch for the POST to policy-engine""" + res_json = MockPolicyEngine2018.get_config(json.get(POLICY_NAME)) + return MockHttpResponse("post", uri, res_json, json=json, **kwargs) + + _LOGGER.info("setup fix_pdp_post") + pdp_client.PolicyRest._lazy_init() + monkeypatch.setattr('policyhandler.pdp_client.PolicyRest._requests_session.post', + monkeyed_policy_rest_post) + yield fix_pdp_post + _LOGGER.info("teardown fix_pdp_post") + +@pytest.fixture() +def fix_pdp_post_big(monkeypatch): + """monkeyed request /getConfig to PDP""" + def monkeyed_policy_rest_post(uri, **kwargs): + """monkeypatch for the POST to policy-engine""" + res_json = MockPolicyEngine2018.get_configs_all() + return MockHttpResponse("post", uri, res_json, **kwargs) + + _LOGGER.info("setup fix_pdp_post_big") + pdp_client.PolicyRest._lazy_init() + monkeypatch.setattr('policyhandler.pdp_client.PolicyRest._requests_session.post', + monkeyed_policy_rest_post) + yield fix_pdp_post_big + _LOGGER.info("teardown fix_pdp_post_big") + + +class MockException(Exception): + """mock exception""" + pass + +@pytest.fixture() +def fix_pdp_post_boom(monkeypatch): + """monkeyed request /getConfig to PDP - exception""" + def monkeyed_policy_rest_post_boom(uri, **_): + """monkeypatch for the POST to policy-engine""" + raise MockException("fix_pdp_post_boom {}".format(uri)) + + _LOGGER.info("setup fix_pdp_post_boom") + pdp_client.PolicyRest._lazy_init() + monkeypatch.setattr('policyhandler.pdp_client.PolicyRest._requests_session.post', + monkeyed_policy_rest_post_boom) + yield fix_pdp_post_boom + _LOGGER.info("teardown fix_pdp_post_boom") + + +@pytest.fixture() +def fix_policy_receiver_websocket(monkeypatch): + """monkeyed websocket for policy_receiver""" + _LOGGER.info("setup fix_policy_receiver_websocket") + monkeypatch.setattr('policyhandler.pdp_api_v0.policy_listener.websocket', MockWebSocket) + + yield fix_policy_receiver_websocket + _LOGGER.info("teardown fix_policy_receiver_websocket") + +class MockBoom(Exception): + """mock exception""" + pass + +@pytest.fixture() +def fix_select_latest_policies_boom(monkeypatch): + """monkeyed exception""" + def monkeyed_boom(*_, **__): + """monkeypatch for the select_latest_policies""" + raise MockBoom("fix_select_latest_policies_boom") + + policy_utils_path = 'policyhandler.pdp_api_v0.policy_utils.PolicyUtils' + + _LOGGER.info("setup fix_select_latest_policies_boom at %s", policy_utils_path) + + monkeypatch.setattr('{}.select_latest_policies'.format(policy_utils_path), monkeyed_boom) + monkeypatch.setattr('{}.select_latest_policy'.format(policy_utils_path), monkeyed_boom) + monkeypatch.setattr('{}.extract_policy_id'.format(policy_utils_path), monkeyed_boom) + + yield fix_select_latest_policies_boom + _LOGGER.info("teardown fix_select_latest_policies_boom at %s", policy_utils_path) diff --git a/tests/pdp_api_v0/mock_expected.py b/tests/pdp_api_v0/mock_expected.py new file mode 100644 index 0000000..6210e10 --- /dev/null +++ b/tests/pdp_api_v0/mock_expected.py @@ -0,0 +1,3012 @@ +# ============LICENSE_START======================================================= +# Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +"""expected message history per test for pdp API 2018 and before""" + + +HISTORY_EXPECTED = { + "tests/pdp_api_v0/test_policy_rest.py::test_get_policy_latest" : [ + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_sit" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + } + ], + "tests/pdp_api_v0/test_policyhandler.py::WebServer2018Test::test_web_all_policies_latest": [ + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_.*" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + } + ], + "tests/pdp_api_v0/test_policyhandler.py::WebServer2018Test::test_web_policies_latest": [ + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_amet.*" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + } + ], + "tests/pdp_api_v0/test_policyhandler.py::WebServer2018Test::test_web_policy_latest": [ + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_sit" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + } + ], + "tests/pdp_api_v0/test_policyhandler.py::WebServer2018Test::test_zzz_get_catch_up": [ + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_.*" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": { + "catch_up": True, + "latest_policies": { + "test_scope_prefix.Config_Lorem": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "0", + "policy_updated_to_ver": "1", + "updated_policy_id": "test_scope_prefix.Config_Lorem" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_Lorem.1.xml", + "policyVersion": "1", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_Lorem" + }, + "test_scope_prefix.Config_amet": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "4", + "policy_updated_to_ver": "5", + "updated_policy_id": "test_scope_prefix.Config_amet" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_amet.5.xml", + "policyVersion": "5", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_amet" + }, + "test_scope_prefix.Config_ametist": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "6", + "policy_updated_to_ver": "7", + "updated_policy_id": "test_scope_prefix.Config_ametist" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_ametist.7.xml", + "policyVersion": "7", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_ametist" + }, + "test_scope_prefix.Config_consectetur": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "5", + "policy_updated_to_ver": "6", + "updated_policy_id": "test_scope_prefix.Config_consectetur" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_consectetur.6.xml", + "policyVersion": "6", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_consectetur" + }, + "test_scope_prefix.Config_dolor": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "2", + "policy_updated_to_ver": "3", + "updated_policy_id": "test_scope_prefix.Config_dolor" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_dolor.3.xml", + "policyVersion": "3", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_dolor" + }, + "test_scope_prefix.Config_ipsum": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "1", + "policy_updated_to_ver": "2", + "updated_policy_id": "test_scope_prefix.Config_ipsum" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_ipsum.2.xml", + "policyVersion": "2", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_ipsum" + }, + "test_scope_prefix.Config_sit": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "3", + "policy_updated_to_ver": "4", + "updated_policy_id": "test_scope_prefix.Config_sit" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_sit.4.xml", + "policyVersion": "4", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_sit" + } + }, + "policy_filter_matches": { + "test_scope_prefix.Config_Lorem": {}, + "test_scope_prefix.Config_amet": {}, + "test_scope_prefix.Config_ametist": {}, + "test_scope_prefix.Config_consectetur": {}, + "test_scope_prefix.Config_dolor": {}, + "test_scope_prefix.Config_ipsum": {}, + "test_scope_prefix.Config_sit": {} + }, + "removed_policies": {} + }, + "method": "put", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_.*" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": { + "catch_up": True, + "latest_policies": { + "test_scope_prefix.Config_Lorem": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "0", + "policy_updated_to_ver": "1", + "updated_policy_id": "test_scope_prefix.Config_Lorem" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_Lorem.1.xml", + "policyVersion": "1", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_Lorem" + }, + "test_scope_prefix.Config_amet": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "4", + "policy_updated_to_ver": "5", + "updated_policy_id": "test_scope_prefix.Config_amet" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_amet.5.xml", + "policyVersion": "5", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_amet" + }, + "test_scope_prefix.Config_ametist": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "6", + "policy_updated_to_ver": "7", + "updated_policy_id": "test_scope_prefix.Config_ametist" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_ametist.7.xml", + "policyVersion": "7", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_ametist" + }, + "test_scope_prefix.Config_consectetur": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "5", + "policy_updated_to_ver": "6", + "updated_policy_id": "test_scope_prefix.Config_consectetur" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_consectetur.6.xml", + "policyVersion": "6", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_consectetur" + }, + "test_scope_prefix.Config_dolor": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "2", + "policy_updated_to_ver": "3", + "updated_policy_id": "test_scope_prefix.Config_dolor" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_dolor.3.xml", + "policyVersion": "3", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_dolor" + }, + "test_scope_prefix.Config_ipsum": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "1", + "policy_updated_to_ver": "2", + "updated_policy_id": "test_scope_prefix.Config_ipsum" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_ipsum.2.xml", + "policyVersion": "2", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_ipsum" + }, + "test_scope_prefix.Config_sit": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "3", + "policy_updated_to_ver": "4", + "updated_policy_id": "test_scope_prefix.Config_sit" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_sit.4.xml", + "policyVersion": "4", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_sit" + } + }, + "policy_filter_matches": { + "test_scope_prefix.Config_Lorem": {}, + "test_scope_prefix.Config_amet": {}, + "test_scope_prefix.Config_ametist": {}, + "test_scope_prefix.Config_consectetur": {}, + "test_scope_prefix.Config_dolor": {}, + "test_scope_prefix.Config_ipsum": {}, + "test_scope_prefix.Config_sit": {} + }, + "removed_policies": {} + }, + "method": "put", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + } + ], + "tests/pdp_api_v0/test_policyhandler.py::WebServer2018Test::test_zzz_policy_updates_and_catch_ups": [ + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_.*" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": { + "catch_up": True, + "latest_policies": { + "test_scope_prefix.Config_Lorem": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "0", + "policy_updated_to_ver": "1", + "updated_policy_id": "test_scope_prefix.Config_Lorem" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_Lorem.1.xml", + "policyVersion": "1", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_Lorem" + }, + "test_scope_prefix.Config_amet": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "4", + "policy_updated_to_ver": "5", + "updated_policy_id": "test_scope_prefix.Config_amet" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_amet.5.xml", + "policyVersion": "5", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_amet" + }, + "test_scope_prefix.Config_ametist": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "6", + "policy_updated_to_ver": "7", + "updated_policy_id": "test_scope_prefix.Config_ametist" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_ametist.7.xml", + "policyVersion": "7", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_ametist" + }, + "test_scope_prefix.Config_consectetur": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "5", + "policy_updated_to_ver": "6", + "updated_policy_id": "test_scope_prefix.Config_consectetur" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_consectetur.6.xml", + "policyVersion": "6", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_consectetur" + }, + "test_scope_prefix.Config_dolor": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "2", + "policy_updated_to_ver": "3", + "updated_policy_id": "test_scope_prefix.Config_dolor" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_dolor.3.xml", + "policyVersion": "3", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_dolor" + }, + "test_scope_prefix.Config_ipsum": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "1", + "policy_updated_to_ver": "2", + "updated_policy_id": "test_scope_prefix.Config_ipsum" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_ipsum.2.xml", + "policyVersion": "2", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_ipsum" + }, + "test_scope_prefix.Config_sit": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "3", + "policy_updated_to_ver": "4", + "updated_policy_id": "test_scope_prefix.Config_sit" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_sit.4.xml", + "policyVersion": "4", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_sit" + } + }, + "policy_filter_matches": { + "test_scope_prefix.Config_Lorem": {}, + "test_scope_prefix.Config_amet": {}, + "test_scope_prefix.Config_ametist": {}, + "test_scope_prefix.Config_consectetur": {}, + "test_scope_prefix.Config_dolor": {}, + "test_scope_prefix.Config_ipsum": {}, + "test_scope_prefix.Config_sit": {} + }, + "removed_policies": {} + }, + "method": "put", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_ipsum" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_sit" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_consectetur" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": { + "catch_up": False, + "latest_policies": { + "test_scope_prefix.Config_consectetur": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "5", + "policy_updated_to_ver": "6", + "updated_policy_id": "test_scope_prefix.Config_consectetur" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_consectetur.6.xml", + "policyVersion": "6", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_consectetur" + }, + "test_scope_prefix.Config_ipsum": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "1", + "policy_updated_to_ver": "2", + "updated_policy_id": "test_scope_prefix.Config_ipsum" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_ipsum.2.xml", + "policyVersion": "2", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_ipsum" + }, + "test_scope_prefix.Config_sit": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "3", + "policy_updated_to_ver": "4", + "updated_policy_id": "test_scope_prefix.Config_sit" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_sit.4.xml", + "policyVersion": "4", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_sit" + } + }, + "policy_filter_matches": { + "test_scope_prefix.Config_consectetur": {}, + "test_scope_prefix.Config_ipsum": {}, + "test_scope_prefix.Config_sit": {} + }, + "removed_policies": {} + }, + "method": "put", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + } + ], + "tests/pdp_api_v0/test_policyhandler.py::WebServer2018Test::test_zzzzz_shutdown": [ + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_.*" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": { + "catch_up": True, + "latest_policies": { + "test_scope_prefix.Config_Lorem": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "0", + "policy_updated_to_ver": "1", + "updated_policy_id": "test_scope_prefix.Config_Lorem" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_Lorem.1.xml", + "policyVersion": "1", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_Lorem" + }, + "test_scope_prefix.Config_amet": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "4", + "policy_updated_to_ver": "5", + "updated_policy_id": "test_scope_prefix.Config_amet" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_amet.5.xml", + "policyVersion": "5", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_amet" + }, + "test_scope_prefix.Config_ametist": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "6", + "policy_updated_to_ver": "7", + "updated_policy_id": "test_scope_prefix.Config_ametist" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_ametist.7.xml", + "policyVersion": "7", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_ametist" + }, + "test_scope_prefix.Config_consectetur": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "5", + "policy_updated_to_ver": "6", + "updated_policy_id": "test_scope_prefix.Config_consectetur" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_consectetur.6.xml", + "policyVersion": "6", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_consectetur" + }, + "test_scope_prefix.Config_dolor": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "2", + "policy_updated_to_ver": "3", + "updated_policy_id": "test_scope_prefix.Config_dolor" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_dolor.3.xml", + "policyVersion": "3", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_dolor" + }, + "test_scope_prefix.Config_ipsum": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "1", + "policy_updated_to_ver": "2", + "updated_policy_id": "test_scope_prefix.Config_ipsum" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_ipsum.2.xml", + "policyVersion": "2", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_ipsum" + }, + "test_scope_prefix.Config_sit": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "3", + "policy_updated_to_ver": "4", + "updated_policy_id": "test_scope_prefix.Config_sit" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_sit.4.xml", + "policyVersion": "4", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_sit" + } + }, + "policy_filter_matches": { + "test_scope_prefix.Config_Lorem": {}, + "test_scope_prefix.Config_amet": {}, + "test_scope_prefix.Config_ametist": {}, + "test_scope_prefix.Config_consectetur": {}, + "test_scope_prefix.Config_dolor": {}, + "test_scope_prefix.Config_ipsum": {}, + "test_scope_prefix.Config_sit": {} + }, + "removed_policies": {} + }, + "method": "put", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_ipsum" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_sit" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_consectetur" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": { + "catch_up": False, + "latest_policies": { + "test_scope_prefix.Config_consectetur": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "5", + "policy_updated_to_ver": "6", + "updated_policy_id": "test_scope_prefix.Config_consectetur" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_consectetur.6.xml", + "policyVersion": "6", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_consectetur" + }, + "test_scope_prefix.Config_ipsum": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "1", + "policy_updated_to_ver": "2", + "updated_policy_id": "test_scope_prefix.Config_ipsum" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_ipsum.2.xml", + "policyVersion": "2", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_ipsum" + }, + "test_scope_prefix.Config_sit": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "3", + "policy_updated_to_ver": "4", + "updated_policy_id": "test_scope_prefix.Config_sit" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_sit.4.xml", + "policyVersion": "4", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_sit" + } + }, + "policy_filter_matches": { + "test_scope_prefix.Config_consectetur": {}, + "test_scope_prefix.Config_ipsum": {}, + "test_scope_prefix.Config_sit": {} + }, + "removed_policies": {} + }, + "method": "put", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + } + ], + "tests/pdp_api_v0/test_policyhandler.py::WebServer2018Test::test_zzz_catch_up_on_deploy_handler_changed": [ + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_.*" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": { + "catch_up": True, + "latest_policies": { + "test_scope_prefix.Config_Lorem": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "0", + "policy_updated_to_ver": "1", + "updated_policy_id": "test_scope_prefix.Config_Lorem" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_Lorem.1.xml", + "policyVersion": "1", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_Lorem" + }, + "test_scope_prefix.Config_amet": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "4", + "policy_updated_to_ver": "5", + "updated_policy_id": "test_scope_prefix.Config_amet" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_amet.5.xml", + "policyVersion": "5", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_amet" + }, + "test_scope_prefix.Config_ametist": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "6", + "policy_updated_to_ver": "7", + "updated_policy_id": "test_scope_prefix.Config_ametist" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_ametist.7.xml", + "policyVersion": "7", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_ametist" + }, + "test_scope_prefix.Config_consectetur": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "5", + "policy_updated_to_ver": "6", + "updated_policy_id": "test_scope_prefix.Config_consectetur" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_consectetur.6.xml", + "policyVersion": "6", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_consectetur" + }, + "test_scope_prefix.Config_dolor": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "2", + "policy_updated_to_ver": "3", + "updated_policy_id": "test_scope_prefix.Config_dolor" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_dolor.3.xml", + "policyVersion": "3", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_dolor" + }, + "test_scope_prefix.Config_ipsum": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "1", + "policy_updated_to_ver": "2", + "updated_policy_id": "test_scope_prefix.Config_ipsum" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_ipsum.2.xml", + "policyVersion": "2", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_ipsum" + }, + "test_scope_prefix.Config_sit": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "3", + "policy_updated_to_ver": "4", + "updated_policy_id": "test_scope_prefix.Config_sit" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_sit.4.xml", + "policyVersion": "4", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_sit" + } + }, + "policy_filter_matches": { + "test_scope_prefix.Config_Lorem": {}, + "test_scope_prefix.Config_amet": {}, + "test_scope_prefix.Config_ametist": {}, + "test_scope_prefix.Config_consectetur": {}, + "test_scope_prefix.Config_dolor": {}, + "test_scope_prefix.Config_ipsum": {}, + "test_scope_prefix.Config_sit": {} + }, + "removed_policies": {} + }, + "method": "put", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_ipsum" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": { + "catch_up": False, + "latest_policies": { + "test_scope_prefix.Config_ipsum": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "1", + "policy_updated_to_ver": "2", + "updated_policy_id": "test_scope_prefix.Config_ipsum" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_ipsum.2.xml", + "policyVersion": "2", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_ipsum" + } + }, + "policy_filter_matches": { + "test_scope_prefix.Config_ipsum": {} + }, + "removed_policies": {} + }, + "method": "put", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_dolor" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_amet" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": { + "catch_up": False, + "latest_policies": { + "test_scope_prefix.Config_amet": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "4", + "policy_updated_to_ver": "5", + "updated_policy_id": "test_scope_prefix.Config_amet" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_amet.5.xml", + "policyVersion": "5", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_amet" + }, + "test_scope_prefix.Config_dolor": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "2", + "policy_updated_to_ver": "3", + "updated_policy_id": "test_scope_prefix.Config_dolor" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_dolor.3.xml", + "policyVersion": "3", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_dolor" + } + }, + "policy_filter_matches": { + "test_scope_prefix.Config_amet": {}, + "test_scope_prefix.Config_dolor": {} + }, + "removed_policies": {} + }, + "method": "put", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_.*" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": { + "catch_up": True, + "latest_policies": { + "test_scope_prefix.Config_Lorem": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "0", + "policy_updated_to_ver": "1", + "updated_policy_id": "test_scope_prefix.Config_Lorem" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_Lorem.1.xml", + "policyVersion": "1", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_Lorem" + }, + "test_scope_prefix.Config_amet": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "4", + "policy_updated_to_ver": "5", + "updated_policy_id": "test_scope_prefix.Config_amet" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_amet.5.xml", + "policyVersion": "5", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_amet" + }, + "test_scope_prefix.Config_ametist": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "6", + "policy_updated_to_ver": "7", + "updated_policy_id": "test_scope_prefix.Config_ametist" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_ametist.7.xml", + "policyVersion": "7", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_ametist" + }, + "test_scope_prefix.Config_consectetur": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "5", + "policy_updated_to_ver": "6", + "updated_policy_id": "test_scope_prefix.Config_consectetur" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_consectetur.6.xml", + "policyVersion": "6", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_consectetur" + }, + "test_scope_prefix.Config_dolor": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "2", + "policy_updated_to_ver": "3", + "updated_policy_id": "test_scope_prefix.Config_dolor" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_dolor.3.xml", + "policyVersion": "3", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_dolor" + }, + "test_scope_prefix.Config_ipsum": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "1", + "policy_updated_to_ver": "2", + "updated_policy_id": "test_scope_prefix.Config_ipsum" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_ipsum.2.xml", + "policyVersion": "2", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_ipsum" + }, + "test_scope_prefix.Config_sit": { + "policy_body": { + "config": { + "policy_hello": "world!", + "policy_updated_from_ver": "3", + "policy_updated_to_ver": "4", + "updated_policy_id": "test_scope_prefix.Config_sit" + }, + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_sit.4.xml", + "policyVersion": "4", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_sit" + } + }, + "policy_filter_matches": { + "test_scope_prefix.Config_Lorem": {}, + "test_scope_prefix.Config_amet": {}, + "test_scope_prefix.Config_ametist": {}, + "test_scope_prefix.Config_consectetur": {}, + "test_scope_prefix.Config_dolor": {}, + "test_scope_prefix.Config_ipsum": {}, + "test_scope_prefix.Config_sit": {} + }, + "removed_policies": {} + }, + "method": "put", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + } + ], + "tests/pdp_api_v0/test_pz_catch_up.py::test_catch_up_failed_dh": [ + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_.*" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": { + "catch_up": True, + "latest_policies": { + "test_scope_prefix.Config_Lorem": { + "policy_body": { + "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_Lorem.1.xml", + "policyVersion": "1", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_Lorem" + }, + "test_scope_prefix.Config_amet": { + "policy_body": { + "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_amet.5.xml", + "policyVersion": "5", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_amet" + }, + "test_scope_prefix.Config_ametist": { + "policy_body": { + "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_ametist.7.xml", + "policyVersion": "7", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_ametist" + }, + "test_scope_prefix.Config_consectetur": { + "policy_body": { + "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_consectetur.6.xml", + "policyVersion": "6", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_consectetur" + }, + "test_scope_prefix.Config_dolor": { + "policy_body": { + "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_dolor.3.xml", + "policyVersion": "3", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_dolor" + }, + "test_scope_prefix.Config_ipsum": { + "policy_body": { + "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_ipsum.2.xml", + "policyVersion": "2", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_ipsum" + }, + "test_scope_prefix.Config_sit": { + "policy_body": { + "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_sit.4.xml", + "policyVersion": "4", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_sit" + } + }, + "policy_filter_matches": { + "test_scope_prefix.Config_Lorem": {}, + "test_scope_prefix.Config_amet": {}, + "test_scope_prefix.Config_ametist": {}, + "test_scope_prefix.Config_consectetur": {}, + "test_scope_prefix.Config_dolor": {}, + "test_scope_prefix.Config_ipsum": {}, + "test_scope_prefix.Config_sit": {} + }, + "removed_policies": {} + }, + "method": "put", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 413 + }, + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_.*" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": { + "catch_up": True, + "latest_policies": { + "test_scope_prefix.Config_Lorem": { + "policy_body": { + "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_Lorem.1.xml", + "policyVersion": "1", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_Lorem" + }, + "test_scope_prefix.Config_amet": { + "policy_body": { + "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_amet.5.xml", + "policyVersion": "5", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_amet" + }, + "test_scope_prefix.Config_ametist": { + "policy_body": { + "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_ametist.7.xml", + "policyVersion": "7", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_ametist" + }, + "test_scope_prefix.Config_consectetur": { + "policy_body": { + "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_consectetur.6.xml", + "policyVersion": "6", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_consectetur" + }, + "test_scope_prefix.Config_dolor": { + "policy_body": { + "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_dolor.3.xml", + "policyVersion": "3", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_dolor" + }, + "test_scope_prefix.Config_ipsum": { + "policy_body": { + "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_ipsum.2.xml", + "policyVersion": "2", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_ipsum" + }, + "test_scope_prefix.Config_sit": { + "policy_body": { + "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_sit.4.xml", + "policyVersion": "4", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_sit" + } + }, + "policy_filter_matches": { + "test_scope_prefix.Config_Lorem": {}, + "test_scope_prefix.Config_amet": {}, + "test_scope_prefix.Config_ametist": {}, + "test_scope_prefix.Config_consectetur": {}, + "test_scope_prefix.Config_dolor": {}, + "test_scope_prefix.Config_ipsum": {}, + "test_scope_prefix.Config_sit": {} + }, + "removed_policies": {} + }, + "method": "put", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 413 + }, + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_.*" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": { + "catch_up": True, + "latest_policies": { + "test_scope_prefix.Config_Lorem": { + "policy_body": { + "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_Lorem.1.xml", + "policyVersion": "1", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_Lorem" + }, + "test_scope_prefix.Config_amet": { + "policy_body": { + "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_amet.5.xml", + "policyVersion": "5", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_amet" + }, + "test_scope_prefix.Config_ametist": { + "policy_body": { + "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_ametist.7.xml", + "policyVersion": "7", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_ametist" + }, + "test_scope_prefix.Config_consectetur": { + "policy_body": { + "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_consectetur.6.xml", + "policyVersion": "6", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_consectetur" + }, + "test_scope_prefix.Config_dolor": { + "policy_body": { + "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_dolor.3.xml", + "policyVersion": "3", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_dolor" + }, + "test_scope_prefix.Config_ipsum": { + "policy_body": { + "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_ipsum.2.xml", + "policyVersion": "2", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_ipsum" + }, + "test_scope_prefix.Config_sit": { + "policy_body": { + "config": "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", + "matchingConditions": { + "ConfigName": "alex_config_name", + "ONAPName": "DCAE" + }, + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "policyName": "test_scope_prefix.Config_sit.4.xml", + "policyVersion": "4", + "property": None, + "responseAttributes": {}, + "type": "JSON" + }, + "policy_id": "test_scope_prefix.Config_sit" + } + }, + "policy_filter_matches": { + "test_scope_prefix.Config_Lorem": {}, + "test_scope_prefix.Config_amet": {}, + "test_scope_prefix.Config_ametist": {}, + "test_scope_prefix.Config_consectetur": {}, + "test_scope_prefix.Config_dolor": {}, + "test_scope_prefix.Config_ipsum": {}, + "test_scope_prefix.Config_sit": {} + }, + "removed_policies": {} + }, + "method": "put", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 413 + } + ], + "tests/pdp_api_v0/test_pz_catch_up.py::test_catch_up_dh_404": [ + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + } + ], + "tests/pdp_api_v0/test_pz_pdp_boom.py::WebServerPDPBoom2018Test::test_web_all_policies_latest": [ + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + } + ], + "tests/pdp_api_v0/test_pz_pdp_boom.py::WebServerPDPBoom2018Test::test_zzz_catch_up_on_deploy_handler_changed": [ + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + } + ], + "tests/pdp_api_v0/test_pz_pdp_boom.py::WebServerPDPBoom2018Test::test_zzz_get_catch_up": [ + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + } + ], + "tests/pdp_api_v0/test_pz_pdp_boom.py::WebServerPDPBoom2018Test::test_zzz_policy_updates_and_catch_ups": [ + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + } + ], + "tests/pdp_api_v0/test_pz_pdp_boom.py::WebServerPDPBoom2018Test::test_zzzzz_shutdown": [ + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + } + ], + "tests/pdp_api_v0/test_pz_ph_boom.py::WebServerInternalBoom2018Test::test_web_all_policies_latest": [ + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_.*" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + } + ], + "tests/pdp_api_v0/test_pz_ph_boom.py::WebServerInternalBoom2018Test::test_web_policies_latest": [ + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_amet.*" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + } + ], + "tests/pdp_api_v0/test_pz_ph_boom.py::WebServerInternalBoom2018Test::test_web_policy_latest": [ + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_sit" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + } + ], + "tests/pdp_api_v0/test_pz_ph_boom.py::WebServerInternalBoom2018Test::test_zzz_catch_up_on_deploy_handler_changed": [ + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_.*" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + } + ], + "tests/pdp_api_v0/test_pz_ph_boom.py::WebServerInternalBoom2018Test::test_zzz_get_catch_up": [ + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_.*" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_.*" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + } + ], + "tests/pdp_api_v0/test_pz_ph_boom.py::WebServerInternalBoom2018Test::test_zzz_policy_updates_and_catch_ups": [ + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_.*" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + } + ], + "tests/pdp_api_v0/test_pz_ph_boom.py::WebServerInternalBoom2018Test::test_zzzzz_shutdown": [ + { + "request": { + "headers": { + "X-ECOMP-RequestID": "*" + }, + "json": None, + "method": "get", + "params": { + "cfy_tenant_name": "default_tenant" + }, + "uri": "http://unit-test-deployment_handler:8188000/policy" + }, + "res": "*", + "status_code": 200 + }, + { + "request": { + "headers": { + "Accept": "application/json", + "Authorization": "Basic auth", + "ClientAuth": "Basic user", + "Content-Type": "application/json", + "Environment": "TEST", + "X-ECOMP-RequestID": "*" + }, + "json": { + "policyName": "test_scope_prefix.Config_.*" + }, + "method": "post", + "params": None, + "uri": "https://unit-test-pdp-server:8081000/pdp/api/getConfig" + }, + "res": "*", + "status_code": 200 + } + ] +} diff --git a/tests/pdp_api_v0/mock_policy_engine.py b/tests/pdp_api_v0/mock_policy_engine.py new file mode 100644 index 0000000..cdded14 --- /dev/null +++ b/tests/pdp_api_v0/mock_policy_engine.py @@ -0,0 +1,130 @@ +# ============LICENSE_START======================================================= +# Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +"""mocking for the policy-engine - shared by many tests""" + +import copy +import json +import re + +from policyhandler.pdp_api_v0.pdp_consts import (POLICY_CONFIG, POLICY_NAME, + POLICY_VERSION) +from policyhandler.pdp_api_v0.policy_utils import PolicyUtils +from policyhandler.policy_consts import POLICY_BODY, POLICY_ID +from policyhandler.utils import Utils + +_LOGGER = Utils.get_logger(__file__) + + +class MockPolicyEngine2018(object): + """pretend this is the policy-engine""" + scope_prefix = "test_scope_prefix.Config_" + LOREM_IPSUM = """Lorem ipsum dolor sit amet consectetur ametist""".split() + LONG_TEXT = "0123456789" * 100 + _policies = [] + + _inited = False + + @staticmethod + def init(): + """init collection of policies: policy_version = policy_index + 1""" + if MockPolicyEngine2018._inited: + return + MockPolicyEngine2018._inited = True + + MockPolicyEngine2018._policies = [ + MockPolicyEngine2018._create_policy_body( + MockPolicyEngine2018.scope_prefix + policy_id, policy_index + 1) + for policy_id in MockPolicyEngine2018.LOREM_IPSUM + for policy_index in range(1 + MockPolicyEngine2018.LOREM_IPSUM.index(policy_id))] + _LOGGER.info("_policies: %s", json.dumps(MockPolicyEngine2018._policies)) + + @staticmethod + def get_config(policy_name): + """find policy the way the policy-engine finds""" + if not policy_name: + return [] + return [copy.deepcopy(policy) + for policy in MockPolicyEngine2018._policies + if re.match(policy_name, policy[POLICY_NAME])] + + @staticmethod + def get_configs_all(): + """get all policies the way the policy-engine finds""" + policies = [copy.deepcopy(policy) + for policy in MockPolicyEngine2018._policies] + for policy in policies: + policy["config"] = MockPolicyEngine2018.LONG_TEXT + return policies + + @staticmethod + def get_policy_id(policy_index): + """get the policy_id by policy_index""" + return (MockPolicyEngine2018.scope_prefix + + MockPolicyEngine2018.LOREM_IPSUM[ + policy_index % len(MockPolicyEngine2018.LOREM_IPSUM)]) + + @staticmethod + def gen_policy_latest(policy_index, version_offset=0): + """generate the policy response from policy-handler by policy_index = version - 1""" + policy_id = MockPolicyEngine2018.get_policy_id(policy_index) + policy = { + POLICY_ID: policy_id, + POLICY_BODY: MockPolicyEngine2018._create_policy_body( + policy_id, policy_index + 1 - version_offset) + } + return policy_id, PolicyUtils.parse_policy_config(policy) + + @staticmethod + def gen_all_policies_latest(version_offset=0): + """generate all latest policies""" + return dict( + MockPolicyEngine2018.gen_policy_latest(policy_index, version_offset=version_offset) + for policy_index in range(len(MockPolicyEngine2018.LOREM_IPSUM)) + ) + + @staticmethod + def gen_policies_latest(match_to_policy_name): + """generate all latest policies""" + return dict((k, v) + for k, v in MockPolicyEngine2018.gen_all_policies_latest().items() + if re.match(match_to_policy_name, k)) + + @staticmethod + def _create_policy_body(policy_id, policy_version=1): + """returns a fake policy-body""" + prev_ver = str(policy_version - 1) + this_ver = str(policy_version) + config = { + "policy_updated_from_ver": prev_ver, + "policy_updated_to_ver": this_ver, + "policy_hello": "world!", + "updated_policy_id": policy_id + } + return { + "policyConfigMessage": "Config Retrieved! ", + "policyConfigStatus": "CONFIG_RETRIEVED", + "type": "JSON", + POLICY_NAME: "{0}.{1}.xml".format(policy_id, this_ver), + POLICY_VERSION: this_ver, + POLICY_CONFIG: json.dumps(config, sort_keys=True), + "matchingConditions": { + "ONAPName": "DCAE", + "ConfigName": "alex_config_name" + }, + "responseAttributes": {}, + "property": None + } diff --git a/tests/pdp_api_v0/mock_websocket.py b/tests/pdp_api_v0/mock_websocket.py new file mode 100644 index 0000000..17f3bbe --- /dev/null +++ b/tests/pdp_api_v0/mock_websocket.py @@ -0,0 +1,90 @@ +# ============LICENSE_START======================================================= +# Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +"""mocking for the websocket - for testing of policy-engine""" + +import json +import time + +from policyhandler.pdp_api_v0.pdp_consts import POLICY_NAME +from policyhandler.pdp_api_v0.policy_listener import (LOADED_POLICIES, + POLICY_VER, + REMOVED_POLICIES) +from policyhandler.utils import Utils + +from .mock_policy_engine import MockPolicyEngine2018 + +_LOGGER = Utils.get_logger(__file__) + +class MockWebSocket(object): + """Mock websocket""" + on_message = None + + @staticmethod + def send_notification(updated_indexes): + """fake notification through the web-socket""" + if not MockWebSocket.on_message: + return + message = { + LOADED_POLICIES: [ + {POLICY_NAME: "{0}.{1}.xml".format( + MockPolicyEngine2018.get_policy_id(policy_index), policy_index + 1), + POLICY_VER: str(policy_index + 1)} + for policy_index in updated_indexes or [] + ], + REMOVED_POLICIES : [] + } + message = json.dumps(message) + _LOGGER.info("send_notification: %s", message) + MockWebSocket.on_message(None, message) + + @staticmethod + def enableTrace(yes_no): + """ignore""" + pass + + class MockSocket(object): + """Mock websocket""" + def __init__(self): + self.connected = True + + class WebSocketApp(object): + """Mocked WebSocketApp""" + def __init__(self, web_socket_url, + on_open=None, on_message=None, on_close=None, on_error=None, on_pong=None): + self.web_socket_url = web_socket_url + self.on_open = on_open + self.on_message = MockWebSocket.on_message = on_message + self.on_close = on_close + self.on_error = on_error + self.on_pong = on_pong + self.sock = MockWebSocket.MockSocket() + _LOGGER.info("MockWebSocket for: %s", self.web_socket_url) + + def run_forever(self, sslopt=None, ping_interval=None): + """forever in the loop""" + _LOGGER.info("MockWebSocket run_forever with sslopt=%s, ping_interval=%s...", + json.dumps(sslopt), ping_interval) + counter = 0 + while self.sock.connected: + counter += 1 + _LOGGER.info("MockWebSocket sleep %s...", counter) + time.sleep(5) + _LOGGER.info("MockWebSocket exit %s", counter) + + def close(self): + """close socket""" + self.sock.connected = False diff --git a/tests/pdp_api_v0/test_policy_rest.py b/tests/pdp_api_v0/test_policy_rest.py new file mode 100644 index 0000000..67b06ae --- /dev/null +++ b/tests/pdp_api_v0/test_policy_rest.py @@ -0,0 +1,47 @@ +# ============LICENSE_START======================================================= +# Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +"""test policy_rest methods directly""" + +import json + +import pytest + +from policyhandler import pdp_client +from policyhandler.onap.audit import Audit +from policyhandler.utils import Utils + +from ..mock_tracker import Tracker +from .mock_policy_engine import MockPolicyEngine2018 + +_LOGGER = Utils.get_logger(__file__) + +@pytest.mark.usefixtures("fix_pdp_api_v0", "fix_pdp_post") +def test_get_policy_latest(): + """test /policy_latest/""" + policy_id, expected_policy = MockPolicyEngine2018.gen_policy_latest(3) + + audit = Audit(job_name="test_get_policy_latest", + req_message="get /policy_latest/{}".format(policy_id or "")) + + policy_latest = pdp_client.PolicyRest.get_latest_policy((audit, policy_id, None, None)) or {} + audit.audit_done(result=json.dumps(policy_latest)) + + _LOGGER.info("expected_policy: %s", json.dumps(expected_policy)) + _LOGGER.info("policy_latest: %s", json.dumps(policy_latest)) + assert Utils.are_the_same(policy_latest, expected_policy) + + Tracker.validate() diff --git a/tests/pdp_api_v0/test_policyhandler.py b/tests/pdp_api_v0/test_policyhandler.py new file mode 100644 index 0000000..2b2629b --- /dev/null +++ b/tests/pdp_api_v0/test_policyhandler.py @@ -0,0 +1,280 @@ +# ============LICENSE_START======================================================= +# Copyright (c) 2017-2019 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# + +"""test of the package for policy-handler of DCAE-Controller""" + +import json +import time +import uuid + +import cherrypy +import pytest +from cherrypy.test.helper import CPWebCase + +from policyhandler.config import Config +from policyhandler.onap.audit import REQUEST_X_ECOMP_REQUESTID, Audit +from policyhandler.pdp_api_v0.pdp_consts import POLICY_NAME +from policyhandler.policy_consts import LATEST_POLICIES +from policyhandler.policy_receiver import PolicyReceiver +from policyhandler.utils import Utils +from policyhandler.web_server import _PolicyWeb + +from ..mock_settings import MockSettings +from ..mock_tracker import Tracker +from .mock_policy_engine import MockPolicyEngine2018 +from .mock_websocket import MockWebSocket + +_LOGGER = Utils.get_logger(__file__) + +@pytest.mark.usefixtures( + "fix_pdp_api_v0", + "fix_pdp_post", + "fix_discovery" +) +class WebServer2018Test(CPWebCase): + """testing the web-server - runs tests in alphabetical order of method names""" + def setup_server(): + """setup the web-server""" + cherrypy.tree.mount(_PolicyWeb(), '/') + + setup_server = staticmethod(setup_server) + + def test_web_healthcheck(self): + """test /healthcheck""" + result = self.getPage("/healthcheck") + _LOGGER.info("healthcheck result: %s", result) + _LOGGER.info("got healthcheck: %s", self.body) + self.assertStatus('200 OK') + + Tracker.validate() + + def test_web_policy_latest(self): + """test /policy_latest/""" + policy_id, expected_policy = MockPolicyEngine2018.gen_policy_latest(3) + + self.getPage("/policy_latest/{0}".format(policy_id or "")) + self.assertStatus('200 OK') + + policy_latest = json.loads(self.body) + + _LOGGER.info("policy_latest: %s", self.body) + _LOGGER.info("expected_policy: %s", json.dumps(expected_policy)) + assert Utils.are_the_same(policy_latest, expected_policy) + + result = self.getPage("/healthcheck") + _LOGGER.info("healthcheck result: %s", result) + + Tracker.validate() + + @pytest.mark.usefixtures("fix_deploy_handler") + def test_web_all_policies_latest(self): + """test GET /policies_latest""" + expected_policies = MockPolicyEngine2018.gen_all_policies_latest() + + result = self.getPage("/policies_latest") + _LOGGER.info("result: %s", result) + _LOGGER.info("body: %s", self.body) + + if Config.is_pdp_api_default(): + self.assertStatus('404 Not Found') + return + + self.assertStatus('200 OK') + + policies_latest = json.loads(self.body) + self.assertIn(LATEST_POLICIES, policies_latest) + policies_latest = policies_latest[LATEST_POLICIES] + + _LOGGER.info("policies_latest: %s", json.dumps(policies_latest)) + _LOGGER.info("expected_policies: %s", json.dumps(expected_policies)) + assert Utils.are_the_same(policies_latest, expected_policies) + + result = self.getPage("/healthcheck") + _LOGGER.info("healthcheck result: %s", result) + + Tracker.validate() + + def test_web_policies_latest(self): + """test POST /policies_latest with policyName""" + match_to_policy_name = MockPolicyEngine2018.scope_prefix + "amet.*" + expected_policies = MockPolicyEngine2018.gen_policies_latest(match_to_policy_name) + + body = json.dumps({POLICY_NAME: match_to_policy_name}) + result = self.getPage("/policies_latest", method='POST', + body=body, + headers=[ + (REQUEST_X_ECOMP_REQUESTID, str(uuid.uuid4())), + ("Content-Type", "application/json"), + ('Content-Length', str(len(body))) + ]) + _LOGGER.info("result: %s", result) + _LOGGER.info("body: %s", self.body) + + if Config.is_pdp_api_default(): + self.assertStatus('404 Not Found') + return + + self.assertStatus('200 OK') + + policies_latest = json.loads(self.body)[LATEST_POLICIES] + + _LOGGER.info("policies_latest: %s", json.dumps(policies_latest)) + _LOGGER.info("expected_policies: %s", json.dumps(expected_policies)) + assert Utils.are_the_same(policies_latest, expected_policies) + + result = self.getPage("/healthcheck") + _LOGGER.info("healthcheck result: %s", result) + + Tracker.validate() + + @pytest.mark.usefixtures("fix_deploy_handler", "fix_policy_receiver_websocket") + def test_zzz_policy_updates_and_catch_ups(self): + """test run policy handler with policy updates and catchups""" + if Config.is_pdp_api_default(): + _LOGGER.info("passive for new PDP API") + return + + _LOGGER.info("start policy_updates_and_catch_ups") + assert not PolicyReceiver.is_running() + + audit = Audit(job_name="test_zzz_policy_updates_and_catch_ups", + req_message="start policy_updates_and_catch_ups") + PolicyReceiver.run(audit) + + _LOGGER.info("sleep before send_notification...") + time.sleep(2) + + MockWebSocket.send_notification([1, 3, 5]) + _LOGGER.info("sleep after send_notification...") + time.sleep(3) + + _LOGGER.info("sleep 10 before shutdown...") + time.sleep(10) + + result = self.getPage("/healthcheck") + _LOGGER.info("healthcheck result: %s", result) + + PolicyReceiver.shutdown(audit) + time.sleep(1) + assert not PolicyReceiver.is_running() + + Tracker.validate() + + @pytest.mark.usefixtures("fix_deploy_handler", "fix_policy_receiver_websocket") + def test_zzz_catch_up_on_deploy_handler_changed(self): + """test run policy handler with deployment-handler changed underneath""" + if Config.is_pdp_api_default(): + _LOGGER.info("passive for new PDP API") + return + + _LOGGER.info("start zzz_catch_up_on_deploy_handler_changed") + assert not PolicyReceiver.is_running() + audit = Audit(job_name="test_zzz_catch_up_on_deploy_handler_changed", + req_message="start zzz_catch_up_on_deploy_handler_changed") + PolicyReceiver.run(audit) + + _LOGGER.info("sleep before send_notification...") + time.sleep(2) + + MockWebSocket.send_notification([1]) + _LOGGER.info("sleep after send_notification...") + time.sleep(3) + + MockSettings.deploy_handler_instance_uuid = str(uuid.uuid4()) + _LOGGER.info("new deploy-handler uuid=%s", MockSettings.deploy_handler_instance_uuid) + + MockWebSocket.send_notification([2, 4]) + _LOGGER.info("sleep after send_notification...") + time.sleep(3) + + _LOGGER.info("sleep 5 before shutdown...") + time.sleep(5) + + result = self.getPage("/healthcheck") + _LOGGER.info("healthcheck result: %s", result) + + PolicyReceiver.shutdown(audit) + time.sleep(1) + assert not PolicyReceiver.is_running() + + Tracker.validate() + + @pytest.mark.usefixtures("fix_deploy_handler", "fix_policy_receiver_websocket") + def test_zzz_get_catch_up(self): + """test /catch_up""" + if Config.is_pdp_api_default(): + _LOGGER.info("passive for new PDP API") + return + + _LOGGER.info("start /catch_up") + assert not PolicyReceiver.is_running() + audit = Audit(job_name="test_zzz_get_catch_up", req_message="start /catch_up") + PolicyReceiver.run(audit) + time.sleep(5) + result = self.getPage("/catch_up") + _LOGGER.info("catch_up result: %s", result) + self.assertStatus('200 OK') + _LOGGER.info("got catch_up: %s", self.body) + + _LOGGER.info("sleep 5 before shutdown...") + time.sleep(5) + + result = self.getPage("/healthcheck") + _LOGGER.info("healthcheck result: %s", result) + + PolicyReceiver.shutdown(audit) + time.sleep(1) + assert not PolicyReceiver.is_running() + + Tracker.validate() + + @pytest.mark.usefixtures( + "fix_deploy_handler", + "fix_policy_receiver_websocket", + "fix_cherrypy_engine_exit") + def test_zzzzz_shutdown(self): + """test shutdown""" + _LOGGER.info("start shutdown") + assert not PolicyReceiver.is_running() + audit = Audit(job_name="test_zzzzz_shutdown", req_message="start shutdown") + PolicyReceiver.run(audit) + + _LOGGER.info("sleep before send_notification...") + time.sleep(2) + + MockWebSocket.send_notification([1, 3, 5]) + _LOGGER.info("sleep after send_notification...") + time.sleep(3) + + result = self.getPage("/healthcheck") + _LOGGER.info("healthcheck result: %s", result) + + WebServer2018Test.do_gc_test = False + _LOGGER.info("shutdown...") + audit.audit_done("shutdown") + result = self.getPage("/shutdown") + _LOGGER.info("shutdown result: %s", result) + self.assertStatus('200 OK') + _LOGGER.info("got shutdown: %s", self.body) + time.sleep(1) + assert not PolicyReceiver.is_running() + + if Config.is_pdp_api_default(): + _LOGGER.info("passive for new PDP API") + return + + Tracker.validate() diff --git a/tests/pdp_api_v0/test_pz_catch_up.py b/tests/pdp_api_v0/test_pz_catch_up.py new file mode 100644 index 0000000..3b37af5 --- /dev/null +++ b/tests/pdp_api_v0/test_pz_catch_up.py @@ -0,0 +1,107 @@ +# ============LICENSE_START======================================================= +# Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +"""test policy catch_up methods directly""" + +import json +import time + +import pytest + +from policyhandler.config import Config +from policyhandler.onap.audit import Audit +from policyhandler.policy_receiver import PolicyReceiver +from policyhandler.utils import Utils + +from ..mock_tracker import Tracker + +_LOGGER = Utils.get_logger(__file__) + +@pytest.mark.usefixtures( + "fix_pdp_api_v0", + "fix_auto_catch_up", + "fix_discovery", + "fix_pdp_post_big", + "fix_deploy_handler_413", + "fix_policy_receiver_websocket" +) +def test_catch_up_failed_dh(): + """test run policy handler with catchups and failed deployment-handler""" + if Config.is_pdp_api_default(): + _LOGGER.info("passive for new PDP API") + return + + _LOGGER.info("start test_catch_up_failed_dh") + assert not PolicyReceiver.is_running() + audit = Audit(job_name="test_catch_up_failed_dh", + req_message="start test_catch_up_failed_dh") + PolicyReceiver.run(audit) + + _LOGGER.info("sleep 12 before shutdown...") + time.sleep(12) + + health = audit.health(full=True) + audit.audit_done(result=json.dumps(health)) + + _LOGGER.info("healthcheck: %s", json.dumps(health)) + assert bool(health) + + PolicyReceiver.shutdown(audit) + time.sleep(1) + assert not PolicyReceiver.is_running() + + health = audit.health(full=True) + _LOGGER.info("healthcheck: %s", json.dumps(health)) + + Tracker.validate() + +@pytest.mark.usefixtures( + "fix_pdp_api_v0", + "fix_auto_catch_up", + "fix_discovery", + "fix_pdp_post", + "fix_deploy_handler_404", + "fix_policy_receiver_websocket" +) +def test_catch_up_dh_404(): + """test run policy handler with catchups and failed deployment-handler""" + if Config.is_pdp_api_default(): + _LOGGER.info("passive for new PDP API") + return + + _LOGGER.info("start test_catch_up_dh_404") + assert not PolicyReceiver.is_running() + audit = Audit(job_name="test_catch_up_dh_404", + req_message="start test_catch_up_dh_404") + PolicyReceiver.run(audit) + + _LOGGER.info("sleep 12 before shutdown...") + time.sleep(12) + + health = audit.health(full=True) + audit.audit_done(result=json.dumps(health)) + + _LOGGER.info("healthcheck: %s", json.dumps(health)) + assert bool(health) + + PolicyReceiver.shutdown(audit) + time.sleep(1) + assert not PolicyReceiver.is_running() + + health = audit.health(full=True) + _LOGGER.info("healthcheck: %s", json.dumps(health)) + + Tracker.validate() diff --git a/tests/pdp_api_v0/test_pz_pdp_boom.py b/tests/pdp_api_v0/test_pz_pdp_boom.py new file mode 100644 index 0000000..effadc2 --- /dev/null +++ b/tests/pdp_api_v0/test_pz_pdp_boom.py @@ -0,0 +1,255 @@ +# ============LICENSE_START======================================================= +# Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +"""test policyhandler web-server when pdp booms = fails""" + +import json +import time +import uuid + +import cherrypy +import pytest +from cherrypy.test.helper import CPWebCase + +from policyhandler.config import Config +from policyhandler.onap.audit import (REQUEST_X_ECOMP_REQUESTID, Audit, + AuditHttpCode) +from policyhandler.pdp_api_v0.pdp_consts import POLICY_NAME +from policyhandler.policy_receiver import PolicyReceiver +from policyhandler.utils import Utils +from policyhandler.web_server import _PolicyWeb + +from ..mock_settings import MockSettings +from ..mock_tracker import Tracker +from .mock_policy_engine import MockPolicyEngine2018 +from .mock_websocket import MockWebSocket + +_LOGGER = Utils.get_logger(__file__) + +@pytest.mark.usefixtures( + "fix_pdp_api_v0", + "fix_discovery", + "fix_pdp_post_boom" +) +class WebServerPDPBoom2018Test(CPWebCase): + """testing the web-server - runs tests in alphabetical order of method names""" + def setup_server(): + """setup the web-server""" + cherrypy.tree.mount(_PolicyWeb(), '/') + + setup_server = staticmethod(setup_server) + + def test_web_healthcheck(self): + """test /healthcheck""" + result = self.getPage("/healthcheck") + _LOGGER.info("healthcheck result: %s", result) + _LOGGER.info("got healthcheck: %s", self.body) + self.assertStatus('200 OK') + + Tracker.validate() + + def test_web_policy_latest(self): + """test /policy_latest/""" + policy_id, _ = MockPolicyEngine2018.gen_policy_latest(3) + + self.getPage("/policy_latest/{0}".format(policy_id or "")) + self.assertStatus(AuditHttpCode.SERVER_INTERNAL_ERROR.value) + + result = self.getPage("/healthcheck") + _LOGGER.info("healthcheck result: %s", result) + + Tracker.validate() + + @pytest.mark.usefixtures("fix_deploy_handler") + def test_web_all_policies_latest(self): + """test GET /policies_latest""" + result = self.getPage("/policies_latest") + _LOGGER.info("result: %s", result) + _LOGGER.info("body: %s", self.body) + + if Config.is_pdp_api_default(): + self.assertStatus('404 Not Found') + return + + self.assertStatus(AuditHttpCode.SERVER_INTERNAL_ERROR.value) + + result = self.getPage("/healthcheck") + _LOGGER.info("healthcheck result: %s", result) + + Tracker.validate() + + def test_web_policies_latest(self): + """test POST /policies_latest with policyName""" + match_to_policy_name = MockPolicyEngine2018.scope_prefix + "amet.*" + + body = json.dumps({POLICY_NAME: match_to_policy_name}) + result = self.getPage("/policies_latest", method='POST', + body=body, + headers=[ + (REQUEST_X_ECOMP_REQUESTID, str(uuid.uuid4())), + ("Content-Type", "application/json"), + ('Content-Length', str(len(body))) + ]) + _LOGGER.info("result: %s", result) + _LOGGER.info("body: %s", self.body) + + if Config.is_pdp_api_default(): + self.assertStatus('404 Not Found') + return + + self.assertStatus(AuditHttpCode.SERVER_INTERNAL_ERROR.value) + + result = self.getPage("/healthcheck") + _LOGGER.info("healthcheck result: %s", result) + + Tracker.validate() + + @pytest.mark.usefixtures("fix_deploy_handler", "fix_policy_receiver_websocket") + def test_zzz_policy_updates_and_catch_ups(self): + """test run policy handler with policy updates and catchups""" + if Config.is_pdp_api_default(): + _LOGGER.info("passive for new PDP API") + return + + _LOGGER.info("start policy_updates_and_catch_ups") + assert not PolicyReceiver.is_running() + audit = Audit(job_name="test_zzz_policy_updates_and_catch_ups", + req_message="start policy_updates_and_catch_ups") + PolicyReceiver.run(audit) + + _LOGGER.info("sleep before send_notification...") + time.sleep(2) + + MockWebSocket.send_notification([1, 3, 5]) + _LOGGER.info("sleep after send_notification...") + time.sleep(3) + + _LOGGER.info("sleep 10 before shutdown...") + time.sleep(10) + + result = self.getPage("/healthcheck") + _LOGGER.info("healthcheck result: %s", result) + + PolicyReceiver.shutdown(audit) + time.sleep(1) + assert not PolicyReceiver.is_running() + + Tracker.validate() + + @pytest.mark.usefixtures("fix_deploy_handler", "fix_policy_receiver_websocket") + def test_zzz_catch_up_on_deploy_handler_changed(self): + """test run policy handler with deployment-handler changed underneath""" + if Config.is_pdp_api_default(): + _LOGGER.info("passive for new PDP API") + return + + _LOGGER.info("start zzz_catch_up_on_deploy_handler_changed") + assert not PolicyReceiver.is_running() + audit = Audit(job_name="test_zzz_catch_up_on_deploy_handler_changed", + req_message="start zzz_catch_up_on_deploy_handler_changed") + PolicyReceiver.run(audit) + + _LOGGER.info("sleep before send_notification...") + time.sleep(2) + + MockWebSocket.send_notification([1]) + _LOGGER.info("sleep after send_notification...") + time.sleep(3) + + MockSettings.deploy_handler_instance_uuid = str(uuid.uuid4()) + _LOGGER.info("new deploy-handler uuid=%s", MockSettings.deploy_handler_instance_uuid) + + MockWebSocket.send_notification([2, 4]) + _LOGGER.info("sleep after send_notification...") + time.sleep(3) + + _LOGGER.info("sleep 5 before shutdown...") + time.sleep(5) + + result = self.getPage("/healthcheck") + _LOGGER.info("healthcheck result: %s", result) + + PolicyReceiver.shutdown(audit) + time.sleep(1) + assert not PolicyReceiver.is_running() + + Tracker.validate() + + @pytest.mark.usefixtures("fix_deploy_handler", "fix_policy_receiver_websocket") + def test_zzz_get_catch_up(self): + """test /catch_up""" + if Config.is_pdp_api_default(): + _LOGGER.info("passive for new PDP API") + return + + _LOGGER.info("start /catch_up") + assert not PolicyReceiver.is_running() + audit = Audit(job_name="test_zzz_get_catch_up", req_message="start /catch_up") + PolicyReceiver.run(audit) + time.sleep(5) + result = self.getPage("/catch_up") + _LOGGER.info("catch_up result: %s", result) + self.assertStatus('200 OK') + _LOGGER.info("got catch_up: %s", self.body) + + _LOGGER.info("sleep 5 before shutdown...") + time.sleep(5) + + result = self.getPage("/healthcheck") + _LOGGER.info("healthcheck result: %s", result) + + PolicyReceiver.shutdown(audit) + time.sleep(1) + assert not PolicyReceiver.is_running() + + Tracker.validate() + + @pytest.mark.usefixtures( + "fix_deploy_handler", + "fix_policy_receiver_websocket", + "fix_cherrypy_engine_exit") + def test_zzzzz_shutdown(self): + """test shutdown""" + _LOGGER.info("start shutdown") + assert not PolicyReceiver.is_running() + audit = Audit(job_name="test_zzzzz_shutdown", req_message="start shutdown") + PolicyReceiver.run(audit) + + _LOGGER.info("sleep before send_notification...") + time.sleep(2) + + MockWebSocket.send_notification([1, 3, 5]) + _LOGGER.info("sleep after send_notification...") + time.sleep(3) + + result = self.getPage("/healthcheck") + _LOGGER.info("healthcheck result: %s", result) + + WebServerPDPBoom2018Test.do_gc_test = False + _LOGGER.info("shutdown...") + audit.audit_done("shutdown") + result = self.getPage("/shutdown") + _LOGGER.info("shutdown result: %s", result) + self.assertStatus('200 OK') + _LOGGER.info("got shutdown: %s", self.body) + time.sleep(1) + assert not PolicyReceiver.is_running() + + if Config.is_pdp_api_default(): + _LOGGER.info("passive for new PDP API") + return + + Tracker.validate() diff --git a/tests/pdp_api_v0/test_pz_ph_boom.py b/tests/pdp_api_v0/test_pz_ph_boom.py new file mode 100644 index 0000000..4203110 --- /dev/null +++ b/tests/pdp_api_v0/test_pz_ph_boom.py @@ -0,0 +1,256 @@ +# ============LICENSE_START======================================================= +# Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +"""test policyhandler web-server when the policy-handler booms = fails""" + +import json +import time +import uuid + +import cherrypy +import pytest +from cherrypy.test.helper import CPWebCase + +from policyhandler.config import Config +from policyhandler.onap.audit import (REQUEST_X_ECOMP_REQUESTID, Audit, + AuditHttpCode) +from policyhandler.pdp_api_v0.pdp_consts import POLICY_NAME +from policyhandler.policy_receiver import PolicyReceiver +from policyhandler.utils import Utils +from policyhandler.web_server import _PolicyWeb + +from ..mock_settings import MockSettings +from ..mock_tracker import Tracker +from .mock_policy_engine import MockPolicyEngine2018 +from .mock_websocket import MockWebSocket + +_LOGGER = Utils.get_logger(__file__) + +@pytest.mark.usefixtures( + "fix_pdp_api_v0", + "fix_discovery", + "fix_pdp_post", + "fix_select_latest_policies_boom" +) +class WebServerInternalBoom2018Test(CPWebCase): + """testing the web-server - runs tests in alphabetical order of method names""" + def setup_server(): + """setup the web-server""" + cherrypy.tree.mount(_PolicyWeb(), '/') + + setup_server = staticmethod(setup_server) + + def test_web_healthcheck(self): + """test /healthcheck""" + result = self.getPage("/healthcheck") + _LOGGER.info("healthcheck result: %s", result) + _LOGGER.info("got healthcheck: %s", self.body) + self.assertStatus('200 OK') + + Tracker.validate() + + def test_web_policy_latest(self): + """test /policy_latest/""" + policy_id, _ = MockPolicyEngine2018.gen_policy_latest(3) + + self.getPage("/policy_latest/{0}".format(policy_id or "")) + self.assertStatus(AuditHttpCode.SERVER_INTERNAL_ERROR.value) + + result = self.getPage("/healthcheck") + _LOGGER.info("healthcheck result: %s", result) + + Tracker.validate() + + @pytest.mark.usefixtures("fix_deploy_handler") + def test_web_all_policies_latest(self): + """test GET /policies_latest""" + result = self.getPage("/policies_latest") + _LOGGER.info("result: %s", result) + _LOGGER.info("body: %s", self.body) + + if Config.is_pdp_api_default(): + self.assertStatus('404 Not Found') + return + + self.assertStatus(AuditHttpCode.SERVER_INTERNAL_ERROR.value) + + result = self.getPage("/healthcheck") + _LOGGER.info("healthcheck result: %s", result) + + Tracker.validate() + + def test_web_policies_latest(self): + """test POST /policies_latest with policyName""" + match_to_policy_name = MockPolicyEngine2018.scope_prefix + "amet.*" + + body = json.dumps({POLICY_NAME: match_to_policy_name}) + result = self.getPage("/policies_latest", method='POST', + body=body, + headers=[ + (REQUEST_X_ECOMP_REQUESTID, str(uuid.uuid4())), + ("Content-Type", "application/json"), + ('Content-Length', str(len(body))) + ]) + _LOGGER.info("result: %s", result) + _LOGGER.info("body: %s", self.body) + + if Config.is_pdp_api_default(): + self.assertStatus('404 Not Found') + return + + self.assertStatus(AuditHttpCode.SERVER_INTERNAL_ERROR.value) + + result = self.getPage("/healthcheck") + _LOGGER.info("healthcheck result: %s", result) + + Tracker.validate() + + @pytest.mark.usefixtures("fix_deploy_handler", "fix_policy_receiver_websocket") + def test_zzz_policy_updates_and_catch_ups(self): + """test run policy handler with policy updates and catchups""" + if Config.is_pdp_api_default(): + _LOGGER.info("passive for new PDP API") + return + + _LOGGER.info("start policy_updates_and_catch_ups") + assert not PolicyReceiver.is_running() + audit = Audit(job_name="test_zzz_policy_updates_and_catch_ups", + req_message="start policy_updates_and_catch_ups") + PolicyReceiver.run(audit) + + _LOGGER.info("sleep before send_notification...") + time.sleep(2) + + MockWebSocket.send_notification([1, 3, 5]) + _LOGGER.info("sleep after send_notification...") + time.sleep(3) + + _LOGGER.info("sleep 10 before shutdown...") + time.sleep(10) + + result = self.getPage("/healthcheck") + _LOGGER.info("healthcheck result: %s", result) + + PolicyReceiver.shutdown(audit) + time.sleep(1) + assert not PolicyReceiver.is_running() + + Tracker.validate() + + @pytest.mark.usefixtures("fix_deploy_handler", "fix_policy_receiver_websocket") + def test_zzz_catch_up_on_deploy_handler_changed(self): + """test run policy handler with deployment-handler changed underneath""" + if Config.is_pdp_api_default(): + _LOGGER.info("passive for new PDP API") + return + + _LOGGER.info("start zzz_catch_up_on_deploy_handler_changed") + assert not PolicyReceiver.is_running() + audit = Audit(job_name="test_zzz_catch_up_on_deploy_handler_changed", + req_message="start zzz_catch_up_on_deploy_handler_changed") + PolicyReceiver.run(audit) + + _LOGGER.info("sleep before send_notification...") + time.sleep(2) + + MockWebSocket.send_notification([1]) + _LOGGER.info("sleep after send_notification...") + time.sleep(3) + + MockSettings.deploy_handler_instance_uuid = str(uuid.uuid4()) + _LOGGER.info("new deploy-handler uuid=%s", MockSettings.deploy_handler_instance_uuid) + + MockWebSocket.send_notification([2, 4]) + _LOGGER.info("sleep after send_notification...") + time.sleep(3) + + _LOGGER.info("sleep 5 before shutdown...") + time.sleep(5) + + result = self.getPage("/healthcheck") + _LOGGER.info("healthcheck result: %s", result) + + PolicyReceiver.shutdown(audit) + time.sleep(1) + assert not PolicyReceiver.is_running() + + Tracker.validate() + + @pytest.mark.usefixtures("fix_deploy_handler", "fix_policy_receiver_websocket") + def test_zzz_get_catch_up(self): + """test /catch_up""" + if Config.is_pdp_api_default(): + _LOGGER.info("passive for new PDP API") + return + + _LOGGER.info("start /catch_up") + assert not PolicyReceiver.is_running() + audit = Audit(job_name="test_zzz_get_catch_up", req_message="start /catch_up") + PolicyReceiver.run(audit) + time.sleep(5) + result = self.getPage("/catch_up") + _LOGGER.info("catch_up result: %s", result) + self.assertStatus('200 OK') + _LOGGER.info("got catch_up: %s", self.body) + + _LOGGER.info("sleep 5 before shutdown...") + time.sleep(5) + + result = self.getPage("/healthcheck") + _LOGGER.info("healthcheck result: %s", result) + + PolicyReceiver.shutdown(audit) + time.sleep(1) + assert not PolicyReceiver.is_running() + + Tracker.validate() + + @pytest.mark.usefixtures( + "fix_deploy_handler", + "fix_policy_receiver_websocket", + "fix_cherrypy_engine_exit") + def test_zzzzz_shutdown(self): + """test shutdown""" + _LOGGER.info("start shutdown") + assert not PolicyReceiver.is_running() + audit = Audit(job_name="test_zzzzz_shutdown", req_message="start shutdown") + PolicyReceiver.run(audit) + + _LOGGER.info("sleep before send_notification...") + time.sleep(2) + + MockWebSocket.send_notification([1, 3, 5]) + _LOGGER.info("sleep after send_notification...") + time.sleep(3) + + result = self.getPage("/healthcheck") + _LOGGER.info("healthcheck result: %s", result) + + WebServerInternalBoom2018Test.do_gc_test = False + _LOGGER.info("shutdown...") + audit.audit_done("shutdown") + result = self.getPage("/shutdown") + _LOGGER.info("shutdown result: %s", result) + self.assertStatus('200 OK') + _LOGGER.info("got shutdown: %s", self.body) + time.sleep(1) + assert not PolicyReceiver.is_running() + + if Config.is_pdp_api_default(): + _LOGGER.info("passive for new PDP API") + return + + Tracker.validate() diff --git a/tests/test_policy_rest.py b/tests/test_policy_rest.py deleted file mode 100644 index ac2529a..0000000 --- a/tests/test_policy_rest.py +++ /dev/null @@ -1,47 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= -# -# ECOMP is a trademark and service mark of AT&T Intellectual Property. -"""test policy_rest methods directly""" - -import json - -import pytest - -from policyhandler.onap.audit import Audit -from policyhandler.policy_rest import PolicyRest -from policyhandler.policy_utils import Utils - -from .mock_policy_engine import MockPolicyEngine -from .mock_settings import Settings -from .mock_tracker import Tracker - - -@pytest.mark.usefixtures("fix_pdp_post") -def test_get_policy_latest(): - """test /policy_latest/""" - policy_id, expected_policy = MockPolicyEngine.gen_policy_latest(3) - - audit = Audit(job_name="test_get_policy_latest", - req_message="get /policy_latest/{}".format(policy_id or "")) - policy_latest = PolicyRest.get_latest_policy((audit, policy_id, None, None)) or {} - audit.audit_done(result=json.dumps(policy_latest)) - - Settings.logger.info("expected_policy: %s", json.dumps(expected_policy)) - Settings.logger.info("policy_latest: %s", json.dumps(policy_latest)) - assert Utils.are_the_same(policy_latest, expected_policy) - - Tracker.validate() diff --git a/tests/test_policy_utils.py b/tests/test_policy_utils.py deleted file mode 100644 index dcf6ccb..0000000 --- a/tests/test_policy_utils.py +++ /dev/null @@ -1,186 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= -# -# ECOMP is a trademark and service mark of AT&T Intellectual Property. - -"""test of the policy_utils""" - -import json -import logging -import re - -from policyhandler.config import Config -from policyhandler.policy_utils import RegexCoarser - -Config.init_config() -LOGGER = logging.getLogger("policy_handler.unit_test_policy_utils") - - -def check_coarse_regex(test_name, patterns, matching_strings=None, expected_subpatterns=None): - """generic test""" - regex_coarser = RegexCoarser(patterns) - coarse_patterns = regex_coarser.get_coarse_regex_patterns(max_length=20) - LOGGER.info("check_coarse_regex %s (%s) for [%s]", - test_name, coarse_patterns, json.dumps(regex_coarser.patterns)) - coarse_regexes = [re.compile(coarse_pattern) for coarse_pattern in coarse_patterns] - coarse_patterns_str = json.dumps(coarse_patterns) - if matching_strings: - for test_str in matching_strings: - LOGGER.info(" match '%s' to %s (%s)", test_str, test_name, coarse_patterns_str) - assert bool(list(filter(None, [ - coarse_regex.match(test_str) for coarse_regex in coarse_regexes - ]))) - - if expected_subpatterns: - for subpattern in expected_subpatterns: - LOGGER.info(" subpattern '%s' in %s", subpattern, coarse_patterns_str) - assert subpattern in coarse_patterns_str - -def check_combined_regex(test_name, patterns, matching_strings=None, unmatching_strings=None): - """generic test""" - regex_coarser = RegexCoarser(patterns) - combined_pattern = regex_coarser.get_combined_regex_pattern() - LOGGER.info("check_combined_regex %s (%s) for [%s]", - test_name, combined_pattern, json.dumps(regex_coarser.patterns)) - coarse_regex = re.compile(combined_pattern) - if matching_strings: - for test_str in matching_strings: - LOGGER.info(" match '%s' to %s (%s)", test_str, test_name, combined_pattern) - assert coarse_regex.match(test_str) - - if unmatching_strings: - for test_str in unmatching_strings: - LOGGER.info(" not match '%s' to %s (%s)", test_str, test_name, combined_pattern) - assert not coarse_regex.match(test_str) - -def test_regex_coarser(): - """test variety of regex combinations""" - - test_data = [ - ( - "simple", - [ - "plain text", "plain pick", - "aaa (((a|b)|c)|d)", - "aaa (((a|b)|c)|d zzz", - "nested (expr[aeiou]ss(ions)?)", - "nested (expr[aeiou]ss(?:ions|ion)?)", - "^ (any expr|more|less|some|who cares)", - " (any expr|more|less|some|who cares)", - "(any expr|more|less|some|who cares)" - ], - [ - 'plain text', - 'nested exprussions', - 'nested expross', - 'aaa c', - 'aaa d', - 'who cares', - ' who cares' - ], - None, - [ - "nested .*", - "plain .*", - "aaa .*", - "(any expr|more|less|some|who cares)", - "^ (any expr|more|less|some|who cares)", - " (any expr|more|less|some|who cares)"] - ), - ( - "combination", - [ - "plain text", - "^with* modifiers?", - "cha[ra][ra]cter classes", - "^with (groups)", - "^with (groups|more groups)", - r"^with (mod+ifiers\s*|in groups{2,3}\s*)+", - "sub", - "substrings", - "su.*bstrings", - "char count{1,3}s", - "nested (expr[aeiou]ss(ions)?)", - r"escaped (\)) chars", - r"escaped ([\)\]]) chars", - r"escaped ([\)\]]){3} chars" - ], - [ - 'plain text', - 'withhh modifier', - 'character classes', - 'with groups', - 'with more groups', - 'with modddifiers in groupss modifiers in groupsss', - 'sub', - 'substrings', - 'char counttts', - 'nested exprassions', - 'nested express', - 'escaped ) chars', - 'escaped ] chars', - 'escaped ]]] chars' - ], - [ - 'plain', - 'text', - 'something with modifiers', - 'su', - 'char counttttts', - 'escaped ]] chars' - ], - [ - "nested .*", - "escaped .*", - "^wit.*", - "plain text", - "cha.*", - "su.*" - ] - ), - ( - "combined", - [ - 'foo+', - 'food', - 'football', - "ba[rh]", - "bard" - ], - [ - 'foo', - 'fooooo', - 'football', - 'food', - 'bar', - 'bah', - 'bard' - ], - [ - 'fo', - 'bat' - ], - [ - "fo.*", - "ba.*" - ] - ) - ] - - for (test_name, patterns, - matching_strings, unmatching_strings, expected_subpatterns) in test_data: - check_combined_regex(test_name, patterns, matching_strings, unmatching_strings) - check_coarse_regex(test_name, patterns, matching_strings, expected_subpatterns) diff --git a/tests/test_policyhandler.py b/tests/test_policyhandler.py deleted file mode 100644 index 4743a6e..0000000 --- a/tests/test_policyhandler.py +++ /dev/null @@ -1,248 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= -# -# ECOMP is a trademark and service mark of AT&T Intellectual Property. - -"""test of the package for policy-handler of DCAE-Controller""" - -import json -import time -import uuid - -import pytest -import cherrypy -from cherrypy.test.helper import CPWebCase - -from policyhandler.onap.audit import REQUEST_X_ECOMP_REQUESTID, Audit -from policyhandler.policy_consts import LATEST_POLICIES, POLICY_NAME -from policyhandler.policy_receiver import PolicyReceiver -from policyhandler.policy_utils import Utils -from policyhandler.web_server import _PolicyWeb - -from .mock_policy_engine import MockPolicyEngine -from .mock_settings import Settings -from .mock_tracker import Tracker -from .mock_websocket import MockWebSocket - - -@pytest.mark.usefixtures("fix_pdp_post", "fix_discovery") -class WebServerTest(CPWebCase): - """testing the web-server - runs tests in alphabetical order of method names""" - def setup_server(): - """setup the web-server""" - cherrypy.tree.mount(_PolicyWeb(), '/') - - setup_server = staticmethod(setup_server) - - def test_web_healthcheck(self): - """test /healthcheck""" - result = self.getPage("/healthcheck") - Settings.logger.info("healthcheck result: %s", result) - Settings.logger.info("got healthcheck: %s", self.body) - self.assertStatus('200 OK') - - Tracker.validate() - - def test_web_policy_latest(self): - """test /policy_latest/""" - policy_id, expected_policy = MockPolicyEngine.gen_policy_latest(3) - - self.getPage("/policy_latest/{0}".format(policy_id or "")) - self.assertStatus('200 OK') - - policy_latest = json.loads(self.body) - - Settings.logger.info("policy_latest: %s", self.body) - Settings.logger.info("expected_policy: %s", json.dumps(expected_policy)) - assert Utils.are_the_same(policy_latest, expected_policy) - - result = self.getPage("/healthcheck") - Settings.logger.info("healthcheck result: %s", result) - - Tracker.validate() - - @pytest.mark.usefixtures("fix_deploy_handler") - def test_web_all_policies_latest(self): - """test GET /policies_latest""" - expected_policies = MockPolicyEngine.gen_all_policies_latest() - - result = self.getPage("/policies_latest") - Settings.logger.info("result: %s", result) - Settings.logger.info("body: %s", self.body) - self.assertStatus('200 OK') - - policies_latest = json.loads(self.body) - self.assertIn(LATEST_POLICIES, policies_latest) - policies_latest = policies_latest[LATEST_POLICIES] - - Settings.logger.info("policies_latest: %s", json.dumps(policies_latest)) - Settings.logger.info("expected_policies: %s", json.dumps(expected_policies)) - assert Utils.are_the_same(policies_latest, expected_policies) - - result = self.getPage("/healthcheck") - Settings.logger.info("healthcheck result: %s", result) - - Tracker.validate() - - def test_web_policies_latest(self): - """test POST /policies_latest with policyName""" - match_to_policy_name = MockPolicyEngine.scope_prefix + "amet.*" - expected_policies = MockPolicyEngine.gen_policies_latest(match_to_policy_name) - - body = json.dumps({POLICY_NAME: match_to_policy_name}) - result = self.getPage("/policies_latest", method='POST', - body=body, - headers=[ - (REQUEST_X_ECOMP_REQUESTID, str(uuid.uuid4())), - ("Content-Type", "application/json"), - ('Content-Length', str(len(body))) - ]) - Settings.logger.info("result: %s", result) - Settings.logger.info("body: %s", self.body) - self.assertStatus('200 OK') - - policies_latest = json.loads(self.body)[LATEST_POLICIES] - - Settings.logger.info("policies_latest: %s", json.dumps(policies_latest)) - Settings.logger.info("expected_policies: %s", json.dumps(expected_policies)) - assert Utils.are_the_same(policies_latest, expected_policies) - - result = self.getPage("/healthcheck") - Settings.logger.info("healthcheck result: %s", result) - - Tracker.validate() - - @pytest.mark.usefixtures("fix_deploy_handler", "fix_policy_receiver_websocket") - def test_zzz_policy_updates_and_catch_ups(self): - """test run policy handler with policy updates and catchups""" - Settings.logger.info("start policy_updates_and_catch_ups") - assert not PolicyReceiver.is_running() - - audit = Audit(job_name="test_zzz_policy_updates_and_catch_ups", - req_message="start policy_updates_and_catch_ups") - PolicyReceiver.run(audit) - - Settings.logger.info("sleep before send_notification...") - time.sleep(2) - - MockWebSocket.send_notification([1, 3, 5]) - Settings.logger.info("sleep after send_notification...") - time.sleep(3) - - Settings.logger.info("sleep 10 before shutdown...") - time.sleep(10) - - result = self.getPage("/healthcheck") - Settings.logger.info("healthcheck result: %s", result) - - PolicyReceiver.shutdown(audit) - time.sleep(1) - assert not PolicyReceiver.is_running() - - Tracker.validate() - - @pytest.mark.usefixtures("fix_deploy_handler", "fix_policy_receiver_websocket") - def test_zzz_catch_up_on_deploy_handler_changed(self): - """test run policy handler with deployment-handler changed underneath""" - Settings.logger.info("start zzz_catch_up_on_deploy_handler_changed") - assert not PolicyReceiver.is_running() - audit = Audit(job_name="test_zzz_catch_up_on_deploy_handler_changed", - req_message="start zzz_catch_up_on_deploy_handler_changed") - PolicyReceiver.run(audit) - - Settings.logger.info("sleep before send_notification...") - time.sleep(2) - - MockWebSocket.send_notification([1]) - Settings.logger.info("sleep after send_notification...") - time.sleep(3) - - Settings.deploy_handler_instance_uuid = str(uuid.uuid4()) - Settings.logger.info("new deploy-handler uuid=%s", Settings.deploy_handler_instance_uuid) - - MockWebSocket.send_notification([2, 4]) - Settings.logger.info("sleep after send_notification...") - time.sleep(3) - - Settings.logger.info("sleep 5 before shutdown...") - time.sleep(5) - - result = self.getPage("/healthcheck") - Settings.logger.info("healthcheck result: %s", result) - - PolicyReceiver.shutdown(audit) - time.sleep(1) - assert not PolicyReceiver.is_running() - - Tracker.validate() - - @pytest.mark.usefixtures("fix_deploy_handler", "fix_policy_receiver_websocket") - def test_zzz_get_catch_up(self): - """test /catch_up""" - Settings.logger.info("start /catch_up") - assert not PolicyReceiver.is_running() - audit = Audit(job_name="test_zzz_get_catch_up", req_message="start /catch_up") - PolicyReceiver.run(audit) - time.sleep(5) - result = self.getPage("/catch_up") - Settings.logger.info("catch_up result: %s", result) - self.assertStatus('200 OK') - Settings.logger.info("got catch_up: %s", self.body) - - Settings.logger.info("sleep 5 before shutdown...") - time.sleep(5) - - result = self.getPage("/healthcheck") - Settings.logger.info("healthcheck result: %s", result) - - PolicyReceiver.shutdown(audit) - time.sleep(1) - assert not PolicyReceiver.is_running() - - Tracker.validate() - - @pytest.mark.usefixtures( - "fix_deploy_handler", - "fix_policy_receiver_websocket", - "fix_cherrypy_engine_exit") - def test_zzzzz_shutdown(self): - """test shutdown""" - Settings.logger.info("start shutdown") - assert not PolicyReceiver.is_running() - audit = Audit(job_name="test_zzzzz_shutdown", req_message="start shutdown") - PolicyReceiver.run(audit) - - Settings.logger.info("sleep before send_notification...") - time.sleep(2) - - MockWebSocket.send_notification([1, 3, 5]) - Settings.logger.info("sleep after send_notification...") - time.sleep(3) - - result = self.getPage("/healthcheck") - Settings.logger.info("healthcheck result: %s", result) - - WebServerTest.do_gc_test = False - Settings.logger.info("shutdown...") - audit.audit_done("shutdown") - result = self.getPage("/shutdown") - Settings.logger.info("shutdown result: %s", result) - self.assertStatus('200 OK') - Settings.logger.info("got shutdown: %s", self.body) - time.sleep(1) - assert not PolicyReceiver.is_running() - - Tracker.validate() diff --git a/tests/test_pz_catch_up.py b/tests/test_pz_catch_up.py deleted file mode 100644 index 89be9bb..0000000 --- a/tests/test_pz_catch_up.py +++ /dev/null @@ -1,96 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= -# -# ECOMP is a trademark and service mark of AT&T Intellectual Property. -"""test policy catch_up methods directly""" - -import json -import time - -import pytest - -from policyhandler.onap.audit import Audit -from policyhandler.policy_receiver import PolicyReceiver - -from .mock_settings import Settings -from .mock_tracker import Tracker - - -@pytest.mark.usefixtures( - "fix_auto_catch_up", - "fix_discovery", - "fix_pdp_post_big", - "fix_deploy_handler_413", - "fix_policy_receiver_websocket" -) -def test_catch_up_failed_dh(): - """test run policy handler with catchups and failed deployment-handler""" - Settings.logger.info("start test_catch_up_failed_dh") - assert not PolicyReceiver.is_running() - audit = Audit(job_name="test_catch_up_failed_dh", - req_message="start test_catch_up_failed_dh") - PolicyReceiver.run(audit) - - Settings.logger.info("sleep 12 before shutdown...") - time.sleep(12) - - health = audit.health(full=True) - audit.audit_done(result=json.dumps(health)) - - Settings.logger.info("healthcheck: %s", json.dumps(health)) - assert bool(health) - - PolicyReceiver.shutdown(audit) - time.sleep(1) - assert not PolicyReceiver.is_running() - - health = audit.health(full=True) - Settings.logger.info("healthcheck: %s", json.dumps(health)) - - Tracker.validate() - -@pytest.mark.usefixtures( - "fix_auto_catch_up", - "fix_discovery", - "fix_pdp_post", - "fix_deploy_handler_404", - "fix_policy_receiver_websocket" -) -def test_catch_up_dh_404(): - """test run policy handler with catchups and failed deployment-handler""" - Settings.logger.info("start test_catch_up_dh_404") - assert not PolicyReceiver.is_running() - audit = Audit(job_name="test_catch_up_dh_404", - req_message="start test_catch_up_dh_404") - PolicyReceiver.run(audit) - - Settings.logger.info("sleep 12 before shutdown...") - time.sleep(12) - - health = audit.health(full=True) - audit.audit_done(result=json.dumps(health)) - - Settings.logger.info("healthcheck: %s", json.dumps(health)) - assert bool(health) - - PolicyReceiver.shutdown(audit) - time.sleep(1) - assert not PolicyReceiver.is_running() - - health = audit.health(full=True) - Settings.logger.info("healthcheck: %s", json.dumps(health)) - - Tracker.validate() diff --git a/tests/test_pz_pdp_boom.py b/tests/test_pz_pdp_boom.py deleted file mode 100644 index 1b6f150..0000000 --- a/tests/test_pz_pdp_boom.py +++ /dev/null @@ -1,226 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= -# -# ECOMP is a trademark and service mark of AT&T Intellectual Property. -"""test policyhandler web-server when pdp booms = fails""" - -import json -import time -import uuid - -import pytest -import cherrypy -from cherrypy.test.helper import CPWebCase - -from policyhandler.onap.audit import (REQUEST_X_ECOMP_REQUESTID, Audit, - AuditHttpCode) -from policyhandler.policy_consts import POLICY_NAME -from policyhandler.policy_receiver import PolicyReceiver -from policyhandler.web_server import _PolicyWeb - -from .mock_policy_engine import MockPolicyEngine -from .mock_settings import Settings -from .mock_tracker import Tracker -from .mock_websocket import MockWebSocket - - -@pytest.mark.usefixtures( - "fix_discovery", - "fix_pdp_post_boom" -) -class WebServerPDPBoomTest(CPWebCase): - """testing the web-server - runs tests in alphabetical order of method names""" - def setup_server(): - """setup the web-server""" - cherrypy.tree.mount(_PolicyWeb(), '/') - - setup_server = staticmethod(setup_server) - - def test_web_healthcheck(self): - """test /healthcheck""" - result = self.getPage("/healthcheck") - Settings.logger.info("healthcheck result: %s", result) - Settings.logger.info("got healthcheck: %s", self.body) - self.assertStatus('200 OK') - - Tracker.validate() - - def test_web_policy_latest(self): - """test /policy_latest/""" - policy_id, _ = MockPolicyEngine.gen_policy_latest(3) - - self.getPage("/policy_latest/{0}".format(policy_id or "")) - self.assertStatus(AuditHttpCode.SERVER_INTERNAL_ERROR.value) - - result = self.getPage("/healthcheck") - Settings.logger.info("healthcheck result: %s", result) - - Tracker.validate() - - @pytest.mark.usefixtures("fix_deploy_handler") - def test_web_all_policies_latest(self): - """test GET /policies_latest""" - result = self.getPage("/policies_latest") - Settings.logger.info("result: %s", result) - Settings.logger.info("body: %s", self.body) - self.assertStatus(AuditHttpCode.SERVER_INTERNAL_ERROR.value) - - result = self.getPage("/healthcheck") - Settings.logger.info("healthcheck result: %s", result) - - Tracker.validate() - - def test_web_policies_latest(self): - """test POST /policies_latest with policyName""" - match_to_policy_name = MockPolicyEngine.scope_prefix + "amet.*" - - body = json.dumps({POLICY_NAME: match_to_policy_name}) - result = self.getPage("/policies_latest", method='POST', - body=body, - headers=[ - (REQUEST_X_ECOMP_REQUESTID, str(uuid.uuid4())), - ("Content-Type", "application/json"), - ('Content-Length', str(len(body))) - ]) - Settings.logger.info("result: %s", result) - Settings.logger.info("body: %s", self.body) - self.assertStatus(AuditHttpCode.SERVER_INTERNAL_ERROR.value) - - result = self.getPage("/healthcheck") - Settings.logger.info("healthcheck result: %s", result) - - Tracker.validate() - - @pytest.mark.usefixtures("fix_deploy_handler", "fix_policy_receiver_websocket") - def test_zzz_policy_updates_and_catch_ups(self): - """test run policy handler with policy updates and catchups""" - Settings.logger.info("start policy_updates_and_catch_ups") - assert not PolicyReceiver.is_running() - audit = Audit(job_name="test_zzz_policy_updates_and_catch_ups", - req_message="start policy_updates_and_catch_ups") - PolicyReceiver.run(audit) - - Settings.logger.info("sleep before send_notification...") - time.sleep(2) - - MockWebSocket.send_notification([1, 3, 5]) - Settings.logger.info("sleep after send_notification...") - time.sleep(3) - - Settings.logger.info("sleep 10 before shutdown...") - time.sleep(10) - - result = self.getPage("/healthcheck") - Settings.logger.info("healthcheck result: %s", result) - - PolicyReceiver.shutdown(audit) - time.sleep(1) - assert not PolicyReceiver.is_running() - - Tracker.validate() - - @pytest.mark.usefixtures("fix_deploy_handler", "fix_policy_receiver_websocket") - def test_zzz_catch_up_on_deploy_handler_changed(self): - """test run policy handler with deployment-handler changed underneath""" - Settings.logger.info("start zzz_catch_up_on_deploy_handler_changed") - assert not PolicyReceiver.is_running() - audit = Audit(job_name="test_zzz_catch_up_on_deploy_handler_changed", - req_message="start zzz_catch_up_on_deploy_handler_changed") - PolicyReceiver.run(audit) - - Settings.logger.info("sleep before send_notification...") - time.sleep(2) - - MockWebSocket.send_notification([1]) - Settings.logger.info("sleep after send_notification...") - time.sleep(3) - - Settings.deploy_handler_instance_uuid = str(uuid.uuid4()) - Settings.logger.info("new deploy-handler uuid=%s", Settings.deploy_handler_instance_uuid) - - MockWebSocket.send_notification([2, 4]) - Settings.logger.info("sleep after send_notification...") - time.sleep(3) - - Settings.logger.info("sleep 5 before shutdown...") - time.sleep(5) - - result = self.getPage("/healthcheck") - Settings.logger.info("healthcheck result: %s", result) - - PolicyReceiver.shutdown(audit) - time.sleep(1) - assert not PolicyReceiver.is_running() - - Tracker.validate() - - @pytest.mark.usefixtures("fix_deploy_handler", "fix_policy_receiver_websocket") - def test_zzz_get_catch_up(self): - """test /catch_up""" - Settings.logger.info("start /catch_up") - assert not PolicyReceiver.is_running() - audit = Audit(job_name="test_zzz_get_catch_up", req_message="start /catch_up") - PolicyReceiver.run(audit) - time.sleep(5) - result = self.getPage("/catch_up") - Settings.logger.info("catch_up result: %s", result) - self.assertStatus('200 OK') - Settings.logger.info("got catch_up: %s", self.body) - - Settings.logger.info("sleep 5 before shutdown...") - time.sleep(5) - - result = self.getPage("/healthcheck") - Settings.logger.info("healthcheck result: %s", result) - - PolicyReceiver.shutdown(audit) - time.sleep(1) - assert not PolicyReceiver.is_running() - - Tracker.validate() - - @pytest.mark.usefixtures( - "fix_deploy_handler", - "fix_policy_receiver_websocket", - "fix_cherrypy_engine_exit") - def test_zzzzz_shutdown(self): - """test shutdown""" - Settings.logger.info("start shutdown") - assert not PolicyReceiver.is_running() - audit = Audit(job_name="test_zzzzz_shutdown", req_message="start shutdown") - PolicyReceiver.run(audit) - - Settings.logger.info("sleep before send_notification...") - time.sleep(2) - - MockWebSocket.send_notification([1, 3, 5]) - Settings.logger.info("sleep after send_notification...") - time.sleep(3) - - result = self.getPage("/healthcheck") - Settings.logger.info("healthcheck result: %s", result) - - WebServerPDPBoomTest.do_gc_test = False - Settings.logger.info("shutdown...") - audit.audit_done("shutdown") - result = self.getPage("/shutdown") - Settings.logger.info("shutdown result: %s", result) - self.assertStatus('200 OK') - Settings.logger.info("got shutdown: %s", self.body) - time.sleep(1) - assert not PolicyReceiver.is_running() - - Tracker.validate() diff --git a/tests/test_pz_ph_boom.py b/tests/test_pz_ph_boom.py deleted file mode 100644 index c392b3a..0000000 --- a/tests/test_pz_ph_boom.py +++ /dev/null @@ -1,228 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= -# -# ECOMP is a trademark and service mark of AT&T Intellectual Property. -"""test policyhandler web-server when the policy-handler booms = fails""" - -import json -import time -import uuid - - -import pytest -import cherrypy -from cherrypy.test.helper import CPWebCase - -from policyhandler.onap.audit import (REQUEST_X_ECOMP_REQUESTID, Audit, - AuditHttpCode) -from policyhandler.policy_consts import POLICY_NAME -from policyhandler.policy_receiver import PolicyReceiver -from policyhandler.web_server import _PolicyWeb - -from .mock_policy_engine import MockPolicyEngine -from .mock_settings import Settings -from .mock_tracker import Tracker -from .mock_websocket import MockWebSocket - - -@pytest.mark.usefixtures( - "fix_discovery", - "fix_pdp_post", - "fix_select_latest_policies_boom" -) -class WebServerInternalBoomTest(CPWebCase): - """testing the web-server - runs tests in alphabetical order of method names""" - def setup_server(): - """setup the web-server""" - cherrypy.tree.mount(_PolicyWeb(), '/') - - setup_server = staticmethod(setup_server) - - def test_web_healthcheck(self): - """test /healthcheck""" - result = self.getPage("/healthcheck") - Settings.logger.info("healthcheck result: %s", result) - Settings.logger.info("got healthcheck: %s", self.body) - self.assertStatus('200 OK') - - Tracker.validate() - - def test_web_policy_latest(self): - """test /policy_latest/""" - policy_id, _ = MockPolicyEngine.gen_policy_latest(3) - - self.getPage("/policy_latest/{0}".format(policy_id or "")) - self.assertStatus(AuditHttpCode.SERVER_INTERNAL_ERROR.value) - - result = self.getPage("/healthcheck") - Settings.logger.info("healthcheck result: %s", result) - - Tracker.validate() - - @pytest.mark.usefixtures("fix_deploy_handler") - def test_web_all_policies_latest(self): - """test GET /policies_latest""" - result = self.getPage("/policies_latest") - Settings.logger.info("result: %s", result) - Settings.logger.info("body: %s", self.body) - self.assertStatus(AuditHttpCode.SERVER_INTERNAL_ERROR.value) - - result = self.getPage("/healthcheck") - Settings.logger.info("healthcheck result: %s", result) - - Tracker.validate() - - def test_web_policies_latest(self): - """test POST /policies_latest with policyName""" - match_to_policy_name = MockPolicyEngine.scope_prefix + "amet.*" - - body = json.dumps({POLICY_NAME: match_to_policy_name}) - result = self.getPage("/policies_latest", method='POST', - body=body, - headers=[ - (REQUEST_X_ECOMP_REQUESTID, str(uuid.uuid4())), - ("Content-Type", "application/json"), - ('Content-Length', str(len(body))) - ]) - Settings.logger.info("result: %s", result) - Settings.logger.info("body: %s", self.body) - self.assertStatus(AuditHttpCode.SERVER_INTERNAL_ERROR.value) - - result = self.getPage("/healthcheck") - Settings.logger.info("healthcheck result: %s", result) - - Tracker.validate() - - @pytest.mark.usefixtures("fix_deploy_handler", "fix_policy_receiver_websocket") - def test_zzz_policy_updates_and_catch_ups(self): - """test run policy handler with policy updates and catchups""" - Settings.logger.info("start policy_updates_and_catch_ups") - assert not PolicyReceiver.is_running() - audit = Audit(job_name="test_zzz_policy_updates_and_catch_ups", - req_message="start policy_updates_and_catch_ups") - PolicyReceiver.run(audit) - - Settings.logger.info("sleep before send_notification...") - time.sleep(2) - - MockWebSocket.send_notification([1, 3, 5]) - Settings.logger.info("sleep after send_notification...") - time.sleep(3) - - Settings.logger.info("sleep 10 before shutdown...") - time.sleep(10) - - result = self.getPage("/healthcheck") - Settings.logger.info("healthcheck result: %s", result) - - PolicyReceiver.shutdown(audit) - time.sleep(1) - assert not PolicyReceiver.is_running() - - Tracker.validate() - - @pytest.mark.usefixtures("fix_deploy_handler", "fix_policy_receiver_websocket") - def test_zzz_catch_up_on_deploy_handler_changed(self): - """test run policy handler with deployment-handler changed underneath""" - Settings.logger.info("start zzz_catch_up_on_deploy_handler_changed") - assert not PolicyReceiver.is_running() - audit = Audit(job_name="test_zzz_catch_up_on_deploy_handler_changed", - req_message="start zzz_catch_up_on_deploy_handler_changed") - PolicyReceiver.run(audit) - - Settings.logger.info("sleep before send_notification...") - time.sleep(2) - - MockWebSocket.send_notification([1]) - Settings.logger.info("sleep after send_notification...") - time.sleep(3) - - Settings.deploy_handler_instance_uuid = str(uuid.uuid4()) - Settings.logger.info("new deploy-handler uuid=%s", Settings.deploy_handler_instance_uuid) - - MockWebSocket.send_notification([2, 4]) - Settings.logger.info("sleep after send_notification...") - time.sleep(3) - - Settings.logger.info("sleep 5 before shutdown...") - time.sleep(5) - - result = self.getPage("/healthcheck") - Settings.logger.info("healthcheck result: %s", result) - - PolicyReceiver.shutdown(audit) - time.sleep(1) - assert not PolicyReceiver.is_running() - - Tracker.validate() - - @pytest.mark.usefixtures("fix_deploy_handler", "fix_policy_receiver_websocket") - def test_zzz_get_catch_up(self): - """test /catch_up""" - Settings.logger.info("start /catch_up") - assert not PolicyReceiver.is_running() - audit = Audit(job_name="test_zzz_get_catch_up", req_message="start /catch_up") - PolicyReceiver.run(audit) - time.sleep(5) - result = self.getPage("/catch_up") - Settings.logger.info("catch_up result: %s", result) - self.assertStatus('200 OK') - Settings.logger.info("got catch_up: %s", self.body) - - Settings.logger.info("sleep 5 before shutdown...") - time.sleep(5) - - result = self.getPage("/healthcheck") - Settings.logger.info("healthcheck result: %s", result) - - PolicyReceiver.shutdown(audit) - time.sleep(1) - assert not PolicyReceiver.is_running() - - Tracker.validate() - - @pytest.mark.usefixtures( - "fix_deploy_handler", - "fix_policy_receiver_websocket", - "fix_cherrypy_engine_exit") - def test_zzzzz_shutdown(self): - """test shutdown""" - Settings.logger.info("start shutdown") - assert not PolicyReceiver.is_running() - audit = Audit(job_name="test_zzzzz_shutdown", req_message="start shutdown") - PolicyReceiver.run(audit) - - Settings.logger.info("sleep before send_notification...") - time.sleep(2) - - MockWebSocket.send_notification([1, 3, 5]) - Settings.logger.info("sleep after send_notification...") - time.sleep(3) - - result = self.getPage("/healthcheck") - Settings.logger.info("healthcheck result: %s", result) - - WebServerInternalBoomTest.do_gc_test = False - Settings.logger.info("shutdown...") - audit.audit_done("shutdown") - result = self.getPage("/shutdown") - Settings.logger.info("shutdown result: %s", result) - self.assertStatus('200 OK') - Settings.logger.info("got shutdown: %s", self.body) - time.sleep(1) - assert not PolicyReceiver.is_running() - - Tracker.validate() diff --git a/tests/test_step_timer.py b/tests/test_step_timer.py deleted file mode 100644 index d4a0df1..0000000 --- a/tests/test_step_timer.py +++ /dev/null @@ -1,209 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= -# -# ECOMP is a trademark and service mark of AT&T Intellectual Property. - -"""test of the step_timer""" - -import json -import logging -import time -from datetime import datetime - -from policyhandler.config import Config -from policyhandler.step_timer import StepTimer - -Config.init_config() - - -class MockTimerController(object): - """testing step_timer""" - logger = logging.getLogger("policy_handler.unit_test.step_timer") - - INIT = "init" - NEXT = "next" - STARTED = "started" - PAUSED = "paused" - STOPPING = "stopping" - STOPPED = "stopped" - - def __init__(self, name, interval): - """step_timer test settings""" - self.name = name or "step_timer" - self.interval = interval or 5 - self.step_timer = None - self.status = None - self.run_counter = 0 - self.status_ts = datetime.utcnow() - self.exe_ts = None - self.exe_interval = None - self.set_status(MockTimerController.INIT) - - def __enter__(self): - """constructor""" - return self - - def __exit__(self, exc_type, exc_value, traceback): - """destructor""" - self.stop_timer() - - def on_time(self, *args, **kwargs): - """timer event""" - self.exe_ts = datetime.utcnow() - self.exe_interval = (self.exe_ts - self.status_ts).total_seconds() - MockTimerController.logger.info("run on_time[%s] (%s, %s) in %s for %s", - self.run_counter, json.dumps(args), json.dumps(kwargs), - self.exe_interval, self.get_status()) - time.sleep(3) - MockTimerController.logger.info("done on_time[%s] (%s, %s) in %s for %s", - self.run_counter, json.dumps(args), json.dumps(kwargs), - self.exe_interval, self.get_status()) - - def verify_last_event(self): - """assertions needs to be in the main thread""" - if self.exe_interval is None: - MockTimerController.logger.info("not executed: %s", self.get_status()) - return - - MockTimerController.logger.info("verify exe %s for %s", - self.exe_interval, self.get_status()) - assert self.exe_interval >= (self.interval - 0.01) - assert self.exe_interval < 2 * self.interval - MockTimerController.logger.info("success %s", self.get_status()) - - def run_timer(self): - """create and start the step_timer""" - if self.step_timer: - self.step_timer.next() - self.set_status(MockTimerController.NEXT) - return - - self.step_timer = StepTimer( - self.name, self.interval, MockTimerController.on_time, - MockTimerController.logger, - self - ) - self.step_timer.start() - self.set_status(MockTimerController.STARTED) - - def pause_timer(self): - """pause step_timer""" - if self.step_timer: - self.step_timer.pause() - self.set_status(MockTimerController.PAUSED) - - def stop_timer(self): - """stop step_timer""" - if self.step_timer: - self.set_status(MockTimerController.STOPPING) - self.step_timer.stop() - self.step_timer.join() - self.step_timer = None - self.set_status(MockTimerController.STOPPED) - - def set_status(self, status): - """set the status of the timer""" - if status in [MockTimerController.NEXT, MockTimerController.STARTED]: - self.run_counter += 1 - - self.status = status - utcnow = datetime.utcnow() - time_step = (utcnow - self.status_ts).total_seconds() - self.status_ts = utcnow - MockTimerController.logger.info("[%s]: %s", time_step, self.get_status()) - - def get_status(self): - """string representation""" - status = "{0}[{1}] {2} in {3} from {4} last exe {5}".format( - self.status, self.run_counter, self.name, self.interval, - str(self.status_ts), str(self.exe_ts) - ) - if self.step_timer: - return "{0}: {1}".format(status, self.step_timer.get_timer_status()) - return status - - -def test_step_timer(): - """test step_timer""" - MockTimerController.logger.info("============ test_step_timer =========") - with MockTimerController("step_timer", 5) as step_timer: - step_timer.run_timer() - time.sleep(1) - step_timer.verify_last_event() - - time.sleep(1 + step_timer.interval) - step_timer.verify_last_event() - - step_timer.pause_timer() - time.sleep(2) - step_timer.verify_last_event() - - step_timer.pause_timer() - time.sleep(2) - step_timer.verify_last_event() - - step_timer.run_timer() - time.sleep(3 * step_timer.interval) - step_timer.verify_last_event() - - step_timer.run_timer() - time.sleep(3 * step_timer.interval) - step_timer.verify_last_event() - - -def test_interrupt_step_timer(): - """test step_timer""" - MockTimerController.logger.info("============ test_interrupt_step_timer =========") - with MockTimerController("step_timer", 5) as step_timer: - step_timer.run_timer() - time.sleep(1) - step_timer.verify_last_event() - - step_timer.pause_timer() - time.sleep(2 + step_timer.interval) - step_timer.verify_last_event() - - step_timer.pause_timer() - time.sleep(2) - step_timer.verify_last_event() - - step_timer.pause_timer() - time.sleep(2) - step_timer.verify_last_event() - - step_timer.run_timer() - time.sleep(2) - step_timer.verify_last_event() - - step_timer.run_timer() - time.sleep(2 + step_timer.interval) - step_timer.verify_last_event() - - step_timer.run_timer() - time.sleep(2) - step_timer.verify_last_event() - - step_timer.pause_timer() - time.sleep(2) - step_timer.verify_last_event() - - step_timer.run_timer() - time.sleep(2) - step_timer.verify_last_event() - - step_timer.run_timer() - time.sleep(3 * step_timer.interval) - step_timer.verify_last_event() diff --git a/tests/test_zzz_memory.py b/tests/test_zzz_memory.py deleted file mode 100644 index e1b5af3..0000000 --- a/tests/test_zzz_memory.py +++ /dev/null @@ -1,118 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= -# -# ECOMP is a trademark and service mark of AT&T Intellectual Property. - -"""test of the package for policy-handler of DCAE-Controller""" - -import gc -import json -import time - -import pytest - -from policyhandler.onap.audit import Audit, AuditHttpCode, Metrics - -from .mock_settings import Settings - - -class Node(object): - """making the cycled objects""" - def __init__(self, name): - self.name = name - self.next = None - def __repr__(self): - return '%s(%s)' % (self.__class__.__name__, self.name) - - -def test_healthcheck(): - """test /healthcheck""" - audit = Audit(job_name="test_healthcheck", - req_message="get /healthcheck") - metrics = Metrics(aud_parent=audit, targetEntity="test_healthcheck") - metrics.metrics_start("test /healthcheck") - time.sleep(0.1) - - metrics.metrics("test /healthcheck") - health = audit.health(full=True) - audit.audit_done(result=json.dumps(health)) - - Settings.logger.info("healthcheck: %s", json.dumps(health)) - assert bool(health) - - -def test_healthcheck_with_error(): - """test /healthcheck""" - audit = Audit(job_name="test_healthcheck_with_error", - req_message="get /healthcheck") - metrics = Metrics(aud_parent=audit, targetEntity="test_healthcheck_with_error") - metrics.metrics_start("test /healthcheck") - time.sleep(0.2) - audit.error("error from test_healthcheck_with_error") - audit.fatal("fatal from test_healthcheck_with_error") - audit.debug("debug from test_healthcheck_with_error") - audit.warn("debug from test_healthcheck_with_error") - audit.info_requested("debug from test_healthcheck_with_error") - if audit.is_success(): - audit.set_http_status_code(AuditHttpCode.DATA_NOT_FOUND_OK.value) - audit.set_http_status_code(AuditHttpCode.SERVER_INTERNAL_ERROR.value) - metrics.metrics("test /healthcheck") - - health = audit.health(full=True) - audit.audit_done(result=json.dumps(health)) - - Settings.logger.info("healthcheck: %s", json.dumps(health)) - assert bool(health) - - -def test_healthcheck_with_garbage(): - """test /healthcheck""" - gc_found = gc.collect() - gc.set_debug(gc.DEBUG_LEAK) - - node1 = Node("one") - node2 = Node("two") - node3 = Node("three") - node1.next = node2 - node2.next = node3 - node3.next = node1 - node1 = node2 = node3 = None - gc_found = gc.collect() - - audit = Audit(job_name="test_healthcheck_with_garbage", - req_message="get /test_healthcheck_with_garbage") - health = audit.health(full=True) - audit.audit_done(result=json.dumps(health)) - - Settings.logger.info("test_healthcheck_with_garbage[%s]: %s", gc_found, json.dumps(health)) - assert bool(health) - assert bool(health.get("runtime", {}).get("gc", {}).get("gc_garbage")) - - Settings.logger.info("clearing up garbage...") - for obj in gc.garbage: - if isinstance(obj, Node): - Settings.logger.info("in garbage: %s 0x%x", obj, id(obj)) - obj.next = None - - gc_found = gc.collect() - Settings.logger.info("after clear test_healthcheck_with_garbage[%s]: %s", - gc_found, json.dumps(audit.health(full=True))) - - gc.set_debug(False) - - gc_found = gc.collect() - Settings.logger.info("after turned off gc debug test_healthcheck_with_garbage[%s]: %s", - gc_found, json.dumps(audit.health(full=True))) diff --git a/tests/utils/__init__.py b/tests/utils/__init__.py new file mode 100644 index 0000000..5e2fe60 --- /dev/null +++ b/tests/utils/__init__.py @@ -0,0 +1,20 @@ +# ================================================================================ +# Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# + + +# empty __init__.py so that pytest can add correct path to coverage report, -- per pytest +# best practice guideline diff --git a/tests/utils/test_step_timer.py b/tests/utils/test_step_timer.py new file mode 100644 index 0000000..152836d --- /dev/null +++ b/tests/utils/test_step_timer.py @@ -0,0 +1,199 @@ +# ============LICENSE_START======================================================= +# Copyright (c) 2017-2019 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# + +"""test of the step_timer""" + +import json +import time +from datetime import datetime + +from policyhandler.step_timer import StepTimer +from policyhandler.utils import Utils + +_LOGGER = Utils.get_logger(__file__) + +class MockTimerController(object): + """testing step_timer""" + INIT = "init" + NEXT = "next" + STARTED = "started" + PAUSED = "paused" + STOPPING = "stopping" + STOPPED = "stopped" + + def __init__(self, name, interval): + """step_timer test settings""" + self.name = name or "step_timer" + self.interval = interval or 5 + self.step_timer = None + self.status = None + self.run_counter = 0 + self.status_ts = datetime.utcnow() + self.exe_ts = None + self.exe_interval = None + self.set_status(MockTimerController.INIT) + + def __enter__(self): + """constructor""" + return self + + def __exit__(self, exc_type, exc_value, traceback): + """destructor""" + self.stop_timer() + + def on_time(self, *args, **kwargs): + """timer event""" + self.exe_ts = datetime.utcnow() + self.exe_interval = (self.exe_ts - self.status_ts).total_seconds() + _LOGGER.info("run on_time[%s] (%s, %s) in %s for %s", + self.run_counter, json.dumps(args), json.dumps(kwargs), + self.exe_interval, self.get_status()) + time.sleep(3) + _LOGGER.info("done on_time[%s] (%s, %s) in %s for %s", + self.run_counter, json.dumps(args), json.dumps(kwargs), + self.exe_interval, self.get_status()) + + def verify_last_event(self): + """assertions needs to be in the main thread""" + if self.exe_interval is None: + _LOGGER.info("not executed: %s", self.get_status()) + return + + _LOGGER.info("verify exe %s for %s", self.exe_interval, self.get_status()) + assert self.exe_interval >= (self.interval - 0.01) + assert self.exe_interval < 2 * self.interval + _LOGGER.info("success %s", self.get_status()) + + def run_timer(self): + """create and start the step_timer""" + if self.step_timer: + self.step_timer.next() + self.set_status(MockTimerController.NEXT) + return + + self.step_timer = StepTimer(self.name, self.interval, MockTimerController.on_time, self) + self.step_timer.start() + self.set_status(MockTimerController.STARTED) + + def pause_timer(self): + """pause step_timer""" + if self.step_timer: + self.step_timer.pause() + self.set_status(MockTimerController.PAUSED) + + def stop_timer(self): + """stop step_timer""" + if self.step_timer: + self.set_status(MockTimerController.STOPPING) + self.step_timer.stop() + self.step_timer.join() + self.step_timer = None + self.set_status(MockTimerController.STOPPED) + + def set_status(self, status): + """set the status of the timer""" + if status in [MockTimerController.NEXT, MockTimerController.STARTED]: + self.run_counter += 1 + + self.status = status + utcnow = datetime.utcnow() + time_step = (utcnow - self.status_ts).total_seconds() + self.status_ts = utcnow + _LOGGER.info("[%s]: %s", time_step, self.get_status()) + + def get_status(self): + """string representation""" + status = "{0}[{1}] {2} in {3} from {4} last exe {5}".format( + self.status, self.run_counter, self.name, self.interval, + str(self.status_ts), str(self.exe_ts) + ) + if self.step_timer: + return "{0}: {1}".format(status, self.step_timer.get_timer_status()) + return status + + +def test_step_timer(): + """test step_timer""" + _LOGGER.info("============ test_step_timer =========") + with MockTimerController("step_timer", 5) as step_timer: + step_timer.run_timer() + time.sleep(1) + step_timer.verify_last_event() + + time.sleep(1 + step_timer.interval) + step_timer.verify_last_event() + + step_timer.pause_timer() + time.sleep(2) + step_timer.verify_last_event() + + step_timer.pause_timer() + time.sleep(2) + step_timer.verify_last_event() + + step_timer.run_timer() + time.sleep(3 * step_timer.interval) + step_timer.verify_last_event() + + step_timer.run_timer() + time.sleep(3 * step_timer.interval) + step_timer.verify_last_event() + + +def test_interrupt_step_timer(): + """test step_timer""" + _LOGGER.info("============ test_interrupt_step_timer =========") + with MockTimerController("step_timer", 5) as step_timer: + step_timer.run_timer() + time.sleep(1) + step_timer.verify_last_event() + + step_timer.pause_timer() + time.sleep(2 + step_timer.interval) + step_timer.verify_last_event() + + step_timer.pause_timer() + time.sleep(2) + step_timer.verify_last_event() + + step_timer.pause_timer() + time.sleep(2) + step_timer.verify_last_event() + + step_timer.run_timer() + time.sleep(2) + step_timer.verify_last_event() + + step_timer.run_timer() + time.sleep(2 + step_timer.interval) + step_timer.verify_last_event() + + step_timer.run_timer() + time.sleep(2) + step_timer.verify_last_event() + + step_timer.pause_timer() + time.sleep(2) + step_timer.verify_last_event() + + step_timer.run_timer() + time.sleep(2) + step_timer.verify_last_event() + + step_timer.run_timer() + time.sleep(3 * step_timer.interval) + step_timer.verify_last_event() diff --git a/tests/utils/test_utils.py b/tests/utils/test_utils.py new file mode 100644 index 0000000..18026ff --- /dev/null +++ b/tests/utils/test_utils.py @@ -0,0 +1,181 @@ +# ============LICENSE_START======================================================= +# Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# + +"""test of the policy_utils""" + +import json +import re + +from policyhandler.utils import RegexCoarser, Utils + +_LOGGER = Utils.get_logger(__file__) + +def check_coarse_regex(test_name, patterns, matching_strings=None, expected_subpatterns=None): + """generic test""" + regex_coarser = RegexCoarser(patterns) + coarse_patterns = regex_coarser.get_coarse_regex_patterns(max_length=20) + _LOGGER.info("check_coarse_regex %s (%s) for [%s]", + test_name, coarse_patterns, json.dumps(regex_coarser.patterns)) + coarse_regexes = [re.compile(coarse_pattern) for coarse_pattern in coarse_patterns] + coarse_patterns_str = json.dumps(coarse_patterns) + if matching_strings: + for test_str in matching_strings: + _LOGGER.info(" match '%s' to %s (%s)", test_str, test_name, coarse_patterns_str) + assert bool(list(filter(None, [ + coarse_regex.match(test_str) for coarse_regex in coarse_regexes + ]))) + + if expected_subpatterns: + for subpattern in expected_subpatterns: + _LOGGER.info(" subpattern '%s' in %s", subpattern, coarse_patterns_str) + assert subpattern in coarse_patterns_str + +def check_combined_regex(test_name, patterns, matching_strings=None, unmatching_strings=None): + """generic test""" + regex_coarser = RegexCoarser(patterns) + combined_pattern = regex_coarser.get_combined_regex_pattern() + _LOGGER.info("check_combined_regex %s (%s) for [%s]", + test_name, combined_pattern, json.dumps(regex_coarser.patterns)) + coarse_regex = re.compile(combined_pattern) + if matching_strings: + for test_str in matching_strings: + _LOGGER.info(" match '%s' to %s (%s)", test_str, test_name, combined_pattern) + assert coarse_regex.match(test_str) + + if unmatching_strings: + for test_str in unmatching_strings: + _LOGGER.info(" not match '%s' to %s (%s)", test_str, test_name, combined_pattern) + assert not coarse_regex.match(test_str) + +def test_regex_coarser(): + """test variety of regex combinations""" + + test_data = [ + ( + "simple", + [ + "plain text", "plain pick", + "aaa (((a|b)|c)|d)", + "aaa (((a|b)|c)|d zzz", + "nested (expr[aeiou]ss(ions)?)", + "nested (expr[aeiou]ss(?:ions|ion)?)", + "^ (any expr|more|less|some|who cares)", + " (any expr|more|less|some|who cares)", + "(any expr|more|less|some|who cares)" + ], + [ + 'plain text', + 'nested exprussions', + 'nested expross', + 'aaa c', + 'aaa d', + 'who cares', + ' who cares' + ], + None, + [ + "nested .*", + "plain .*", + "aaa .*", + "(any expr|more|less|some|who cares)", + "^ (any expr|more|less|some|who cares)", + " (any expr|more|less|some|who cares)"] + ), + ( + "combination", + [ + "plain text", + "^with* modifiers?", + "cha[ra][ra]cter classes", + "^with (groups)", + "^with (groups|more groups)", + r"^with (mod+ifiers\s*|in groups{2,3}\s*)+", + "sub", + "substrings", + "su.*bstrings", + "char count{1,3}s", + "nested (expr[aeiou]ss(ions)?)", + r"escaped (\)) chars", + r"escaped ([\)\]]) chars", + r"escaped ([\)\]]){3} chars" + ], + [ + 'plain text', + 'withhh modifier', + 'character classes', + 'with groups', + 'with more groups', + 'with modddifiers in groupss modifiers in groupsss', + 'sub', + 'substrings', + 'char counttts', + 'nested exprassions', + 'nested express', + 'escaped ) chars', + 'escaped ] chars', + 'escaped ]]] chars' + ], + [ + 'plain', + 'text', + 'something with modifiers', + 'su', + 'char counttttts', + 'escaped ]] chars' + ], + [ + "nested .*", + "escaped .*", + "^wit.*", + "plain text", + "cha.*", + "su.*" + ] + ), + ( + "combined", + [ + 'foo+', + 'food', + 'football', + "ba[rh]", + "bard" + ], + [ + 'foo', + 'fooooo', + 'football', + 'food', + 'bar', + 'bah', + 'bard' + ], + [ + 'fo', + 'bat' + ], + [ + "fo.*", + "ba.*" + ] + ) + ] + + for (test_name, patterns, + matching_strings, unmatching_strings, expected_subpatterns) in test_data: + check_combined_regex(test_name, patterns, matching_strings, unmatching_strings) + check_coarse_regex(test_name, patterns, matching_strings, expected_subpatterns) diff --git a/tests/utils/test_zzz_memory.py b/tests/utils/test_zzz_memory.py new file mode 100644 index 0000000..4b934cb --- /dev/null +++ b/tests/utils/test_zzz_memory.py @@ -0,0 +1,115 @@ +# ============LICENSE_START======================================================= +# Copyright (c) 2017-2019 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# + +"""test of the package for policy-handler of DCAE-Controller""" + +import gc +import json +import time + +from policyhandler.onap.audit import Audit, AuditHttpCode, Metrics +from policyhandler.utils import Utils + +_LOGGER = Utils.get_logger(__file__) + +class Node(object): + """making the cycled objects""" + def __init__(self, name): + self.name = name + self.next = None + def __repr__(self): + return '%s(%s)' % (self.__class__.__name__, self.name) + + +def test_healthcheck(): + """test /healthcheck""" + audit = Audit(job_name="test_healthcheck", + req_message="get /healthcheck") + metrics = Metrics(aud_parent=audit, targetEntity="test_healthcheck") + metrics.metrics_start("test /healthcheck") + time.sleep(0.1) + + metrics.metrics("test /healthcheck") + health = audit.health(full=True) + audit.audit_done(result=json.dumps(health)) + + _LOGGER.info("healthcheck: %s", json.dumps(health)) + assert bool(health) + + +def test_healthcheck_with_error(): + """test /healthcheck""" + audit = Audit(job_name="test_healthcheck_with_error", + req_message="get /healthcheck") + metrics = Metrics(aud_parent=audit, targetEntity="test_healthcheck_with_error") + metrics.metrics_start("test /healthcheck") + time.sleep(0.2) + audit.error("error from test_healthcheck_with_error") + audit.fatal("fatal from test_healthcheck_with_error") + audit.debug("debug from test_healthcheck_with_error") + audit.warn("debug from test_healthcheck_with_error") + audit.info_requested("debug from test_healthcheck_with_error") + if audit.is_success(): + audit.set_http_status_code(AuditHttpCode.DATA_NOT_FOUND_OK.value) + audit.set_http_status_code(AuditHttpCode.SERVER_INTERNAL_ERROR.value) + metrics.metrics("test /healthcheck") + + health = audit.health(full=True) + audit.audit_done(result=json.dumps(health)) + + _LOGGER.info("healthcheck: %s", json.dumps(health)) + assert bool(health) + + +def test_healthcheck_with_garbage(): + """test /healthcheck""" + gc_found = gc.collect() + gc.set_debug(gc.DEBUG_LEAK) + + node1 = Node("one") + node2 = Node("two") + node3 = Node("three") + node1.next = node2 + node2.next = node3 + node3.next = node1 + node1 = node2 = node3 = None + gc_found = gc.collect() + + audit = Audit(job_name="test_healthcheck_with_garbage", + req_message="get /test_healthcheck_with_garbage") + health = audit.health(full=True) + audit.audit_done(result=json.dumps(health)) + + _LOGGER.info("test_healthcheck_with_garbage[%s]: %s", gc_found, json.dumps(health)) + assert bool(health) + assert bool(health.get("runtime", {}).get("gc", {}).get("gc_garbage")) + + _LOGGER.info("clearing up garbage...") + for obj in gc.garbage: + if isinstance(obj, Node): + _LOGGER.info("in garbage: %s 0x%x", obj, id(obj)) + obj.next = None + + gc_found = gc.collect() + _LOGGER.info("after clear test_healthcheck_with_garbage[%s]: %s", + gc_found, json.dumps(audit.health(full=True))) + + gc.set_debug(False) + + gc_found = gc.collect() + _LOGGER.info("after turned off gc debug test_healthcheck_with_garbage[%s]: %s", + gc_found, json.dumps(audit.health(full=True))) -- cgit 1.2.3-korg