[SEBA-184] test updates for attworkflow

Change-Id: I1c7adea2a81c43fd3536cce18b103725ae35341e
diff --git a/Jenkinsfile-rcordlite-zerotouch b/Jenkinsfile-rcordlite-zerotouch
index 22edfdb..4625ce0 100644
--- a/Jenkinsfile-rcordlite-zerotouch
+++ b/Jenkinsfile-rcordlite-zerotouch
@@ -47,6 +47,7 @@
                     helm ls | grep xos-core && helm delete --purge xos-core || true
                     helm ls | grep cord-kafka && helm delete --purge cord-kafka || true
                     helm ls | grep voltha-kafka && helm delete --purge voltha-kafka || true
+                    helm ls | grep hippie && helm delete --purge hippie-oss || true
                     """
                 } catch(error) { currentBuild.result = 'FAILURE' }
                 // Wait for helm delete
@@ -55,7 +56,7 @@
                         try {
                             sh """
                             export KUBECONFIG=/home/cord/${deployment_config.pod_config}
-                            ! helm ls | grep -E 'onos-voltha|onos-fabric|voltha |rcord-lite|xos-core|cord-kafka|voltha-kafka’
+                            ! helm ls | grep -E 'onos-voltha|onos-fabric|voltha |rcord-lite|xos-core|cord-kafka|voltha-kafka'
                             ! kubectl get pods --all-namespaces | grep -E 'onos-voltha|onos-fabric|cord-kafka|voltha |rcord-lite-|xos-'
                             """
                             return true
@@ -66,6 +67,20 @@
                 }
             }
         }
+        stage('Restart OLT processes') {
+            timeout(5) {
+                try {
+                    sh """
+                    export KUBECONFIG=/home/cord/${deployment_config.pod_config}
+                    sshpass -p onl ssh -l root 10.192.4.218 'pkill bal_core_dist || true'
+                    sshpass -p onl ssh -l root 10.192.4.218 'pkill openolt || true'
+                    sshpass -p onl ssh -l root 10.192.4.218 'cd /broadcom; ./bal_core_dist -C :55001 < /dev/tty1 > ./bal.log 2>&1 &'
+                    sshpass -p onl ssh -l root 10.192.4.218 'cd /broadcom; ./openolt -C 127.0.0.1:55001 < /dev/tty1 > ./openolt.log 2>&1 &'
+                    sleep 120
+                    """
+                } catch(error) { currentBuild.result = 'FAILURE' }
+            }
+        }
         stage('Install Kafka') {
             timeout(10) {
                 try {
@@ -89,6 +104,7 @@
                     helm install -n xos-core xos-core
                     helm dep update xos-profiles/rcord-lite
                     helm install -n rcord-lite xos-profiles/rcord-lite
+                    helm install -n hippie-oss xos-services/hippie-oss
                     """
                 } catch(error) { currentBuild.result = 'FAILURE' }
             }
@@ -139,20 +155,6 @@
                 }
             }
         }
