[VOL-3138] Leveraging enableLldp flag to count OLT NNI flows

Change-Id: Iff0f037e3389678260d2f0f3c3d03719d246eea7
diff --git a/libraries/flows.robot b/libraries/flows.robot
index 8e15939..8772e63 100644
--- a/libraries/flows.robot
+++ b/libraries/flows.robot
@@ -28,20 +28,21 @@
     [Documentation]  Calculate how many flows should be created based on the workflow, the number of UNIs
     ...     and whether the subscribers have been provisioned
     [Arguments]  ${workflow}    ${uni_count}    ${olt_count}    ${provisioned}
-    ...     ${withEapol}    ${withDhcp}     ${withIgmp}
+    ...     ${withEapol}    ${withDhcp}     ${withIgmp}    ${withLldp}
     ${expectedFlows}=   Run Keyword If  $workflow=="att"  Calculate Att flows
-    ...     ${uni_count}    ${olt_count}    ${provisioned}  ${withEapol}    ${withDhcp}     ${withIgmp}
+    ...     ${uni_count}    ${olt_count}    ${provisioned}  ${withEapol}    ${withDhcp}     ${withIgmp}     ${withLldp}
     ...     ELSE IF     $workflow=="dt"     Calculate Dt Flows
-    ...     ${uni_count}    ${olt_count}    ${provisioned}
+    ...     ${uni_count}    ${olt_count}    ${provisioned}  ${withLldp}
     ...     ELSE IF     $workflow=="tt"     Calculate Tt Flows
-    ...     ${uni_count}    ${olt_count}    ${provisioned}  ${withDhcp}     ${withIgmp}
+    ...     ${uni_count}    ${olt_count}    ${provisioned}  ${withDhcp}     ${withIgmp}     ${withLldp}
     ...     ELSE    Fail    Workflow ${workflow} should be one of 'att', 'dt', 'tt'
     Return From Keyword     ${expectedFlows}
 
 Calculate Att flows
     [Documentation]  Calculate the flow for the ATT workflow
     ...     NOTE we may need to add support for IGMP enabled/disabled
-    [Arguments]  ${uni_count}    ${olt_count}   ${provisioned}      ${withEapol}    ${withDhcp}     ${withIgmp}
+    [Arguments]  ${uni_count}    ${olt_count}   ${provisioned}      ${withEapol}    ${withDhcp}
+    ...     ${withIgmp}    ${withLldp}
     # (1 EAPOL * ONUs) * (1 LLDP + 1 DHCP * OLTS) before provisioning
     # (1 EAPOL, 1 DHCP, 1 IGMP, 4 DP * ONUs) * (1 LLDP + 1 DHCP * OLTS) after provisioning
     ${eapFlowsCount}=   Run Keyword If   $withEapol=='true'
@@ -56,43 +57,70 @@
     ...     Evaluate     2
     ...     ELSE
     ...     Evaluate     0
+    ${lldpFlowsCount}=   Run Keyword If   $withLldp=='true'
+    ...     Evaluate     1
+    ...     ELSE
+    ...     Evaluate     0
     ${flow_count}=  Run Keyword If  $provisioned=='false'
-    ...     Evaluate    (${uni_count} * ${eapFlowsCount}) + (${olt_count} * 2)
+    ...     Calculate Att Preprovisioned Flows   ${olt_count}    ${uni_count}
+    ...     ${eapFlowsCount}   ${dhcpFlowsCount}   ${igmpFlowsCount}    ${lldpFlowsCount}
     ...     ELSE
     ...     Calculate Att Provisioned Flows  ${olt_count}    ${uni_count}
-    ...     ${eapFlowsCount}   ${dhcpFlowsCount}   ${igmpFlowsCount}
+    ...     ${eapFlowsCount}   ${dhcpFlowsCount}   ${igmpFlowsCount}    ${lldpFlowsCount}
     Return From Keyword     ${flow_count}
 
