[VOL-2282]
Run robot tests with Python 3
- Remove HTTP and database robot libraries that aren't used
- Make robot lint treat warnings as errors
- Reformat robot tests to pass lint, and other minor fixes
- Lint/reformat of python code
- Add yaml and json linting
- Clean up Makefile
- Assume the KUBECONFIG and VOLTCONFIG env vars are defined
Change-Id: Ibf0a6b525802ed907efc38b34c8e3b99b2044bf1
diff --git a/libraries/DependencyLibrary.py b/libraries/DependencyLibrary.py
index 9d402af..15c1dbc 100644
--- a/libraries/DependencyLibrary.py
+++ b/libraries/DependencyLibrary.py
@@ -11,9 +11,12 @@
# 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.
-#
+
+from __future__ import absolute_import
+
from robot.libraries.BuiltIn import BuiltIn
+
class DependencyLibrary(object):
ROBOT_LISTENER_API_VERSION = 2
ROBOT_LIBRARY_SCOPE = "GLOBAL"
@@ -24,10 +27,10 @@
def require_test_case(self, name):
key = name.lower()
- if (key not in self.test_status):
+ if key not in self.test_status:
BuiltIn().fail("required test case can't be found: '%s'" % name)
- if (self.test_status[key] != "PASS"):
+ if self.test_status[key] != "PASS":
BuiltIn().fail("required test case failed: '%s'" % name)
return True
diff --git a/libraries/k8s.robot b/libraries/k8s.robot
index 53cd8b3..246a6a5 100644
--- a/libraries/k8s.robot
+++ b/libraries/k8s.robot
@@ -11,13 +11,11 @@
# 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.
-
# voltctl common functions
*** Settings ***
Documentation Library for various utilities
Library SSHLibrary
-Library HttpLibrary.HTTP
Library String
Library DateTime
Library Process
@@ -49,20 +47,23 @@
... kubectl get pods -n ${namespace} | grep ${name} | awk 'NR==1{print $1}'
Log ${restart_pod_name}
Should Not Be Empty ${restart_pod_name} Unable to parse pod name
- ${rc} ${output}= Run and Return Rc and Output kubectl delete pod ${restart_pod_name} -n ${namespace} --grace-period=0 --force
+ ${rc} ${output}= Run and Return Rc and Output
+ ... kubectl delete pod ${restart_pod_name} -n ${namespace} --grace-period=0 --force
Log ${output}
Validate Pod Status
[Arguments] ${pod_name} ${namespace} ${expectedStatus}
[Documentation] To run the kubectl command and check the status of the given pod matches the expected status
- ${length}= Run ${KUBECTL_CONFIG}; kubectl get pod -n ${namespace} | wc -l
+ ${length}= Run kubectl get pod -n ${namespace} | wc -l
FOR ${index} IN RANGE ${length}-1
- ${currentPodName}= Run ${KUBECTL_CONFIG}; kubectl get pod -n ${namespace} -o jsonpath={.items[${index}].status.containerStatuses[0].name}
+ ${currentPodName}= Run
+ ... kubectl get pod -n ${namespace} -o=jsonpath="{.items[${index}].status.containerStatuses[0].name}"
Log Required Pod : ${pod_name}
Log Current Pod: ${currentPodName}
Run Keyword and Ignore Error Run Keyword If '${currentPodName}'=='${pod_name}' Exit For Loop
END
- ${currentStatusofPod}= Run ${KUBECTL_CONFIG}; kubectl get pod -n ${namespace} -o jsonpath={.items[${index}].status.phase}
+ ${currentStatusofPod}= Run
+ ... kubectl get pod -n ${namespace} -o=jsonpath="{.items[${index}].status.phase}"
Log ${currentStatusofPod}
Should Contain ${currentStatusofPod} ${expectedStatus}
@@ -73,28 +74,42 @@
&{containerDict} Get Container Dictionary
FOR ${podName} IN @{PODLIST1}
${containerName} Get From Dictionary ${containerDict} ${podName}
- ${rc} ${logOutput} Run And Return Rc And Output ${KUBECTL_CONFIG};kubectl logs --timestamps -n voltha --since-time=${datetime} ${containerName}
- Run Keyword And Ignore Error Run Keyword If '${logOutput}'=='${EMPTY}' Run Keywords Log No Log found in pod ${podName}
+ ${rc} ${logOutput} Run And Return Rc And Output
+ ... kubectl logs --timestamps -n voltha --since-time=${datetime} ${containerName}
+ Run Keyword And Ignore Error
+ ... Run Keyword If '${logOutput}'=='${EMPTY}'
+ ... Run Keywords Log No Log found in pod ${podName}
... AND Continue For Loop
${errorDict} Check For Error Logs in Pod Type1 Given the Log Output ${logOutput}
${returnStatusFlagList} Get Dictionary Keys ${errorDict}
${returnStatusFlag} Get From List ${returnStatusFlagList} 0
- Run Keyword And Ignore Error Run Keyword If '${returnStatusFlag}'=='Nologfound' Run Keywords Log No Error Log found in pod ${podName}
+ Run Keyword And Ignore Error
+ ... Run Keyword If '${returnStatusFlag}'=='Nologfound'
+ ... Run Keywords Log No Error Log found in pod ${podName}
... AND Continue For Loop
- Run Keyword And Ignore Error Run Keyword If '${returnStatusFlag}'=='UnexpectedErrorfound' Run Keywords Log Unexpected Error Log found in pod ${podName}
+ Run Keyword And Ignore Error
+ ... Run Keyword If '${returnStatusFlag}'=='UnexpectedErrorfound'
+ ... Run Keywords Log Unexpected Error Log found in pod ${podName}
... AND Set to Dictionary ${errorPodDict} ${podName} ${errorDict}
END
FOR ${podName} IN @{PODLIST2}
${containerName} Get From Dictionary ${containerDict} ${podName}
- ${rc} ${logOutput} Run And Return Rc And Output ${KUBECTL_CONFIG};kubectl logs --timestamps -n voltha --since-time=${datetime} ${containerName}
- Run Keyword And Ignore Error Run Keyword If '${logOutput}'=='${EMPTY}' Run Keywords Log No Log found in pod ${podName}
+ ${rc} ${logOutput} Run And Return Rc And Output
+ ... kubectl logs --timestamps -n voltha --since-time=${datetime} ${containerName}
+ Run Keyword And Ignore Error
+ ... Run Keyword If '${logOutput}'=='${EMPTY}'
+ ... Run Keywords Log No Log found in pod ${podName}
... AND Continue For Loop
${errorDict} Check For Error Logs in Pod Type2 Given the Log Output ${logOutput}
${returnStatusFlagList} Get Dictionary Keys ${errorDict}
${returnStatusFlag} Get From List ${returnStatusFlagList} 0
- Run Keyword And Ignore Error Run Keyword If '${returnStatusFlag}'=='Nologfound' Run Keywords Log No Error Log found in pod ${podName}
+ Run Keyword And Ignore Error
+ ... Run Keyword If '${returnStatusFlag}'=='Nologfound'
+ ... Run Keywords Log No Error Log found in pod ${podName}
... AND Continue For Loop
- Run Keyword And Ignore Error Run Keyword If '${returnStatusFlag}'=='UnexpectedErrorfound' Run Keywords Log Unexpected Error Log found in pod ${podName}
+ Run Keyword And Ignore Error
+ ... Run Keyword If '${returnStatusFlag}'=='UnexpectedErrorfound'
+ ... Run Keywords Log Unexpected Error Log found in pod ${podName}
... AND Set to Dictionary ${errorPodDict} ${podName} ${errorDict}
END
Print to Console Error Statement logged in the following pods : ${errorPodDict}
@@ -106,10 +121,13 @@
Log ${logOutput}
${linesContainingLog} = Get Lines Matching Regexp ${logOutput} .*\s\${logLevel}.* partial_match=true
${is_exec_status} ${output} Run Keyword And Ignore Error Should Be Empty ${linesContainingLog}
- ${returnStatusFlag} Set Variable If '${is_exec_status}'=='PASS' Nologfound '${is_exec_status}'=='FAIL' Errorlogfound
- ${linesContainingError} = Get Lines Matching Regexp ${logOutput} .*\s\${logLevel}.*${errorMessage} partial_match=true
+ ${returnStatusFlag} Set Variable If '${is_exec_status}'=='PASS'
+ ... Nologfound '${is_exec_status}'=='FAIL' Errorlogfound
+ ${linesContainingError} = Get Lines Matching Regexp
+ ... ${logOutput} .*\s\${logLevel}.*${errorMessage} partial_match=true
${is_exec_status} ${output} Run Keyword And Ignore Error Should Be Empty ${linesContainingError}
- ${returnStatusFlag} Set Variable If '${is_exec_status}'=='PASS' UnexpectedErrorfound '${is_exec_status}'=='FAIL' MatchingErrorlogfound
+ ${returnStatusFlag} Set Variable If '${is_exec_status}'=='PASS'
+ ... UnexpectedErrorfound '${is_exec_status}'=='FAIL' MatchingErrorlogfound
Log {linesContainingError}
&{errorDict} Create Dictionary ${returnStatusFlag} ${linesContainingLog}
[Return] ${errorDict}
@@ -118,12 +136,16 @@
[Arguments] ${logOutput} ${logLevel}=warn ${errorMessage}=${EMPTY}
[Documentation] Checks for error message in the particular set of pods
Log ${logOutput}
- ${linesContainingLog} = Get Lines Matching Regexp ${logOutput} .*?\s.*level.*${logLevel}.* partial_match=true
+ ${linesContainingLog} = Get Lines Matching Regexp
+ ... ${logOutput} .*?\s.*level.*${logLevel}.* partial_match=true
${is_exec_status} ${output} Run Keyword And Ignore Error Should Be Empty ${linesContainingLog}
- ${returnStatusFlag} Set Variable If '${is_exec_status}'=='PASS' Nologfound '${is_exec_status}'=='FAIL' Errorlogfound
- ${linesContainingError} = Get Lines Matching Regexp ${logOutput} .*?\s.*level.*${logLevel}.*msg.*${errorMessage} partial_match=true
+ ${returnStatusFlag} Set Variable If '${is_exec_status}'=='PASS'
+ ... Nologfound '${is_exec_status}'=='FAIL' Errorlogfound
+ ${linesContainingError} = Get Lines Matching Regexp
+ ... ${logOutput} .*?\s.*level.*${logLevel}.*msg.*${errorMessage} partial_match=true
${is_exec_status} ${output} Run Keyword And Ignore Error Should Be Empty ${linesContainingError}
- ${returnStatusFlag} Set Variable If '${is_exec_status}'=='PASS' UnexpectedErrorfound '${is_exec_status}'=='FAIL' MatchingErrorlogfound
+ ${returnStatusFlag} Set Variable If '${is_exec_status}'=='PASS'
+ ... UnexpectedErrorfound '${is_exec_status}'=='FAIL' MatchingErrorlogfound
Log {linesContainingError}
&{errorDict} Create Dictionary ${returnStatusFlag} ${linesContainingLog}
[Return] ${errorDict}
@@ -132,13 +154,13 @@
[Documentation] Creates a mapping for pod name and container name and returns the same
&{containerDict} Create Dictionary
${containerName} Set Variable ${EMPTY}
- ${podName} Run ${KUBECTL_CONFIG};kubectl get deployment -n voltha | awk 'NR>1 {print $1}'
+ ${podName} Run kubectl get deployment -n voltha | awk 'NR>1 {print $1}'
@{podNameList}= Split To Lines ${podName}
Append To List ${podNameList} voltha-etcd-cluster voltha-kafka voltha-ro-core voltha-zookeeper
Log ${podNameList}
#Creatiing dictionary to correspond pod name and container name
FOR ${pod} IN @{podNameList}
- ${containerName} Run ${KUBECTL_CONFIG};kubectl get pod -n voltha | grep ${pod} | awk '{print $1}'
+ ${containerName} Run kubectl get pod -n voltha | grep ${pod} | awk '{print $1}'
&{containerDict} Set To Dictionary ${containerDict} ${pod} ${containerName}
END
Log ${containerDict}
@@ -146,25 +168,41 @@
Validate Error For Given Pods
[Arguments] ${datetime} ${podDict}
- [Documentation] This keyword is used to get the list of pods if there is any unexpected error in a particular pod(s) given the time-${datetime} from which the log needs to be analysed and the dictionary of pods and the error in the dictionary format ${podDict] .
+ [Documentation]
+ ... This keyword is used to get the list of pods if there is any unexpected error
+ ... in a particular pod(s) given the time-${datetime} from which the log needs to
+ ... be analysed and the dictionary of pods and the error in the dictionary format
+ ... ${podDict] .
...
- ... Usage : ${returnStatusFlag} Validate Error For Given Pods ${datetime} ${podDict}
- ... where,
+ ... Usage: ${returnStatusFlag} Validate Error For Given Pods ${datetime} ${podDict}
+ ...
+ ... Arguments:
+ ...
... ${datetime} = time from which the log needs to be taken
- ... ${podDict} = Key-value pair of the pod name and the error msg expected like ${podDict} = Set Dictionary ${podDict} radius sample error message.
+ ... ${podDict} = Key-value pair of the pod name and the error msg
...
- ... In case the radius pod log has any other error than the expected error, then the podname will be returned
+ ... Example: ${podDict} = Set Dictionary ${podDict} radius sample error message.
+ ...
+ ... In case the radius pod log has any other error than the expected
+ ... error, then the podname will be returned
${podList} = Get Dictionary Keys ${podDict}
FOR ${podName} IN @{podList}
${containerName} Get From Dictionary ${containerDict} ${podName}
${expectedError} Get From Dictionary ${podDict} ${podName}
- ${rc} ${logOutput} Run And Return Rc And Output ${KUBECTL_CONFIG};kubectl logs --timestamps -n voltha --since-time=${datetime} ${containerName}
- Run Keyword And Ignore Error Run Keyword If '${logOutput}'=='${EMPTY}' Run Keywords Log No Log found in pod ${podName}
+ ${rc} ${logOutput} Run And Return Rc And Output
+ ... kubectl logs --timestamps -n voltha --since-time=${datetime} ${containerName}
+ Run Keyword And Ignore Error
+ ... Run Keyword If '${logOutput}'=='${EMPTY}'
+ ... Run Keywords Log No Log found in pod ${podName}
... AND Continue For Loop
${returnStatusFlag} Check For Error Logs in Pod Type1 Given the Log Output ${logOutput}
- Run Keyword And Ignore Error Run Keyword If '${returnStatusFlag}'=='Nologfound' Run Keywords Log No Error Log found in pod ${podName}
+ Run Keyword And Ignore Error
+ ... Run Keyword If '${returnStatusFlag}'=='Nologfound'
+ ... Run Keywords Log No Error Log found in pod ${podName}
... AND Continue For Loop
- Run Keyword And Ignore Error Run Keyword If '${returnStatusFlag}'=='UnexpectedErrorfound' Run Keywords Log Unexpected Error Log found in pod ${podName}
+ Run Keyword And Ignore Error
+ ... Run Keyword If '${returnStatusFlag}'=='UnexpectedErrorfound'
+ ... Run Keywords Log Unexpected Error Log found in pod ${podName}
... AND Append To List ${errorPodList} ${podName}
END
[Return] ${errorPodList}
@@ -178,7 +216,7 @@
Delete K8s Pods By Label
[Arguments] ${namespace} ${key} ${value}
- [Documentation] Uses kubectl to delete a PODs, filtering by label
+ [Documentation] Uses kubectl to delete a PODs, filtering by label
${rc}= Run and Return Rc
... kubectl -n ${namespace} delete pods -l${key}=${value}
Should Be Equal as Integers ${rc} 0
@@ -193,7 +231,8 @@
Pod Exists
[Arguments] ${namespace} ${name}
[Documentation] Succeeds it the named POD exists
- ${rc} ${count} Run and Return Rc kubectl get -n ${namespace} pod -o json | jq -r ".items[].metadata.name" | grep ${name}
+ ${rc} ${count} Run and Return Rc
+ ... kubectl get -n ${namespace} pod -o json | jq -r ".items[].metadata.name" | grep ${name}
Should Be True ${count}>0
Pod Does Not Exist
@@ -204,7 +243,7 @@
Should Be Equal As Integers ${count} 0
Should Be True ${count}==0
-Pods Does Not Exist By Label
+Pods Do Not Exist By Label
[Arguments] ${namespace} ${key} ${value}
[Documentation] Succeeds if the named POD does not exist
${rc} ${count} Run and Return Rc And Output
@@ -215,7 +254,8 @@
Get Available Deployment Replicas
[Arguments] ${namespace} ${name}
[Documentation] Succeeds if the named POD exists and has a ready count > 0
- ${rc} ${count} Run and Return Rc and Output ${KUBECTL_CONFIG};kubectl get -n ${namespace} deploy/${name} -o jsonpath='{.status.availableReplicas}'
+ ${rc} ${count} Run and Return Rc and Output
+ ... kubectl get -n ${namespace} deploy/${name} -o jsonpath='{.status.availableReplicas}'
${result}= Run Keyword If '${count}' == '' Set Variable 0
... ELSE Set Variable ${count}
[Return] ${result}
@@ -234,7 +274,7 @@
Should Be Equal as Integers ${rc} 0
${replicas}= Run Keyword If '${value}' == '' Set Variable 0
... ELSE Set Variable ${value}
- [Return] ${replicas}
+ [Return] ${replicas}
Does Deployment Have Replicas
[Arguments] ${namespace} ${name} ${expected_count}
@@ -246,12 +286,12 @@
... ELSE Set Variable ${value}
Should be Equal as Integers ${replicas} ${expected_count}
-Pods Does Not Ready By Label
+Pods Are Ready By Label
[Arguments] ${namespace} ${key} ${value}
- [Documentation] Check PODs Ready Status
- ${rc} ${count} Run and Return Rc and Output
- ... kubectl -n ${namespace} get pods -l ${key}=${value} -o json | jq -r ".items[].status.containerStatuses[].ready" | grep -c false
- Should Be Equal as Integers ${rc} 0
+ [Documentation] Check that all pods with a label are ready
+ ${output}= Run
+ ... kubectl -n ${namespace} get pods -l ${key}=${value} -o=jsonpath="{.items[].status.containerStatuses[].ready}"
+ Should Not Contain ${output} "false"
Check Expected Running Pods Number By Label
[Arguments] ${namespace} ${key} ${value} ${number}
diff --git a/libraries/onos.robot b/libraries/onos.robot
index 5c3dd0a..9ebcbc2 100644
--- a/libraries/onos.robot
+++ b/libraries/onos.robot
@@ -11,13 +11,11 @@
# 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 HttpLibrary.HTTP
Library String
Library DateTime
Library Process
@@ -37,7 +35,7 @@
[Return] ${output}
Validate OLT Device in ONOS
-# FIXME use volt-olts to check that the OLT is ONOS
+ # FIXME use volt-olts to check that the OLT is ONOS
[Arguments] ${serial_number}
[Documentation] Checks if olt has been connected to ONOS
${resp}= Get Request ONOS onos/v1/devices
@@ -141,9 +139,13 @@
Remove All Devices From ONOS
[Arguments] ${url}
[Documentation] Executes the device-remove command on each device in ONOS
- ${rc} @{dpids} Run And Return Rc And Output curl --fail -sSL ${url}/onos/v1/devices | jq -r '.devices[].id'
+ ${rc} @{dpids} Run And Return Rc And Output
+ ... curl --fail -sSL ${url}/onos/v1/devices | jq -r '.devices[].id'
Should Be Equal As Integers ${rc} 0
${count}= Get length ${dpids}
- :FOR ${dpid} IN @{dpids}
- \ ${rc}= Run Keyword If '${dpid}' != '' Run And Return Rc curl -XDELETE --fail -sSL ${url}/onos/v1/devices/${dpid}
- \ Run Keyword If '${dpid}' != '' Should Be Equal As Integers ${rc} 0
+ FOR ${dpid} IN @{dpids}
+ ${rc}= Run Keyword If '${dpid}' != ''
+ ... Run And Return Rc curl -XDELETE --fail -sSL ${url}/onos/v1/devices/${dpid}
+ Run Keyword If '${dpid}' != ''
+ ... Should Be Equal As Integers ${rc} 0
+ END
diff --git a/libraries/utils.robot b/libraries/utils.robot
index c235383..a4ad0f4 100644
--- a/libraries/utils.robot
+++ b/libraries/utils.robot
@@ -11,13 +11,11 @@
# 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.
-
# robot test functions
*** Settings ***
Documentation Library for various utilities
Library SSHLibrary
-Library HttpLibrary.HTTP
Library String
Library DateTime
Library Process
@@ -29,26 +27,26 @@
Check CLI Tools Configured
[Documentation] Tests that use 'voltctl' and 'kubectl' should execute this keyword in suite setup
# check voltctl and kubectl configured
- ${voltctl_rc}= Run And Return RC ${VOLTCTL_CONFIG}; voltctl device list
- ${kubectl_rc}= Run And Return RC ${KUBECTL_CONFIG}; kubectl get pods
+ ${voltctl_rc}= Run And Return RC voltctl device list
+ ${kubectl_rc}= Run And Return RC kubectl get pods
Run Keyword If ${voltctl_rc} != 0 or ${kubectl_rc} != 0 FATAL ERROR
... VOLTCTL and KUBECTL not configured. Please configure before executing tests.
Send File To Onos
- [Documentation] Send the content of the file to Onos to selected section of configuration using Post Request
- [Arguments] ${CONFIG_FILE} ${section}
- ${Headers}= Create Dictionary Content-Type application/json
- ${File_Data}= Get Binary File ${CONFIG_FILE}
- Log ${Headers}
- Log ${File_Data}
- ${resp}= Post Request ONOS /onos/v1/network/configuration/${section} headers=${Headers} data=${File_Data}
- Should Be Equal As Strings ${resp.status_code} 200
+ [Documentation] Send the content of the file to Onos to selected section of configuration
+ ... using Post Request
+ [Arguments] ${CONFIG_FILE} ${section}
+ ${Headers}= Create Dictionary Content-Type application/json
+ ${File_Data}= OperatingSystem.Get File ${CONFIG_FILE}
+ Log ${Headers}
+ Log ${File_Data}
+ ${resp}= Post Request ONOS
+ ... /onos/v1/network/configuration/${section} headers=${Headers} data=${File_Data}
+ Should Be Equal As Strings ${resp.status_code} 200
Common Test Suite Setup
[Documentation] Setup the test suite
# BBSim sanity test doesn't need these imports from other repositories
- Run Keyword If ${external_libs} Import Library
- ... ${CURDIR}/../../voltha/tests/atests/common/testCaseUtils.py
Run Keyword If ${external_libs} Import Resource
... ${CURDIR}/../../cord-tester/src/test/cord-api/Framework/Subscriber.robot
Run Keyword If ${external_libs} Import Resource
@@ -59,7 +57,6 @@
... ${CURDIR}/../../cord-tester/src/test/cord-api/Framework/Kubernetes.robot
Set Global Variable ${KUBECTL_CONFIG} export KUBECONFIG=%{KUBECONFIG}
Set Global Variable ${VOLTCTL_CONFIG} export VOLTCONFIG=%{VOLTCONFIG}
- Set Global Variable ${export_kubeconfig} export KUBECONFIG=%{KUBECONFIG}
${k8s_node_ip}= Evaluate ${nodes}[0].get("ip")
${k8s_node_user}= Evaluate ${nodes}[0].get("user")
${k8s_node_pass}= Evaluate ${nodes}[0].get("pass")
@@ -75,7 +72,7 @@
${num_onus}= Convert to String ${num_onus}
#send sadis file to onos
${sadis_file}= Get Variable Value ${sadis.file}
- Log To Console \nSadis File:${sadis_file}
+ Log To Console \nSadis File:${sadis_file}
Run Keyword Unless '${sadis_file}' is '${None}' Send File To Onos ${sadis_file} apps/
Set Suite Variable ${num_onus}
Set Suite Variable ${olt_serial_number}
@@ -92,45 +89,56 @@
Set Suite Variable ${datetime}
WPA Reassociate
- [Arguments] ${iface} ${ip} ${user} ${pass}=${None} ${container_type}=${None} ${container_name}=${None}
[Documentation] Executes a particular wpa_cli reassociate, which performs force reassociation
+ [Arguments] ${iface} ${ip} ${user} ${pass}=${None}
+ ... ${container_type}=${None} ${container_name}=${None}
#Below for loops are used instead of sleep time, to execute reassociate command and check status
- : FOR ${i} IN RANGE 70
- \ ${output}= Login And Run Command On Remote System wpa_cli -i ${iface} reassociate ${ip} ${user}
- ... ${pass} ${container_type} ${container_name}
- \ ${passed}= Run Keyword And Return Status Should Contain ${output} OK
- \ Run Keyword If ${passed} Exit For Loop
- : FOR ${i} IN RANGE 70
- \ ${output}= Login And Run Command On Remote System wpa_cli status | grep SUCCESS ${ip} ${user}
- ... ${pass} ${container_type} ${container_name}
- \ ${passed}= Run Keyword And Return Status Should Contain ${output} SUCCESS
- \ Run Keyword If ${passed} Exit For Loop
-
+ FOR ${i} IN RANGE 70
+ ${output}= Login And Run Command On Remote System
+ ... wpa_cli -i ${iface} reassociate ${ip} ${user}
+ ... ${pass} ${container_type} ${container_name}
+ ${passed}= Run Keyword And Return Status Should Contain ${output} OK
+ Run Keyword If ${passed} Exit For Loop
+ END
+ FOR ${i} IN RANGE 70
+ ${output}= Login And Run Command On Remote System
+ ... wpa_cli status | grep SUCCESS ${ip} ${user}
+ ... ${pass} ${container_type} ${container_name}
+ ${passed}= Run Keyword And Return Status Should Contain ${output} SUCCESS
+ Run Keyword If ${passed} Exit For Loop
+ END
+
Validate Authentication After Reassociate
- [Arguments] ${auth_pass} ${iface} ${ip} ${user} ${pass}=${None} ${container_type}=${None} ${container_name}=${None}
- [Documentation] Executes a particular reassociate request on the RG using wpa_cli. auth_pass determines if authentication should pass
+ [Arguments] ${auth_pass} ${iface} ${ip} ${user} ${pass}=${None}
+ ... ${container_type}=${None} ${container_name}=${None}
+ [Documentation]
+ ... Executes a particular reassociate request on the RG using wpa_cli.
+ ... auth_pass determines if authentication should pass
WPA Reassociate ${iface} ${ip} ${user} ${pass} ${container_type} ${container_name}
- Run Keyword If '${auth_pass}' == 'True' Wait Until Keyword Succeeds ${timeout} 2s Check Remote File Contents
- ... True /tmp/wpa.log authentication completed successfully ${ip} ${user} ${pass}
- ... ${container_type} ${container_name}
+ Run Keyword If '${auth_pass}' == 'True' Wait Until Keyword Succeeds ${timeout} 2s
+ ... Check Remote File Contents True /tmp/wpa.log authentication completed successfully
+ ... ${ip} ${user} ${pass} ${container_type} ${container_name}
Run Keyword If '${auth_pass}' == 'False' Sleep 20s
- Run Keyword If '${auth_pass}' == 'False' Check Remote File Contents False /tmp/wpa.log
- ... authentication completed successfully ${ip} ${user} ${pass} ${container_type} ${container_name}
+ Run Keyword If '${auth_pass}' == 'False' Check Remote File Contents False /tmp/wpa.log
+ ... authentication completed successfully ${ip} ${user} ${pass}
+ ... ${container_type} ${container_name}
Send Dhclient Request To Release Assigned IP
- [Arguments] ${iface} ${ip} ${user} ${path_dhcpleasefile} ${pass}=${None} ${container_type}=${None}
- ... ${container_name}=${None}
+ [Arguments] ${iface} ${ip} ${user} ${path_dhcpleasefile} ${pass}=${None}
+ ... ${container_type}=${None} ${container_name}=${None}
[Documentation] Executes a dhclient with option to release ip against a particular interface on the RG (src)
- ${result}= Login And Run Command On Remote System dhclient -nw -r ${iface} && rm ${path_dhcpleasefile}/dhclient.* ${ip} ${user}
+ ${result}= Login And Run Command On Remote System
+ ... dhclient -nw -r ${iface} && rm ${path_dhcpleasefile}/dhclient.* ${ip} ${user}
... ${pass} ${container_type} ${container_name}
Log ${result}
#Should Contain ${result} DHCPRELEASE
[Return] ${result}
Check Remote File Contents For WPA Logs
- [Arguments] ${file_should_exist} ${file} ${pattern} ${ip} ${user} ${pass}=${None} ${container_type}=${None}
- ... ${container_name}=${None} ${prompt}=~$
+ [Arguments] ${file_should_exist} ${file} ${pattern} ${ip} ${user} ${pass}=${None}
+ ... ${container_type}=${None} ${container_name}=${None} ${prompt}=~$
[Documentation] Checks for particular pattern count in a file
- ${result}= Login And Run Command On Remote System cat ${file} | grep '${pattern}' | wc -l ${ip} ${user} ${pass}
+ ${result}= Login And Run Command On Remote System
+ ... cat ${file} | grep '${pattern}' | wc -l ${ip} ${user} ${pass}
... ${container_type} ${container_name} ${prompt}
[Return] ${result}
diff --git a/libraries/voltctl.robot b/libraries/voltctl.robot
index 8e624c7..dcd2b12 100644
--- a/libraries/voltctl.robot
+++ b/libraries/voltctl.robot
@@ -11,13 +11,11 @@
# 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.
-
# voltctl common functions
*** Settings ***
Documentation Library for various utilities
Library SSHLibrary
-Library HttpLibrary.HTTP
Library String
Library DateTime
Library Process
@@ -27,8 +25,8 @@
*** Keywords ***
Test Empty Device List
- [Documentation] Verify that there are no devices in the system
- ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list -o json
+ [Documentation] Verify that there are no devices in the system
+ ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list -o json
Should Be Equal As Integers ${rc} 0
${jsondata}= To Json ${output}
Log ${jsondata}
@@ -47,13 +45,15 @@
Enable Device
[Arguments] ${device_id}
[Documentation] Enables a device in VOLTHA
- ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device enable ${device_id}
+ ${rc} ${output}= Run and Return Rc and Output
+ ... ${VOLTCTL_CONFIG}; voltctl device enable ${device_id}
Should Be Equal As Integers ${rc} 0
Disable Device
[Arguments] ${device_id}
[Documentation] Enables a device in VOLTHA
- ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device disable ${device_id}
+ ${rc} ${output}= Run and Return Rc and Output
+ ... ${VOLTCTL_CONFIG}; voltctl device disable ${device_id}
Should Be Equal As Integers ${rc} 0
Disable Devices In Voltha
@@ -61,15 +61,18 @@
[Arguments] ${filter}
${arg}= Set Variable ${EMPTY}
${arg}= Run Keyword If len('${filter}'.strip()) != 0 Set Variable --filter ${filter}
- ${rc} ${devices}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list ${arg} --orderby Root -q | xargs echo -n
+ ${rc} ${devices}= Run and Return Rc and Output
+ ... ${VOLTCTL_CONFIG}; voltctl device list ${arg} --orderby Root -q | xargs echo -n
Should Be Equal As Integers ${rc} 0
- ${rc} ${output}= Run Keyword If len('${devices}') != 0 Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device disable ${devices}
+ ${rc} ${output}= Run Keyword If len('${devices}') != 0 Run and Return Rc and Output
+ ... ${VOLTCTL_CONFIG}; voltctl device disable ${devices}
Run Keyword If len('${devices}') != 0 Should Be Equal As Integers ${rc} 0
Test Devices Disabled In Voltha
[Documentation] Tests to verify that all devices in VOLTHA are disabled
[Arguments] ${filter}
- ${rc} ${count}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list --filter '${filter},AdminState!=DISABLED' -q | wc -l
+ ${rc} ${count}= Run and Return Rc and Output
+ ... ${VOLTCTL_CONFIG}; voltctl device list --filter '${filter},AdminState!=DISABLED' -q | wc -l
Should Be Equal As Integers ${rc} 0
Should Be Equal As Integers ${count} 0
@@ -78,23 +81,28 @@
[Arguments] ${filter}
${arg}= Set Variable ${EMPTY}
${arg}= Run Keyword If len('${filter}'.strip()) != 0 Set Variable --filter ${filter}
- ${rc} ${devices}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list ${arg} --orderby Root -q | xargs echo -n
+ ${rc} ${devices}= Run and Return Rc and Output
+ ... ${VOLTCTL_CONFIG}; voltctl device list ${arg} --orderby Root -q | xargs echo -n
Should Be Equal As Integers ${rc} 0
- ${rc} ${output}= Run Keyword If len('${devices}') != 0 Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device delete ${devices}
+ ${rc} ${output}= Run Keyword If len('${devices}') != 0 Run and Return Rc and Output
+ ... ${VOLTCTL_CONFIG}; voltctl device delete ${devices}
Run Keyword If len('${devices}') != 0 Should Be Equal As Integers ${rc} 0
Get Device Flows from Voltha
[Arguments] ${device_id}
[Documentation] Gets device flows from VOLTHA
- ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device flows ${device_id}
+ ${rc} ${output}= Run and Return Rc and Output
+ ... ${VOLTCTL_CONFIG}; voltctl device flows ${device_id}
Should Be Equal As Integers ${rc} 0
[Return] ${output}
Get Logical Device Output from Voltha
[Arguments] ${device_id}
[Documentation] Gets logicaldevice flows and ports from VOLTHA
- ${rc1} ${flows}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl logicaldevice flows ${device_id}
- ${rc2} ${ports}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl logicaldevice ports ${device_id}
+ ${rc1} ${flows}= Run and Return Rc and Output
+ ... ${VOLTCTL_CONFIG}; voltctl logicaldevice flows ${device_id}
+ ${rc2} ${ports}= Run and Return Rc and Output
+ ... ${VOLTCTL_CONFIG}; voltctl logicaldevice ports ${device_id}
Log ${flows}
Log ${ports}
Should Be Equal As Integers ${rc1} 0
@@ -103,8 +111,10 @@
Get Device Output from Voltha
[Arguments] ${device_id}
[Documentation] Gets device flows and ports from VOLTHA
- ${rc1} ${flows}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device flows ${device_id}
- ${rc2} ${ports}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device ports ${device_id}
+ ${rc1} ${flows}= Run and Return Rc and Output
+ ... ${VOLTCTL_CONFIG}; voltctl device flows ${device_id}
+ ${rc2} ${ports}= Run and Return Rc and Output
+ ... ${VOLTCTL_CONFIG}; voltctl device ports ${device_id}
Log ${flows}
Log ${ports}
Should Be Equal As Integers ${rc1} 0
@@ -117,10 +127,11 @@
Should Be Equal As Integers ${rc1} 0
Validate Device
- [Arguments] ${admin_state} ${oper_status} ${connect_status} ${serial_number}=${EMPTY} ${device_id}=${EMPTY}
- ... ${onu_reason}=${EMPTY} ${onu}=False
- [Documentation] Parses the output of "voltctl device list" and inspects device ${serial_number} and ${device_id}
+ [Documentation]
+ ... Parses the output of "voltctl device list" and inspects device ${serial_number} and ${device_id}
... Arguments are matched for device states of: "admin_state", "oper_status", and "connect_status"
+ [Arguments] ${admin_state} ${oper_status} ${connect_status} ${serial_number}=${EMPTY}
+ ... ${device_id}=${EMPTY} ${onu_reason}=${EMPTY} ${onu}=False
${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list -o json
Should Be Equal As Integers ${rc} 0
${jsondata}= To Json ${output}
@@ -138,34 +149,36 @@
Log ${value}
Should Be Equal '${astate}' '${admin_state}' Device ${serial_number} admin_state != ${admin_state}
... values=False
- Should Be Equal '${opstatus}' '${oper_status}' Device ${serial_number} oper_status != ${oper_status}
+ Should Be Equal '${opstatus}' '${oper_status}' Device ${serial_number} oper_status != ${oper_status}
... values=False
Should Be Equal '${cstatus}' '${connect_status}' Device ${serial_number} conn_status != ${connect_status}
... values=False
Run Keyword If '${onu}' == 'True' Should Be Equal '${mib_state}' '${onu_reason}'
- ... Device ${serial_number} mib_state incorrect (${mib_state}) values=False
+ ... Device ${serial_number} mib_state incorrect (${mib_state}) values=False
Validate OLT Device
- [Arguments] ${admin_state} ${oper_status} ${connect_status} ${serial_number}=${EMPTY}
+ [Arguments] ${admin_state} ${oper_status} ${connect_status} ${serial_number}=${EMPTY}
... ${device_id}=${EMPTY}
[Documentation] Parses the output of "voltctl device list" and inspects device ${serial_number} and/or
- ... ${device_id} Match on OLT Serial number or Device Id and inspect states
- Validate Device ${admin_state} ${oper_status} ${connect_status} ${serial_number} ${device_id}
+ ... ${device_id} Match on OLT Serial number or Device Id and inspect states
+ Validate Device ${admin_state} ${oper_status} ${connect_status} ${serial_number} ${device_id}
Validate ONU Devices
[Arguments] ${admin_state} ${oper_status} ${connect_status} ${List_ONU_Serial}
- [Documentation] Parses the output of "voltctl device list" and inspects device ${List_ONU_Serial}
+ [Documentation] Parses the output of "voltctl device list" and inspects device ${List_ONU_Serial}
... Iteratively match on each Serial number contained in ${List_ONU_Serial} and inspect
... states including MIB state
- FOR ${serial_number} IN @{List_ONU_Serial}
+ FOR ${serial_number} IN @{List_ONU_Serial}
Validate Device ${admin_state} ${oper_status} ${connect_status} ${serial_number}
- ... onu_reason=omci-flows-pushed onu=True
+ ... onu_reason=omci-flows-pushed onu=True
END
Validate Device Port Types
+ [Documentation]
+ ... Parses the output of voltctl device ports <device_id> and matches the port types listed
[Arguments] ${device_id} ${pon_type} ${ethernet_type}
- [Documentation] Parses the output of voltctl device ports <device_id> and matches the port types listed
- ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device ports ${device_id} -o json
+ ${rc} ${output}= Run and Return Rc and Output
+ ... ${VOLTCTL_CONFIG}; voltctl device ports ${device_id} -o json
Should Be Equal As Integers ${rc} 0
${jsondata}= To Json ${output}
Log ${jsondata}
@@ -178,27 +191,27 @@
Should Be Equal '${astate}' 'ENABLED' Device ${device_id} port admin_state != ENABLED values=False
Should Be Equal '${opstatus}' 'ACTIVE' Device ${device_id} port oper_status != ACTIVE values=False
Should Be True '${type}' == '${pon_type}' or '${type}' == '${ethernet_type}'
- ... Device ${device_id} port type is neither ${pon_type} or ${ethernet_type}
+ ... Device ${device_id} port type is neither ${pon_type} or ${ethernet_type}
END
Validate OLT Port Types
- [Documentation] Parses the output of voltctl device ports ${olt_device_id} and matches the port types listed
- [Arguments] ${pon_type} ${ethernet_type}
- Validate Device Port Types ${olt_device_id} ${pon_type} ${ethernet_type}
+ [Documentation] Parses the output of voltctl device ports ${olt_device_id} and matches the port types listed
+ [Arguments] ${pon_type} ${ethernet_type}
+ Validate Device Port Types ${olt_device_id} ${pon_type} ${ethernet_type}
Validate ONU Port Types
- [Arguments] ${List_ONU_Serial} ${pon_type} ${ethernet_type}
- [Documentation] Parses the output of voltctl device ports for each ONU SN listed in ${List_ONU_Serial}
- ... and matches the port types listed
+ [Arguments] ${List_ONU_Serial} ${pon_type} ${ethernet_type}
+ [Documentation] Parses the output of voltctl device ports for each ONU SN listed in ${List_ONU_Serial}
+ ... and matches the port types listed
FOR ${serial_number} IN @{List_ONU_Serial}
${onu_dev_id}= Get Device ID From SN ${serial_number}
- Validate Device Port Types ${onu_dev_id} ${pon_type} ${ethernet_type}
+ Validate Device Port Types ${onu_dev_id} ${pon_type} ${ethernet_type}
END
Validate Device Flows
[Arguments] ${device_id} ${test}=${EMPTY}
[Documentation] Parses the output of voltctl device flows <device_id> and expects flow count > 0
- ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device flows ${device_id} -o json
+ ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device flows ${device_id} -o json
Should Be Equal As Integers ${rc} 0
${jsondata}= To Json ${output}
Log ${jsondata}
@@ -206,7 +219,7 @@
Log 'Number of flows = ' ${length}
Run Keyword If '${test}' == '${EMPTY}' Should Be True ${length} > 0
... Number of flows for ${device_id} was 0
- ... ELSE Should Be True ${length} == ${test}
+ ... ELSE Should Be True ${length} == ${test}
... Number of flows for ${device_id} was not ${test}
Validate OLT Flows
@@ -217,7 +230,7 @@
[Arguments] ${List_ONU_Serial} ${test}
[Documentation] Parses the output of voltctl device flows for each ONU SN listed in ${List_ONU_Serial}
... and expects flow count == 0
- FOR ${serial_number} IN @{List_ONU_Serial}
+ FOR ${serial_number} IN @{List_ONU_Serial}
${onu_dev_id}= Get Device ID From SN ${serial_number}
Validate Device Flows ${onu_dev_id} ${test}
END
@@ -239,7 +252,7 @@
Should Be Equal '${rootdev}' '${olt_device_id}' Root Device does not match ${olt_device_id} values=False
Should Be Equal '${sn}' '${BBSIM_OLT_SN}' Logical Device ${sn} does not match ${BBSIM_OLT_SN}
... values=False
- [Return] ${devid}
+ [Return] ${devid}
Validate Logical Device Ports
[Arguments] ${logical_device_id}
@@ -261,12 +274,12 @@
${jsondata}= To Json ${output}
Log ${jsondata}
${length}= Get Length ${jsondata}
- Should Be True ${length} > 0 Number of flows for ${logical_device_id} was 0
+ Should Be True ${length} > 0 Number of flows for ${logical_device_id} was 0
Retrieve Peer List From OLT
- [Arguments] ${olt_peer_list}
+ [Arguments] ${olt_peer_list}
[Documentation] Retrieve the list of peer device id list from port list
- ${rc} ${output}= Run and Return Rc and Output
+ ${rc} ${output}= Run and Return Rc and Output
... ${VOLTCTL_CONFIG}; voltctl device ports ${olt_device_id} -o json
Should Be Equal As Integers ${rc} 0
${jsondata}= To Json ${output}
@@ -295,12 +308,12 @@
Match OLT Peer Id
[Arguments] ${olt_peer_id}
[Documentation] Lookup the OLT Peer Id in against the list of ONU device Ids
- ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list -o json
+ ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list -o json
Should Be Equal As Integers ${rc} 0
${jsondata}= To Json ${output}
Log ${jsondata}
${length}= Get Length ${jsondata}
- FOR ${INDEX} IN RANGE 0 ${length}
+ FOR ${INDEX} IN RANGE 0 ${length}
${value}= Get From List ${jsondata} ${INDEX}
${devid}= Get From Dictionary ${value} id
Run Keyword If '${devid}' == '${olt_peer_id}' Exit For Loop
@@ -340,7 +353,7 @@
Get Device ID From SN
[Arguments] ${serial_number}
[Documentation] Gets the device id by matching for ${serial_number}
- ${rc} ${id}= Run and Return Rc and Output
+ ${rc} ${id}= Run and Return Rc and Output
... ${VOLTCTL_CONFIG}; voltctl device list --filter=SerialNumber=${serial_number} --format='{{.Id}}'
Should Be Equal As Integers ${rc} 0
Log ${id}
@@ -349,7 +362,7 @@
Get Logical Device ID From SN
[Arguments] ${serial_number}
[Documentation] Gets the device id by matching for ${serial_number}
- ${rc} ${id}= Run and Return Rc and Output
+ ${rc} ${id}= Run and Return Rc and Output
... ${VOLTCTL_CONFIG}; voltctl logicaldevice list --filter=SerialNumber=${serial_number} --format='{{.Id}}'
Should Be Equal As Integers ${rc} 0
Log ${id}
@@ -365,7 +378,7 @@
Get SN From Device ID
[Arguments] ${device_id}
[Documentation] Gets the device id by matching for ${device_id}
- ${rc} ${sn}= Run and Return Rc and Output
+ ${rc} ${sn}= Run and Return Rc and Output
... ${VOLTCTL_CONFIG}; voltctl device list --filter=Id=${device_id} --format='{{.SerialNumber}}'
Should Be Equal As Integers ${rc} 0
Log ${sn}
@@ -374,7 +387,7 @@
Validate Device Removed
[Arguments] ${id}
[Documentation] Verifys that device, ${serial_number}, has been removed
- ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list -o json
+ ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list -o json
Should Be Equal As Integers ${rc} 0
${jsondata}= To Json ${output}
Log ${jsondata}
diff --git a/libraries/voltha.robot b/libraries/voltha.robot
index 1009eda..f1f47aa 100644
--- a/libraries/voltha.robot
+++ b/libraries/voltha.robot
@@ -11,13 +11,11 @@
# 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.
-
# voltha common functions
*** Settings ***
Documentation Library for various utilities
Library SSHLibrary
-Library HttpLibrary.HTTP
Library String
Library DateTime
Library Process
@@ -46,7 +44,7 @@
[Arguments] ${name}
[Documentation] Uses a script to restart a kubectl port-forward
${rc} ${pid} Run And Return Rc And Output
- ... ps e -ww | grep _TAG=${name} | grep -v grep | awk '{printf(\"%s %s\\n\",$1,$5)}' | grep -v bash | awk '{print $1}'
+ ... ps e -ww | grep _TAG=${name} | awk '{printf(\"%s %s\\n\",$1,$5)}' | grep kubectl | awk '{print $1}'
Should Be Equal as Integers ${rc} 0
Run Keyword If '${pid}' != '' Run And Return Rc kill -9 ${pid}
Should Be Equal as Integers ${rc} 0