-        stage('Restart OLT processes') {
-            timeout(5) {
-                try {
-                    sh """
-                    export KUBECONFIG=/home/cord/${deployment_config.pod_config}
-                    sshpass -p onl ssh -l root 10.192.4.218 'pkill bal_core_dist'
-                    sshpass -p onl ssh -l root 10.192.4.218 'pkill openolt'
-                    sshpass -p onl ssh -l root 10.192.4.218 'cd /broadcom; ./bal_core_dist -C 127.0.0.1:40000 -A 127.0.0.1:50000 < /dev/tty1 > ./bal.log 2>&1 &'
-                    sshpass -p onl ssh -l root 10.192.4.218 'cd /broadcom; ./openolt -C 127.0.0.1:40000 -A 127.0.0.1:50000 < /dev/tty1 > ./openolt.log 2>&1 &'
-                    sleep 180
-                    """
-                } catch(error) { currentBuild.result = 'FAILURE' }
-            }
-        }
         stage('Download cord-tester repo') {
             timeout(10) {
                 try {
@@ -190,12 +192,25 @@
                     rm -rf Log/ || true
                     pybot -d Log -T FabricConfig.txt || true
                     pybot -d Log -T HippieOSS.txt || true
+                    sleep 5
                     pybot -d Log -T OSSVolt.txt || true
                     pybot -d Log -T RealOLT_Test.txt || true
                     """
                 } catch(error) { currentBuild.result = 'FAILURE' }
             }
         }
+        stage('Subscriber Validation and Ping Tests') {
+             timeout(20) {
+                try {
+                    sh """
+                    export KUBECONFIG=/home/cord/${deployment_config.pod_config}
+                    cd /home/cord/cord-tester/src/test/cord-api/Tests/
+                    pybot -d Log -T HippieOSS_instances.txt || true
+                    pybot -d Log -T -v src_ip:${deployment_config.srcHost.ip} -v src_user:${deployment_config.srcHost.user} -v src_pass:${deployment_config.srcHost.pass} -v dst_user:${deployment_config.dstHost.user} -v dst_pass:${deployment_config.dstHost.pass} -v dst_ip:${deployment_config.dstHost.ip} -v dst_host_ip:${deployment_config.dstHost.hostIp} -v src_gateway:${deployment_config.srcHost.gateway} -v dst_gateway:${deployment_config.dstHost.gateway} -v ENABLE_STATUS:FAIL -v MACIP_STATUS:PASS Subscriber_StatusChecks.txt || true
+                    """
+                } catch(error) { currentBuild.result = 'FAILURE' }
+            }
+        }
         stage('Publish') {
             try {
                 sh """
diff --git a/src/test/cord-api/Properties/RestApiProperties.py b/src/test/cord-api/Properties/RestApiProperties.py
index 24c5802..072c1ec 100644
--- a/src/test/cord-api/Properties/RestApiProperties.py
+++ b/src/test/cord-api/Properties/RestApiProperties.py
@@ -66,4 +66,8 @@
 SWITCH_PORT = '/xosapi/v1/fabric/switchports'
 PORT_INTERFACE = '/xosapi/v1/fabric/portinterfaces'
 OSS_SERVICE = '/xosapi/v1/hippie-oss/hippieossservices'
+OSS_SERVICEINSTANCE = '/xosapi/v1/hippie-oss/hippieossserviceinstances'
 OSS_VOLT = '/xosapi/v1/core/servicedependencys'
+BNG_MAP = '/xosapi/v1/fabric-crossconnect/bngportmappings'
+ATT_SERVICE = '/xosapi/v1/att-workflow-driver/attworkflowdriverservices'
+ATT_WHITELIST = '/xosapi/v1/att-workflow-driver/attworkflowdriverwhitelistentries'
diff --git a/src/test/cord-api/Tests/BNGPortMapping.txt b/src/test/cord-api/Tests/BNGPortMapping.txt
new file mode 100644
index 0000000..274932d
--- /dev/null
+++ b/src/test/cord-api/Tests/BNGPortMapping.txt
@@ -0,0 +1,51 @@
+*** Settings ***
+Documentation     Test suite for configuring BNG Port Mapping
+Suite Setup       Read InputFile
+Test Template     Configuring BNG Port Mapping 
+Library           Collections
+Library           String
+Library           OperatingSystem
+Library           XML
+Library           RequestsLibrary
+Library           ../Framework/utils/utils.py
+Library           ../Framework/restApi.py
+
+*** Variables ***
+${PATHFILE}       ${CURDIR}/data/BNGPortMapping.json
+
+*** Test Cases ***    TYPE                         LISTINDEX
+Test Create BNGPortMapping-1
+                      CREATE                       0
+Test Get BNGPortMapping-1
+                      RETRIEVE                     0
+
+*** Keywords ***
+Read InputFile
+    ${BNGList}=    utils.jsonToList    ${PATHFILE}    BNGPortMapping
+    Set Suite Variable    ${dlist}    ${BNGList}
+    Set Global Variable    ${BNG_Id}    ${EMPTY}
+
+Configuring BNG Port Mapping 
+    [Arguments]    ${type}    ${listIndex}
+    Run Keyword If    "${type}" == "CREATE"    Create BNG Mapping    ${listIndex}
+    Run Keyword If    "${type}" == "RETRIEVE"    Validate posted BNG Port   ${listIndex}
+
+Create BNG Mapping
+    [Arguments]    ${listIndex}
+    ${BNGList} =    Get Variable Value    ${dlist}
+    ${BNGDict}=    utils.listToDict    ${BNGList}    ${listIndex}
+    ${api_result_status}    ${api_result_json}=    restApi.ApiPostReturnJson    BNG_MAP    ${BNGDict}
+    Should Be True    ${api_result_status}
+    ${BNG_Id}=    Get From Dictionary    ${api_result_json}    id
+    Set Global Variable    ${BNG_Id}
+
+Validate posted BNG Port
+    [Arguments]    ${listIndex}
+    Log    ${BNG_Id}
+    ${json_result}=    restApi.ApiChameleonGet    BNG_MAP    ${BNG_Id}
+    Log    ${json_result}
+    ${BNGList} =    Get Variable Value    ${dlist}
+    ${BNGDict}=    utils.listToDict    ${BNGList}    ${listIndex}
+    Log    ${BNGDict}
+    ${test_result}=    utils.compare_dict    ${BNGDict}    ${json_result}
+    Should Be True    ${test_result}
diff --git a/src/test/cord-api/Tests/FabricConfig.txt b/src/test/cord-api/Tests/FabricConfig.txt
index fc57902..410b169 100644
--- a/src/test/cord-api/Tests/FabricConfig.txt
+++ b/src/test/cord-api/Tests/FabricConfig.txt
@@ -28,10 +28,6 @@
                       INTERFACECREATE                       0
 Test Get FabricPortInterface-1
                       INTERFACERETRIEVE     0
-Test Create FarbicSwitch-2
-                      CREATE                       1
-Test Get FabricSwitch-2
-                      RETRIEVE     1
 Test Create FabricSwitchPort-2
                       PORTCREATE                       1
 Test Get FabricSwitchPort-2
@@ -40,14 +36,6 @@
                       INTERFACECREATE                       1
 Test Get FabricPortInterface-2
                       INTERFACERETRIEVE     1
-Test Create FarbicSwitch-3
-                      CREATE                       2
-Test Get FabricSwitch-3
-                      RETRIEVE     2
-Test Create FarbicSwitch-4
-                      CREATE                       3
-Test Get FabricSwitch-4
-                      RETRIEVE     3
 
 *** Keywords ***
 Read InputFile
diff --git a/src/test/cord-api/Tests/Subscriber_StatusChecks.txt b/src/test/cord-api/Tests/Subscriber_StatusChecks.txt
index 0743414..ae85153 100644
--- a/src/test/cord-api/Tests/Subscriber_StatusChecks.txt
+++ b/src/test/cord-api/Tests/Subscriber_StatusChecks.txt
@@ -1,6 +1,6 @@
 *** Settings ***
 Documentation     Test suite for checking the subscriber status after discovery
-Suite Setup       Read InputFile
+Suite Setup       Setup
 Test Template     Subscriber Status Test
 Library           Collections
 Library           String
@@ -8,12 +8,22 @@
 Library           XML
 Library           RequestsLibrary
 Library           ../Framework/utils/utils.py
+Resource          ../Framework/utils/utils.robot
 Library           ../Framework/restApi.py
 
 *** Variables ***
 ${PATHFILE}       ${CURDIR}/data/Subscriber_TopDown.json
 &{input_dict}    mac_address=test    ip_address=test2
 &{status}    status=test
+${src_ip}         X.X.X.X
+${src_gateway}    X.X.X.X
+${src_user}       user
+${src_pass}       pass
+${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
 
 *** Test Cases ***    TYPE                         LISTINDEX
 Test Status Subscriber-1
@@ -22,14 +32,14 @@
                       STATUSCHANGE             0
 Push MACandIP Subscriber-1
                       PUSH                     0
-Test Status Subscriber-2
-                      STATUS                       1
-Change Subscriber-2 status
-                      STATUSCHANGE             1
-Push MACandIP Subscriber-2
-                      PUSH                     1
 
 *** Keywords ***
+Setup
+    [Documentation]    Read input file and send arping requests from host/dst to their gateways
+    Read InputFile
+    Run Keyword And Ignore Error    Wait Until Keyword Succeeds    300s    5s    Ping Gateway    ${src_ip}    ${src_user}    ${src_pass}    ${src_gateway}
+    Run Keyword And Ignore Error    Wait Until Keyword Succeeds    300s    5s    Ping Gateway    ${dst_ip}    ${dst_user}    ${dst_pass}    ${dst_gateway}
+
 Read InputFile
     ${SubscriberList}=    utils.jsonToList    ${PATHFILE}   SubscriberInfo 
     Set Suite Variable    ${slist}    ${SubscriberList}
@@ -39,7 +49,7 @@
 Subscriber Status Test
     [Arguments]    ${type}    ${listIndex}
     Run Keyword If    "${type}" == "PUSH"    Push MAC and IP For Subscriber    ${listIndex}
-    Run Keyword If    "${type}" == "STATUS"    Subscriber Status Check    ${listIndex}
+    Run Keyword If    "${type}" == "STATUS"    Wait Until Keyword Succeeds    60s    5s    Subscriber Status Check    ${listIndex}
     Run Keyword If    "${type}" == "STATUSCHANGE"    Subscriber Status Change   ${listIndex}
 
 Subscriber Status Check
@@ -57,7 +67,8 @@
     ${status}=	Get From Dictionary    ${getJsonDict}    status
     ${Subscriber_Id}=    Get From Dictionary    ${getJsonDict}   id
     Set Global Variable    ${Subscriber_Id}
-    Should Be Equal    ${status}    awaiting_auth
+    Should Be Equal    ${status}    awaiting-auth
+    Wait Until Keyword Succeeds    60s    2s    Test Ping    ${ENABLE_STATUS}    ${src_ip}    ${src_user}    ${src_pass}    ${dst_host_ip}
     #Set Global Variable    ${Subscriber_Id}
 
 Subscriber Status Change
@@ -65,6 +76,7 @@
     ${status}=    Create Dictionary    status=enabled
     ${api_result_status}=    restApi.ApiChameleonPut    VOLT_SUBSCRIBER    ${status}    ${Subscriber_Id}
     Should Be True    ${api_result_status}
+    Wait Until Keyword Succeeds    60s    2s    Test Ping    ${ENABLE_STATUS}    ${src_ip}    ${src_user}    ${src_pass}    ${dst_host_ip}
 
 Push MAC and IP For Subscriber
     [Arguments]    ${listIndex}
@@ -75,3 +87,18 @@
     ${input_dict}=    Create Dictionary    mac_address=${mac_address}    ip_address=${ip_address}
     ${api_result_status}=    restApi.ApiChameleonPut    VOLT_SUBSCRIBER    ${input_dict}    ${Subscriber_Id}
     Should Be True    ${api_result_status}
+    Wait Until Keyword Succeeds    60s    2s    Test Ping    ${MACIP_STATUS}    ${src_ip}    ${src_user}    ${src_pass}    ${dst_host_ip}
+
+Ping Gateway
+    [Documentation]    SSH's into a host and sends an arping to its gateway for host discovery
+    [Arguments]    ${ip}    ${user}    ${pass}    ${gateway}    ${prompt}=$    ${prompt_timeout}=60s
+    ${conn_id}=    SSHLibrary.Open Connection    ${ip}    prompt=${prompt}    timeout=${prompt_timeout}
+    SSHLibrary.Login    ${user}    ${pass}
+    SSHLibrary.Write    sudo arping -c 1 ${gateway}
+    Read Until    [sudo] password for ${user}:
+    SSHLibrary.Write    ${pass}
+    ${result}=    Read Until    ${prompt}
+    Should Not Contain    ${result}    100% unanswered
+    Should Contain    ${result}    0% unanswered
+    Log To Console    \n ${result}
+    SSHLibrary.Close Connection
diff --git a/src/test/cord-api/Tests/data/AttWhiteList.json b/src/test/cord-api/Tests/data/AttWhiteList.json
new file mode 100644
index 0000000..cd0624a
--- /dev/null
+++ b/src/test/cord-api/Tests/data/AttWhiteList.json
@@ -0,0 +1,10 @@
+{
+    "AttWhiteList" : [
+    {
+            "serial_number": "",
+            "device_id" : "1",
+            "pon_port_id" : "",
+            "owner_id" : "1"
+    }
+  ]
+}
diff --git a/src/test/cord-api/Tests/data/AttWorkFlowDriver.json b/src/test/cord-api/Tests/data/AttWorkFlowDriver.json
new file mode 100644
index 0000000..22572b7
--- /dev/null
+++ b/src/test/cord-api/Tests/data/AttWorkFlowDriver.json
@@ -0,0 +1,7 @@
+{
+    "AttWorkFlowDriver" : [
+    {
+            "name": "att-workflow-driver"
+    }
+  ]
+}
diff --git a/src/test/cord-api/Tests/data/BNGPortMapping.json b/src/test/cord-api/Tests/data/BNGPortMapping.json
new file mode 100644
index 0000000..d69cf92
--- /dev/null
+++ b/src/test/cord-api/Tests/data/BNGPortMapping.json
@@ -0,0 +1,8 @@
+{
+    "BNGPortMapping" : [
+    {
+            "s_tag": "any",
+            "switch_port" : 8
+    }
+  ]
+}
diff --git a/src/test/cord-api/Tests/data/FabricPortInterface.json b/src/test/cord-api/Tests/data/FabricPortInterface.json
index 7a5061b..a0e724f 100644
--- a/src/test/cord-api/Tests/data/FabricPortInterface.json
+++ b/src/test/cord-api/Tests/data/FabricPortInterface.json
@@ -1,12 +1,12 @@
 {
     "FabricPortInterface" : [
     {
-            "name": "OLT Leaf1- Interface-1",
+            "name": "Switch Interface-1",
             "ips": "10.8.2.254/24",
-            "port_id": 8
+            "port_id": 1
     },
     {
-            "name": "OLT Leaf2- Interface-2",
+            "name": "Switch Interface-2",
             "ips": "10.8.3.254/24",
             "vlanUntagged": 100,
             "port_id": 9
diff --git a/src/test/cord-api/Tests/data/FabricSwitch.json b/src/test/cord-api/Tests/data/FabricSwitch.json
index 6f32b22..8c2ac96 100644
--- a/src/test/cord-api/Tests/data/FabricSwitch.json
+++ b/src/test/cord-api/Tests/data/FabricSwitch.json
@@ -2,39 +2,12 @@
     "FabricSwitchInfo" : [
     {
             "driver": "ofdpa3",
-            "ipv4Loopback": "192.168.9.22",
-            "ipv4NodeSid": 18,
-            "isEdgeRouter": true,
-            "name": "Fabric Switch - Leaf1",
-            "ofId": "of:0000cc37abd93769",
-            "routerMac": "00:00:00:00:00:01"
-    },
-    {
-            "driver": "ofdpa3",
-            "ipv4Loopback": "192.168.9.23",
-            "ipv4NodeSid": 17,
-            "isEdgeRouter": true,
-            "name": "Fabric Switch - Leaf2",
-            "ofId": "of:0000cc37abb6b564",
-            "routerMac": "00:00:00:00:00:02"
-    },
-    {
-            "driver": "ofdpa3",
             "ipv4Loopback": "192.168.9.24",
             "ipv4NodeSid": 19,
             "isEdgeRouter": false,
-            "name": "Fabric Switch - Spine1",
+            "name": "Fabric Switch - 1",
             "ofId": "of:0000cc37ab5b6da8",
             "routerMac": "00:00:00:00:00:03"
-    },
-    {
-            "driver": "ofdpa3",
-            "ipv4Loopback": "192.168.9.25",
-            "ipv4NodeSid": 20,
-            "isEdgeRouter": false,
-            "name": "Fabric Switch - Spine2",
-            "ofId": "of:0000cc37abd9386d",
-            "routerMac": "00:00:00:00:00:04"
     }
   ]
 }
diff --git a/src/test/cord-api/Tests/data/FabricSwitchPort.json b/src/test/cord-api/Tests/data/FabricSwitchPort.json
index 712c755..53d282e 100644
--- a/src/test/cord-api/Tests/data/FabricSwitchPort.json
+++ b/src/test/cord-api/Tests/data/FabricSwitchPort.json
@@ -6,8 +6,8 @@
             "host_learning": false
     },
     {
-            "portId": 5,
-            "switch_id" : 6
+            "portId": 8,
+            "switch_id" : 1
     }
   ]
 }
diff --git a/src/test/cord-api/Tests/data/FabricSwitch_2x2.json b/src/test/cord-api/Tests/data/FabricSwitch_2x2.json
new file mode 100644
index 0000000..6f32b22
--- /dev/null
+++ b/src/test/cord-api/Tests/data/FabricSwitch_2x2.json
@@ -0,0 +1,40 @@
+{
+    "FabricSwitchInfo" : [
+    {
+            "driver": "ofdpa3",
+            "ipv4Loopback": "192.168.9.22",
+            "ipv4NodeSid": 18,
+            "isEdgeRouter": true,
+            "name": "Fabric Switch - Leaf1",
+            "ofId": "of:0000cc37abd93769",
+            "routerMac": "00:00:00:00:00:01"
+    },
+    {
+            "driver": "ofdpa3",
+            "ipv4Loopback": "192.168.9.23",
+            "ipv4NodeSid": 17,
+            "isEdgeRouter": true,
+            "name": "Fabric Switch - Leaf2",
+            "ofId": "of:0000cc37abb6b564",
+            "routerMac": "00:00:00:00:00:02"
+    },
+    {
+            "driver": "ofdpa3",
+            "ipv4Loopback": "192.168.9.24",
+            "ipv4NodeSid": 19,
+            "isEdgeRouter": false,
+            "name": "Fabric Switch - Spine1",
+            "ofId": "of:0000cc37ab5b6da8",
+            "routerMac": "00:00:00:00:00:03"
+    },
+    {
+            "driver": "ofdpa3",
+            "ipv4Loopback": "192.168.9.25",
+            "ipv4NodeSid": 20,
+            "isEdgeRouter": false,
+            "name": "Fabric Switch - Spine2",
+            "ofId": "of:0000cc37abd9386d",
+            "routerMac": "00:00:00:00:00:04"
+    }
+  ]
+}
diff --git a/src/test/cord-api/Tests/data/RealOLTDevice.json b/src/test/cord-api/Tests/data/RealOLTDevice.json
index 802c3d1..0ac640d 100644
--- a/src/test/cord-api/Tests/data/RealOLTDevice.json
+++ b/src/test/cord-api/Tests/data/RealOLTDevice.json
@@ -4,7 +4,7 @@
             "device_type": "openolt",
             "host": "10.192.4.218",
             "port": 9191,
-            "switch_datapath_id": "of:0000cc37abd93769",
+            "switch_datapath_id": "of:0000cc37ab5b6da8",
             "switch_port": "7",
             "outer_tpid": "0x8100",
             "name": "olt-1",
diff --git a/src/test/cord-api/Tests/data/Subscriber_TopDown.json b/src/test/cord-api/Tests/data/Subscriber_TopDown.json
index 89c82e2..d9e632c 100644
--- a/src/test/cord-api/Tests/data/Subscriber_TopDown.json
+++ b/src/test/cord-api/Tests/data/Subscriber_TopDown.json
@@ -5,7 +5,8 @@
             "c_tag": 999,
             "mac_address" : "08:35:71:06:b9:69",
             "ip_address" : "10.8.2.105",
-            "onu_device": "ALPHe3d1cfa7"
+            "onu_device": "ALPHe3d1cfa7",
+            "status": "disabled"
      },
      {
             "name": "My House-306",