+Calculate Att Preprovisioned Flows
+    [Documentation]  This calcualtes the flows before subscribers are provisioned in the ATT workflow
+    [Arguments]  ${olt_count}   ${uni_count}    ${eapFlowsCount}   ${dhcpFlowsCount}
+    ...    ${igmpFlowsCount}   ${lldpFlowsCount}
+    ${eap}=     Evaluate    ${uni_count} * ${eapFlowsCount}
+    ${nni}=     Evaluate    (${olt_count} * ${dhcpFlowsCount}) + (${olt_count} * ${lldpFlowsCount})
+    ${total}=   Evaluate    ${eap} + ${nni}
+    Return From Keyword     ${total}
+
 Calculate Att Provisioned Flows
-    [Documentation]  This calculate the flows for provisioned subscribers in the ATT workflow
-    [Arguments]  ${olt_count}   ${uni_count}    ${eapFlowsCount}   ${dhcpFlowsCount}   ${igmpFlowsCount}
+    [Documentation]  This calculates the flows for provisioned subscribers in the ATT workflow
+    [Arguments]  ${olt_count}   ${uni_count}    ${eapFlowsCount}   ${dhcpFlowsCount}
+    ...    ${igmpFlowsCount}   ${lldpFlowsCount}
     ${eap}=     Evaluate    ${uni_count} * ${eapFlowsCount}
     ${dhcp}=    Evaluate    ${uni_count} * ${dhcpFlowsCount}
     ${igmp}=    Evaluate    ${uni_count} * ${igmpFlowsCount}
     ${dataplane}=   Evaluate    ${uni_count} * 4
-    ${nni}=     Evaluate    ${olt_count} * 2
+    ${nni}=     Evaluate    (${olt_count} * ${dhcpFlowsCount}) + (${olt_count} * ${lldpFlowsCount})
     ${total}=   Evaluate    ${eap} + ${dhcp} + ${igmp} + ${dataplane} + ${nni}
     Return From Keyword     ${total}
 
 Calculate Dt flows
     [Documentation]  Calculate the flow for the DT workflow
-    [Arguments]  ${uni_count}    ${olt_count}   ${provisioned}
+    [Arguments]  ${uni_count}    ${olt_count}   ${provisioned}   ${withLldp}
     # (1 LLDP * OLTS) before provisioning
     # (4 DP * ONUs) * (1 LLDP * OLTS) after provisioning
+    ${lldpFlowsCount}=   Run Keyword If   $withLldp=='true'
+    ...     Evaluate     1
+    ...     ELSE
+    ...     Evaluate     0
     ${flow_count}=  Run Keyword If  $provisioned=='false'
-        ...     Evaluate    (${olt_count} * 1)
+        ...     Evaluate    (${olt_count} * ${lldpFlowsCount})
         ...     ELSE
-        ...     Evaluate    (${uni_count} * 4) + (${olt_count} * 1)
+        ...     Evaluate    (${uni_count} * 4) + (${olt_count} * ${lldpFlowsCount})
     Return From Keyword     ${flow_count}
 
 Calculate Tt flows
     [Documentation]  Calculate the flow for the TT workflow
-    [Arguments]  ${uni_count}    ${olt_count}   ${provisioned}  ${withDhcp}     ${withIgmp}
+    [Arguments]  ${uni_count}    ${olt_count}   ${provisioned}  ${withDhcp}     ${withIgmp}    ${withLldp}
     # TODO account for withDhcp, withIgmp, see Calculate Att flows for examples
     # (1 LLDP + 1 DHCP * OLTS) before provisioning
     # (1 DHCP, 1 IGMP, 4 DP * ONUs) * (1 LLDP + 1 DHCP * OLTS) after provisioning
+    ${dhcpFlowsCount}=   Run Keyword If   $withDhcp=='true'
+    ...     Evaluate     1
+    ...     ELSE
+    ...     Evaluate     0
+    ${lldpFlowsCount}=   Run Keyword If   $withLldp=='true'
+    ...     Evaluate     1
+    ...     ELSE
+    ...     Evaluate     0
     ${flow_count}=  Run Keyword If  $provisioned=='false'
-        ...     Evaluate    (${olt_count} * 2)
+        ...     Evaluate    (${olt_count} * ${dhcpFlowsCount}) + (${olt_count} * ${lldpFlowsCount})
         ...     ELSE
