b792311ab89d1ee8be41bb45b781612e7363d5b5
[it/dep.git] / smo-install / test / pythonsdk / src / orantests / network_slicing / test_network_slicing.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 #
21 # SPDX-License-Identifier: Apache-2.0
22 # ============LICENSE_END=====================================================
23 #
24 ###
25 """Network Slicing option2 test module."""
26
27 import logging
28 import logging.config
29 import pytest
30 from onapsdk.configuration import settings
31 from preparation.aai_preparation import AaiPreparation
32 from preparation.ns_simulators import NsSimulators
33 from preparation.oof_preparation import OofPreparation
34 from preparation.sdc_preparation import SdcPreparation
35 from preparation.so_preparation import SoPreparation
36 from preparation.msb_preparation import MsbPreparation
37 from preparation.uui_preparation import UuiPreparation
38
39 logging.config.dictConfig(settings.LOG_CONFIG)
40 logger = logging.getLogger("Test Network Slicing usecase Option2")
41 sdc_template_suffix = ""
42 sdcPreparation = SdcPreparation(sdc_template_suffix)
43 soPreparation = SoPreparation()
44 aaiPreparation = AaiPreparation()
45 oofPreparation = OofPreparation()
46 msbPreparation = MsbPreparation()
47 uuiPreparation = UuiPreparation()
48 ns_sims = NsSimulators()
49
50 @pytest.fixture(scope="module", autouse=True)
51 def pre_config():
52     """Set the onap components before executing the tests."""
53     logger.info("Test class setup for Network Slicing usecase Option2")
54
55     logger.info("Start needed simulators")
56     ns_sims.start_and_wait_ns_simulators()
57
58     logger.info("PreConfig Step1: Create SDC Templates")
59     res = sdcPreparation.prepare_sdc()
60     cst_id = res[0]
61     cst_invariant_id = res[1]
62     sp_id = res[2]
63     logger.info("SDC Templates created successfully, cst_id:" + cst_id + "; sp_id:" + sp_id + "; cst_invariant_id:" + cst_invariant_id)
64
65     logger.info("PreConfig Step2: AAI Configuration")
66     aaiPreparation.prepare_aai()
67     logger.info("AAI Configured successfully")
68
69     #cst_id = "test"
70     #cst_invariant_id = "test"
71     #sp_id = "03d396bf-0246-4d48-817a-b219cc2e7a5a"
72     logger.info("PreConfig Step3: SO Configuration")
73     soPreparation.prepare_so(cst_id, sp_id)
74     logger.info("SO Configured successfully")
75
76     logger.info("PreConfig Step4: OOF Configuration - Optimization Policy Creation")
77     oofPreparation.prepare_oof(sdcPreparation.updated_name("EmbbNst_O2"), sdcPreparation.updated_name("EmbbAn_NF"), sdcPreparation.updated_name("Tn_ONAP_internal_BH"))
78     logger.info("OOF Configured successfully")
79
80     logger.info("PreConfig Step5: MSB Configuration - Create msb services")
81     msbPreparation.prepare_msb()
82     logger.info("MSB Configured successfully")
83
84     logger.info("PreConfig Step6: UUI Configuration - Update uui settings")
85     uuiPreparation.prepare_uui(cst_id, cst_invariant_id)
86     logger.info("UUI Configured successfully")
87
88     ### Cleanup code
89     yield
90     logger.info("Start to cleanup user case specific configurations")
91     ns_sims.stop_and_wait_ns_simulators()
92     #aaiPreparation.cleanup_aai()
93     #soPreparation.cleanup_so()
94     #oofPreparation.cleanup_oof()
95     #msbPreparation.cleanup_msb()
96     #uuiPreparation.cleanup_uui(cst_id, cst_invariant_id)
97     logger.info("Test Session cleanup done")
98
99 def test_network_slicing_option2():
100     """The Network Slicing option2 usecase."""
101     logger.info("Good")