[VOL-3717] Allowing to pass the olt type via pod-configs yaml file
Change-Id: Ic3873d05d15b40bbbac02eb1d221644a7aaa4c56
diff --git a/libraries/k8s.robot b/libraries/k8s.robot
index 59e6544..213246e 100644
--- a/libraries/k8s.robot
+++ b/libraries/k8s.robot
@@ -326,6 +326,20 @@
... kubectl scale --replicas=${count} -n ${namespace} deploy/${name}
Should Be Equal as Integers ${rc} 0
+Get K8s Deployment by Pod Label
+ [Arguments] ${namespace} ${key} ${value}
+ [Documentation] Uses kubectl to scale a deployment given the app name of the pod
+ ${rc} ${name} Run And Return Rc And Output
+ ... kubectl describe rs -n ${namespace} -l ${key}=${value} | grep "Controlled By" | awk -F'/' '{print $2}'
+ Should Be Equal as Integers ${rc} 0
+ [Return] ${name}
+
+Scale K8s Deployment by Pod Label
+ [Arguments] ${namespace} ${key} ${value} ${count}
+ [Documentation] Uses kubectl to scale a deployment given the app name of the pod
+ ${name} Get K8s Deployment by Pod Label ${namespace} ${key} ${value}
+ Scale K8s Deployment ${namespace} ${name} ${count}
+
Pod Exists
[Arguments] ${namespace} ${name}
[Documentation] Succeeds it the named POD exists
@@ -366,6 +380,12 @@
... ELSE Set Variable ${count}
[Return] ${result}
+Check Expected Available Deployment Replicas By Pod Label
+ [Arguments] ${namespace} ${key} ${value} ${expected}
+ [Documentation] Succeeds if the named deployment has the expected number of available replicas
+ ${name} Get K8s Deployment by Pod Label ${namespace} ${key} ${value}
+ Check Expected Available Deployment Replicas ${namespace} ${name} ${expected}
+
Check Expected Available Deployment Replicas
[Arguments] ${namespace} ${name} ${expected}
[Documentation] Succeeds if the named deployment has the expected number of available replicas
diff --git a/libraries/utils.robot b/libraries/utils.robot
index 36ccb6f..e54ea22 100755
--- a/libraries/utils.robot
+++ b/libraries/utils.robot
@@ -71,10 +71,11 @@
${pass} Evaluate ${olts}[${I}].get("pass")
${serial_number} Evaluate ${olts}[${I}].get("serial")
${olt_ssh_ip} Evaluate ${olts}[${I}].get("sship")
+ ${type} Evaluate ${olts}[${I}].get("type")
${onu_count}= Get ONU Count For OLT ${hosts.src} ${serial_number}
${onu_list}= Get ONU List For OLT ${hosts.src} ${serial_number}
${olt} Create Dictionary ip ${ip} user ${user} pass
- ... ${pass} sn ${serial_number} onucount ${onu_count}
+ ... ${pass} sn ${serial_number} onucount ${onu_count} type ${type}
... sship ${olt_ssh_ip} onus ${onu_list}
Append To List ${list_olts} ${olt}
END
@@ -89,7 +90,7 @@
Set Suite Variable ${list_olts}
${olt_count}= Get Length ${list_olts}
Set Suite Variable ${olt_count}
- @{container_list}= Create List adapter-open-olt adapter-open-onu voltha-api-server
+ @{container_list}= Create List ${OLT_ADAPTER_APP_LABEL} adapter-open-onu voltha-api-server
... voltha-ro-core voltha-rw-core-11 voltha-rw-core-12 voltha-ofagent
Set Suite Variable ${container_list}
${datetime}= Get Current Date
@@ -555,7 +556,9 @@
${olt_ids} Create List
FOR ${I} IN RANGE 0 ${num_olts}
#create/preprovision device
- ${olt_device_id}= Create Device ${list_olts}[${I}][ip] ${OLT_PORT}
+ ${olt_device_id}= Run Keyword If "${list_olts}[${I}][type]" == "${None}"
+ ... Create Device ${list_olts}[${I}][ip] ${OLT_PORT}
+ ... ELSE Create Device ${list_olts}[${I}][ip] ${OLT_PORT} ${list_olts}[${I}][type]
${olt_serial_number}= Set Variable ${list_olts}[${I}][sn]
#Set Suite Variable ${olt_device_id}
#validate olt states
diff --git a/tests/dt-workflow/Voltha_DT_FailureScenarios.robot b/tests/dt-workflow/Voltha_DT_FailureScenarios.robot
index 19462dd..877fe87 100644
--- a/tests/dt-workflow/Voltha_DT_FailureScenarios.robot
+++ b/tests/dt-workflow/Voltha_DT_FailureScenarios.robot
@@ -190,7 +190,7 @@
${podStatusOutput}= Run kubectl get pods -n ${NAMESPACE}
Log ${podStatusOutput}
${countBforRestart}= Run kubectl get pods -n ${NAMESPACE} | grep Running | wc -l
- ${podName} Set Variable adapter-open-olt
+ ${podName} Set Variable ${OLT_ADAPTER_APP_LABEL}
Wait Until Keyword Succeeds ${timeout} 15s Delete K8s Pods By Label ${NAMESPACE} app ${podName}
Sleep 5s
Wait Until Keyword Succeeds ${timeout} 2s Validate Pods Status By Label ${NAMESPACE}
@@ -235,12 +235,13 @@
... ${onu_device_id} onu=True onu_reason=omci-flows-pushed
END
# Scale down the open OLT adapter deployment to 0 PODs and once confirmed, scale it back to 1
- Scale K8s Deployment voltha open-olt-voltha-adapter-openolt 0
- Wait Until Keyword Succeeds ${timeout} 2s Pod Does Not Exist voltha open-olt-voltha-adapter-openolt
+ Scale K8s Deployment by Pod Label ${NAMESPACE} app ${OLT_ADAPTER_APP_LABEL} 0
+ Wait Until Keyword Succeeds ${timeout} 2s Pods Do Not Exist By Label ${NAMESPACE} app
+ ... ${OLT_ADAPTER_APP_LABEL}
# Scale up the open OLT adapter deployment and make sure both it and the ofagent deployment are back
- Scale K8s Deployment voltha open-olt-voltha-adapter-openolt 1
+ Scale K8s Deployment by Pod Label ${NAMESPACE} app ${OLT_ADAPTER_APP_LABEL} 1
Wait Until Keyword Succeeds ${timeout} 2s
- ... Check Expected Available Deployment Replicas voltha open-olt-voltha-adapter-openolt 1
+ ... Check Expected Available Deployment Replicas By Pod Label ${NAMESPACE} app ${OLT_ADAPTER_APP_LABEL} 1
# Ensure the device is available in ONOS, this represents system connectivity being restored
FOR ${I} IN RANGE 0 ${olt_count}
diff --git a/tests/functional/K8S_SystemTest.robot b/tests/functional/K8S_SystemTest.robot
index 13c55bc..13023ef 100644
--- a/tests/functional/K8S_SystemTest.robot
+++ b/tests/functional/K8S_SystemTest.robot
@@ -36,7 +36,7 @@
${common_pod_label_key} app
${rwcore_pod_label_value} rw-core
${ofagent_pod_label_value} ofagent
-${adapter_openolt_pod_label_value} adapter-open-olt
+${adapter_openolt_pod_label_value} ${OLT_ADAPTER_APP_LABEL}
${teardown_device} false
${has_dataplane} false
diff --git a/tests/functional/Voltha_ErrorScenarios.robot b/tests/functional/Voltha_ErrorScenarios.robot
index 458a89d..c5840f5 100644
--- a/tests/functional/Voltha_ErrorScenarios.robot
+++ b/tests/functional/Voltha_ErrorScenarios.robot
@@ -77,7 +77,9 @@
#${olt_device_id}= Get OLTDeviceID From OLT List ${olt_serial_number}
Run Keyword If ${has_dataplane} Wait Until Keyword Succeeds 120s 10s
... Check Remote System Reachability True ${olt_ssh_ip}
- ${olt_device_id}= Create Device ${olt_ip} ${OLT_PORT}
+ ${olt_device_id}= Run Keyword If "${list_olts}[${I}][type]" == "${None}"
+ ... Create Device ${olt_ip} ${OLT_PORT}
+ ... ELSE Create Device ${olt_ip} ${OLT_PORT} ${list_olts}[${I}][type]
Set Suite Variable ${olt_device_id}
Wait Until Keyword Succeeds ${timeout} 5s Validate OLT Device PREPROVISIONED UNKNOWN UNKNOWN
... ${olt_device_id}
@@ -195,7 +197,9 @@
${olt_serial_number}= Get From Dictionary ${list_olts}[${I}] sn
#${olt_device_id}= Get OLTDeviceID From OLT List ${olt_serial_number}
#create/preprovision device
- ${olt_device_id}= Create Device ${olt_ip} ${OLT_PORT}
+ ${olt_device_id}= Run Keyword If "${list_olts}[${I}][type]" == "${None}"
+ ... Create Device ${olt_ip} ${OLT_PORT}
+ ... ELSE Create Device ${olt_ip} ${OLT_PORT} ${list_olts}[${I}][type]
Set Suite Variable ${olt_device_id}
#validate olt states
Wait Until Keyword Succeeds ${timeout} 5s Validate OLT Device PREPROVISIONED UNKNOWN
@@ -240,7 +244,9 @@
${olt_serial_number}= Get From Dictionary ${list_olts}[${I}] sn
#${olt_device_id}= Get OLTDeviceID From OLT List ${olt_serial_number}
#create/preprovision OLT device
- ${olt_device_id}= Create Device ${olt_ip} ${OLT_PORT}
+ ${olt_device_id}= Run Keyword If "${list_olts}[${I}][type]" == "${None}"
+ ... Create Device ${olt_ip} ${OLT_PORT}
+ ... ELSE Create Device ${olt_ip} ${OLT_PORT} ${list_olts}[${I}][type]
Set Suite Variable ${olt_device_id}
#validate olt states
Wait Until Keyword Succeeds ${timeout} 5s Validate OLT Device PREPROVISIONED UNKNOWN
@@ -288,7 +294,9 @@
Should Be Empty ${logical_id}
Run Keyword If ${has_dataplane} Sleep 180s
... ELSE Sleep 10s
- ${olt_device_id}= Create Device ${olt_ip} ${OLT_PORT}
+ ${olt_device_id}= Run Keyword If "${list_olts}[${I}][type]" == "${None}"
+ ... Create Device ${olt_ip} ${OLT_PORT}
+ ... ELSE Create Device ${olt_ip} ${OLT_PORT} ${list_olts}[${I}][type]
Set Suite Variable ${olt_device_id}
Wait Until Keyword Succeeds ${timeout} 5s Validate OLT Device PREPROVISIONED UNKNOWN
... UNKNOWN ${olt_device_id}
diff --git a/tests/functional/Voltha_FailureScenarios.robot b/tests/functional/Voltha_FailureScenarios.robot
index cbebeff..9889db8 100644
--- a/tests/functional/Voltha_FailureScenarios.robot
+++ b/tests/functional/Voltha_FailureScenarios.robot
@@ -203,7 +203,7 @@
${podStatusOutput}= Run kubectl get pods -n ${NAMESPACE}
Log ${podStatusOutput}
${countBforRestart}= Run kubectl get pods -n ${NAMESPACE} | grep Running | wc -l
- ${podName} Set Variable adapter-open-olt
+ ${podName} Set Variable ${OLT_ADAPTER_APP_LABEL}
Wait Until Keyword Succeeds ${timeout} 15s Delete K8s Pods By Label ${NAMESPACE} app ${podName}
Sleep 5s
Wait Until Keyword Succeeds ${timeout} 2s Validate Pods Status By Label ${NAMESPACE}
@@ -302,12 +302,13 @@
... ${ONOS_SSH_PORT} ${onu_port}
END
# Scale down the open OLT adapter deployment to 0 PODs and once confirmed, scale it back to 1
- Scale K8s Deployment voltha open-olt-voltha-adapter-openolt 0
- Wait Until Keyword Succeeds ${timeout} 2s Pod Does Not Exist voltha open-olt-voltha-adapter-openolt
+ Scale K8s Deployment by Pod Label ${NAMESPACE} app ${OLT_ADAPTER_APP_LABEL} 0
+ Wait Until Keyword Succeeds ${timeout} 2s Pods Do Not Exist By Label ${NAMESPACE} app
+ ... ${OLT_ADAPTER_APP_LABEL}
# Scale up the open OLT adapter deployment and make sure both it and the ofagent deployment are back
- Scale K8s Deployment voltha open-olt-voltha-adapter-openolt 1
+ Scale K8s Deployment by Pod Label ${NAMESPACE} app ${OLT_ADAPTER_APP_LABEL} 1
Wait Until Keyword Succeeds ${timeout} 2s
- ... Check Expected Available Deployment Replicas voltha open-olt-voltha-adapter-openolt 1
+ ... Check Expected Available Deployment Replicas By Pod Label ${NAMESPACE} app ${OLT_ADAPTER_APP_LABEL} 1
# Ensure the device is available in ONOS, this represents system connectivity being restored
FOR ${I} IN RANGE 0 ${olt_count}
diff --git a/tests/functional/Voltha_PODTests.robot b/tests/functional/Voltha_PODTests.robot
index 1fb30f8..36ad29d 100644
--- a/tests/functional/Voltha_PODTests.robot
+++ b/tests/functional/Voltha_PODTests.robot
@@ -384,7 +384,10 @@
... Verify Device Flows Removed ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${of_id}
# Recreate the OLT
Run Keyword If ${has_dataplane} Sleep 180s
- ${olt_device_id}= Create Device ${olt_ip} ${OLT_PORT}
+ # This dneeds to be done in for loop, test is not ready
+ ${olt_device_id}= Run Keyword If "${list_olts}[${I}][type]" == "${None}"
+ ... Create Device ${list_olts}[${I}][ip] ${OLT_PORT}
+ ... ELSE Create Device ${list_olts}[${I}][ip] ${OLT_PORT} ${list_olts}[${I}][type]
Set Suite Variable ${olt_device_id}
Wait Until Keyword Succeeds ${timeout} 5s Validate OLT Device PREPROVISIONED
... UNKNOWN UNKNOWN ${olt_device_id}
diff --git a/tests/functional/Voltha_StartContainerPODTests.robot b/tests/functional/Voltha_StartContainerPODTests.robot
index e4b429c..fd6e0c4 100755
--- a/tests/functional/Voltha_StartContainerPODTests.robot
+++ b/tests/functional/Voltha_StartContainerPODTests.robot
@@ -104,7 +104,7 @@
${list_sim_names} Create List sim-voltha-adapter-simulated-olt sim-voltha-adapter-simulated-onu
${sim} CreateDictionary helmchart=sim namespace=voltha
... apps=${list_sim_apps} names=${list_sim_names}
- ${list_openolt_apps} Create List adapter-open-olt
+ ${list_openolt_apps} Create List ${OLT_ADAPTER_APP_LABEL}
${list_openolt_names} Create List open-olt-voltha-adapter-openolt
${open-olt} CreateDictionary helmchart=open-olt namespace=voltha
... apps=${list_openolt_apps} names=${list_openolt_names}
diff --git a/tests/functional/Voltha_multipleOLTTests.robot b/tests/functional/Voltha_multipleOLTTests.robot
index 831afc1..ed59324 100755
--- a/tests/functional/Voltha_multipleOLTTests.robot
+++ b/tests/functional/Voltha_multipleOLTTests.robot
@@ -112,7 +112,7 @@
Set Suite Variable ${k8s_node_ip}
Set Suite Variable ${k8s_node_user}
Set Suite Variable ${k8s_node_pass}
- @{container_list}= Create List adapter-open-olt adapter-open-onu voltha-api-server
+ @{container_list}= Create List ${OLT_ADAPTER_APP_LABEL} adapter-open-onu voltha-api-server
... voltha-ro-core voltha-rw-core-11 voltha-rw-core-12 voltha-ofagent
Set Suite Variable ${container_list}
${datetime}= Get Current Date
@@ -131,7 +131,9 @@
Should Not Be Equal As Integers ${num_bbsims} 0
Run Keyword Unless ${has_dataplane} Set Suite Variable ${num_olts} ${num_bbsims}
FOR ${I} IN RANGE 0 ${num_olts}
- ${olt_device_id}= Create Device ${list_olts}[${I}][ip] ${OLT_PORT}
+ ${olt_device_id}= Run Keyword If "${list_olts}[${I}][type]" == "${None}"
+ ... Create Device ${list_olts}[${I}][ip] ${OLT_PORT}
+ ... ELSE Create Device ${list_olts}[${I}][ip] ${OLT_PORT} ${list_olts}[${I}][type]
Set Suite Variable ${olt_device_id}
#validate olt states
Wait Until Keyword Succeeds ${timeout} 5s Validate OLT Device PREPROVISIONED UNKNOWN UNKNOWN
diff --git a/tests/openonu-go-adapter/Voltha_ONUReconcileTests.robot b/tests/openonu-go-adapter/Voltha_ONUReconcileTests.robot
index 6510280..56a97d3 100755
--- a/tests/openonu-go-adapter/Voltha_ONUReconcileTests.robot
+++ b/tests/openonu-go-adapter/Voltha_ONUReconcileTests.robot
@@ -218,7 +218,9 @@
${olt_ids} Create List
FOR ${I} IN RANGE 0 ${num_olts}
#create/preprovision device
- ${olt_device_id}= Create Device ${list_olts}[${I}][ip] ${OLT_PORT}
+ ${olt_device_id}= Run Keyword If "${list_olts}[${I}][type]" == "${None}"
+ ... Create Device ${list_olts}[${I}][ip] ${OLT_PORT}
+ ... ELSE Create Device ${list_olts}[${I}][ip] ${OLT_PORT} ${list_olts}[${I}][type]
${olt_serial_number}= Set Variable ${list_olts}[${I}][sn]
#validate olt states
Wait Until Keyword Succeeds ${timeout} 5s
diff --git a/tests/openonu-go-adapter/Voltha_ONUStateTests.robot b/tests/openonu-go-adapter/Voltha_ONUStateTests.robot
index 3228783..f4838e2 100755
--- a/tests/openonu-go-adapter/Voltha_ONUStateTests.robot
+++ b/tests/openonu-go-adapter/Voltha_ONUStateTests.robot
@@ -235,7 +235,9 @@
${olt_ids} Create List
FOR ${I} IN RANGE 0 ${num_olts}
#create/preprovision device
- ${olt_device_id}= Create Device ${list_olts}[${I}][ip] ${OLT_PORT}
+ ${olt_device_id}= Run Keyword If "${list_olts}[${I}][type]" == "${None}"
+ ... Create Device ${list_olts}[${I}][ip] ${OLT_PORT}
+ ... ELSE Create Device ${list_olts}[${I}][ip] ${OLT_PORT} ${list_olts}[${I}][type]
${olt_serial_number}= Set Variable ${list_olts}[${I}][sn]
#validate olt states
Wait Until Keyword Succeeds ${timeout} 5s
diff --git a/variables/variables.robot b/variables/variables.robot
index 331e6fd..6e82260 100644
--- a/variables/variables.robot
+++ b/variables/variables.robot
@@ -21,3 +21,4 @@
@{PODLIST1} voltha-kafka voltha-ofagent
@{PODLIST2} bbsim etcd-operator-etcd-operator-etcd-operator radius voltha-api-server
... voltha-cli-server voltha-ro-core voltha-rw-core-11
+${OLT_ADAPTER_APP_LABEL} adapter-open-olt