diff options
author | Gary Wu <gary.i.wu@huawei.com> | 2018-09-27 10:38:50 -0700 |
---|---|---|
committer | Gary Wu <gary.i.wu@huawei.com> | 2018-09-27 10:39:43 -0700 |
commit | 9abb61ca2cea1907cab2cec312d6dca6e53a93cd (patch) | |
tree | c8ff0718b6626832efd3ff3acc48590dbd6cb64c /tests/dcaegen2/prh-testcases/resources/PrhLibrary.py | |
parent | a328a3e2e531240ea4a9ed2ce4a284af1be5e225 (diff) |
Move CSIT to integration/csit repo
To facilite branching of CSIT tests, all CSIT test
code and scripts are relocated to the integration/csit
repo.
Change-Id: I1e4c0eff44691f73f8098b3c52764107f6b8b8df
Issue-ID: INT-671
Signed-off-by: Gary Wu <gary.i.wu@huawei.com>
Diffstat (limited to 'tests/dcaegen2/prh-testcases/resources/PrhLibrary.py')
-rw-r--r-- | tests/dcaegen2/prh-testcases/resources/PrhLibrary.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/dcaegen2/prh-testcases/resources/PrhLibrary.py b/tests/dcaegen2/prh-testcases/resources/PrhLibrary.py new file mode 100644 index 00000000..6a95c71e --- /dev/null +++ b/tests/dcaegen2/prh-testcases/resources/PrhLibrary.py @@ -0,0 +1,46 @@ +import json + +import docker + + +class PrhLibrary(object): + + def __init__(self): + pass + + @staticmethod + def check_for_log(search_for): + client = docker.from_env() + container = client.containers.get('prh') + for line in container.logs(stream=True): + if search_for in line.strip(): + return True + else: + return False + + @staticmethod + def create_pnf_ready_notification(json_file): + json_to_python = json.loads(json_file) + ipv4 = json_to_python["event"]["pnfRegistrationFields"]["oamV4IpAddress"] + ipv6 = json_to_python["event"]["pnfRegistrationFields"]["oamV6IpAddress"] + correlationId = json_to_python["event"]["commonEventHeader"]["sourceName"] + str_json = '{"correlationId":"' + correlationId + '","ipaddress-v4-oam":"' + ipv4 + '","ipaddress-v6-oam":"' + ipv6 + '"}' + python_to_json = json.dumps(str_json) + return python_to_json.replace("\\", "")[1:-1] + + @staticmethod + def create_pnf_name(json_file): + json_to_python = json.loads(json_file) + correlationId = json_to_python["event"]["commonEventHeader"]["sourceName"] + return correlationId + + @staticmethod + def stop_aai(): + client = docker.from_env() + container = client.containers.get('aai_simulator') + container.stop() + + def create_invalid_notification(self, json_file): + return self.create_pnf_ready_notification(json_file).replace("\":", "\": ")\ + .replace("ipaddress-v4-oam", "oamV4IpAddress").replace("ipaddress-v6-oam", "oamV6IpAddress")\ + .replace("}", "\\n}") |