enhancing physical pod e2e tests

Change-Id: Ia03607c858e11dab3fb64f4303d68cc47f344d23
diff --git a/src/test/cord-api/Framework/ATTWorkFlowDriver.robot b/src/test/cord-api/Framework/ATTWorkFlowDriver.robot
index d38c8c4..785e53b 100644
--- a/src/test/cord-api/Framework/ATTWorkFlowDriver.robot
+++ b/src/test/cord-api/Framework/ATTWorkFlowDriver.robot
@@ -1,5 +1,19 @@
+# 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     Library to retrieve status fields from ATT WorkFlow Driver Service Instance List 
+Documentation     Library to retrieve status fields from ATT WorkFlow Driver Service Instance List
 Library           Collections
 Library           String
 Library           OperatingSystem
@@ -16,9 +30,9 @@
     Log    ${json_result}
     ${json_result_list}=    Get From dictionary    ${json_result}    items
     ${getJsonDict}=    utils.getDictFromListOfDict    ${json_result_list}    serial_number    ${onu_device}
-    ${status}=  Get From Dictionary    ${getJsonDict}   valid 
+    ${status}=  Get From Dictionary    ${getJsonDict}   status
     ${authentication_status}=  Get From Dictionary    ${getJsonDict}   authentication_state
-    [Return]    ${status}    ${authentication_status} 
+    [Return]    ${status}    ${authentication_status}
 
 Create Whitelist Entry
     [Arguments]    ${entry_list}    ${list_index}
diff --git a/src/test/cord-api/Framework/Subscriber.robot b/src/test/cord-api/Framework/Subscriber.robot
index 864bef2..e4791f0 100644
--- a/src/test/cord-api/Framework/Subscriber.robot
+++ b/src/test/cord-api/Framework/Subscriber.robot
@@ -27,11 +27,22 @@
     SSHLibrary.Write    sudo wpa_supplicant -B -i ${iface} -Dwired -c /etc/wpa_supplicant/${conf_file}
     Read Until    [sudo] password for ${user}:
     SSHLibrary.Write    ${pass}
-    ${result}=    Read Until    ${prompt}
+    ${result}=    Read Until    wpa_supplicant
+    Log To Console    \n\n ${result}\n
     SSHLibrary.Close Connection
     Should Contain    ${result}    Successfully initialized wpa_supplicant
     [Return]    ${result}
 
+Delete IP Addresses from Interface on Remote Host
+    [Arguments]    ${ip}    ${user}    ${pass}    ${interface}    ${prompt}=$    ${prompt_timeout}=60s
+    ${conn_id}=    SSHLibrary.Open Connection    ${ip}    prompt=${prompt}    timeout=${prompt_timeout}
+    SSHLibrary.Login    ${user}    ${pass}
+    SSHLibrary.Write    sudo ip addr flush dev ${interface}; echo $?
+    Read Until    [sudo] password for ${user}:
+    SSHLibrary.Write    ${pass}
+    ${result}=    Read Until    ${prompt}
+    SSHLibrary.Close Connection
+
 Subscriber Status Check
     [Arguments]    ${onu_device}
     [Documentation]    Returns Status from Subscribers List for a particular ONU device
@@ -70,13 +81,60 @@
     ${api_result}=    restApi.ApiChameleonDelete    VOLT_SUBSCRIBER    ${id}
     Should Be True    ${api_result}
 
-Delete IP Addresses from Interface on Remote Host
-    [Arguments]    ${ip}    ${user}    ${pass}    ${interface}    ${prompt}=$    ${prompt_timeout}=60s
-    [Documentation]    Deletes all ip addresses assigned to a particular interface on a remote host
+Add Double Vlan Interface on Host
+    [Arguments]    ${ip}    ${user}    ${pass}    ${interface}    ${stag}    ${ctag}    ${prompt}=$    ${prompt_timeout}=60s
     ${conn_id}=    SSHLibrary.Open Connection    ${ip}    prompt=${prompt}    timeout=${prompt_timeout}
     SSHLibrary.Login    ${user}    ${pass}