-        ...     Evaluate    (${uni_count} * 6) + (${olt_count} * 1)
+        ...     Evaluate    (${uni_count} * 6) + (${olt_count} * ${dhcpFlowsCount}) + (${olt_count} * ${lldpFlowsCount})
     Return From Keyword     ${flow_count}
\ No newline at end of file
diff --git a/libraries/onos.robot b/libraries/onos.robot
index a3c047f..a68292d 100755
--- a/libraries/onos.robot
+++ b/libraries/onos.robot
@@ -360,9 +360,9 @@
 Wait for all flows to in ADDED state
     [Documentation]  Waits until the flows have been provisioned
     [Arguments]  ${onos_ip}    ${onos_port}     ${workflow}    ${uni_count}    ${olt_count}    ${provisioned}
-    ...     ${withEapol}    ${withDhcp}     ${withIgmp}
+    ...     ${withEapol}    ${withDhcp}     ${withIgmp}     ${withLldp}
     ${targetFlows}=     Calculate flows by workflow     ${workflow}    ${uni_count}    ${olt_count}     ${provisioned}
-    ...     ${withEapol}    ${withDhcp}     ${withIgmp}
+    ...     ${withEapol}    ${withDhcp}     ${withIgmp}     ${withLldp}
     Wait Until Keyword Succeeds     10m     5s      Count ADDED flows
     ...     ${onos_ip}    ${onos_port}  ${targetFlows}
 
diff --git a/libraries/voltctl.robot b/libraries/voltctl.robot
index 16f4829..5724871 100644
--- a/libraries/voltctl.robot
+++ b/libraries/voltctl.robot
@@ -499,9 +499,9 @@
 Wait for Logical Devices flows
     [Documentation]  Waits until the flows have been provisioned in the logical device
     [Arguments]  ${workflow}    ${uni_count}    ${olt_count}    ${provisioned}
-    ...     ${withEapol}    ${withDhcp}     ${withIgmp}
+    ...     ${withEapol}    ${withDhcp}     ${withIgmp}     ${withLldp}
     ${targetFlows}=     Calculate flows by workflow     ${workflow}    ${uni_count}    ${olt_count}     ${provisioned}
-    ...     ${withEapol}    ${withDhcp}     ${withIgmp}
+    ...     ${withEapol}    ${withDhcp}     ${withIgmp}    ${withLldp}
     Log     ${targetFlows}
     # TODO extend Validate Logical Device Flows to check the correct number of flows
     Wait Until Keyword Succeeds     10m     5s  Count Logical Devices flows     ${targetFlows}
@@ -526,9 +526,9 @@
 Wait for OpenOLT Devices flows
     [Documentation]  Waits until the flows have been provisioned in the openolt devices
     [Arguments]  ${workflow}    ${uni_count}    ${olt_count}    ${provisioned}
-    ...     ${withEapol}    ${withDhcp}     ${withIgmp}
+    ...     ${withEapol}    ${withDhcp}     ${withIgmp}     ${withLldp}
     ${targetFlows}=     Calculate flows by workflow     ${workflow}    ${uni_count}    ${olt_count}     ${provisioned}
-    ...     ${withEapol}    ${withDhcp}     ${withIgmp}
+    ...     ${withEapol}    ${withDhcp}     ${withIgmp}     ${withLldp}
     # In the physical device we only have 2 data plane flows (on the PON) instead of 4
     Run Keyword If  $provisioned=='true'
     ...     ${targetFlows}=     Evaluate    ${targetFlows} - (${uni_count} * 2)
diff --git a/tests/scale/Voltha_Scale_Tests.robot b/tests/scale/Voltha_Scale_Tests.robot
index 76708ea..328de27 100644
--- a/tests/scale/Voltha_Scale_Tests.robot
+++ b/tests/scale/Voltha_Scale_Tests.robot
@@ -62,7 +62,6 @@
 ${pon}  1
 ${onu}  1
 
-${enableLLDP}   false
 ${enableFlowProvisioning}   true
 ${enableSubscriberProvisioning}     true
 
@@ -70,6 +69,8 @@
 ${withEapol}    false
 ${withDhcp}    false
 ${withIgmp}    false
