c580f56e0a749c872b1af40a658bb2f0a0e87d7c
[it/dep.git] / smo-install / test / pythonsdk / src / orantests / network_slicing / conftest.py
1 #!/usr/bin/env python3
2 ###
3 # ============LICENSE_START=======================================================
4 # ORAN SMO PACKAGE - PYTHONSDK TESTS
5 # ================================================================================
6 # Copyright (C) 2022 AT&T Intellectual Property. All rights
7 #                             reserved.
8 # ================================================================================
9 # Licensed under the Apache License, Version 2.0 (the "License");
10 # you may not use this file except in compliance with the License.
11 # You may obtain a copy of the License at
12 #
13 # http://www.apache.org/licenses/LICENSE-2.0
14 #
15 # Unless required by applicable law or agreed to in writing, software
16 # distributed under the License is distributed on an "AS IS" BASIS,
17 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 # See the License for the specific language governing permissions and
19 # limitations under the License.
20 # ============LICENSE_END============================================
21 # ===================================================================
22 #
23 ###
24 """Module called by pytest."""
25 import logging
26 import logging.config
27 from onapsdk.configuration import settings
28 from waiting import wait
29 from preparation.ns_simulators import NsSimulators
30 from oransdk.utils.healthcheck import HealthCheck
31
32 logging.config.dictConfig(settings.LOG_CONFIG)
33 logger = logging.getLogger("Test Session setup")
34
35 ns_sims = NsSimulators()
36
37 ###### Entry points of PYTEST Session
38 def pytest_sessionstart():
39     """Pytest calls it when starting a test session."""
40     logger.info("Check and wait for SMO to be running")
41     wait(lambda: HealthCheck.is_onap_up(18), sleep_seconds=settings.DEFAULT_CHECK_RETRY, timeout_seconds=settings.DEFAULT_CHECK_TIMEOUT, waiting_for="SMO to be ready")
42     logger.info("Check and wait for for Policy to be running")
43     wait(lambda: HealthCheck.policy_component_ready(), sleep_seconds=settings.DEFAULT_CHECK_RETRY, timeout_seconds=settings.DEFAULT_CHECK_TIMEOUT, waiting_for="Policy to be ready")
44     logger.info("Check and wait for for SDNC to be running")
45     wait(lambda: HealthCheck.sdnc_component_ready(), sleep_seconds=settings.DEFAULT_CHECK_RETRY, timeout_seconds=settings.DEFAULT_CHECK_TIMEOUT, waiting_for="SDNC to be ready")
46     logger.info("Check and wait for for SDC to be running")
47     wait(lambda: HealthCheck.sdc_component_ready(), sleep_seconds=settings.DEFAULT_CHECK_RETRY, timeout_seconds=settings.DEFAULT_CHECK_TIMEOUT, waiting_for="SDC to be ready")
48     logger.info("Check and wait for for AAI to be running")
49     wait(lambda: HealthCheck.aai_component_ready(), sleep_seconds=settings.DEFAULT_CHECK_RETRY, timeout_seconds=settings.DEFAULT_CHECK_TIMEOUT, waiting_for="AAI to be ready")
50     logger.info("Check and wait for for SO to be running")
51     wait(lambda: HealthCheck.so_component_ready(), sleep_seconds=settings.DEFAULT_CHECK_RETRY, timeout_seconds=settings.DEFAULT_CHECK_TIMEOUT, waiting_for="SO to be ready")
52     logger.info("Check and wait for for MSB to be running")
53     wait(lambda: HealthCheck.msb_component_ready(), sleep_seconds=settings.DEFAULT_CHECK_RETRY, timeout_seconds=settings.DEFAULT_CHECK_TIMEOUT, waiting_for="MSB to be ready")
54     logger.info("Check and wait for for OOF to be running")
55     wait(lambda: HealthCheck.oof_component_ready(), sleep_seconds=settings.DEFAULT_CHECK_RETRY, timeout_seconds=settings.DEFAULT_CHECK_TIMEOUT, waiting_for="OOF to be ready")
56
57     ## Just kill any simulators that could already be running
58     ns_sims.stop_and_wait_ns_simulators()
59
60     ###### END of FIRST start, now we can start the sims for the real tests.
61     logger.info("Tests session setup is ready")