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