aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMariusz Wagner <mariusz.wagner@nokia.com>2018-09-14 14:24:02 +0200
committerMariusz Wagner <mariusz.wagner@nokia.com>2018-09-14 14:24:02 +0200
commit831baffde96cd7f644375a2e24f3c39fdd2b7616 (patch)
tree69d5a90cbac279c40afd4bffc928dffebda6f8eb /test
parent856c8b960d127d1a425c70070c92406f9239c831 (diff)
Added keyword to common.robot
- add new keyword to read files in common.robot - fix one keyword in common.robot - used new keyword in PRH suite - use new keyword in dcaegen2 suite Issue-ID: INT-661 Change-Id: I36cd2d5b82a20938a7b0775c9792dc2364a21922 Signed-off-by: Mariusz Wagner <mariusz.wagner@nokia.com>
Diffstat (limited to 'test')
-rw-r--r--test/csit/tests/common.robot15
-rw-r--r--test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_IPV4.json11
-rw-r--r--test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_IPV6.json11
-rw-r--r--test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_all_fields.json11
-rw-r--r--test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_IPV4_and_IPV6.json11
-rw-r--r--test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName.json11
-rw-r--r--test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName_IPV4_and_IPV6.json11
-rw-r--r--test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName_and_IPV4.json11
-rw-r--r--test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName_and_IPV6.json11
-rw-r--r--test/csit/tests/dcaegen2/prh-testcases/assets/json_events/not_json_format.json11
-rw-r--r--test/csit/tests/dcaegen2/prh-testcases/prh_tests.robot38
-rw-r--r--test/csit/tests/dcaegen2/prh-testcases/resources/prh_library.robot19
-rw-r--r--test/csit/tests/dcaegen2/testcases/dcae_ves.robot66
-rw-r--r--test/csit/tests/dcaegen2/testcases/resources/DMaaP.py112
-rw-r--r--test/csit/tests/dcaegen2/testcases/resources/DcaeLibrary.py86
-rw-r--r--test/csit/tests/dcaegen2/testcases/resources/DcaeVariables.py9
-rw-r--r--test/csit/tests/dcaegen2/testcases/resources/dcae_keywords.robot76
-rw-r--r--test/csit/tests/dcaegen2/testcases/resources/dcae_properties.robot3
18 files changed, 332 insertions, 191 deletions
diff --git a/test/csit/tests/common.robot b/test/csit/tests/common.robot
index 944be6b9f..8af66a5df 100644
--- a/test/csit/tests/common.robot
+++ b/test/csit/tests/common.robot
@@ -1,22 +1,29 @@
#Robot functions that will be shared also with other tests
+*** Settings ***
+Library OperatingSystem
*** Keywords ***
json_from_file
#Robot function to extract the json object from a file
[Arguments] ${file_path}
- ${json_file}= Get file ${file_path}
+ ${json_file}= Get File ${file_path}
${json_object}= Evaluate json.loads('''${json_file}''') json
- [return] ${json_object}
+ [Return] ${json_object}
string_from_json
#Robot function to transform the json object to a string
[Arguments] ${json_value}
${json_string}= Stringify Json ${json_value}
- [return] ${json_string}
+ [Return] ${json_string}
random_ip
#Robot function to generate a random IP
[Arguments]
${numbers}= Evaluate random.sample([x for x in range(1, 256)], 4) random
${generated_ip}= Catenate ${numbers[0]}.${numbers[1]}.${numbers[2]}.${numbers[3]}
- [return] ${generated_ip} \ No newline at end of file
+ [Return] ${generated_ip}
+
+Get Data From File
+ [Arguments] ${file}
+ ${data}= Get File ${file}
+ [Return] ${data}
diff --git a/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_IPV4.json b/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_IPV4.json
new file mode 100644
index 000000000..2ffe356fc
--- /dev/null
+++ b/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_IPV4.json
@@ -0,0 +1,11 @@
+{
+ "event": {
+ "commonEventHeader": {
+ "sourceName":"NOK6061ZW2"
+ },
+ "pnfRegistrationFields": {
+ "oamV4IpAddress":"10.17.123.234",
+ "oamV6IpAddress":""
+ }
+ }
+}
diff --git a/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_IPV6.json b/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_IPV6.json
new file mode 100644
index 000000000..c4a0e7271
--- /dev/null
+++ b/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_IPV6.json
@@ -0,0 +1,11 @@
+{
+ "event": {
+ "commonEventHeader": {
+ "sourceName":"ERI6061ZW3"
+ },
+ "pnfRegistrationFields": {
+ "oamV4IpAddress":"",
+ "oamV6IpAddress":"2001:0db8:85a3:0000:0000:8b2e:0370:7334"
+ }
+ }
+}
diff --git a/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_all_fields.json b/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_all_fields.json
new file mode 100644
index 000000000..16963e1bc
--- /dev/null
+++ b/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_all_fields.json
@@ -0,0 +1,11 @@
+{
+ "event": {
+ "commonEventHeader": {
+ "sourceName":"NOK6061ZW1"
+ },
+ "pnfRegistrationFields": {
+ "oamV4IpAddress":"10.16.123.234",
+ "oamV6IpAddress":"2001:0db8:85a3:0000:0000:8a2e:0370:7334"
+ }
+ }
+}
diff --git a/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_IPV4_and_IPV6.json b/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_IPV4_and_IPV6.json
new file mode 100644
index 000000000..1e3afa9df
--- /dev/null
+++ b/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_IPV4_and_IPV6.json
@@ -0,0 +1,11 @@
+{
+ "event": {
+ "commonEventHeader": {
+ "sourceName":"NOK6061ZW4"
+ },
+ "pnfRegistrationFields": {
+ "oamV4IpAddress":"",
+ "oamV6IpAddress":""
+ }
+ }
+}
diff --git a/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName.json b/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName.json
new file mode 100644
index 000000000..126987fd6
--- /dev/null
+++ b/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName.json
@@ -0,0 +1,11 @@
+{
+ "event": {
+ "commonEventHeader": {
+ "sourceName":""
+ },
+ "pnfRegistrationFields": {
+ "oamV4IpAddress":"10.18.123.234",
+ "oamV6IpAddress":"2001:0db8:85a3:0000:0000:8a2a:0370:7334"
+ }
+ }
+}
diff --git a/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName_IPV4_and_IPV6.json b/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName_IPV4_and_IPV6.json
new file mode 100644
index 000000000..de1f576c8
--- /dev/null
+++ b/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName_IPV4_and_IPV6.json
@@ -0,0 +1,11 @@
+{
+ "event": {
+ "commonEventHeader": {
+ "sourceName":""
+ },
+ "pnfRegistrationFields": {
+ "oamV4IpAddress":"",
+ "oamV6IpAddress":""
+ }
+ }
+}
diff --git a/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName_and_IPV4.json b/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName_and_IPV4.json
new file mode 100644
index 000000000..4838f1b01
--- /dev/null
+++ b/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName_and_IPV4.json
@@ -0,0 +1,11 @@
+{
+ "event": {
+ "commonEventHeader": {
+ "sourceName":""
+ },
+ "pnfRegistrationFields": {
+ "oamV4IpAddress":"",
+ "oamV6IpAddress":"2001:0db8:85a3:0000:0000:8b2f:0370:7334"
+ }
+ }
+}
diff --git a/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName_and_IPV6.json b/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName_and_IPV6.json
new file mode 100644
index 000000000..04ab7cebd
--- /dev/null
+++ b/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName_and_IPV6.json
@@ -0,0 +1,11 @@
+{
+ "event": {
+ "commonEventHeader": {
+ "sourceName":""
+ },
+ "pnfRegistrationFields": {
+ "oamV4IpAddress":"10.17.163.234",
+ "oamV6IpAddress":""
+ }
+ }
+}
diff --git a/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/not_json_format.json b/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/not_json_format.json
new file mode 100644
index 000000000..c87e188ff
--- /dev/null
+++ b/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/not_json_format.json
@@ -0,0 +1,11 @@
+{
+ "event": {
+ "commonEventHeader": {
+ "sourceName":"NOK6061ZW1"
+ },
+ "pnfRegistrationFields": {
+ "oamV4IpAddress":"10.16.123.234",
+ "oamV6IpAddress":"2001:0db8:85a3:0000:0000:8a2e:0370:7334",
+ }
+ }
+}
diff --git a/test/csit/tests/dcaegen2/prh-testcases/prh_tests.robot b/test/csit/tests/dcaegen2/prh-testcases/prh_tests.robot
index 5150a4b35..23d86663a 100644
--- a/test/csit/tests/dcaegen2/prh-testcases/prh_tests.robot
+++ b/test/csit/tests/dcaegen2/prh-testcases/prh_tests.robot
@@ -1,17 +1,24 @@
*** Settings ***
Documentation Integration tests for PRH.
... PRH receive events from DMaaP and produce or not PNF_READY notification depends on required fields in received event.
-Suite Setup Run keywords Create header
-... Create sessions
+Suite Setup Run keywords Create header Create sessions
Library resources/PrhLibrary.py
Resource resources/prh_library.robot
+Resource ../../common.robot
*** Variables ***
${DMAAP_SIMULATOR_URL} http://${DMAAP_SIMULATOR}
${AAI_SIMULATOR_URL} http://${AAI_SIMULATOR}
${PRH_URL} http://${PRH}
-${EVENT_WITH_ALL_VALID_REQUIRED_FIELDS} {"event": {"commonEventHeader": {"sourceName":"NOK6061ZW1"}, "pnfRegistrationFields": {"oamV4IpAddress":"10.16.123.234", "oamV6IpAddress":"2001:0db8:85a3:0000:0000:8a2e:0370:7334"}}}
-${Not_json_format} ""
+${EVENT_WITH_ALL_VALID_REQUIRED_FIELDS} %{WORKSPACE}/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_all_fields.json
+${EVENT_WITH_IPV4} %{WORKSPACE}/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_IPV4.json
+${EVENT_WITH_IPV6} %{WORKSPACE}/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_IPV6.json
+${EVENT_WITH_MISSING_IPV4_AND_IPV6} %{WORKSPACE}/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_IPV4_and_IPV6.json
+${EVENT_WITH_MISSING_SOURCENAME} %{WORKSPACE}/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName.json
+${EVENT_WITH_MISSING_SOURCENAME_AND_IPV4} %{WORKSPACE}/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName_and_IPV4.json
+${EVENT_WITH_MISSING_SOURCENAME_AND_IPV6} %{WORKSPACE}/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName_and_IPV6.json
+${EVENT_WITH_MISSING_SOURCENAME_IPV4_AND_IPV6} %{WORKSPACE}/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName_IPV4_and_IPV6.json
+${Not_json_format} %{WORKSPACE}/test/csit/tests/dcaegen2/prh-testcases/assets/json_events/not_json_format.json
*** Test Cases ***
Valid DMaaP event can be converted to PNF_READY notification
@@ -19,37 +26,40 @@ Valid DMaaP event can be converted to PNF_READY notification
[Tags] PRH Valid event
[Template] Valid event processing
${EVENT_WITH_ALL_VALID_REQUIRED_FIELDS}
- {"event": {"commonEventHeader": {"sourceName":"NOK6061ZW2"}, "pnfRegistrationFields": {"oamV4IpAddress":"10.17.123.234", "oamV6IpAddress":""}}}
- {"event": {"commonEventHeader": {"sourceName":"ERI6061ZW3"}, "pnfRegistrationFields": {"oamV4IpAddress":"", "oamV6IpAddress":"2001:0db8:85a3:0000:0000:8b2e:0370:7334"}}}
+ ${EVENT_WITH_IPV4}
+ ${EVENT_WITH_IPV6}
Invalid DMaaP event cannot be converted to PNF_READY notification
[Documentation] PRH get invalid event from DMaaP with missing required fields - PRH does not produce PNF_READY notification
[Tags] PRH Invalid event
[Template] Invalid event processing
- {"event": {"commonEventHeader": {"sourceName":"NOK6061ZW4"}, "pnfRegistrationFields": {"oamV4IpAddress":"", "oamV6IpAddress":""}}}
- {"event": {"commonEventHeader": {"sourceName":""}, "pnfRegistrationFields": {"oamV4IpAddress":"10.18.123.234", "oamV6IpAddress":"2001:0db8:85a3:0000:0000:8a2a:0370:7334"}}}
- {"event": {"commonEventHeader": {"sourceName":""}, "pnfRegistrationFields": {"oamV4IpAddress":"10.17.163.234", "oamV6IpAddress":""}}}
- {"event": {"commonEventHeader": {"sourceName":""}, "pnfRegistrationFields": {"oamV4IpAddress":"", "oamV6IpAddress":"2001:0db8:85a3:0000:0000:8b2f:0370:7334"}}}
- {"event": {"commonEventHeader": {"sourceName":""}, "pnfRegistrationFields": {"oamV4IpAddress":"", "oamV6IpAddress":""}}}
+ ${EVENT_WITH_MISSING_IPV4_AND_IPV6}
+ ${EVENT_WITH_MISSING_SOURCENAME}
+ ${EVENT_WITH_MISSING_SOURCENAME_AND_IPV4}
+ ${EVENT_WITH_MISSING_SOURCENAME_AND_IPV6}
+ ${EVENT_WITH_MISSING_SOURCENAME_IPV4_AND_IPV6}
Get valid event from DMaaP and record in AAI does not exist
[Documentation] PRH get valid event from DMaaP with all required fields and in AAI record doesn't exist - PRH does not produce PNF_READY notification
[Tags] PRH Missing AAI record
[Timeout] 30s
+ ${data}= Get Data From File ${EVENT_WITH_ALL_VALID_REQUIRED_FIELDS}
Set PNF name in AAI wrong_aai_record
- Set event in DMaaP ${EVENT_WITH_ALL_VALID_REQUIRED_FIELDS}
+ Set event in DMaaP ${data}
Wait Until Keyword Succeeds 100x 300ms Check PRH log java.io.IOException: Connection closed prematurely
Event in DMaaP is not JSON format
[Documentation] PRH get not JSON format event from DMaaP - PRH does not produce PNF_READY notification
[Tags] PRH
- Set event in DMaaP ${Not_json_format}
+ ${data}= Get Data From File ${Not_json_format}
+ Set event in DMaaP ${data}
Wait Until Keyword Succeeds 100x 300ms Check PRH log |java.lang.IllegalStateException: Not a JSON Array:
Get valid event from DMaaP and AAI is not responding
[Documentation] PRH get valid event from DMaaP with all required fields and AAI is not responding - PRH does not produce PNF_READY notification
[Tags] PRH AAI
[Timeout] 180s
+ ${data}= Get Data From File ${EVENT_WITH_ALL_VALID_REQUIRED_FIELDS}
Stop AAI
- Set event in DMaaP ${EVENT_WITH_ALL_VALID_REQUIRED_FIELDS}
+ Set event in DMaaP ${data}
Wait Until Keyword Succeeds 100x 300ms Check PRH log java.net.UnknownHostException: aai
diff --git a/test/csit/tests/dcaegen2/prh-testcases/resources/prh_library.robot b/test/csit/tests/dcaegen2/prh-testcases/resources/prh_library.robot
index b7e339bc9..73ce2a2c4 100644
--- a/test/csit/tests/dcaegen2/prh-testcases/resources/prh_library.robot
+++ b/test/csit/tests/dcaegen2/prh-testcases/resources/prh_library.robot
@@ -2,6 +2,7 @@
Library RequestsLibrary
Library Collections
Library PrhLibrary.py
+Resource ../../../common.robot
*** Keywords ***
Create header
@@ -17,18 +18,20 @@ Create sessions
Invalid event processing
[Arguments] ${input_invalid_event_in_dmaap}
[Timeout] 30s
- Set event in DMaaP ${input_invalid_event_in_dmaap}
- ${invalid_notification}= Create invalid notification ${input_invalid_event_in_dmaap}
- ${notification}= Catenate SEPARATOR= \\n |org.onap.dcaegen2.services.prh.exceptions.DmaapNotFoundException: Incorrect json, consumerDmaapModel can not be created: ${invalid_notification}
- Wait Until Keyword Succeeds 100x 100ms Check PRH log ${notification}
-
+ ${data}= Get Data From File ${input_invalid_event_in_dmaap}
+ Set event in DMaaP ${data}
+ ${invalid_notification}= Create invalid notification ${data}
+ ${notification}= Catenate SEPARATOR= \\n |org.onap.dcaegen2.services.prh.exceptions.DmaapNotFoundException: Incorrect json, consumerDmaapModel can not be created: ${invalid_notification}
+ Wait Until Keyword Succeeds 100x 100ms Check PRH log ${notification}
+
Valid event processing
[Arguments] ${input_valid_event_in_dmaap}
[Timeout] 30s
- ${posted_event_to_dmaap}= Create PNF_Ready notification ${input_valid_event_in_dmaap}
- ${pnf_name}= Create PNF name ${input_valid_event_in_dmaap}
+ ${data}= Get Data From File ${input_valid_event_in_dmaap}
+ ${posted_event_to_dmaap}= Create PNF_Ready notification ${data}
+ ${pnf_name}= Create PNF name ${data}
Set PNF name in AAI ${pnf_name}
- Set event in DMaaP ${input_valid_event_in_dmaap}
+ Set event in DMaaP ${data}
Wait Until Keyword Succeeds 100x 300ms Check PNF_READY notification ${posted_event_to_dmaap}
Check PRH log
diff --git a/test/csit/tests/dcaegen2/testcases/dcae_ves.robot b/test/csit/tests/dcaegen2/testcases/dcae_ves.robot
index 393359f54..daed35fa8 100644
--- a/test/csit/tests/dcaegen2/testcases/dcae_ves.robot
+++ b/test/csit/tests/dcaegen2/testcases/dcae_ves.robot
@@ -5,8 +5,9 @@ Library OperatingSystem
Library Collections
Library DcaeLibrary
Resource resources/dcae_keywords.robot
+Resource ../../common.robot
Test Setup Cleanup VES Events
-Suite Setup VES Collector Suite Setup DMaaP
+Suite Setup Run keywords VES Collector Suite Setup DMaaP Create sessions Create header
Suite Teardown VES Collector Suite Shutdown DMaaP
*** Variables ***
@@ -15,13 +16,12 @@ ${VESC_URL} http://%{VESC_IP}:8080
${VES_ANY_EVENT_PATH} /eventListener/v5
${VES_BATCH_EVENT_PATH} /eventListener/v5/eventBatch
${VES_THROTTLE_STATE_EVENT_PATH} /eventListener/v5/clientThrottlingState
-${HEADER_STRING} content-type=application/json
${EVENT_DATA_FILE} %{WORKSPACE}/test/csit/tests/dcaegen2/testcases/assets/json_events/ves_volte_single_fault_event.json
${EVENT_MEASURE_FILE} %{WORKSPACE}/test/csit/tests/dcaegen2/testcases/assets/json_events/ves_vfirewall_measurement.json
${EVENT_DATA_FILE_BAD} %{WORKSPACE}/test/csit/tests/dcaegen2/testcases/assets/json_events/ves_volte_single_fault_event_bad.json
${EVENT_BATCH_DATA_FILE} %{WORKSPACE}/test/csit/tests/dcaegen2/testcases/assets/json_events/ves_volte_fault_eventlist_batch.json
${EVENT_THROTTLING_STATE_DATA_FILE} %{WORKSPACE}/test/csit/tests/dcaegen2/testcases/assets/json_events/ves_volte_fault_provide_throttle_state.json
-${EVENT_PNF_REGISTRATION} %{WORKSPACE}/test/csit/tests/dcaegen2/testcases/assets/json_events/ves_pnf_registration_event.json
+${EVENT_PNF_REGISTRATION} %{WORKSPACE}/test/csit/tests/dcaegen2/testcases/assets/json_events/ves_pnf_registration_event.json
#DCAE Health Check
${CONFIG_BINDING_URL} http://localhost:8443
@@ -30,22 +30,20 @@ ${CB_SERVICE_COMPONENT_PATH} /service_component/
${VES_Service_Name1} dcae-controller-ves-collector
${VES_Service_Name2} ves-collector-not-exist
-*** Test Cases ***
+*** Test Cases ***
VES Collector Health Check
[Tags] DCAE-VESC-R1
[Documentation] Ves Collector Health Check
${uuid}= Generate UUID
- ${session}= Create Session dcae ${VESC_URL}
${headers}= Create Dictionary Accept=*/* X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID}
- ${resp}= Get Request dcae /healthcheck headers=${headers}
+ ${resp}= Get Request ${suite_dcae_vesc_url_session} /healthcheck headers=${headers}
Should Be Equal As Strings ${resp.status_code} 200
Publish Single VES VoLTE Fault Event
[Tags] DCAE-VESC-R1
[Documentation] Post single event and expect 200 Response
- ${evtdata}= Get Event Data From File ${EVENT_DATA_FILE}
- ${headers}= Create Header From String ${HEADER_STRING}
- ${resp}= Publish Event To VES Collector No Auth ${VESC_URL} ${VES_ANY_EVENT_PATH} ${headers} ${evtdata}
+ ${evtdata}= Get Data From File ${EVENT_DATA_FILE}
+ ${resp}= Publish Event To VES Collector No Auth ${VES_ANY_EVENT_PATH} ${evtdata}
Log Receive HTTP Status code ${resp.status_code}
Should Be Equal As Strings ${resp.status_code} 200
${isEmpty}= Is Json Empty ${resp}
@@ -56,9 +54,8 @@ Publish Single VES VoLTE Fault Event
Publish Single VES VNF Measurement Event
[Tags] DCAE-VESC-R1
[Documentation] Post single event and expect 200 Response
- ${evtdata}= Get Event Data From File ${EVENT_MEASURE_FILE}
- ${headers}= Create Header From String ${HEADER_STRING}
- ${resp}= Publish Event To VES Collector No Auth ${VESC_URL} ${VES_ANY_EVENT_PATH} ${headers} ${evtdata}
+ ${evtdata}= Get Data From File ${EVENT_MEASURE_FILE}
+ ${resp}= Publish Event To VES Collector No Auth ${VES_ANY_EVENT_PATH} ${evtdata}
Log Receive HTTP Status code ${resp.status_code}
Should Be Equal As Strings ${resp.status_code} 200
${isEmpty}= Is Json Empty ${resp}
@@ -69,9 +66,8 @@ Publish Single VES VNF Measurement Event
Publish VES VoLTE Fault Batch Events
[Tags] DCAE-VESC-R1
[Documentation] Post batched events and expect 200 Response
- ${evtdata}= Get Event Data From File ${EVENT_BATCH_DATA_FILE}
- ${headers}= Create Header From String ${HEADER_STRING}
- ${resp}= Publish Event To VES Collector No Auth ${VESC_URL} ${VES_BATCH_EVENT_PATH} ${headers} ${evtdata}
+ ${evtdata}= Get Data From File ${EVENT_BATCH_DATA_FILE}
+ ${resp}= Publish Event To VES Collector No Auth ${VES_BATCH_EVENT_PATH} ${evtdata}
Should Be Equal As Strings ${resp.status_code} 200
#${ret}= DMaaP Message Receive ab305d54-85b4-a31b-7db2-fb6b9e546016
${ret}= DMaaP Message Receive ab305d54-85b4-a31b-7db2-fb6b9e546025
@@ -80,10 +76,9 @@ Publish VES VoLTE Fault Batch Events
Publish Single VES VoLTE Fault Event With Bad Data
[Tags] DCAE-VESC-R1
[Documentation] Run with JSON Envent with missing comma to expect 400 response
- ${evtdata}= Get Event Data From File ${EVENT_DATA_FILE_BAD}
- ${headers}= Create Header From String ${HEADER_STRING}
+ ${evtdata}= Get Data From File ${EVENT_DATA_FILE_BAD}
Log Send HTTP Request with invalid Json Event Data
- ${resp}= Publish Event To VES Collector No Auth ${VESC_URL} ${VES_ANY_EVENT_PATH} ${headers} ${evtdata}
+ ${resp}= Publish Event To VES Collector No Auth ${VES_ANY_EVENT_PATH} ${evtdata}
Log Receive HTTP Status code ${resp.status_code}
Should Be Equal As Strings ${resp.status_code} 400
${isEmpty}= Is Json Empty ${resp}
@@ -92,20 +87,18 @@ Publish Single VES VoLTE Fault Event With Bad Data
Publish VES Event With Invalid Method
[Tags] DCAE-VESC-R1
[Documentation] Use invalid Put instead of Post method to expect 405 response
- ${evtdata}= Get Event Data From File ${EVENT_DATA_FILE}
- ${headers}= Create Header From String ${HEADER_STRING}
+ ${evtdata}= Get Data From File ${EVENT_DATA_FILE}
Log Send HTTP Request with invalid method Put instead of Post
- ${resp}= Publish Event To VES Collector With Put Method No Auth ${VESC_URL} ${VES_ANY_EVENT_PATH} ${headers} ${evtdata}
+ ${resp}= Publish Event To VES Collector With Put Method No Auth ${VES_ANY_EVENT_PATH} ${evtdata}
Log Receive HTTP Status code ${resp.status_code}
Should Be Equal As Strings ${resp.status_code} 404
Publish VES Event With Invalid URL Path
[Tags] DCAE-VESC-R1
[Documentation] Use invalid url path to expect 404 response
- ${evtdata}= Get Event Data From File ${EVENT_DATA_FILE}
- ${headers}= Create Header From String ${HEADER_STRING}
+ ${evtdata}= Get Data From File ${EVENT_DATA_FILE}
Log Send HTTP Request with invalid /listener/v5/ instead of /eventListener/v5 path
- ${resp}= Publish Event To VES Collector No Auth ${VESC_URL} /listener/v5/ ${headers} ${evtdata}
+ ${resp}= Publish Event To VES Collector No Auth /listener/v5/ ${evtdata}
Log Receive HTTP Status code ${resp.status_code}
Should Be Equal As Strings ${resp.status_code} 404
@@ -123,10 +116,9 @@ Publish VES Event With Invalid URL Path
Publish Single VES Fault Event Over HTTPS
[Tags] DCAE-VESC-R1
[Documentation] Post single event and expect 200 Response
- ${evtdata}= Get Event Data From File ${EVENT_DATA_FILE}
- ${headers}= Create Header From String ${HEADER_STRING}
+ ${evtdata}= Get Data From File ${EVENT_DATA_FILE}
Log Login User=${VESC_HTTPS_USER}, Pd=${VESC_HTTPS_PD}
- ${resp}= Publish Event To VES Collector ${VESC_URL_HTTPS} ${VES_ANY_EVENT_PATH} ${headers} ${evtdata} sample1 sample1
+ ${resp}= Publish Event To VES Collector ${VES_ANY_EVENT_PATH} ${evtdata}
Log Receive HTTP Status code ${resp.status_code}
Should Be Equal As Strings ${resp.status_code} 200
${isEmpty}= Is Json Empty ${resp}
@@ -137,9 +129,8 @@ Publish Single VES Fault Event Over HTTPS
Publish Single VES Measurement Event Over HTTPS
[Tags] DCAE-VESC-R1
[Documentation] Post single event and expect 200 Response
- ${evtdata}= Get Event Data From File ${EVENT_MEASURE_FILE}
- ${headers}= Create Header From String ${HEADER_STRING}
- ${resp}= Publish Event To VES Collector ${VESC_URL_HTTPS} ${VES_ANY_EVENT_PATH} ${headers} ${evtdata} ${VESC_HTTPS_USER} ${VESC_HTTPS_PD}
+ ${evtdata}= Get Data From File ${EVENT_MEASURE_FILE}
+ ${resp}= Publish Event To VES Collector ${VES_ANY_EVENT_PATH} ${evtdata}
Log Receive HTTP Status code ${resp.status_code}
Should Be Equal As Strings ${resp.status_code} 200
${isEmpty}= Is Json Empty ${resp}
@@ -150,9 +141,8 @@ Publish Single VES Measurement Event Over HTTPS
Publish VES Fault Batch Events Over HTTPS
[Tags] DCAE-VESC-R1
[Documentation] Post batched events and expect 202 Response
- ${evtdata}= Get Event Data From File ${EVENT_BATCH_DATA_FILE}
- ${headers}= Create Header From String ${HEADER_STRING}
- ${resp}= Publish Event To VES Collector ${VESC_URL_HTTPS} ${VES_BATCH_EVENT_PATH} ${headers} ${evtdata} ${VESC_HTTPS_USER} ${VESC_HTTPS_PD}
+ ${evtdata}= Get Data From File ${EVENT_BATCH_DATA_FILE}
+ ${resp}= Publish Event To VES Collector ${VES_BATCH_EVENT_PATH} ${evtdata}
Should Be Equal As Strings ${resp.status_code} 200
#${ret}= DMaaP Message Receive ab305d54-85b4-a31b-7db2-fb6b9e546016
${ret}= DMaaP Message Receive ab305d54-85b4-a31b-7db2-fb6b9e546025
@@ -161,19 +151,17 @@ Publish VES Fault Batch Events Over HTTPS
Publish VES Event With Invalid URL Path HTTPS
[Tags] DCAE-VESC-R1
[Documentation] Use invalid url path to expect 404 response
- ${evtdata}= Get Event Data From File ${EVENT_DATA_FILE}
- ${headers}= Create Header From String ${HEADER_STRING}
+ ${evtdata}= Get Data From File ${EVENT_DATA_FILE}
Log Send HTTP Request with invalid /eventlistener/v5/ instead of /eventListener/v5 path
- ${resp}= Publish Event To VES Collector ${VESC_URL_HTTPS} /eventlistener/v5 ${headers} ${evtdata} ${VESC_HTTPS_USER} ${VESC_HTTPS_PD}
+ ${resp}= Publish Event To VES Collector /eventlistener/v5 ${evtdata}
Log Receive HTTP Status code ${resp.status_code}
Should Be Equal As Strings ${resp.status_code} 404
Publish PNF Registration Event
[Tags] DCAE-VESC-R1
[Documentation] Post PNF registration event and expect 200 Response
- ${evtdata}= Get Event Data From File ${EVENT_PNF_REGISTRATION}
- ${headers}= Create Header From String ${HEADER_STRING}
- ${resp}= Publish Event To VES Collector No Auth ${VESC_URL} ${VES_ANY_EVENT_PATH} ${headers} ${evtdata}
+ ${evtdata}= Get Data From File ${EVENT_PNF_REGISTRATION}
+ ${resp}= Publish Event To VES Collector No Auth ${VES_ANY_EVENT_PATH} ${evtdata}
Log Receive HTTP Status code ${resp.status_code}
Should Be Equal As Strings ${resp.status_code} 200
${isEmpty}= Is Json Empty ${resp}
diff --git a/test/csit/tests/dcaegen2/testcases/resources/DMaaP.py b/test/csit/tests/dcaegen2/testcases/resources/DMaaP.py
index db59557db..092b60817 100644
--- a/test/csit/tests/dcaegen2/testcases/resources/DMaaP.py
+++ b/test/csit/tests/dcaegen2/testcases/resources/DMaaP.py
@@ -8,9 +8,13 @@ import posixpath
import BaseHTTPServer
import urllib
import urlparse
-import cgi, sys, shutil, mimetypes
+import cgi
+import sys
+import shutil
+import mimetypes
from jsonschema import validate
-import jsonschema, json
+import jsonschema
+import json
import DcaeVariables
import SimpleHTTPServer
from robot.api import logger
@@ -25,7 +29,7 @@ EvtSchema = None
DMaaPHttpd = None
-def cleanUpEvent():
+def clean_up_event():
sz = DcaeVariables.VESEventQ.qsize()
for i in range(sz):
try:
@@ -33,8 +37,9 @@ def cleanUpEvent():
except:
pass
-def enqueEvent(evt):
- if DcaeVariables.VESEventQ != None:
+
+def enque_event(evt):
+ if DcaeVariables.VESEventQ is not None:
try:
DcaeVariables.VESEventQ.put(evt)
if DcaeVariables.IsRobotRun:
@@ -46,12 +51,13 @@ def enqueEvent(evt):
print (str(e))
return False
return False
-
-def dequeEvent(waitSec=25):
+
+
+def deque_event(wait_sec=25):
if DcaeVariables.IsRobotRun:
logger.console("Enter DequeEvent")
try:
- evt = DcaeVariables.VESEventQ.get(True, waitSec)
+ evt = DcaeVariables.VESEventQ.get(True, wait_sec)
if DcaeVariables.IsRobotRun:
logger.console("DMaaP Event dequeued - size=" + str(len(evt)))
else:
@@ -64,7 +70,8 @@ def dequeEvent(waitSec=25):
else:
print("DMaaP Event dequeue timeout")
return None
-
+
+
class DMaaPHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_PUT(self):
@@ -73,7 +80,7 @@ class DMaaPHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_POST(self):
- respCode = 0
+ resp_code = 0
# Parse the form data posted
'''
form = cgi.FieldStorage(
@@ -95,21 +102,21 @@ class DMaaPHandler(BaseHTTPServer.BaseHTTPRequestHandler):
'''
if 'POST' not in self.requestline:
- respCode = 405
+ resp_code = 405
'''
- if respCode == 0:
+ if resp_code == 0:
if '/eventlistener/v5' not in self.requestline and '/eventlistener/v5/eventBatch' not in self.requestline and \
'/eventlistener/v5/clientThrottlingState' not in self.requestline:
- respCode = 404
+ resp_code = 404
- if respCode == 0:
+ if resp_code == 0:
if 'Y29uc29sZTpaakprWWpsbE1qbGpNVEkyTTJJeg==' not in str(self.headers):
- respCode = 401
+ resp_code = 401
'''
- if respCode == 0:
+ if resp_code == 0:
content_len = int(self.headers.getheader('content-length', 0))
post_body = self.rfile.read(content_len)
@@ -123,21 +130,21 @@ class DMaaPHandler(BaseHTTPServer.BaseHTTPRequestHandler):
if indx != 0:
post_body = post_body[indx:]
- if enqueEvent(post_body) == False:
+ if not enque_event(post_body):
print "enque event fails"
global EvtSchema
try:
- if EvtSchema == None:
- with open(DcaeVariables.CommonEventSchemaV5) as file:
- EvtSchema = json.load(file)
+ if EvtSchema is None:
+ with open(DcaeVariables.CommonEventSchemaV5) as opened_file:
+ EvtSchema = json.load(opened_file)
decoded_body = json.loads(post_body)
jsonschema.validate(decoded_body, EvtSchema)
except:
- respCode = 400
+ resp_code = 400
# Begin the response
- if DcaeVariables.IsRobotRun == False:
+ if not DcaeVariables.IsRobotRun:
print ("Response Message:")
'''
@@ -154,18 +161,18 @@ class DMaaPHandler(BaseHTTPServer.BaseHTTPRequestHandler):
'''
- if respCode == 0:
+ if resp_code == 0:
if 'clientThrottlingState' in self.requestline:
self.send_response(204)
else:
self.send_response(200)
self.send_header('Content-Type', 'application/json')
self.end_headers()
- #self.wfile.write("{'responses' : {'200' : {'description' : 'Success'}}}")
+ # self.wfile.write("{'responses' : {'200' : {'description' : 'Success'}}}")
self.wfile.write("{'count': 1, 'serverTimeMs': 3}")
self.wfile.close()
else:
- self.send_response(respCode)
+ self.send_response(resp_code)
'''
self.end_headers()
@@ -190,8 +197,7 @@ class DMaaPHandler(BaseHTTPServer.BaseHTTPRequestHandler):
self.wfile.write('\t%s=%s\n' % (field, form[field].value))
'''
return
-
-
+
def do_GET(self):
"""Serve a GET request."""
f = self.send_head()
@@ -219,7 +225,6 @@ class DMaaPHandler(BaseHTTPServer.BaseHTTPRequestHandler):
"""
path = self.translate_path(self.path)
- f = None
if os.path.isdir(path):
parts = urlparse.urlsplit(self.path)
if not parts.path.endswith('/'):
@@ -268,18 +273,18 @@ class DMaaPHandler(BaseHTTPServer.BaseHTTPRequestHandler):
"""
try:
- list = os.listdir(path)
+ list_dir = os.listdir(path)
except os.error:
self.send_error(404, "No permission to list directory")
return None
- list.sort(key=lambda a: a.lower())
+ list_dir.sort(key=lambda a: a.lower())
f = StringIO()
displaypath = cgi.escape(urllib.unquote(self.path))
f.write('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">')
f.write("<html>\n<title>Directory listing for %s</title>\n" % displaypath)
f.write("<body>\n<h2>Directory listing for %s</h2>\n" % displaypath)
f.write("<hr>\n<ul>\n")
- for name in list:
+ for name in list_dir:
fullname = os.path.join(path, name)
displayname = linkname = name
# Append / for directories or @ for symbolic links
@@ -301,7 +306,8 @@ class DMaaPHandler(BaseHTTPServer.BaseHTTPRequestHandler):
self.end_headers()
return f
- def translate_path(self, path):
+ @staticmethod
+ def translate_path(path):
"""Translate a /-separated PATH to the local filename syntax.
Components that mean special things to the local file system
@@ -310,8 +316,8 @@ class DMaaPHandler(BaseHTTPServer.BaseHTTPRequestHandler):
"""
# abandon query parameters
- path = path.split('?',1)[0]
- path = path.split('#',1)[0]
+ path = path.split('?', 1)[0]
+ path = path.split('#', 1)[0]
# Don't forget explicit trailing slash when normalizing. Issue17324
trailing_slash = path.rstrip().endswith('/')
path = posixpath.normpath(urllib.unquote(path))
@@ -327,7 +333,8 @@ class DMaaPHandler(BaseHTTPServer.BaseHTTPRequestHandler):
path += '/'
return path
- def copyfile(self, source, outputfile):
+ @staticmethod
+ def copyfile(source, outputfile):
"""Copy all data between two file objects.
The SOURCE argument is a file object open for reading
@@ -368,26 +375,26 @@ class DMaaPHandler(BaseHTTPServer.BaseHTTPRequestHandler):
return self.extensions_map['']
if not mimetypes.inited:
- mimetypes.init() # try to read system mime.types
+ mimetypes.init() # try to read system mime.types
extensions_map = mimetypes.types_map.copy()
extensions_map.update({
- '': 'application/octet-stream', # Default
+ '': 'application/octet-stream', # Default
'.py': 'text/plain',
'.c': 'text/plain',
'.h': 'text/plain',
})
-def test(HandlerClass = DMaaPHandler,
- ServerClass = BaseHTTPServer.HTTPServer, protocol="HTTP/1.0", port=3904):
+
+def test(handler_class=DMaaPHandler, server_class=BaseHTTPServer.HTTPServer, protocol="HTTP/1.0", port=3904):
print "Load event schema file: " + DcaeVariables.CommonEventSchemaV5
- with open(DcaeVariables.CommonEventSchemaV5) as file:
+ with open(DcaeVariables.CommonEventSchemaV5) as opened_file:
global EvtSchema
- EvtSchema = json.load(file)
+ EvtSchema = json.load(opened_file)
server_address = ('', port)
- HandlerClass.protocol_version = protocol
- httpd = ServerClass(server_address, HandlerClass)
+ handler_class.protocol_version = protocol
+ httpd = server_class(server_address, handler_class)
global DMaaPHttpd
DMaaPHttpd = httpd
@@ -395,10 +402,10 @@ def test(HandlerClass = DMaaPHandler,
sa = httpd.socket.getsockname()
print "Serving HTTP on", sa[0], "port", sa[1], "..."
- #httpd.serve_forever()
+ # httpd.serve_forever()
+
-def _main_ (HandlerClass = DMaaPHandler,
- ServerClass = BaseHTTPServer.HTTPServer, protocol="HTTP/1.0"):
+def _main_(handler_class=DMaaPHandler, server_class=BaseHTTPServer.HTTPServer, protocol="HTTP/1.0"):
if sys.argv[1:]:
port = int(sys.argv[1])
@@ -406,18 +413,19 @@ def _main_ (HandlerClass = DMaaPHandler,
port = 3904
print "Load event schema file: " + DcaeVariables.CommonEventSchemaV5
- with open(DcaeVariables.CommonEventSchemaV5) as file:
+ with open(DcaeVariables.CommonEventSchemaV5) as opened_file:
global EvtSchema
- EvtSchema = json.load(file)
+ EvtSchema = json.load(opened_file)
server_address = ('', port)
- HandlerClass.protocol_version = protocol
- httpd = ServerClass(server_address, HandlerClass)
+ handler_class.protocol_version = protocol
+ httpd = server_class(server_address, handler_class)
sa = httpd.socket.getsockname()
print "Serving HTTP on", sa[0], "port", sa[1], "..."
httpd.serve_forever()
-
+
+
if __name__ == '__main__':
- _main_() \ No newline at end of file
+ _main_()
diff --git a/test/csit/tests/dcaegen2/testcases/resources/DcaeLibrary.py b/test/csit/tests/dcaegen2/testcases/resources/DcaeLibrary.py
index e581f1b2c..b43ee29e2 100644
--- a/test/csit/tests/dcaegen2/testcases/resources/DcaeLibrary.py
+++ b/test/csit/tests/dcaegen2/testcases/resources/DcaeLibrary.py
@@ -5,24 +5,34 @@ Created on Aug 18, 2017
'''
from robot.api import logger
from Queue import Queue
-import uuid, time, datetime,json, threading,os, platform, subprocess,paramiko
+import uuid
+import time
+import datetime
+import json
+import threading
+import os
+import platform
+import subprocess
+import paramiko
import DcaeVariables
import DMaaP
+
class DcaeLibrary(object):
def __init__(self):
pass
- def setup_dmaap_server(self, portNum=3904):
- if DcaeVariables.HttpServerThread != None:
- DMaaP.cleanUpEvent()
+ @staticmethod
+ def setup_dmaap_server(port_num=3904):
+ if DcaeVariables.HttpServerThread is not None:
+ DMaaP.clean_up_event()
logger.console("Clean up event from event queue before test")
logger.info("DMaaP Server already started")
return "true"
DcaeVariables.IsRobotRun = True
- DMaaP.test(port=portNum)
+ DMaaP.test(port=port_num)
try:
DcaeVariables.VESEventQ = Queue()
DcaeVariables.HttpServerThread = threading.Thread(name='DMAAP_HTTPServer', target=DMaaP.DMaaPHttpd.serve_forever)
@@ -34,8 +44,9 @@ class DcaeLibrary(object):
print (str(e))
return "false"
- def shutdown_dmaap(self):
- if DcaeVariables.HTTPD != None:
+ @staticmethod
+ def shutdown_dmaap():
+ if DcaeVariables.HTTPD is not None:
DcaeVariables.HTTPD.shutdown()
logger.console("DMaaP Server shut down")
time.sleep(3)
@@ -43,20 +54,23 @@ class DcaeLibrary(object):
else:
return "false"
- def cleanup_ves_events(self):
- if DcaeVariables.HttpServerThread != None:
- DMaaP.cleanUpEvent()
+ @staticmethod
+ def cleanup_ves_events():
+ if DcaeVariables.HttpServerThread is not None:
+ DMaaP.clean_up_event()
logger.console("DMaaP event queue is cleaned up")
return "true"
logger.console("DMaaP server not started yet")
return "false"
- def enable_vesc_https_auth(self):
+ @staticmethod
+ def enable_vesc_https_auth():
+ global client
if 'Windows' in platform.system():
try:
client = paramiko.SSHClient()
client.load_system_host_keys()
- #client.set_missing_host_key_policy(paramiko.WarningPolicy)
+ # client.set_missing_host_key_policy(paramiko.WarningPolicy)
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(os.environ['CSIT_IP'], port=22, username=os.environ['CSIT_USER'], password=os.environ['CSIT_PD'])
@@ -73,42 +87,42 @@ class DcaeLibrary(object):
time.sleep(5)
return
- def dmaap_message_receive(self, evtobj, action='contain'):
+ @staticmethod
+ def dmaap_message_receive(evtobj, action='contain'):
- evtStr = DMaaP.dequeEvent()
- while evtStr != None:
- logger.console("DMaaP receive VES Event:\n" + evtStr)
+ evt_str = DMaaP.deque_event()
+ while evt_str != None:
+ logger.console("DMaaP receive VES Event:\n" + evt_str)
if action == 'contain':
- if evtobj in evtStr:
- logger.info("DMaaP Receive Expected Publish Event:\n" + evtStr)
+ if evtobj in evt_str:
+ logger.info("DMaaP Receive Expected Publish Event:\n" + evt_str)
return 'true'
if action == 'sizematch':
- if len(evtobj) == len(evtStr):
+ if len(evtobj) == len(evt_str):
return 'true'
if action == 'dictmatch':
- evtDict = json.loads(evtStr)
- if cmp(evtobj, evtDict) == 0:
+ evt_dict = json.loads(evt_str)
+ if cmp(evtobj, evt_dict) == 0:
return 'true'
- evtStr = DMaaP.dequeEvent()
+ evt_str = DMaaP.deque_event()
return 'false'
-
- def create_header_from_string(self, dictStr):
- logger.info("Enter create_header_from_string: dictStr")
- return dict(u.split("=") for u in dictStr.split(","))
-
- def is_json_empty(self, resp):
+
+ @staticmethod
+ def is_json_empty(resp):
logger.info("Enter is_json_empty: resp.text: " + resp.text)
- if resp.text == None or len(resp.text) < 2:
+ if resp.text is None or len(resp.text) < 2:
return 'True'
return 'False'
- def Generate_UUID(self):
+ @staticmethod
+ def generate_uuid():
"""generate a uuid"""
return uuid.uuid4()
- def get_json_value_list(self, jsonstr, keyval):
+ @staticmethod
+ def get_json_value_list(jsonstr, keyval):
logger.info("Enter Get_Json_Key_Value_List")
- if jsonstr == None or len(jsonstr) < 2:
+ if jsonstr is None or len(jsonstr) < 2:
logger.info("No Json data found")
return []
try:
@@ -122,12 +136,14 @@ class DcaeLibrary(object):
print str(e)
return []
- def generate_MilliTimestamp_UUID(self):
+ @staticmethod
+ def generate_millitimestamp_uuid():
"""generate a millisecond timestamp uuid"""
then = datetime.datetime.now()
return int(time.mktime(then.timetuple())*1e3 + then.microsecond/1e3)
- def test (self):
+ @staticmethod
+ def test():
import json
from pprint import pprint
@@ -138,7 +154,6 @@ class DcaeLibrary(object):
pprint(data)
-
if __name__ == '__main__':
'''
dictStr = "action=getTable,Accept=application/json,Content-Type=application/json,X-FromAppId=1234908903284"
@@ -156,4 +171,3 @@ if __name__ == '__main__':
ret = lib.setup_dmaap_server()
print ret
time.sleep(100000)
-
diff --git a/test/csit/tests/dcaegen2/testcases/resources/DcaeVariables.py b/test/csit/tests/dcaegen2/testcases/resources/DcaeVariables.py
index 4d51a8f5a..a9456d0fa 100644
--- a/test/csit/tests/dcaegen2/testcases/resources/DcaeVariables.py
+++ b/test/csit/tests/dcaegen2/testcases/resources/DcaeVariables.py
@@ -1,13 +1,14 @@
+import os
-import os, time
-def GetEnvironmentVariable(envVarstr):
- return os.environ.get(envVarstr)
+def get_environment_variable(env_varstr):
+ return os.environ.get(env_varstr)
+
DCAE_HEALTH_CHECK_URL = "http://135.205.228.129:8500"
DCAE_HEALTH_CHECK_URL1 = "http://135.205.228.170:8500"
-CommonEventSchemaV5 = GetEnvironmentVariable('WORKSPACE') + "/test/csit/tests/dcaegen2/testcases/assets/json_events/CommonEventFormat_28.3.json"
+CommonEventSchemaV5 = get_environment_variable('WORKSPACE') + "/test/csit/tests/dcaegen2/testcases/assets/json_events/CommonEventFormat_28.3.json"
HttpServerThread = None
HTTPD = None
diff --git a/test/csit/tests/dcaegen2/testcases/resources/dcae_keywords.robot b/test/csit/tests/dcaegen2/testcases/resources/dcae_keywords.robot
index 98b341529..6820050fe 100644
--- a/test/csit/tests/dcaegen2/testcases/resources/dcae_keywords.robot
+++ b/test/csit/tests/dcaegen2/testcases/resources/dcae_keywords.robot
@@ -1,4 +1,4 @@
- *** Settings ***
+*** Settings ***
Documentation The main interface for interacting with DCAE. It handles low level stuff like managing the http request library and DCAE required fields
Library RequestsLibrary
Library DcaeLibrary
@@ -6,9 +6,23 @@ Library OperatingSystem
Library Collections
Variables ../resources/DcaeVariables.py
Resource ../resources/dcae_properties.robot
+
*** Variables ***
${DCAE_HEALTH_CHECK_BODY} %{WORKSPACE}/test/csit/tests/dcae/testcases/assets/json_events/dcae_healthcheck.json
+
*** Keywords ***
+Create sessions
+ [Documentation] Create all required sessions
+ Create Session dcae_vesc_url ${VESC_URL}
+ Set Suite Variable ${suite_dcae_vesc_url_session} dcae_vesc_url
+ ${auth}= Create List ${VESC_HTTPS_USER} ${VESC_HTTPS_PD}
+ Create Session dcae_vesc_url_https ${VESC_URL_HTTPS} auth=${auth} disable_warnings=1
+ Set Suite Variable ${suite_dcae_vesc_url_https_session} dcae_vesc_url_https
+
+Create header
+ ${headers}= Create Dictionary Content-Type=application/json
+ Set Suite Variable ${suite_headers} ${headers}
+
Get DCAE Nodes
[Documentation] Get DCAE Nodes from Consul Catalog
#Log Creating session ${GLOBAL_DCAE_CONSUL_URL}
@@ -22,7 +36,8 @@ Get DCAE Nodes
${NodeListLength}= Get Length ${NodeList}
${len}= Get Length ${NodeList}
Should Not Be Equal As Integers ${len} 0
- [return] ${NodeList}
+ [Return] ${NodeList}
+
DCAE Node Health Check
[Documentation] Perform DCAE Node Health Check
[Arguments] ${NodeName}
@@ -38,18 +53,22 @@ DCAE Node Health Check
Should Not Be Equal As Integers ${len} 0
DCAE Check Health Status ${NodeName} ${StatusList[0]} Serf Health Status
#Run Keyword if ${len} > 1 DCAE Check Health Status ${NodeName} ${StatusList[1]} Serf Health Status
+
DCAE Check Health Status
[Arguments] ${NodeName} ${ItemStatus} ${CheckType}
Should Be Equal As Strings ${ItemStatus} passing
Log Node: ${NodeName} ${CheckType} check pass ok
+
VES Collector Suite Setup DMaaP
[Documentation] Start DMaaP Mockup Server
${ret}= Setup DMaaP Server
Should Be Equal As Strings ${ret} true
+
VES Collector Suite Shutdown DMaaP
[Documentation] Shutdown DMaaP Mockup Server
${ret}= Shutdown DMaap
Should Be Equal As Strings ${ret} true
+
Check DCAE Results
[Documentation] Parse DCAE JSON response and make sure all rows have healthTestStatus=GREEN
[Arguments] ${json}
@@ -65,6 +84,7 @@ Check DCAE Results
\ ${cells}= Get From Dictionary ${row} cells
\ ${dict}= Make A Dictionary ${cells} ${columns}
\ Dictionary Should Contain Item ${dict} healthTestStatus GREEN
+
Make A Dictionary
[Documentation] Given a list of column names and a list of dictionaries, map columname=value
[Arguments] ${columns} ${names} ${valuename}=value
@@ -77,57 +97,49 @@ Make A Dictionary
\ ${value}= Get From Dictionary ${valued} ${valueName}
\ Set To Dictionary ${dict} ${name} ${value}
[Return] ${dict}
-Get Event Data From File
- [Arguments] ${jsonfile}
- ${data}= OperatingSystem.Get File ${jsonfile}
- #Should Not Be_Equal ${data} None
- [return] ${data}
+
Json String To Dictionary
[Arguments] ${json_string}
${json_dict}= evaluate json.loads('''${json_string}''') json
- [return] ${json_dict}
+ [Return] ${json_dict}
+
Dictionary To Json String
[Arguments] ${json_dict}
${json_string}= evaluate json.dumps(${json_dict}) json
- [return] ${json_string}
+ [Return] ${json_string}
+
Get DCAE Service Component Status
[Documentation] Get the status of a DCAE Service Component
[Arguments] ${url} ${urlpath} ${usr} ${passwd}
${auth}= Create List ${usr} ${passwd}
${session}= Create Session dcae-service-component ${url} auth=${auth}
${resp}= Get Request dcae-service-component ${urlpath}
- [return] ${resp}
+ [Return] ${resp}
+
Publish Event To VES Collector No Auth
[Documentation] Send an event to VES Collector
- [Arguments] ${url} ${evtpath} ${httpheaders} ${evtdata}
- Log Creating session ${url}
- ${session}= Create Session dcaegen2-d1 ${url}
- ${resp}= Post Request dcaegen2-d1 ${evtpath} data=${evtdata} headers=${httpheaders}
+ [Arguments] ${evtpath} ${evtdata}
+ ${resp}= Post Request ${suite_dcae_vesc_url_session} ${evtpath} data=${evtdata} headers=${suite_headers}
#Log Received response from dcae ${resp.json()}
- [return] ${resp}
+ [Return] ${resp}
+
Publish Event To VES Collector
[Documentation] Send an event to VES Collector
- [Arguments] ${url} ${evtpath} ${httpheaders} ${evtdata} ${user} ${pd}
- ${auth}= Create List ${user} ${pd}
- Log Creating session ${url}
- ${session}= Create Session dcaegen2-d1 ${url} auth=${auth} disable_warnings=1
- ${resp}= Post Request dcaegen2-d1 ${evtpath} data=${evtdata} headers=${httpheaders}
+ [Arguments] ${evtpath} ${evtdata}
+ ${resp}= Post Request ${suite_dcae_vesc_url_https_session} ${evtpath} data=${evtdata} headers=${suite_headers}
#Log Received response from dcae ${resp.json()}
- [return] ${resp}
+ [Return] ${resp}
+
Publish Event To VES Collector With Put Method
[Documentation] Send an event to VES Collector
- [Arguments] ${url} ${evtpath} ${httpheaders} ${evtdata} ${user} ${pd}
- ${auth}= Create List ${user} ${pd}
- Log Creating session ${url}
- ${session}= Create Session dcae-d1 ${url} auth=${auth}
- ${resp}= Put Request dcae-d1 ${evtpath} data=${evtdata} headers=${httpheaders}
+ [Arguments] ${evtpath} ${evtdata}
+ ${resp}= Put Request ${suite_dcae_vesc_url_https_session} ${evtpath} data=${evtdata} headers=${suite_headers}
#Log Received response from dcae ${resp.json()}
- [return] ${resp}
+ [Return] ${resp}
+
Publish Event To VES Collector With Put Method No Auth
[Documentation] Send an event to VES Collector
- [Arguments] ${url} ${evtpath} ${httpheaders} ${evtdata}
- Log Creating session ${url}
- ${session}= Create Session dcae-d1 ${url}
- ${resp}= Put Request dcae-d1 ${evtpath} data=${evtdata} headers=${httpheaders}
+ [Arguments] ${evtpath} ${evtdata}
+ ${resp}= Put Request ${suite_dcae_vesc_url_session} ${evtpath} data=${evtdata} headers=${suite_headers}
#Log Received response from dcae ${resp.json()}
- [return] ${resp}
+ [Return] ${resp}
diff --git a/test/csit/tests/dcaegen2/testcases/resources/dcae_properties.robot b/test/csit/tests/dcaegen2/testcases/resources/dcae_properties.robot
index 692488814..135ff263a 100644
--- a/test/csit/tests/dcaegen2/testcases/resources/dcae_properties.robot
+++ b/test/csit/tests/dcaegen2/testcases/resources/dcae_properties.robot
@@ -1,9 +1,8 @@
+*** Settings ***
Documentation store all properties that can change or are used in multiple places here
... format is all caps with underscores between words and prepended with GLOBAL
... make sure you prepend them with GLOBAL so that other files can easily see it is from this file.
-
-
*** Variables ***
${GLOBAL_APPLICATION_ID} robot-dcaegen2
${GLOBAL_DCAE_CONSUL_URL} http://135.205.228.129:8500