VOL-3099 Check for iperf3 and jq tools on RG

Change-Id: I6d615b4f197d3bb3c99246d5942a9d5cfff13cea
diff --git a/libraries/utils.robot b/libraries/utils.robot
index 677616d..631365e 100644
--- a/libraries/utils.robot
+++ b/libraries/utils.robot
@@ -513,21 +513,27 @@
     ...    SSHLibrary.Login With Public Key    ${user}    %{HOME}/.ssh/id_rsa
     ${namespace}=    Run Keyword If    '${container_type}' == 'K8S'    SSHLibrary.Execute Command
     ...    kubectl get pods --all-namespaces | grep ${container_name} | awk '{print $1}'
-    ${output}=    Run Keyword If    '${container_type}' == 'LXC'
-    ...    SSHLibrary.Execute Command    lxc exec ${container_name} -- ${cmd}
+    ${stdout}    ${stderr}    ${rc}=    Run Keyword If    '${container_type}' == 'LXC'
+    ...        SSHLibrary.Execute Command    lxc exec ${container_name} -- ${cmd}
+    ...        return_stderr=True    return_rc=True
     ...    ELSE IF    '${container_type}' == 'K8S'
-    ...    SSHLibrary.Execute Command    kubectl -n ${namespace} exec ${container_name} -- ${cmd}
+    ...        SSHLibrary.Execute Command    kubectl -n ${namespace} exec ${container_name} -- ${cmd}
+    ...        return_stderr=True    return_rc=True
     ...    ELSE
-    ...    SSHLibrary.Execute Command    ${cmd}
-    Log    ${output}
+    ...        SSHLibrary.Execute Command    ${cmd}    return_stderr=True    return_rc=True
+
+    Log    ${stdout}
+    Log    ${stderr}
+    Log    ${rc}
     SSHLibrary.Close Connection
-    [Return]    ${output}
+    [Return]    ${stdout}    ${stderr}    ${rc}
 
 Run Iperf3 Test Client
     [Arguments]    ${src}    ${server}    ${args}
     [Documentation]    Login to ${src} and run the iperf3 client against ${server} using ${args}.
     ...    Return a Dictionary containing the results of the test.
-    ${output}=    Execute Remote Command    iperf3 -J -c ${server} ${args} | jq -M -c '.'
+    ${output}    ${stderr}    ${rc}=    Execute Remote Command    iperf3 -J -c ${server} ${args} | jq -M -c '.'
     ...    ${src['ip']}    ${src['user']}    ${src['pass']}    ${src['container_type']}    ${src['container_name']}
+    Should Be Equal As Integers    ${rc}    0
     ${object}=    Evaluate    json.loads(r'''${output}''')    json
     [Return]    ${object}
diff --git a/tests/dt-workflow/Voltha_DT_PODTests.robot b/tests/dt-workflow/Voltha_DT_PODTests.robot
index 7e51f05..cc93101 100644
--- a/tests/dt-workflow/Voltha_DT_PODTests.robot
+++ b/tests/dt-workflow/Voltha_DT_PODTests.robot
@@ -53,7 +53,7 @@
 
 # For dataplane bandwidth testing
 ${upper_margin_pct}      105     # Allow 5% over the limit
-${lower_margin_pct}      93      # Allow 7% under the limit
+${lower_margin_pct}      92      # Allow 8% under the limit
 ${udp_rate_multiplier}   1.10    # Send UDP at bw profile limit * rate_multiplier
 ${udp_packet_bytes}      1400    # UDP payload in bytes
 
@@ -365,7 +365,7 @@
 Data plane verification using TCP for DT
     [Documentation]    Test bandwidth profile is met and not exceeded for each subscriber.
     ...    Assumes iperf3 and jq installed on client and iperf -s running on DHCP server
-    [Tags]    dataplaneDt    BW-profile-TCP-Dt    VOL-3061    notready
+    [Tags]    dataplaneDt    BW-profile-TCP-Dt    VOL-3061
     [Setup]    None
     [Teardown]    None
     Pass Execution If   '${has_dataplane}'=='False'    Bandwidth profile validation can be done only in
@@ -374,6 +374,12 @@
     FOR    ${I}    IN RANGE    0    ${num_onus}
         ${src}=    Set Variable    ${hosts.src[${I}]}
         ${dst}=    Set Variable    ${hosts.dst[${I}]}
+
+        # Check for iperf3 and jq tools
+        ${stdout}    ${stderr}    ${rc}=    Execute Remote Command    which iperf3 jq
+        ...    ${src['ip']}    ${src['user']}    ${src['pass']}    ${src['container_type']}    ${src['container_name']}
+        Pass Execution If    ${rc} != 0    Skipping test: iperf3 / jq not found on the RG
+
         ${onu_port}=    Wait Until Keyword Succeeds    ${timeout}    2s    Get ONU Port in ONOS    ${src['onu']}
         ...    ${of_id}
         ${subscriber_id}=    Set Variable    ${of_id}/${onu_port}
diff --git a/tests/functional/Voltha_PODTests.robot b/tests/functional/Voltha_PODTests.robot
index 529be4c..7da9d5c 100644
--- a/tests/functional/Voltha_PODTests.robot
+++ b/tests/functional/Voltha_PODTests.robot
@@ -53,7 +53,7 @@
 
 # For dataplane bandwidth testing
 ${upper_margin_pct}      105     # Allow 5% over the limit
-${lower_margin_pct}      93      # Allow 7% under the limit
+${lower_margin_pct}      92      # Allow 8% under the limit
 ${udp_rate_multiplier}   1.10    # Send UDP at bw profile limit * rate_multiplier
 ${udp_packet_bytes}      1400    # UDP payload in bytes
 
@@ -463,6 +463,12 @@
     FOR    ${I}    IN RANGE    0    ${num_onus}
         ${src}=    Set Variable    ${hosts.src[${I}]}
         ${dst}=    Set Variable    ${hosts.dst[${I}]}
+
+        # Check for iperf3 and jq tools
+        ${stdout}    ${stderr}    ${rc}=    Execute Remote Command    which iperf3 jq
+        ...    ${src['ip']}    ${src['user']}    ${src['pass']}    ${src['container_type']}    ${src['container_name']}
+        Pass Execution If    ${rc} != 0    Skipping test: iperf3 / jq not found on the RG
+
         ${onu_port}=    Wait Until Keyword Succeeds    ${timeout}    2s    Get ONU Port in ONOS    ${src['onu']}
         ...    ${of_id}
         ${subscriber_id}=    Set Variable    ${of_id}/${onu_port}