-    SSHLibrary.Write    sudo ip addr flush dev ${interface}; echo $?
+    SSHLibrary.Write    sudo ip link add link ${interface} name ${interface}.${stag} type vlan id ${stag}
+    Read Until    [sudo] password for ${user}:
+    SSHLibrary.Write    ${pass}
+    SSHLibrary.Write    sudo ip link set ${interface}.${stag} up
+    ${result}=    Read Until    ${prompt}
+    SSHLibrary.Write    sudo ip link add link ${interface}.${stag} name ${interface}.${stag}.${ctag} type vlan id ${ctag}
+    ${result}=    Read Until    ${prompt}
+    SSHLibrary.Write    sudo ip link set ${interface}.${stag}.${ctag} up
+    ${result}=    Read Until    ${prompt}
+    SSHLibrary.Write    ifconfig ${interface}.${stag}.${ctag}
+    ${result}=    Read Until    ${prompt}
+    SSHLibrary.Close Connection
+
+Delete Interface on Remote Host
+    [Arguments]    ${ip}    ${user}    ${pass}    ${interface}    ${prompt}=$    ${prompt_timeout}=60s
+    ${conn_id}=    SSHLibrary.Open Connection    ${ip}    prompt=${prompt}    timeout=${prompt_timeout}
+    SSHLibrary.Login    ${user}    ${pass}
+    SSHLibrary.Write    sudo ip link del ${interface}
+    Read Until    [sudo] password for ${user}:
+    SSHLibrary.Write    ${pass}
+    Read Until    ${prompt}
+    SSHLibrary.Close Connection
+
+Add Ip Address on Interface on Host
+    [Arguments]    ${ip}    ${user}    ${pass}    ${ip_address}    ${interface}    ${prompt}=$    ${prompt_timeout}=60s
+    ${conn_id}=    SSHLibrary.Open Connection    ${ip}    prompt=${prompt}    timeout=${prompt_timeout}
+    SSHLibrary.Login    ${user}    ${pass}
+    SSHLibrary.Write    sudo ip addr add ${ip_address} dev ${interface}
+    Read Until    [sudo] password for ${user}:
+    SSHLibrary.Write    ${pass}
+    Read Until    ${prompt}
+    SSHLibrary.Close Connection
+
+Start DHCP Server on Remote Host
+    [Arguments]    ${ip}    ${user}    ${pass}    ${interface}    ${prompt}=$    ${prompt_timeout}=60s
+    ${conn_id}=    SSHLibrary.Open Connection    ${ip}    prompt=${prompt}    timeout=${prompt_timeout}
+    SSHLibrary.Login    ${user}    ${pass}
+    SSHLibrary.Write    sudo dhcpd -cf /etc/dhcp/dhcpd.conf ${interface}
     Read Until    [sudo] password for ${user}:
     SSHLibrary.Write    ${pass}
     ${result}=    Read Until    ${prompt}
+    Should Contain    ${result}    Listening on LPF/${interface}
     SSHLibrary.Close Connection
+
+Add Route to Remote Host
+    [Arguments]    ${ip}    ${user}    ${pass}    ${subnet}    ${gateway}    ${interface}    ${prompt}=$    ${prompt_timeout}=60s
+    ${conn_id}=    SSHLibrary.Open Connection    ${ip}    prompt=${prompt}    timeout=${prompt_timeout}
+    SSHLibrary.Login    ${user}    ${pass}
+    SSHLibrary.Write    sudo ip route add ${subnet} via ${gateway} dev ${interface}
+    Read Until    [sudo] password for ${user}:
+    SSHLibrary.Write    ${pass}
+    ${result}=    Read Until    ${prompt}
+    SSHLibrary.Close Connection
\ No newline at end of file
diff --git a/src/test/cord-api/Framework/utils/utils.robot b/src/test/cord-api/Framework/utils/utils.robot
index 251b472..76cca11 100644
--- a/src/test/cord-api/Framework/utils/utils.robot
+++ b/src/test/cord-api/Framework/utils/utils.robot
@@ -176,4 +176,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
+    Should Contain    ${rc}    0
\ No newline at end of file
diff --git a/src/test/cord-api/Tests/WorkflowValidations/ATT_Test001.txt b/src/test/cord-api/Tests/WorkflowValidations/ATT_Test001.txt
index 27da4b6..34223c6 100644
--- a/src/test/cord-api/Tests/WorkflowValidations/ATT_Test001.txt
+++ b/src/test/cord-api/Tests/WorkflowValidations/ATT_Test001.txt
@@ -1,34 +1,49 @@
+# 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 successful ping from end-end
 Suite Setup       Read InputFile
-#Suite Teardown    Teardown
+Suite Teardown    Teardown
 Library           Collections
 Library           String
 Library           OperatingSystem
 Library           XML
 Library           RequestsLibrary
 Library           ../../Framework/utils/utils.py
-Resource           ../../Framework/utils/utils.robot
+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
+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/ATTWhiteList.json
 ${SUBSCRIBER_PATHFILE}    ${CURDIR}/data/ATTSubscriber.json
