Add Onap Jakarta support
[it/dep.git] / smo-install / test / pythonsdk / src / orantests / smo / dmaap.py
1 #!/usr/bin/env python3
2 ###
3 # ============LICENSE_START=======================================================
4 # ORAN SMO PACKAGE - PYTHONSDK TESTS
5 # ================================================================================
6 # Copyright (C) 2021-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
25 """Dmaap utils module."""
26 import logging
27 import logging.config
28 from onapsdk.configuration import settings
29 from waiting import wait
30 from oransdk.dmaap.dmaap import OranDmaap
31
32 logging.config.dictConfig(settings.LOG_CONFIG)
33 logger = logging.getLogger("DMaap utils")
34 dmaap = OranDmaap()
35
36 class DmaapUtils():
37     """Can be used to have dmaap utils methods."""
38
39     @classmethod
40     def clean_dmaap(cls, dmaap_group, dmaap_user):
41         """Clean DMAAP useful topics."""
42         dmaap.create_topic(settings.DMAAP_TOPIC_FAULT_JSON)
43         dmaap.create_topic(settings.DMAAP_TOPIC_PNFREG_JSON)
44         # Purge the FAULT TOPIC
45         wait(lambda: (dmaap.get_message_from_topic(settings.DMAAP_TOPIC_FAULT, 5000, dmaap_group, dmaap_user).json() == []), sleep_seconds=10, timeout_seconds=60, waiting_for="DMaap topic SEC_FAULT_OUTPUT to be empty")
46         wait(lambda: (dmaap.get_message_from_topic(settings.DMAAP_TOPIC_PNFREG, 5000, dmaap_group, dmaap_user).json() == []), sleep_seconds=10, timeout_seconds=60, waiting_for="DMaap topic unauthenticated.VES_PNFREG_OUTPUT to be empty")