aboutsummaryrefslogtreecommitdiffstats
path: root/tests/dcaegen2/prh-testcases/resources
diff options
context:
space:
mode:
Diffstat (limited to 'tests/dcaegen2/prh-testcases/resources')
-rw-r--r--tests/dcaegen2/prh-testcases/resources/.env3
-rw-r--r--tests/dcaegen2/prh-testcases/resources/PrhLibrary.py170
-rw-r--r--tests/dcaegen2/prh-testcases/resources/docker-compose.yml11
-rw-r--r--tests/dcaegen2/prh-testcases/resources/prh_config_library.robot43
-rw-r--r--tests/dcaegen2/prh-testcases/resources/prh_library.robot107
-rw-r--r--tests/dcaegen2/prh-testcases/resources/prh_sessions.robot25
-rw-r--r--tests/dcaegen2/prh-testcases/resources/simulator/AAI.py16
-rw-r--r--tests/dcaegen2/prh-testcases/resources/simulator/DMaaP.py65
8 files changed, 316 insertions, 124 deletions
diff --git a/tests/dcaegen2/prh-testcases/resources/.env b/tests/dcaegen2/prh-testcases/resources/.env
index a558a2e8..b1de55a9 100644
--- a/tests/dcaegen2/prh-testcases/resources/.env
+++ b/tests/dcaegen2/prh-testcases/resources/.env
@@ -1,5 +1,4 @@
-LOG_LEVEL=INFO
-PRH_LOG_LEVEL=TRACE
HOSTNAME=dcae-prh
CONSUL_HOST=consul
CONFIG_BINDING_SERVICE=cbs
+CONFIG_BINDING_SERVICE_SERVICE_PORT=10000 \ No newline at end of file
diff --git a/tests/dcaegen2/prh-testcases/resources/PrhLibrary.py b/tests/dcaegen2/prh-testcases/resources/PrhLibrary.py
index 88aeb45c..b3f5f8d9 100644
--- a/tests/dcaegen2/prh-testcases/resources/PrhLibrary.py
+++ b/tests/dcaegen2/prh-testcases/resources/PrhLibrary.py
@@ -1,5 +1,5 @@
import json
-
+import re
import docker
import time
@@ -10,84 +10,73 @@ class PrhLibrary(object):
pass
@staticmethod
- def find_log_entry(search_for):
- print (type(search_for))
+ def find_one_of_log_entryies(searched_entries):
+ print(type(searched_entries))
client = docker.from_env()
container = client.containers.get('prh')
- print ("Check for log searches for pattern: ", search_for )
+ print("Check for log searches for pattern: ", searched_entries)
for line in container.logs(stream=True):
- print ("Check for log analysis line: ", line )
- if search_for in line.strip():
+ print("Check for log analysis line: ", line )
+ for searched_entry in searched_entries:
+ if searched_entry in line.strip():
+ return True
+ else:
+ return False
+
+ @staticmethod
+ def find_log_json(prefix, json_message):
+ print("Looking for:")
+ print("Prefix: " + str(prefix))
+ print("Json: " + str(json_message))
+ try:
+ decoded_message = json.loads(json_message)
+ except json.JSONDecodeError:
+ print("Could not decode given message")
+ return False
+ pattern = re.compile(prefix + "(.*)$")
+ client = docker.from_env()
+ container = client.containers.get('prh')
+ for line in container.logs(stream=True):
+ print("Check for log analysis line: ", line )
+ if PrhLibrary.__same_json_in_log(decoded_message, line, pattern):
return True
else:
return False
@staticmethod
def create_invalid_notification(json_file):
- event = json.loads(json_file)[0]
- correlation_id = PrhLibrary.extract_correlation_id_value(event, "correlationId")
- ipv4 = PrhLibrary.extract_value_from_pnfRegistrationFields(event, "oamV4IpAddress", "oamV4IpAddress")
- ipv6 = PrhLibrary.extract_value_from_pnfRegistrationFields(event, "oamV6IpAddress", "oamV6IpAddress")
- serial_number = PrhLibrary.extract_value_from_pnfRegistrationFields(event, "serialNumber", "serialNumber")
- vendor_name = PrhLibrary.extract_value_from_pnfRegistrationFields(event, "vendorName", "vendorName")
- model_number = PrhLibrary.extract_value_from_pnfRegistrationFields(event, "modelNumber", "modelNumber")
- unit_type = PrhLibrary.extract_value_from_pnfRegistrationFields(event, "unitType", "unitType")
-
- additional_fields = PrhLibrary.extract_additional_fields(event)
-
- str_json = '{' + correlation_id + ipv4 + ipv6 + serial_number + vendor_name + model_number + unit_type + '"nfNamingCode":""' + "," + '"softwareVersion":"",' + additional_fields
- return json.dumps(str_json).replace("\\", "")[1:-1].replace("\":", "\": ").rstrip(',') + '\\n}'
+ output = {}
+ input = json.loads(json_file)
+ output["correlationId"] = PrhLibrary.__extract_correlation_id_value(input)
+ output["oamV4IpAddress"] = PrhLibrary.__extract_value_from_pnfRegistrationFields(input, "oamV4IpAddress")
+ output["oamV6IpAddress"] = PrhLibrary.__extract_value_from_pnfRegistrationFields(input, "oamV6IpAddress")
+ output["serialNumber"] = PrhLibrary.__extract_value_from_pnfRegistrationFields(input, "serialNumber")
+ output["vendorName"] = PrhLibrary.__extract_value_from_pnfRegistrationFields(input, "vendorName")
+ output["modelNumber"] = PrhLibrary.__extract_value_from_pnfRegistrationFields(input, "modelNumber")
+ output["unitType"] = PrhLibrary.__extract_value_from_pnfRegistrationFields(input, "unitType")
+ output['nfNamingCode'] = ''
+ output['softwareVersion'] = ''
+
+ output["additionalFields"] = PrhLibrary.__get_additional_fields_as_key_value_pairs(input)
+
+ return json.dumps(output)
@staticmethod
def create_pnf_ready_notification_as_pnf_ready(json_file):
- json_to_python = json.loads(json_file)
- correlation_id = PrhLibrary.extract_correlation_id_value(json_to_python, "correlationId")
-
- additional_fields = PrhLibrary.extract_additional_fields_value(json_to_python)
+ output = {}
+ input = json.loads(json_file)[0]
- str_json = '{' + correlation_id + additional_fields
+ output["correlationId"] = PrhLibrary.__extract_correlation_id_value(input)
+ output["serialNumber"] = PrhLibrary.__extract_value_from_pnfRegistrationFields(input, "serialNumber")
+ output["equip-vendor"] = PrhLibrary.__extract_value_from_pnfRegistrationFields(input, "vendorName")
+ output["equip-model"] = PrhLibrary.__extract_value_from_pnfRegistrationFields(input, "modelNumber")
+ output["equip-type"] = PrhLibrary.__extract_value_from_pnfRegistrationFields(input, "unitType")
+ output["nf-role"] = PrhLibrary.__extract_nf_role(input)
+ output["sw-version"] = ""
- return json.dumps(str_json.rstrip(',') + '}').replace("\\", "")[1:-1]
-
- @staticmethod
- def extract_additional_fields_value(content):
- fields = PrhLibrary.get_additional_fields_as_key_value_pairs(content)
- if len(fields) == 0:
- return ""
- return PrhLibrary.build_additional_fields_json(fields)
-
- @staticmethod
- def extract_additional_fields(content):
- fields = PrhLibrary.get_additional_fields_as_key_value_pairs(content)
- if fields == []:
- return '"additionalFields":null'
- return PrhLibrary.build_additional_fields_json(fields)
-
- @staticmethod
- def get_additional_fields_as_key_value_pairs(content):
- return content.get("event").get("pnfRegistrationFields").get(
- "additionalFields") if "additionalFields" in content["event"]["pnfRegistrationFields"] else []
-
- @staticmethod
- def build_additional_fields_json(fields):
- res = '"additionalFields":{'
- for f in fields:
- res += '"' + f + '":"' + fields.get(f) + '",'
- return res.rstrip(',') + '},'
-
- @staticmethod
- def extract_value_from_pnfRegistrationFields(content, name, key):
- return '"' + name + '":"' + (content.get("event").get("pnfRegistrationFields").get(key) + '",' if key in content["event"]["pnfRegistrationFields"] else '",')
-
- @staticmethod
- def extract_correlation_id_value(content, name):
- return '"' + name + '":"' + (content.get("event").get("commonEventHeader").get("sourceName") + '",' if "sourceName" in content["event"]["commonEventHeader"] else '",')
+ output["additionalFields"] = PrhLibrary.__get_additional_fields_as_key_value_pairs(input)
- @staticmethod
- def create_pnf_name(json_file):
- json_to_python = json.loads(json_file)
- correlation_id = json_to_python.get("event").get("commonEventHeader").get("sourceName") + '",' if "sourceName" in json_to_python["event"]["commonEventHeader"] else '",'
- return correlation_id
+ return json.dumps(output)
@staticmethod
def ensure_container_is_running(name):
@@ -127,4 +116,55 @@ class PrhLibrary(object):
@staticmethod
def is_in_status(client, name, status):
- return len(client.containers.list(all=True, filters={"name": "^/"+name+"$", "status": status})) == 1 \ No newline at end of file
+ return len(client.containers.list(all=True, filters={"name": "^/"+name+"$", "status": status})) == 1
+
+ @staticmethod
+ def create_pnf_name(json_file):
+ json_to_python = json.loads(json_file)
+ correlation_id = json_to_python.get("event").get("commonEventHeader").get("sourceName") + '",' if "sourceName" in json_to_python["event"]["commonEventHeader"] else '",'
+ return correlation_id
+
+ @staticmethod
+ def __get_additional_fields_as_key_value_pairs(content):
+ return content.get("event").get("pnfRegistrationFields").get(
+ "additionalFields") if "additionalFields" in content["event"]["pnfRegistrationFields"] else {}
+
+ @staticmethod
+ def __extract_value_from_pnfRegistrationFields(content, key):
+ return content["event"]["pnfRegistrationFields"][key] if key in content["event"]["pnfRegistrationFields"] else ''
+
+ @staticmethod
+ def __extract_correlation_id_value(content):
+ return content["event"]["commonEventHeader"]["sourceName"] if "sourceName" in content["event"]["commonEventHeader"] else ''
+
+ @staticmethod
+ def __extract_nf_role(content):
+ return content["event"]["commonEventHeader"]["nfNamingCode"] if "nfNamingCode" in content["event"]["commonEventHeader"] else ''
+
+ @staticmethod
+ def __same_json_in_log(decoded_message, line, pattern):
+ extracted_json = PrhLibrary.__extract_json(line, pattern)
+ if extracted_json is not None:
+ print("Found json: " + extracted_json)
+ try:
+ if json.loads(extracted_json) == decoded_message:
+ return True
+ except json.JSONDecodeError:
+ print("Could not decode")
+ return False
+
+ @staticmethod
+ def __extract_json(line, pattern):
+ full_message = PrhLibrary.__extract_full_message_from_line(line)
+ if full_message is not None:
+ match = pattern.match(full_message)
+ if match:
+ return match.group(1).replace("\\n", "\n").replace("\\t", "\t")
+ return None
+
+ @staticmethod
+ def __extract_full_message_from_line(line):
+ split = line.split("|")
+ if len(split) > 3:
+ return split[3]
+ return None
diff --git a/tests/dcaegen2/prh-testcases/resources/docker-compose.yml b/tests/dcaegen2/prh-testcases/resources/docker-compose.yml
index aba658b0..ca94dfb2 100644
--- a/tests/dcaegen2/prh-testcases/resources/docker-compose.yml
+++ b/tests/dcaegen2/prh-testcases/resources/docker-compose.yml
@@ -8,11 +8,10 @@ services:
volumes:
- ./simulator/certs:/tmp/certs
environment:
- - LOG_LEVEL
- - PRH_LOG_LEVEL
- - HOSTNAME
- - CONSUL_HOST
+ - HOSTNAME=dcae-prh
+ - CONSUL_HOST # not in use, but still required by SDK - should be removed later on
- CONFIG_BINDING_SERVICE
+ - CONFIG_BINDING_SERVICE_SERVICE_PORT
container_name: prh
depends_on:
cbs:
@@ -55,6 +54,10 @@ services:
image: consul:1.0.6
restart: on-failure
command: ["kv", "put", "-http-addr=http://consul:8500", "dcae-prh", '{
+ "cbs.updates-interval": 0,
+ "logging.level.org.onap.dcaegen2.services.prh": "debug",
+ "logging.level.org.onap.dcaegen2.services.sdk": "debug",
+ "logging.level.org.onap.dcaegen2.services.prh.controllers.AppInfoController": "off",
"dmaap.dmaapConsumerConfiguration.dmaapUserName":"admin",
"dmaap.dmaapConsumerConfiguration.dmaapUserPassword":"admin",
"dmaap.dmaapConsumerConfiguration.dmaapContentType": "application/json",
diff --git a/tests/dcaegen2/prh-testcases/resources/prh_config_library.robot b/tests/dcaegen2/prh-testcases/resources/prh_config_library.robot
new file mode 100644
index 00000000..26a62704
--- /dev/null
+++ b/tests/dcaegen2/prh-testcases/resources/prh_config_library.robot
@@ -0,0 +1,43 @@
+*** Settings ***
+Documentation Keywords related to checking and updating PRH app config based on CBS config
+Library RequestsLibrary
+Library Collections
+
+*** Keywords ***
+
+Put key-value to consul
+ [Arguments] ${key} ${value}
+ ${prh_config}= Get PRH config from consul
+ set to dictionary ${prh_config} ${key} ${value}
+ put request consul_session /v1/kv/dcae-prh json=${prh_config}
+ Get PRH config from consul prh config in consul after update
+
+Get PRH config from consul
+ [Arguments] ${logMessage}=prh config in consul
+ ${phr_config_response}= get request consul_session /v1/kv/dcae-prh?raw
+ log ${logMessage}: ${phr_config_response.content}
+ [Return] ${phr_config_response.json()}
+
+Force PRH config refresh
+ ${refresh_response}= post request prh_session /actuator/refresh
+ should be equal as integers ${refresh_response.status_code} 200
+
+Check key-value in PRH app environment
+ [Arguments] ${key} ${expected_value}
+ ${env_response}= get request prh_session /actuator/env/${key}
+ should be equal as integers ${env_response.status_code} 200
+ log ${env_response.content}
+ should be equal ${env_response.json()["property"]["value"]} ${expected_value}
+
+Set scheduled CBS updates interval
+ [Arguments] ${cbs_updates_interval}
+ Put key-value to consul cbs.updates-interval ${cbs_updates_interval}
+ Force PRH config refresh
+
+Set logging level in CBS
+ [Arguments] ${logger} ${level}
+ Put key-value to consul logging.level.${logger} ${level}
+
+Generate random value
+ ${some_random_value} evaluate random.randint(sys.maxint/10, sys.maxint) modules=random,sys
+ [Return] ${some_random_value} \ No newline at end of file
diff --git a/tests/dcaegen2/prh-testcases/resources/prh_library.robot b/tests/dcaegen2/prh-testcases/resources/prh_library.robot
index 1fae1005..3ed377c7 100644
--- a/tests/dcaegen2/prh-testcases/resources/prh_library.robot
+++ b/tests/dcaegen2/prh-testcases/resources/prh_library.robot
@@ -13,27 +13,29 @@ Verify PNF ready sent
Add PNF entry in AAI ${pnf_entry}
Set VES event in DMaaP ${ves_event}
Wait Until Keyword Succeeds 10x 3000ms Check CBS ready
- Wait Until Keyword Succeeds 10x 3000ms Check recorded PNF_READY notification ${expected_pnf_ready_event}
+ Wait Until Keyword Succeeds 10x 3000ms Check created PNF_READY notification ${expected_pnf_ready_event}
Verify PNF ready sent and logical link created
[Arguments] ${test_case_directory}
${expected_logical_link}= Get Data From File ${test_case_directory}/expected-logical-link.json
Verify PNF ready sent ${test_case_directory}
- Check recorded Logical Link ${expected_logical_link}
+ Check created Logical Link ${expected_logical_link}
Verify event with missing required field is logged
[Arguments] ${test_case_directory}
${invalid_ves_event}= Get Data From File ${test_case_directory}/invalid-ves-event.json
Set VES event in DMaaP ${invalid_ves_event}
- ${error_msg}= Create event parsing error ${invalid_ves_event}
- Wait Until Keyword Succeeds 10x 3000ms Check PRH log ${error_msg}
+ Log Invalid ves event: ${invalid_ves_event}
+ ${notification}= Create invalid notification ${invalid_ves_event}
+ ${error_msg}= Set Variable Incorrect json, consumerDmaapModel can not be created:
+ Wait Until Keyword Succeeds 10x 3000ms Check PRH json log ${error_msg} ${notification}
Verify incorrect JSON event is logged
[Timeout] 60s
[Arguments] ${test_case_directory}
${invalid_ves_event}= Get Data From File ${test_case_directory}/invalid-ves-event.json
Set VES event in DMaaP ${invalid_ves_event}
- Wait Until Keyword Succeeds 10x 3000ms Check PRH log |com.google.gson.JsonSyntaxException: Expected a com.google.gson.JsonArray
+ Check PRH log |WARN |Incorrect json, consumerDmaapModel can not be created:
Verify missing AAI record is logged
[Timeout] 100s
@@ -42,8 +44,7 @@ Verify missing AAI record is logged
${ves_event}= Get Data From File ${test_case_directory}/ves-event.json
Add PNF entry in AAI ${incorrect_aai_entry}
Set VES event in DMaaP ${ves_event}
- Wait Until Keyword Succeeds 10x 3000ms Check PRH log |AAIProducerTask exception has been registered
- Wait Until Keyword Succeeds 10x 3000ms Check PRH log |Chain of tasks have been aborted due to errors in PRH workflow
+ Check PRH log Request failed for URL 'https://aai:3334/aai/v12/network/pnfs/pnf/NOK6061ZW8'. Response code: 404 Not Found
Verify AAI not responding is logged
[Timeout] 100s
@@ -51,30 +52,56 @@ Verify AAI not responding is logged
${ves_event}= Get Data From File ${test_case_directory}/ves-event.json
Ensure Container Is Exited aai_simulator
Set VES event in DMaaP ${ves_event}
- Wait Until Keyword Succeeds 10x 3000ms Check PRH log java.net.UnknownHostException: aai
+ Check PRH log connection timed out: aai Host is unreachable: aai
Ensure Container Is Running aai_simulator
+Verify PNF re registration
+ [Timeout] 500s
+ [Arguments] ${test_case_directory}
+ ${aai_entry}= Get Data From File ${test_case_directory}/aai-entry.json
+ Log PNF Re-registration: AAI entry for AAI Simulator ${aai_entry}
+ Add PNF entry in AAI ${aai_entry}
+ ${service_instance}= Get Data From File ${test_case_directory}/aai-entry-service-instance.json
+ Add service instance entry in AAI ${service_instance}
+
+ ${ves_event}= Get Data From File ${test_case_directory}/ves-event.json
+ Set VES event in DMaaP ${ves_event}
+ ${expected_pnf_update_event}= Get Data From File ${test_case_directory}/expected-pnf-update-event.json
+ Wait Until Keyword Succeeds 10x 3000ms Check created PNF_UPDATE notification ${expected_pnf_update_event}
+
Check CBS ready
- ${resp}= Get Request ${consul_setup_session} /v1/catalog/services
+ ${resp}= Get Request ${consul_session} /v1/catalog/services
Should Be Equal As Strings ${resp.status_code} 200
Log Service Catalog response: ${resp.content}
Dictionary Should Contain Key ${resp.json()} cbs |Consul service catalog should contain CBS entry
-Check recorded PNF_READY notification
+Check created PNF_READY notification
[Arguments] ${expected_event_pnf_ready_in_dpaap}
- ${resp}= Get Request ${dmaap_setup_session} /setup/pnf_ready headers=${suite_headers}
+ ${resp}= Get Request ${dmaap_session} /verify/pnf_ready headers=${suite_headers}
Should Be Equal As Strings ${resp.status_code} 200
Should Be Equal As JSON ${resp.content} ${expected_event_pnf_ready_in_dpaap}
-Check recorded Logical Link
+Check created PNF_UPDATE notification
+ [Arguments] ${expected_event_pnf_update_in_dpaap}
+ ${resp}= Get Request ${dmaap_session} /verify/pnf_update headers=${suite_headers}
+ Log Response from DMaaP: ${resp.content}
+ Should Be Equal As Strings ${resp.status_code} 200
+ #Should Be Equal As JSON ${resp.content} ${expected_event_pnf_ready_in_dpaap}
+
+Check created Logical Link
[Arguments] ${expected_logical_link_in_aai}
- ${resp}= Get Request ${aai_setup_session} /setup/created_logical_link headers=${suite_headers}
+ ${resp}= Get Request ${aai_session} /verify/created_logical_link headers=${suite_headers}
Should Be Equal As Strings ${resp.status_code} 200
Should Be Equal As JSON ${resp.content} ${expected_logical_link_in_aai}
Check PRH log
- [Arguments] ${log_entry}
- ${found}= Find log entry ${log_entry}
+ [Arguments] @{log_entries}
+ ${found}= Find one of log entryies ${log_entries}
+ Should Be True ${found}
+
+Check PRH json log
+ [Arguments] ${prefix} ${json}
+ ${found}= Find log json ${prefix} ${json}
Should Be True ${found}
Create event parsing error
@@ -87,12 +114,19 @@ Add PNF entry in AAI
[Arguments] ${pnf_entry}
${headers}= Create Dictionary Accept=application/json Content-Type=application/json
Log AAI url ${AAI_SIMULATOR_SETUP_URL}
- ${resp}= Put Request ${aai_setup_session} /setup/add_pnf_entry headers=${suite_headers} data=${pnf_entry}
+ ${resp}= Put Request ${aai_session} /setup/add_pnf_entry headers=${suite_headers} data=${pnf_entry}
+ Should Be Equal As Strings ${resp.status_code} 200
+
+Add service instance entry in AAI
+ [Arguments] ${aai_service_instance}
+ ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
+ Log AAI url ${AAI_SIMULATOR_SETUP_URL}
+ ${resp}= Put Request ${aai_session} /setup/add_service_instace headers=${suite_headers} data=${aai_service_instance}
Should Be Equal As Strings ${resp.status_code} 200
Set VES event in DMaaP
[Arguments] ${ves_event}
- ${resp}= Put Request ${dmaap_setup_session} /setup/ves_event headers=${suite_headers} data=${ves_event}
+ ${resp}= Put Request ${dmaap_session} /setup/ves_event headers=${suite_headers} data=${ves_event}
Should Be Equal As Strings ${resp.status_code} 200
Should Be Equal As JSON
@@ -103,26 +137,39 @@ Should Be Equal As JSON
${actual_json}= Evaluate json.loads("""${actual}""") json
Should Be Equal ${actual_json} ${expected_json}
-Create sessions
- Create Session dmaap_setup_session ${DMAAP_SIMULATOR_SETUP_URL}
- Set Suite Variable ${dmaap_setup_session} dmaap_setup_session
- Create Session aai_setup_session ${AAI_SIMULATOR_SETUP_URL}
- Set Suite Variable ${aai_setup_session} aai_setup_session
- Create Session consul_setup_session ${CONSUL_SETUP_URL}
- Set Suite Variable ${consul_setup_session} consul_setup_session
-
Reset Simulators
Reset AAI simulator
Reset DMaaP simulator
Reset AAI simulator
- ${resp}= Post Request ${aai_setup_session} /reset
+ ${resp}= Post Request ${aai_session} /reset
Should Be Equal As Strings ${resp.status_code} 200
Reset DMaaP simulator
- ${resp}= Post Request ${dmaap_setup_session} /reset
+ ${resp}= Post Request ${dmaap_session} /reset
Should Be Equal As Strings ${resp.status_code} 200
-Create headers
- ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
- Set Suite Variable ${suite_headers} ${headers}
+
+Verify change logging level
+ ${logger}= Set Variable org.onap.dcaegen2.services.prh.controllers.AppInfoController
+ Change logging level ${logger} TRACE
+ Verify logging level ${logger} TRACE
+ Verify logs with heartbeat
+ [Teardown] Change logging level ${logger} INFO
+
+Change logging level
+ [Arguments] ${logger} ${log_level}
+ ${request_body}= Create Dictionary configuredLevel=${log_level}
+ ${resp}= Post Request prh_session /actuator/loggers/${logger} json=${request_body}
+ Should Be Equal As Integers ${resp.status_code} 204
+
+Verify logging level
+ [Arguments] ${logger} ${expected_log_level}
+ ${resp}= Get Request prh_session /actuator/loggers/${logger}
+ Should Be Equal As Integers ${resp.status_code} 200
+ Log ${resp.content}
+ Should Be Equal As Strings ${resp.json()["configuredLevel"]} ${expected_log_level} ignore_case=true
+
+Verify logs with heartbeat
+ Get Request prh_session /heartbeat
+ Check PRH log Heartbeat request received \ No newline at end of file
diff --git a/tests/dcaegen2/prh-testcases/resources/prh_sessions.robot b/tests/dcaegen2/prh-testcases/resources/prh_sessions.robot
new file mode 100644
index 00000000..2fadbbae
--- /dev/null
+++ b/tests/dcaegen2/prh-testcases/resources/prh_sessions.robot
@@ -0,0 +1,25 @@
+*** Settings ***
+Library RequestsLibrary
+Library Collections
+
+*** Variables ***
+${DMAAP_SIMULATOR_SETUP_URL} http://${DMAAP_SIMULATOR_SETUP}
+${AAI_SIMULATOR_SETUP_URL} http://${AAI_SIMULATOR_SETUP}
+${CONSUL_SETUP_URL} http://${CONSUL_SETUP}
+${PRH_SETUP_URL} http://${PRH_SETUP}
+
+*** Keywords ***
+Create sessions
+ Create Session dmaap_session ${DMAAP_SIMULATOR_SETUP_URL}
+ Set Suite Variable ${dmaap_session} dmaap_session
+ Create Session aai_session ${AAI_SIMULATOR_SETUP_URL}
+ Set Suite Variable ${aai_session} aai_session
+ Create Session consul_session ${CONSUL_SETUP_URL}
+ Set Suite Variable ${consul_session} consul_session
+ Create Session prh_session ${PRH_SETUP_URL}
+ Set Suite Variable ${prh_session} prh_session
+
+
+Create headers
+ ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
+ Set Suite Variable ${suite_headers} ${headers} \ No newline at end of file
diff --git a/tests/dcaegen2/prh-testcases/resources/simulator/AAI.py b/tests/dcaegen2/prh-testcases/resources/simulator/AAI.py
index ff368034..f6d3b1f6 100644
--- a/tests/dcaegen2/prh-testcases/resources/simulator/AAI.py
+++ b/tests/dcaegen2/prh-testcases/resources/simulator/AAI.py
@@ -22,6 +22,7 @@ AAI_RESOURCE_NOT_FOUND = b'{}'
pnf_entries = {}
patched_pnf = AAI_RESOURCE_NOT_FOUND
created_logical_link = AAI_RESOURCE_NOT_FOUND
+service_instance = AAI_RESOURCE_NOT_FOUND
class AAISetup(BaseHTTPRequestHandler):
@@ -30,7 +31,7 @@ class AAISetup(BaseHTTPRequestHandler):
if re.search('/setup/patched_pnf', self.path):
httpServerLib.set_response_200_ok(self, payload = patched_pnf)
logger.debug('AAISetup GET /setup/patched_pnf -> 200 OK')
- elif re.search('/setup/created_logical_link', self.path):
+ elif re.search('/verify/created_logical_link', self.path):
httpServerLib.set_response_200_ok(self, payload = created_logical_link)
logger.debug('AAISetup GET /setup/created_logical_link -> 200 OK')
else:
@@ -53,6 +54,13 @@ class AAISetup(BaseHTTPRequestHandler):
httpServerLib.set_response_200_ok(self)
logger.debug('AAISetup PUT /setup/add_pnf_entry [' + pnf_name + '] -> 200 OK')
+ elif re.search('/setup/add_service_instace', self.path):
+ service_instance_payload = httpServerLib.get_payload(self)
+ global service_instance
+ service_instance = json.loads(service_instance_payload)
+ httpServerLib.set_response_200_ok(self)
+ logger.debug('AAISetup PUT /setup/add_service_instace -> 200 OK')
+
elif re.search('/set_pnf', self.path):
pnf_name = httpServerLib.get_payload(self).decode()
pnf_entries[pnf_name] = AAI_RESOURCE_NOT_FOUND
@@ -70,9 +78,11 @@ class AAISetup(BaseHTTPRequestHandler):
global pnf_entries
global patched_pnf
global created_logical_link
+ global service_instance
pnf_entries = {}
patched_pnf = AAI_RESOURCE_NOT_FOUND
created_logical_link = AAI_RESOURCE_NOT_FOUND
+ service_instance = AAI_RESOURCE_NOT_FOUND
httpServerLib.set_response_200_ok(self)
logger.debug('AAISetup POST /reset -> 200 OK')
@@ -95,6 +105,9 @@ class AAIHandler(BaseHTTPRequestHandler):
else:
httpServerLib.set_response_404_not_found(self)
logger.info('AAIHandler GET /aai/v12/network/pnfs/pnf/' + pnf_name + ' -> 404 Not found, actual entries: ' + str(pnf_entries.keys()))
+ elif re.search('aai/v12/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vFW/service-instances/service-instance/bbs_service', self.path):
+ httpServerLib.set_response_200_ok(self, payload = service_instance)
+ logger.debug('AAIHandler GET aai/v12/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vFW/service-instances/service-instance/bbs_service -> 200 OK')
else:
httpServerLib.set_response_404_not_found(self)
logger.info('AAIHandler GET ' + self.path + ' -> 404 Not found')
@@ -142,7 +155,6 @@ class AAIHandler(BaseHTTPRequestHandler):
def _main_(handler_class=AAIHandler, protocol="HTTP/1.0"):
handler_class.protocol_version = protocol
- httpServerLib.start_http_endpoint(3333, AAIHandler)
httpServerLib.start_https_endpoint(3334, AAIHandler, keyfile="certs/aai.key", certfile="certs/aai.crt", ca_certs="certs/root.crt")
httpServerLib.start_http_endpoint(3335, AAISetup)
while 1:
diff --git a/tests/dcaegen2/prh-testcases/resources/simulator/DMaaP.py b/tests/dcaegen2/prh-testcases/resources/simulator/DMaaP.py
index ce9858d6..5ec601f6 100644
--- a/tests/dcaegen2/prh-testcases/resources/simulator/DMaaP.py
+++ b/tests/dcaegen2/prh-testcases/resources/simulator/DMaaP.py
@@ -2,6 +2,7 @@ import logging
import re
import sys
import time
+import json
from http.server import BaseHTTPRequestHandler
import httpServerLib
@@ -17,17 +18,22 @@ logger = logging.getLogger('DMaaP-simulator-logger')
DMAAP_EMPTY = b'[]'
-ves_event = DMAAP_EMPTY
-captured_prh_event = DMAAP_EMPTY
+event_ves = DMAAP_EMPTY
+event_pnf_ready = DMAAP_EMPTY
+event_pnf_update = DMAAP_EMPTY
class DmaapSetup(BaseHTTPRequestHandler):
def do_GET(self):
try:
- if re.search('/setup/pnf_ready', self.path):
- global captured_prh_event
- httpServerLib.set_response_200_ok(self, payload = captured_prh_event)
- logger.debug('DmaapSetup GET /setup/pnf_ready -> 200 OK')
+ if re.search('/verify/pnf_ready', self.path):
+ global event_pnf_ready
+ httpServerLib.set_response_200_ok(self, payload = event_pnf_ready)
+ logger.debug('DmaapSetup GET /verify/pnf_ready -> 200 OK')
+ elif re.search('/verify/pnf_update', self.path):
+ global event_pnf_update
+ httpServerLib.set_response_200_ok(self, payload = event_pnf_update)
+ logger.debug('DmaapSetup GET /verify/pnf_ready -> 200 OK')
else:
httpServerLib.set_response_404_not_found(self)
logger.info('DmaapSetup GET ' + self.path + ' -> 404 Not found')
@@ -38,10 +44,10 @@ class DmaapSetup(BaseHTTPRequestHandler):
def do_PUT(self):
try:
if re.search('/setup/ves_event', self.path):
- global ves_event
- ves_event = httpServerLib.get_payload(self)
+ global event_ves
+ event_ves = httpServerLib.get_payload(self)
httpServerLib.set_response_200_ok(self)
- logger.debug('DmaapSetup PUT /setup/ves_event -> 200 OK, content: ' + ves_event.decode("utf-8"))
+ logger.debug('DmaapSetup PUT /setup/ves_event -> 200 OK, content: ' + event_ves.decode("utf-8"))
else:
httpServerLib.set_response_404_not_found(self)
logger.info('DmaapSetup PUT ' + self.path + ' -> 404 Not found')
@@ -52,10 +58,12 @@ class DmaapSetup(BaseHTTPRequestHandler):
def do_POST(self):
try:
if re.search('/reset', self.path):
- global ves_event
- global captured_prh_event
- ves_event = DMAAP_EMPTY
- captured_prh_event = DMAAP_EMPTY
+ global event_ves
+ global event_pnf_ready
+ global event_pnf_update
+ event_ves = DMAAP_EMPTY
+ event_pnf_ready = DMAAP_EMPTY
+ event_pnf_update = DMAAP_EMPTY
httpServerLib.set_response_200_ok(self)
logger.debug('DmaapSetup POST /reset -> 200 OK')
else:
@@ -70,11 +78,17 @@ class DMaaPHandler(BaseHTTPRequestHandler):
def do_POST(self):
try:
if re.search('/events/unauthenticated.PNF_READY', self.path):
- global captured_prh_event
- captured_prh_event = httpServerLib.get_payload(self)
+ global event_pnf_ready
+ event_pnf_ready = httpServerLib.get_payload(self)
httpServerLib.set_response_200_ok(self)
logger.debug('DMaaPHandler POST /events/unauthenticated.PNF_READY -> 200, content: '
- + captured_prh_event.decode("utf-8"))
+ + event_pnf_ready.decode("utf-8"))
+ elif re.search('/events/unauthenticated.PNF_UPDATE', self.path):
+ global event_pnf_update
+ event_pnf_update = httpServerLib.get_payload(self)
+ httpServerLib.set_response_200_ok(self)
+ logger.debug('DMaaPHandler POST /events/unauthenticated.PNF_READY -> 200, content: '
+ + event_pnf_update.decode("utf-8"))
else:
httpServerLib.set_response_404_not_found(self)
logger.info('DMaaPHandler POST ' + self.path + ' -> 404 Not found')
@@ -85,12 +99,12 @@ class DMaaPHandler(BaseHTTPRequestHandler):
def do_GET(self):
try:
if re.search('/events/unauthenticated.VES_PNFREG_OUTPUT/OpenDCAE-c12/c12', self.path):
- global ves_event
- httpServerLib.set_response_200_ok(self, payload = ves_event)
+ global event_ves
+ httpServerLib.set_response_200_ok(self, payload=self.pack_event_json_as_quoted_string_into_array(event_ves))
logger.debug(
'DMaaPHandler GET /events/unauthenticated.VES_PNFREG_OUTPUT/OpenDcae-c12/c12 -> 200, content: '
- + ves_event.decode("utf-8"))
- ves_event = DMAAP_EMPTY
+ + event_ves.decode("utf-8"))
+ event_ves = DMAAP_EMPTY
logger.debug('DMaaPHandler GET /events/unauthenticated.VES_PNFREG_OUTPUT/OpenDcae-c12/c12 -> 200')
else:
httpServerLib.set_response_404_not_found(self)
@@ -99,9 +113,18 @@ class DMaaPHandler(BaseHTTPRequestHandler):
logger.error(e)
httpServerLib.set_response_500_server_error(self)
+ def pack_event_json_as_quoted_string_into_array(self, event):
+ if event == DMAAP_EMPTY:
+ return DMAAP_EMPTY
+ else:
+ decoded = event_ves.decode("utf-8")
+ packed = '[' + json.dumps(decoded) + ']'
+ logger.info("prepared response: " + packed)
+ return packed.encode()
+
+
def _main_(handler_class=DMaaPHandler, protocol="HTTP/1.0"):
handler_class.protocol_version = protocol
- httpServerLib.start_http_endpoint(2222, DMaaPHandler)
httpServerLib.start_https_endpoint(2223, DMaaPHandler, keyfile="certs/dmaap-mr.key", certfile="certs/dmaap-mr.crt", ca_certs="certs/root.crt")
httpServerLib.start_http_endpoint(2224, DmaapSetup)
while 1: