[VOL-3007] Adding parameters for flow calculation

Change-Id: I75ebfe83ba07d57030fcefdf857e314917bf2693
diff --git a/libraries/flows.robot b/libraries/flows.robot
new file mode 100644
index 0000000..678270a
--- /dev/null
+++ b/libraries/flows.robot
@@ -0,0 +1,98 @@
+# 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.
+# onos common functions
+
+*** Settings ***
+Documentation     Library for various utilities
+Library           SSHLibrary
+Library           String
+Library           DateTime
+Library           Process
+Library           Collections
+Library           RequestsLibrary
+Library           OperatingSystem
+
+*** Keywords ***
+Calculate flows by workflow
+    [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}
+    ${expectedFlows}=   Run Keyword If  $workflow=="att"  Calculate Att flows
+    ...     ${uni_count}    ${olt_count}    ${provisioned}  ${withEapol}    ${withDhcp}     ${withIgmp}
+    ...     ELSE IF     $workflow=="dt"     Calculate Dt Flows
+    ...     ${uni_count}    ${olt_count}    ${provisioned}
+    ...     ELSE IF     $workflow=="tt"     Calculate Tt Flows
+    ...     ${uni_count}    ${olt_count}    ${provisioned}  ${withDhcp}     ${withIgmp}
+    ...     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}
+    # (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'
+    ...     Evaluate     1
+    ...     ELSE
+    ...     Evaluate     0
+    ${dhcpFlowsCount}=   Run Keyword If   $withDhcp=='true'
+    ...     Evaluate     1
+    ...     ELSE
+    ...     Evaluate     0
+    ${igmpFlowsCount}=   Run Keyword If   $withIgmp=='true'
+    ...     Evaluate     2
+    ...     ELSE
+    ...     Evaluate     0
+    ${flow_count}=  Run Keyword If  $provisioned=='false'
+    ...     Evaluate    (${uni_count} * ${eapFlowsCount}) + (${olt_count} * 2)
+    ...     ELSE
+    ...     Calculate Att Provisione Flows  ${olt_count}    ${uni_count}
+    ...     ${eapFlowsCount}   ${dhcpFlowsCount}   ${igmpFlowsCount}
+    Return From Keyword     ${flow_count}
+
+Calculate Att Provisione Flows
+    [Documentation]  This calculate the flows for provisioned subscribers in the ATT workflow
+    [Arguments]  ${olt_count}   ${uni_count}    ${eapFlowsCount}   ${dhcpFlowsCount}   ${igmpFlowsCount}
+    ${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
+    ${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}
+    # (1 LLDP * OLTS) before provisioning
+    # (4 DP * ONUs) * (1 LLDP * OLTS) after provisioning
+    ${flow_count}=  Run Keyword If  $provisioned=='false'
+        ...     Evaluate    (${olt_count} * 1)
+        ...     ELSE
+        ...     Evaluate    (${uni_count} * 4) + (${olt_count} * 1)
+    Return From Keyword     ${flow_count}
+
+Calculate Tt flows
+    [Documentation]  Calculate the flow for the TT workflow
+    [Arguments]  ${uni_count}    ${olt_count}   ${provisioned}  ${withDhcp}     ${withIgmp}
+    # 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
+    ${flow_count}=  Run Keyword If  $provisioned=='false'
+        ...     Evaluate    (${olt_count} * 2)
+        ...     ELSE
+        ...     Evaluate    (${uni_count} * 6) + (${olt_count} * 1)
+    Return From Keyword     ${flow_count}
\ No newline at end of file
diff --git a/libraries/onos.robot b/libraries/onos.robot
index 69ee7e2..0810bfe 100644
--- a/libraries/onos.robot
+++ b/libraries/onos.robot
@@ -22,6 +22,7 @@
 Library           Collections
 Library           RequestsLibrary
 Library           OperatingSystem
+Resource          ./flows.robot
 
 *** Keywords ***
 Validate OLT Device in ONOS
@@ -358,7 +359,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}
     ${targetFlows}=     Calculate flows by workflow     ${workflow}    ${uni_count}    ${olt_count}     ${provisioned}
+    ...     ${withEapol}    ${withDhcp}     ${withIgmp}
     Wait Until Keyword Succeeds     10m     5s      Count ADDED flows
     ...     ${onos_ip}    ${onos_port}  ${targetFlows}
 
diff --git a/libraries/utils.robot b/libraries/utils.robot
index 8c9f655..677616d 100644
--- a/libraries/utils.robot
+++ b/libraries/utils.robot
@@ -484,53 +484,6 @@
     Should Be Equal As Numbers    ${rc}    0
     [return]    ${output}
 
-Calculate flows by workflow
-    [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}
-    ${expectedFlows}=   Run Keyword If  $workflow=="att"  Calculate Att flows
-    ...     ${uni_count}    ${olt_count}    ${provisioned}
-    ...     ELSE IF     $workflow=="dt"     Calculate Dt Flows
-    ...     ${uni_count}    ${olt_count}    ${provisioned}
-    ...     ELSE IF     $workflow=="tt"     Calculate Tt Flows
-    ...     ${uni_count}    ${olt_count}    ${provisioned}
-    ...     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}
-    # (1 EAPOL * ONUs) * (1 LLDP + 1 DHCP * OLTS) before provisioning
-    # (1 EAPOL, 1 DHCP, 1 IGMP, 4 DP * ONUs) * (1 LLDP + 1 DHCP * OLTS) before provisioning
-    ${flow_count}=  Run Keyword If  $provisioned=='false'
-    ...     Evaluate    (${uni_count} * 1) + (${olt_count} * 2)
-    ...     ELSE
-    ...     Evaluate    (${uni_count} * 7) + (${olt_count} * 2)
-    Return From Keyword     ${flow_count}
-
-Calculate Dt flows
-    [Documentation]  Calculate the flow for the DT workflow
-    [Arguments]  ${uni_count}    ${olt_count}   ${provisioned}
-    # (1 LLDP * OLTS) before provisioning
-    # (4 DP * ONUs) * (1 LLDP * OLTS) before provisioning
-    ${flow_count}=  Run Keyword If  $provisioned=='false'
-        ...     Evaluate    (${olt_count} * 1)
-        ...     ELSE
-        ...     Evaluate    (${uni_count} * 4) + (${olt_count} * 1)
-    Return From Keyword     ${flow_count}
-
-Calculate Tt flows
-    [Documentation]  Calculate the flow for the TT workflow
-    [Arguments]  ${uni_count}    ${olt_count}   ${provisioned}
-    # (1 LLDP + 1 DHCP * OLTS) before provisioning
-    # (1 DHCP, 1 IGMP, 4 DP * ONUs) * (1 LLDP + 1 DHCP * OLTS) before provisioning
-    ${flow_count}=  Run Keyword If  $provisioned=='false'
-        ...     Evaluate    (${olt_count} * 2)
-        ...     ELSE
-        ...     Evaluate    (${uni_count} * 6) + (${olt_count} * 1)
-    Return From Keyword     ${flow_count}
-
 Get Bandwidth Profile Name For Given Subscriber
     [Arguments]    ${subscriber_id}   ${stream_type}=upstreamBandwidthProfile
     [Documentation]    Keyword to get the bandwidth details of the given subscriber
diff --git a/libraries/voltctl.robot b/libraries/voltctl.robot
index d315ff6..0d51b0e 100644
--- a/libraries/voltctl.robot
+++ b/libraries/voltctl.robot
@@ -23,6 +23,7 @@
 Library           RequestsLibrary
 Library           OperatingSystem
 Resource          ./utils.robot
+Resource          ./flows.robot
 
 *** Keywords ***
 Test Empty Device List
@@ -486,7 +487,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}
     ${targetFlows}=     Calculate flows by workflow     ${workflow}    ${uni_count}    ${olt_count}     ${provisioned}
+    ...     ${withEapol}    ${withDhcp}     ${withIgmp}
     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}
diff --git a/tests/scale/Voltha_Scale_Tests.robot b/tests/scale/Voltha_Scale_Tests.robot
index c2c1527..c5b530c 100644
--- a/tests/scale/Voltha_Scale_Tests.robot
+++ b/tests/scale/Voltha_Scale_Tests.robot
@@ -49,7 +49,7 @@
 Resource          ../../libraries/onos.robot
 Resource          ../../libraries/voltctl.robot
 Resource          ../../libraries/voltha.robot
-Resource          ../../libraries/utils.robot
+Resource          ../../libraries/flows.robot
 Resource          ../../libraries/k8s.robot
 Resource          ../../variables/variables.robot
 
@@ -67,8 +67,9 @@
 ${enableSubscriberProvisioning}     true
 
 ${workflow}     att
-#${flowsBeforeProvisioning}  1
-#${flowsAfterProvisioning}  1
+${withEapol}    false
+${withDhcp}    false
+${withIgmp}    false
 
 # Per-test logging on failure is turned off by default; set this variable to enable
 ${container_log_dir}    ${None}
@@ -80,7 +81,7 @@
     [Tags]      setup
     ${olt_device_ids}=      Create List
     FOR    ${INDEX}    IN RANGE    0    ${olt}
-        ${olt_device_id}=    Create Device  bbsim${INDEX}     50060     openolt     0f:f1:ce:c${INDEX}:ff:ee
+        ${olt_device_id}=    Create Device  bbsim${INDEX}     50060     openolt
         Enable Device    ${olt_device_id}
         Append To List  ${olt_device_ids}    ${olt_device_id}
     END
@@ -98,19 +99,20 @@
     Wait for Ports in ONOS      ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}  ${total_onus}   BBSM
 
 Flows validation in VOLTHA before subscriber provisioning
-    [Documentation]    Check that all the flows has been acknowledged
+    [Documentation]    Check that all the flows has been stored in the logical device
     [Tags]      non-critical    flow-before   plot-voltha-flows-before
     # 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}
 
 Flows validation in ONOS before subscriber provisioning
-    [Documentation]    Check that all the flows has been stored in the logical device
+    [Documentation]    Check that all the flows has been acknowledged
     [Tags]      non-critical    flow-before   plot-onos-flows-before
     # 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
+    ...     ${workflow}    ${total_onus}    ${olt}    false     ${withEapol}    ${withDhcp}     ${withIgmp}
 
 Wait for subscribers to be Authenticated
     [Documentation]    Check that all subscribers have successfully authenticated
@@ -132,6 +134,7 @@
     # 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}
 
 Flows validation in ONOS after subscriber provisioning
     [Documentation]    Check that all the flows has been acknowledged
@@ -139,7 +142,7 @@
     # 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
+    ...     ${workflow}    ${total_onus}    ${olt}    true      ${withEapol}    ${withDhcp}     ${withIgmp}
 
 Wait for subscribers to have an IP
     [Documentation]    Check that all subscribers have received a DHCP_ACK