[VOL-3796] OpenOnu-Go-Adapter: Create target for multiple OLT (2x2x2) environment
Change-Id: I5e1e5044c979a9d3f8af770935179cb8351e2dfe
diff --git a/libraries/bbsim.robot b/libraries/bbsim.robot
old mode 100644
new mode 100755
index 12ce3a6..92e4424
--- a/libraries/bbsim.robot
+++ b/libraries/bbsim.robot
@@ -57,3 +57,17 @@
... bbsimctl onu igmp ${onu} ${task} ${group_address}
Log ${res}
Should Be Equal as Integers ${rc} 0
+
+Power On ONU
+ [Documentation] This keyword turns on the power for onu device.
+ [Arguments] ${namespace} ${bbsim_pod_name} ${onu}
+ ${result} ${rc}= Exec Pod And Return Output And RC ${namespace} ${bbsim_pod_name}
+ ... bbsimctl onu poweron ${onu}
+ Should Contain ${result} successfully msg=Can not poweron ${onu} values=False
+
+Power Off ONU
+ [Documentation] This keyword turns off the power for onu device.
+ [Arguments] ${namespace} ${bbsim_pod_name} ${onu}
+ ${result} ${rc}= Exec Pod And Return Output And RC ${namespace} ${bbsim_pod_name}
+ ... bbsimctl onu shutdown ${onu}
+ Should Contain ${result} successfully msg=Can not shutdown ${onu} values=False
diff --git a/libraries/k8s.robot b/libraries/k8s.robot
old mode 100644
new mode 100755
index bb909d1..63b9efe
--- a/libraries/k8s.robot
+++ b/libraries/k8s.robot
@@ -64,10 +64,12 @@
[return] ${output}
Exec Pod In Kube
- [Arguments] ${namespace} ${name} ${command}
+ [Arguments] ${namespace} ${name} ${command} ${grep}=${EMPTY}
[Documentation] Uses kubectl to execute a command in the pod and return the output
- ${rc} ${exec_pod_name}= Run and Return Rc and Output
- ... kubectl -n ${namespace} get pods -l app.kubernetes.io/name=${name} -o name
+ ${rc} ${exec_pod_name}= Run Keyword If '${grep}'=='${EMPTY}'
+ ... Run and Return Rc and Output kubectl -n ${namespace} get pods -l app.kubernetes.io/name=${name} -o name
+ ... ELSE Run and Return Rc and Output
+ ... kubectl -n ${namespace} get pods -l app.kubernetes.io/name=${name} -o name \| grep ${grep}
Log ${exec_pod_name}
Should Not Be Empty ${exec_pod_name} Unable to parse pod name
${rc} ${output}= Run and Return Rc and Output
@@ -377,9 +379,9 @@
Wait For Pods Not Exist
[Arguments] ${namespace} ${list_names}
[Documentation] Checks the passed PODs are no longer existing
- FOR ${pod_name} IN @{list_names}
+ FOR ${pod_name} IN @{list_names}
Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 3s
- ... Pod Does Not Exist ${namespace} ${pod_name}
+ ... Pod Does Not Exist ${namespace} ${pod_name}
END
Pods Do Not Exist By Label
@@ -441,9 +443,9 @@
Wait For Pods Ready
[Arguments] ${namespace} ${list_apps}
[Documentation] Checks the passed PODs are ready
- FOR ${app_name} IN @{list_apps}
+ FOR ${app_name} IN @{list_apps}
Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 3s
- ... Pods Are Ready By Label ${namespace} app ${app_name}
+ ... Pods Are Ready By Label ${namespace} app ${app_name}
END
Check Expected Running Pods Number By Label
diff --git a/libraries/onu_utilities.robot b/libraries/onu_utilities.robot
index f15ff7e..88e0d72 100755
--- a/libraries/onu_utilities.robot
+++ b/libraries/onu_utilities.robot
@@ -32,19 +32,39 @@
Power On ONU Device
[Documentation] This keyword turns on the power for all onus.
[Arguments] ${namespace}
+ FOR ${J} IN RANGE 0 ${num_olts}
+ ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn]
+ ${bbsim}= Catenate SEPARATOR= bbsim ${J}
+ ${bbsim_pod}= Get Pod Name By Label ${namespace} release ${bbsim}
+ Power On ONU Device per OLT ${namespace} ${olt_serial_number} ${bbsim_pod}
+ END
+
+Power On ONU Device per OLT
+ [Documentation] This keyword turns on the power for all onus.
+ [Arguments] ${namespace} ${olt_serial_number} ${bbsim_pod}
FOR ${I} IN RANGE 0 ${num_all_onus}
${src}= Set Variable ${hosts.src[${I}]}
- ${result}= Exec Pod In Kube ${namespace} bbsim bbsimctl onu poweron ${src['onu']}
- Should Contain ${result} successfully msg=Can not poweron ${src['onu']} values=False
+ Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
+ Power On ONU ${namespace} ${bbsim_pod} ${src['onu']}
END
Power Off ONU Device
- [Documentation] This keyword turns off the power for all onus.
+ [Documentation] This keyword turns off the power for all onus per olt.
[Arguments] ${namespace}
+ FOR ${J} IN RANGE 0 ${num_olts}
+ ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn]
+ ${bbsim}= Catenate SEPARATOR= bbsim ${J}
+ ${bbsim_pod}= Get Pod Name By Label ${namespace} release ${bbsim}
+ Power Off ONU Device per OLT ${namespace} ${olt_serial_number} ${bbsim_pod}
+ END
+
+Power Off ONU Device per OLT
+ [Documentation] This keyword turns off the power for all onus per olt.
+ [Arguments] ${namespace} ${olt_serial_number} ${bbsim_pod}
FOR ${I} IN RANGE 0 ${num_all_onus}
${src}= Set Variable ${hosts.src[${I}]}
- ${result}= Exec Pod In Kube ${namespace} bbsim bbsimctl onu shutdown ${src['onu']}
- Should Contain ${result} successfully msg=Can not shutdown ${src['onu']} values=False
+ Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
+ Power Off ONU ${namespace} ${bbsim_pod} ${src['onu']}
END
Current State Test
@@ -210,18 +230,18 @@
log ${jsondata}
Run Keyword And Continue On Failure Should Be Equal As Integers ${length} ${nbofetcddata}
... msg=Number etcd data (${length}) does not match required (${nbofetcddata})!
- ${pononuuniidlist}= Create List
+ ${oltpononuuniidlist}= Create List
${serialnumberlist}= Create List
FOR ${INDEX} IN RANGE 0 ${length}
${value}= Get From List ${jsondata} ${INDEX}
# TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
# When testing multi-tcont this may need some adjustment.
${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
- ${pononuuniid}= Read Pon Onu Uni String ${tp_path}
- ${list_id}= Get Index From List ${pononuuniidlist} ${pononuuniid}
+ ${oltpononuuniid}= Read Pon Onu Uni String ${tp_path}
+ ${list_id}= Get Index From List ${oltpononuuniidlist} ${oltpononuuniid}
Should Be Equal As Integers ${list_id} -1
- ... msg=Combination of Pon, Onu and Uni (${pononuuniid}) exist multiple in etcd data!
- Append To List ${pononuuniidlist} ${pononuuniid}
+ ... msg=Combination of Pon, Onu and Uni (${oltpononuuniid}) exist multiple in etcd data!
+ Append To List ${oltpononuuniidlist} ${oltpononuuniid}
Validate Onu Id ${value}
Validate Uni Id ${value}
${serial_number}= Get From Dictionary ${value} serial_number
@@ -252,7 +272,7 @@
# TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
# When testing multi-tcont this may need some adjustment.
${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
- ${pononuuniid}= Read Pon Onu Uni String ${tp_path}
+ ${oltpononuuniid}= Read Pon Onu Uni String ${tp_path}
${cookieslice}= Get From Dictionary ${value['uni_config'][0]['flow_params'][0]} cookie_slice
#@{cookieslicelist}= Split String ${cookieslice} ,
${foundcookieslices}= Get Length ${cookieslice}
@@ -264,9 +284,9 @@
... set_vid
${evalresult}= Evaluate 2 <= ${setvid} <= 4095
Should Be True ${evalresult} msg=set_vid out of range (${setvid})!
- Set To Dictionary ${vlan_rules} ${pononuuniid} ${setvid}
+ Set To Dictionary ${vlan_rules} ${oltpononuuniid} ${setvid}
${oldsetvidvalid} Set Variable If ${prevvlanrules} is ${NONE} False True
- ${prevsetvid}= Set Variable If ${oldsetvidvalid} ${prevvlanrules['${pononuuniid}']}
+ ${prevsetvid}= Set Variable If ${oldsetvidvalid} ${prevvlanrules['${oltpononuuniid}']}
Run Keyword If ${oldsetvidvalid} and ${setvidequal}
... Should Be Equal As Integers ${prevsetvid} ${setvid}
... ELSE IF ${oldsetvidvalid} and not ${setvidequal}
@@ -312,14 +332,15 @@
[Return] ${string}
Read Pon Onu Uni String
- [Documentation] This keyword builds a thre digit string using Pon, Onu and Uni value of given tp-path taken
+ [Documentation] This keyword builds a four digit string using Olt, Pon, Onu and Uni value of given tp-path taken
... taken from etcd data of onu go adapter
[Arguments] ${tp_path}
${tppathlines}= Replace String ${tp_path} / \n
+ ${olt}= Get Value Of Tp Path Element ${tppathlines} olt
${pon}= Get Value Of Tp Path Element ${tppathlines} pon
${onu}= Get Value Of Tp Path Element ${tppathlines} onu
${uni}= Get Value Of Tp Path Element ${tppathlines} uni
- ${valuesid}= Set Variable ${pon}/${onu}/${uni}
+ ${valuesid}= Set Variable ${olt}/${pon}/${onu}/${uni}
log ${valuesid}
[Return] ${valuesid}
@@ -373,7 +394,8 @@
${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS
... ${olt_serial_number}
Set Global Variable ${of_id}
- Wait for Ports in ONOS ${onos_ssh_connection} ${count} ${of_id} BBSM ${max_wait_time}
+ ${count2check} Set Variable If ${count}==${num_all_onus} ${onu_count} ${count}
+ Wait for Ports in ONOS ${onos_ssh_connection} ${count2check} ${of_id} BBSM ${max_wait_time}
END
Wait for all ONU Ports in ONOS Disabled