+# as of now the LLDP flow is always installed
+${withLLDP}   true
 
 # Per-test logging on failure is turned off by default; set this variable to enable
 ${container_log_dir}    ${None}
@@ -78,7 +79,7 @@
 
 Create and Enable devices
     [Documentation]  Create and enable the OLTs in VOLTHA
-    [Tags]      setup
+    [Tags]      non-critical    setup
     ${olt_device_ids}=      Create List
     FOR    ${INDEX}    IN RANGE    0    ${olt}
         ${olt_device_id}=    Create Device  bbsim${INDEX}     50060     openolt
@@ -104,14 +105,14 @@
     # NOTE fail the test immediately if we're trying to check flows without provisioning them
     Should Be Equal   ${enableFlowProvisioning}     true
     Wait for Logical Devices flows   ${workflow}    ${total_onus}    ${olt}    false
-    ...     ${withEapol}    ${withDhcp}     ${withIgmp}
+    ...     ${withEapol}    ${withDhcp}     ${withIgmp}    ${withLLDP}
 
 Flows validation in VOLTHA Adapters before subscriber provisioning
     [Documentation]  Check that all flows has been store in devices of type openolt
     [Tags]      non-critical    flow-before   plot-voltha-openolt-flows-before
     Should Be Equal   ${enableFlowProvisioning}     true
     Wait for OpenOLT Devices flows   ${workflow}    ${total_onus}    ${olt}    false
-    ...     ${withEapol}    ${withDhcp}     ${withIgmp}
+    ...     ${withEapol}    ${withDhcp}     ${withIgmp}    ${withLLDP}
 
 Flows validation in ONOS before subscriber provisioning
     [Documentation]    Check that all the flows has been acknowledged
@@ -119,7 +120,8 @@
     # NOTE fail the test immediately if we're trying to check flows without provisioning them
     Should Be Equal   ${enableFlowProvisioning}     true
     Wait for all flows to in ADDED state    ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}
-    ...     ${workflow}    ${total_onus}    ${olt}    false     ${withEapol}    ${withDhcp}     ${withIgmp}
+    ...     ${workflow}    ${total_onus}    ${olt}    false     ${withEapol}    ${withDhcp}
+    ...     ${withIgmp}   ${withLLDP}
 
 Wait for subscribers to be Authenticated
     [Documentation]    Check that all subscribers have successfully authenticated
@@ -141,14 +143,14 @@
     # NOTE fail the test immediately if we're trying to check flows without provisioning them
     Should Be Equal   ${enableFlowProvisioning}     true
     Wait for Logical Devices flows   ${workflow}    ${total_onus}    ${olt}    true
-    ...     ${withEapol}    ${withDhcp}     ${withIgmp}
+    ...     ${withEapol}    ${withDhcp}     ${withIgmp}    ${withLLDP}
 
 Flows validation in VOLTHA Adapters after subscriber provisioning
     [Documentation]  Check that all flows has been store in devices of type openolt
     [Tags]      non-critical    flow-after   plot-voltha-openolt-flows-after
     Should Be Equal   ${enableFlowProvisioning}     true
     Wait for OpenOLT Devices flows   ${workflow}    ${total_onus}    ${olt}    true
-    ...     ${withEapol}    ${withDhcp}     ${withIgmp}
+    ...     ${withEapol}    ${withDhcp}     ${withIgmp}    ${withLLDP}
 
 Flows validation in ONOS after subscriber provisioning
     [Documentation]    Check that all the flows has been acknowledged
@@ -156,7 +158,8 @@
     # NOTE fail the test immediately if we're trying to check flows without provisioning them
     Should Be Equal   ${enableFlowProvisioning}     true
     Wait for all flows to in ADDED state    ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}
-    ...     ${workflow}    ${total_onus}    ${olt}    true      ${withEapol}    ${withDhcp}     ${withIgmp}
+    ...     ${workflow}    ${total_onus}    ${olt}    true      ${withEapol}    ${withDhcp}
+    ...     ${withIgmp}   ${withLLDP}
 
 Wait for subscribers to have an IP
     [Documentation]    Check that all subscribers have received a DHCP_ACK