3 # ============LICENSE_START=======================================================
4 # ORAN SMO PACKAGE - PYTHONSDK TESTS
5 # ================================================================================
6 # Copyright (C) 2021-2022 AT&T Intellectual Property. All rights
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
13 # http://www.apache.org/licenses/LICENSE-2.0
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 # ===================================================================
24 """Module called by pytest."""
28 from onapsdk.configuration import settings
29 from waiting import wait
30 from oransdk.utils.healthcheck import HealthCheck
31 from smo.smo import Smo
32 from smo.network_simulators import NetworkSimulators
35 # Set working dir as python script location
36 abspath = os.path.abspath(__file__)
37 dname = os.path.dirname(abspath)
40 logging.config.dictConfig(settings.LOG_CONFIG)
41 logger = logging.getLogger("Test Session setup")
43 network_sims = NetworkSimulators("./resources")
46 ###### Entry points of PYTEST Session
47 def pytest_sessionstart():
48 """Pytest calls it when starting a test session."""
49 logger.info("Check and wait for SMO to be running")
50 smo.wait_for_smo_to_be_running()
52 logger.info("Check and wait for for Policy to be running")
53 wait(lambda: HealthCheck.policy_component_ready(), sleep_seconds=settings.POLICY_CHECK_RETRY, timeout_seconds=settings.POLICY_CHECK_TIMEOUT, waiting_for="Policy to be ready")
54 logger.info("Check and wait for for SDNC to be running")
55 wait(lambda: HealthCheck.sdnc_component_ready(), sleep_seconds=settings.SDNC_CHECK_RETRY, timeout_seconds=settings.SDNC_CHECK_TIMEOUT, waiting_for="SDNC to be ready")
56 logger.info("Check and wait for for Clamp to be running")
57 wait(lambda: HealthCheck.clamp_component_ready(), sleep_seconds=settings.CLAMP_CHECK_RETRY, timeout_seconds=settings.CLAMP_CHECK_TIMEOUT, waiting_for="Clamp to be ready")
59 ## Just kill any simulators that could already be runnin
60 network_sims.stop_network_simulators()
61 ###### END of FIRST start, now we can start the sims for the real tests.
62 logger.info("Tests session setup is ready")