-${src_ip}         X.X.X.X
-${src_gateway}    X.X.X.X
-${src_user}       user
-${src_pass}       pass
-${src_iface}      eth0
-${dst_ip}         X.X.X.X
-${dst_user}       user
-${dst_pass}       pass
-${dst_gateway}    X.X.X.X
-${dst_host_ip}    X.X.X.X
+${src_ip}          X.X.X.X
+${src_gateway}     X.X.X.X
+${src_user}        user
+${src_pass}        pass
+${src_iface}       eth0
+${dst_ip}          X.X.X.X
+${dst_dp_iface}    eth0
+${dst_dp_ip}       X.X.X.X
+${dst_user}        user
+${dst_pass}        pass
+${dst_gateway}     X.X.X.X
 
 *** Test Cases ***
 Validate ONU States
@@ -55,13 +70,23 @@
     [Documentation]    Validate subscriber status in the rcordsubscriber list
     Wait Until Keyword Succeeds    60s    2s    Validate Subscriber Status    ENABLED
 
+Configure QinQ Interface on Dest Server
+    [Documentation]    Configure a QinQ (802.11q) interface to pass double tagged traffic from RG
+    Add Double Vlan Interface on Host    ${dst_ip}    ${dst_user}    ${dst_pass}    ${dst_dp_iface}    ${s_tag}    ${c_tag}
+    Add IP Address on Interface on Host    ${dst_ip}    ${dst_user}    ${dst_pass}    ${dst_dp_ip}/24    ${dst_dp_iface}.${stag}.${c_tag}
+    Add Route to Remote Host    ${dst_ip}    ${dst_user}    ${dst_pass}    ${dst_dp_ip}    ${src_gateway}    ${dst_dp_iface}.${stag}.${c_tag}
+
+Start DHCP Server on QinQ Interface
+    [Documentation]    Start dhcpd on the previously configured interface on the destination server
+    Start DHCP Server on Remote Host    ${dst_ip}    ${dst_user}    ${dst_pass}    ${dst_dp_iface}.${stag}.${ctag}
+
 Execute Dhclient on RG
     [Documentation]    Run dhclient on the dataplane interface on the RG
     Send Dhclient Request    ${src_ip}    ${src_user}    ${src_pass}    ${src_iface}
 
 Test E2E Connectivity
     [Documentation]    Test pings after subscriber has been authenticated + enabled
-    Wait Until Keyword Succeeds    60s    2s    Test Ping    PASS    ${src_ip}    ${src_user}    ${src_pass}    ${dst_host_ip}
+    Wait Until Keyword Succeeds    60s    5s    Test Ping    PASS    ${src_ip}    ${src_user}    ${src_pass}    ${dst_dp_ip}
 
 *** Keywords ***
 Read InputFile
@@ -74,17 +99,23 @@
     Set Global Variable    ${onu_device}
     ${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
+    Set Suite Variable    ${s_tag}
+    Set Suite Variable    ${c_tag}
 
 Teardown
     [Documentation]    Delete xos objects and kill process on src host
-    ##in some tests, these processes will not get started
     Run Keyword And Ignore Error    Kill Linux Process    ${src_ip}    ${src_user}    ${src_pass}    [w]pa_supplicant
     Run Keyword And Ignore Error    Kill Linux Process    ${src_ip}    ${src_user}    ${src_pass}    [d]hclient
+    Run Keyword And Ignore Error    Kill Linux Process    ${dst_ip}    ${dst_user}    ${dst_pass}    [d]hcpd
     Delete IP Addresses from Interface on Remote Host    ${src_ip}    ${src_user}    ${src_pass}    ${src_iface}
-    Clean Up Objects   ${VOLT_SUBSCRIBER}
-    ##need to keep retrying to delete olt device until subscriber is completely removed from xos
-    Wait Until Keyword Succeeds    60s    2s    Clean Up Objects   ${VOLT_DEVICE}
-    Clean Up Objects   ${ATT_WHITELIST}
+    Delete Interface on Remote Host    ${dst_ip}    ${dst_user}    ${dst_pass}    ${dst_dp_iface}.${stag}
+    #Clean Up Objects   ${VOLT_SUBSCRIBER}
+    #Clean Up Objects   ${VOLT_DEVICE}
+    #Clean Up Objects   ${ATT_WHITELIST}
 
 Validate ONU States
     [Arguments]    ${expected_op_status}    ${expected_admin_status}
@@ -101,4 +132,4 @@
 Validate Subscriber Status
     [Arguments]    ${exepected_status}
     ${status}    Subscriber Status Check    ${onu_device}
-    Should Be Equal    ${status}    ${exepected_status}
+    Should Be Equal    ${status}    ${exepected_status}
\ No newline at end of file