initial seba-in-a-box functional tests
Change-Id: I955888d602e184b8986ef21e4969fd55b5368325
diff --git a/src/test/cord-api/Framework/ATTWorkFlowDriver.robot b/src/test/cord-api/Framework/ATTWorkFlowDriver.robot
index 3d63dde..402721d 100644
--- a/src/test/cord-api/Framework/ATTWorkFlowDriver.robot
+++ b/src/test/cord-api/Framework/ATTWorkFlowDriver.robot
@@ -45,6 +45,16 @@
Set Global Variable ${AttWhiteList_Id}
[Return] ${AttWhiteList_Id}
+Retrieve Whitelist Entry
+ [Arguments] ${serial_number}
+ [Documentation] Returns the whitelist entry per the onu's serial number
+ ${json_result}= restApi.ApiGet ATT_WHITELIST
+ Log ${json_result}
+ ${json_result_list}= Get From dictionary ${json_result} items
+ ${getJsonDict}= utils.getDictFromListOfDict ${json_result_list} serial_number ${serial_number}
+ ${id}= Get From Dictionary ${getJsonDict} id
+ [Return] ${id}
+
Delete Whitelist Entry
[Arguments] ${id}
[Documentation] Sends a DELETE to delete an att whitelist in XOS
diff --git a/src/test/cord-api/Framework/ONU.robot b/src/test/cord-api/Framework/ONU.robot
index e5b7a2e..1b9c278 100644
--- a/src/test/cord-api/Framework/ONU.robot
+++ b/src/test/cord-api/Framework/ONU.robot
@@ -28,8 +28,19 @@
${api_result}= restApi.ApiPost ONU_DEVICE ${onu_dictionary}
Should Be True ${api_result}
+Retrieve ONU Device
+ [Arguments] ${serial_number}
+ [Documentation] Returns the onu device id based on the onu's serial number
+ ${json_result}= restApi.ApiGet ONU_DEVICE
+ Log ${json_result}
+ Log To Console ${json_result}
+ ${json_result_list}= Get From dictionary ${json_result} items
+ ${getJsonDict}= utils.getDictFromListOfDict ${json_result_list} serial_number ${serial_number}
+ ${id}= Get From Dictionary ${getJsonDict} id
+ [Return] ${id}
+
Delete ONU Device
[Arguments] ${id}
[Documentation] Sends a DELETE to delete an onu device in XOS
${api_result}= restApi.ApiChameleonDelete ONU_DEVICE ${id}
- Should Be True ${api_result}
\ No newline at end of file
+ Should Be True ${api_result}
diff --git a/src/test/cord-api/Framework/utils/utils.robot b/src/test/cord-api/Framework/utils/utils.robot
index 7838551..0bfcd13 100644
--- a/src/test/cord-api/Framework/utils/utils.robot
+++ b/src/test/cord-api/Framework/utils/utils.robot
@@ -170,6 +170,17 @@
Should Be Equal As Strings ${resp.status_code} 200
[Return] ${resp}
+CORD Put
+ [Documentation] Make a PUT call to XOS
+ [Arguments] ${service} ${data} ${data_id}
+ ${data}= Evaluate json.dumps(${data}) json
+ ${resp}= Put Request ${SERVER_IP} uri=${service}/${data_id} data=${data}
+ Log ${resp.content}
+ Should Be Equal As Strings ${resp.status_code} 200
+ ${id}= Get Json Value ${resp.content} /id
+ Set Suite Variable ${id}
+ [Return] ${resp}
+
CORD Delete
[Documentation] Make a DELETE call to XOS
[Arguments] ${service} ${data_id}
@@ -192,4 +203,4 @@
Kill Linux Process
[Arguments] ${ip} ${user} ${pass} ${process}
${rc}= Run Sudo Command On Remote System ${ip} sudo kill $(ps aux | grep '${process}' | awk '{print $2}'); echo $? ${user} ${pass}
- Should Contain ${rc} 0
\ No newline at end of file
+ Should Contain ${rc} 0
diff --git a/src/test/cord-api/Tests/WorkflowValidations/SIAB.robot b/src/test/cord-api/Tests/WorkflowValidations/SIAB.robot
new file mode 100644
index 0000000..9d71da4
--- /dev/null
+++ b/src/test/cord-api/Tests/WorkflowValidations/SIAB.robot
@@ -0,0 +1,151 @@
+# Copyright 2017-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+*** Settings ***
+Documentation Test various E2E conditions for seba-in-a-box
+Suite Setup Setup
+Suite Teardown Teardown
+Test Teardown Clean Test Environment
+Library Collections
+Library String
+Library OperatingSystem
+Library XML
+Library RequestsLibrary
+Library ../../Framework/utils/utils.py
+Resource ../../Framework/utils/utils.robot
+Library ../../Framework/restApi.py
+Resource ../../Framework/Subscriber.robot
+Resource ../../Framework/ATTWorkFlowDriver.robot
+Resource ../../Framework/ONU.robot
+Resource ../../Framework/DHCP.robot
+Variables ../../Properties/RestApiProperties.py
+
+*** Variables ***
+${WHITELIST_PATHFILE} ${CURDIR}/data/SIABWhitelist.json
+${SUBSCRIBER_PATHFILE} ${CURDIR}/data/SIABSubscriber.json
+${VOLT_DEVICE_PATHFILE} ${CURDIR}/data/SIABOLTDevice.json
+
+*** Test Cases ***
+Send Auth Request and Validate PING
+ [Tags] inittest
+ ${auth_request}= Run kubectl -n voltha exec ${RG_CONTAINER} -- wpa_supplicant -i eth0 -Dwired -c /etc/wpa_supplicant/wpa_supplicant.conf -B
+ Should Contain ${auth_request} Successfully initialized wpa_supplicant
+ Run kubectl -n voltha exec ${RG_CONTAINER} -- dhclient
+ Run kubectl -n voltha exec ${RG_CONTAINER} -- dhclient -r
+ Run kubectl -n voltha exec ${RG_CONTAINER} -- dhclient
+ Wait Until Keyword Succeeds 10s 2s Validate ONU States ACTIVE ENABLED
+ Wait Until Keyword Succeeds 60s 2s Validate ATT Workflow Driver SI ENABLED APPROVED
+ Wait Until Keyword Succeeds 60s 2s Validate Subscriber Status enabled
+ Should Contain ${auth_request} Successfully initialized wpa_supplicant
+ Wait Until Keyword Succeeds 60s 2s Ping From RG PASS
+
+Disable Subscriber
+ [Tags] disable
+ ${subscriber_id}= Retrieve Subscriber ${c_tag}
+ CORD Put ${VOLT_SUBSCRIBER} {"status":"disabled"} ${subscriber_id}
+ Wait Until Keyword Succeeds 60s 2s Ping From RG FAIL
+
+Enable Subscriber
+ [Tags] enable
+ ${subscriber_id}= Retrieve Subscriber ${c_tag}
+ CORD Put ${VOLT_SUBSCRIBER} {"status":"enabled"} ${subscriber_id}
+ Wait Until Keyword Succeeds 60s 2s Ping From RG PASS
+
+Change Whitelist to Wrong Port Location
+ [Tags] notready
+ ${whitelist_id}= Retrieve Whitelist Entry ${onu_sn}
+ CORD Put ${ATT_WHITELIST} {"pon_port_id": 55 } ${whitelist_id}
+ Wait Until Keyword Succeeds 60s 2s Validate ATT Workflow Driver SI DISABLED AWAITING
+ Wait Until Keyword Succeeds 60s 2s Validate Subscriber Status awaiting-auth
+ Wait Until Keyword Succeeds 60s 2s Ping From RG FAIL
+
+Update Whitelist to Correct Port Location
+ [Tags] notready
+ ${whitelist_id}= Retrieve Whitelist Entry ${onu_sn}
+ CORD Put ${ATT_WHITELIST} {"pon_port_id": 1 } ${whitelist_id}
+ ${auth_request}= Run kubectl -n voltha exec ${RG_CONTAINER} -- wpa_supplicant -i eth0 -Dwired -c /etc/wpa_supplicant/wpa_supplicant.conf -B
+ Should Contain ${auth_request} Successfully initialized wpa_supplicant
+ Wait Until Keyword Succeeds 60s 2s Validate ATT Workflow Driver SI ENABLED APPROVED
+ Wait Until Keyword Succeeds 60s 2s Validate Subscriber Status enabled
+ Wait Until Keyword Succeeds 60s 2s Ping From RG PASS
+
+*** Keywords ***
+Setup
+ ${auth} = Create List ${XOS_USER} ${XOS_PASSWD}
+ ${HEADERS} Create Dictionary Content-Type=application/json
+ Create Session ${server_ip} http://${server_ip}:${server_port} auth=${AUTH} headers=${HEADERS}
+ ${att_workflow_service_id}= Get Service Owner Id ${ATT_SERVICE}
+ ${volt_service_id}= Get Service Owner Id ${VOLT_SERVICE}
+ ${AttWhiteListList}= utils.jsonToList ${WHITELIST_PATHFILE} AttWhiteListInfo
+ Set Suite Variable ${alist} ${AttWhiteListList}
+ ${AttWhiteListList} = Get Variable Value ${alist}
+ ${AttWhiteListDict}= utils.listToDict ${AttWhiteListList} 0
+ ${AttWhiteListDict}= utils.setFieldValueInDict ${AttWhiteListDict} owner_id ${att_workflow_service_id}
+ ${onu_sn}= Get From Dictionary ${AttWhiteListDict} serial_number
+ Log ${onu_sn}
+ Set Global Variable ${onu_sn}
+ ${SubscriberList}= utils.jsonToList ${SUBSCRIBER_PATHFILE} SubscriberInfo
+ Set Global Variable ${slist} ${SubscriberList}
+ ${SubscriberList} = Get Variable Value ${slist}
+ ${SubscriberDict}= utils.listToDict ${SubscriberList} 0
+ ${s_tag}= utils.getFieldValueFromDict ${SubscriberDict} s_tag
+ ${c_tag}= utils.getFieldValueFromDict ${SubscriberDict} c_tag
+ ${VoltDeviceList}= utils.jsonToList ${VOLT_DEVICE_PATHFILE} VOLTDeviceInfo
+ Set Global Variable ${vlist} ${VoltDeviceList}
+ Set Suite Variable ${s_tag}
+ Set Suite Variable ${c_tag}
+ ${RG_CONTAINER}= Run kubectl -n voltha get pod|grep "^rg-"|cut -d' ' -f1
+ Set Suite Variable ${RG_CONTAINER}
+
+Teardown
+ [Documentation] Performs any additional cleanup required
+ Log Suite Teardown cleanup
+ Delete All Sessions
+
+Clean Test Environment
+ ## TODO: fix this. not working right now
+ #Run kubectl -n voltha exec ${RG_CONTAINER} -- kill $(ps aux | grep [w]pa_supplicant | awk '{print $2}')
+ Log Need to kill wpa_supplicant process on RG
+
+Validate ONU States
+ [Arguments] ${expected_op_status} ${expected_admin_status}
+ ${operational_status} ${admin_status} ONU Status Check ${onu_sn}
+ Should Be Equal ${operational_status} ${expected_op_status}
+ Should Be Equal ${admin_status} ${expected_admin_status}
+
+Validate ATT Workflow Driver SI
+ [Arguments] ${expected_status} ${expected_auth_status}
+ ${onu_state} ${authentication_status} Service Instance Status Check ${onu_sn}
+ Should Be Equal ${onu_state} ${expected_status}
+ Should Be Equal ${authentication_status} ${expected_auth_status}
+
+Validate Subscriber Status
+ [Arguments] ${exepected_status}
+ ${status} Subscriber Status Check ${onu_sn}
+ Should Be Equal ${status} ${exepected_status}
+
+Ping From RG
+ [Arguments] ${status}
+ ${result}= Run kubectl -n voltha exec ${RG_CONTAINER} -- ping -c 5 172.18.0.10
+ Run Keyword If '${status}' == 'PASS' Should Contain ${result} 64 bytes
+ Run Keyword If '${status}' == 'PASS' Should Contain ${result} 0% packet loss
+ Run Keyword If '${status}' == 'PASS' Should Not Contain ${result} 100% packet loss
+ Run Keyword If '${status}' == 'PASS' Should Not Contain ${result} 80% packet loss
+ Run Keyword If '${status}' == 'PASS' Should Not Contain ${result} 60% packet loss
+ Run Keyword If '${status}' == 'PASS' Should Not Contain ${result} 40% packet loss
+ Run Keyword If '${status}' == 'PASS' Should Not Contain ${result} 20% packet loss
+ Run Keyword If '${status}' == 'PASS' Should Not Contain ${result} Destination Host Unreachable
+ Run Keyword If '${status}' == 'FAIL' Should Not Contain ${result} 64 bytes
+ Run Keyword If '${status}' == 'FAIL' Should Contain ${result} 100% packet loss
+ Log To Console \n ${result}
diff --git a/src/test/cord-api/Tests/WorkflowValidations/data/SIABOLTDevice.json b/src/test/cord-api/Tests/WorkflowValidations/data/SIABOLTDevice.json
new file mode 100644
index 0000000..36db256
--- /dev/null
+++ b/src/test/cord-api/Tests/WorkflowValidations/data/SIABOLTDevice.json
@@ -0,0 +1,15 @@
+{
+ "VOLTDeviceInfo" : [
+ {
+ "device_type": "ponsim_olt",
+ "host": "olt.voltha.svc",
+ "port": 50060,
+ "switch_datapath_id": "of:0000000000000001",
+ "switch_port": "2",
+ "outer_tpid": "0x8100",
+ "name": "PONSIM OLT",
+ "uplink": "2",
+ "volt_service_id": 2
+ }
+ ]
+}
diff --git a/src/test/cord-api/Tests/WorkflowValidations/data/SIABSubscriber.json b/src/test/cord-api/Tests/WorkflowValidations/data/SIABSubscriber.json
new file mode 100644
index 0000000..52b4244
--- /dev/null
+++ b/src/test/cord-api/Tests/WorkflowValidations/data/SIABSubscriber.json
@@ -0,0 +1,13 @@
+{
+ "SubscriberInfo" : [
+ {
+ "name": "QQClient",
+ "s_tag": 222,
+ "c_tag": 111,
+ "onu_device": "PSMO12345678",
+ "mac_address": "00:AA:00:00:00:01",
+ "ip_address": "10.8.2.1",
+ "status": "pre-provisioned"
+ }
+ ]
+}
diff --git a/src/test/cord-api/Tests/WorkflowValidations/data/SIABWhitelist.json b/src/test/cord-api/Tests/WorkflowValidations/data/SIABWhitelist.json
new file mode 100644
index 0000000..c52efd7
--- /dev/null
+++ b/src/test/cord-api/Tests/WorkflowValidations/data/SIABWhitelist.json
@@ -0,0 +1,10 @@
+{
+ "AttWhiteListInfo" : [
+ {
+ "serial_number": "PSMO12345678",
+ "device_id" : "of:0000aabbccddeeff",
+ "pon_port_id" : 1,
+ "owner_id" : "1"
+ }
+ ]
+}
diff --git a/src/test/cord-api/Tests/WorkflowValidations/data/SIABWorkflowDriver.json b/src/test/cord-api/Tests/WorkflowValidations/data/SIABWorkflowDriver.json
new file mode 100644
index 0000000..86d0e4e
--- /dev/null
+++ b/src/test/cord-api/Tests/WorkflowValidations/data/SIABWorkflowDriver.json
@@ -0,0 +1,7 @@
+{
+ "AttWorkFlowDriverInfo" : [
+ {
+ "name": "att-workflow-driver"
+ }
+ ]
+}