... for comparison ${ODL_STREAM} to the given ${lower_bound},
... in order to replace ad-hoc conditional execution in suites.
Library Collections
+Library String
*** Variables ***
&{Stream_dict} hydrogen=${1} stable-helium=${2} stable-lithium=${3} beryllium=${4} boron=${5} carbon=${6} nitrogen=${7}
... return ${value_if_false} otherwise.
BuiltIn.Run_Keyword_And_Return Set_Variable_If_At_Most carbon ${value_if_true} ${value_if_false}
+CompareStream__Convert_Input
+ [Arguments] @{arguments}
+ [Documentation] Splits arguments into args and kwargs is used in Run_Keyword_If_At_Least_Else and Run_Keyword_If_At_Most_Else.
+ ... The problem is, when the string contains =, but it is not a named argument (name=value). There can be many values containing =, but
+ ... for sure it is present in xmls. If the string starts with "<" it will be treated as it is xml and splitting for
+ ... name and value will not be executed.
+ ... If named argument is passed into this kw, only string data are supported e.g. name=string. Complex variables such as lists or dictionaries
+ ... are not supported.
+ ${args} BuiltIn.Create_List
+ ${kwargs} BuiltIn.Create_Dictionary
+ : FOR ${arg} IN @{arguments}
+ \ ${removed} String.Remove_String ${arg} \n ${Space} \t
+ \ ... \r
+ \ ${splitted} BuiltIn.Run_Keyword_If "${removed[0]}" == "<" BuiltIn.Create List ${arg}
+ \ ... ELSE String.Split_String ${arg} separator== max_split=1
+ \ ${len} BuiltIn.Get_Length ${splitted}
+ \ Run Keyword If ${len}==1 Collections.Append_To_List ${args} @{splitted}[0]
+ \ ... ELSE Collections.Set_To_Dictionary ${kwargs} @{splitted}
+ BuiltIn.Return_From_Keyword ${args} ${kwargs}
+
Run_Keyword_If_At_Least
[Arguments] ${lower_bound} ${kw_name} @{varargs} &{kwargs}
[Documentation] Compare ${lower_bound} to ${ODL_STREAM} and in case ${ODL_STREAM} is at least ${lower_bound},
BuiltIn.Run_Keyword_If "${position}" == "-1" BuiltIn.Fail Missing else statement in defined expresion
${varargs_if} Collections.Get_Slice_From_List ${varargs} 0 ${position}
${varargs_else} Collections.Get_Slice_From_List ${varargs} ${position+1}
- ${resp} BuiltIn.Run_Keyword_If &{Stream_dict}[${ODL_STREAM}] >= &{Stream_dict}[${lower_bound}] @{varargs_if}
- ... ELSE @{varargs_else}
+ ${args_if} ${kwargs_if} CompareStream__Convert_Input @{varargs_if}
+ ${args_else} ${kwargs_else} CompareStream__Convert_Input @{varargs_else}
+ ${resp} BuiltIn.Run_Keyword_If &{Stream_dict}[${ODL_STREAM}] >= &{Stream_dict}[${lower_bound}] @{args_if} &{kwargs_if}
+ ... ELSE @{args_else} &{kwargs_else}
[Return] ${resp}
Run_Keyword_If_At_Most
BuiltIn.Run_Keyword_If "${position}" == "-1" BuiltIn.Fail Missing else statement in defined expresion
${varargs_if} Collections.Get_Slice_From_List ${varargs} 0 ${position}
${varargs_else} Collections.Get_Slice_From_List ${varargs} ${position+1}
- ${resp} BuiltIn.Run_Keyword_If &{Stream_dict}[${ODL_STREAM}] <= &{Stream_dict}[${upper_bound}] @{varargs_if}
- ... ELSE @{varargs_else}
+ ${args_if} ${kwargs_if} CompareStream__Convert_Input @{varargs_if}
+ ${args_else} ${kwargs_else} CompareStream__Convert_Input @{varargs_else}
+ ${resp} BuiltIn.Run_Keyword_If &{Stream_dict}[${ODL_STREAM}] >= &{Stream_dict}[${lower_bound}] @{args_if} &{kwargs_if}
+ ... ELSE @{args_else} &{kwargs_else}
[Return] ${resp}
Run_Keyword_If_More_Than
Library SSHLibrary
Library String
Library ./Sxp.py
+Resource CompareStream.robot
Resource KarafKeywords.robot
Resource Utils.robot
-Resource CompareStream.robot
+Resource TemplatedRequests.robot
Variables ../variables/Variables.py
*** Variables ***
[Arguments] ${node}=127.0.0.1 ${session}=session ${domain}=global ${scope}=all
[Documentation] Gets all binding via RPC from Master DB of node
${DATA} Get Bindings From Node Xml ${node} ${scope} ${domain}
- ${resp} Run Keyword If '${ODL_STREAM}' not in ['beryllium', 'stable-lithium'] Post Request ${session} ${REST_CONTEXT}:get-node-bindings data=${DATA}
- ... headers=${HEADERS_XML}
- ... ELSE Get Request ${session} /restconf/operational/network-topology:network-topology/topology/sxp/node/${node}/master-database/ headers=${HEADERS_XML}
- Should be Equal As Strings ${resp.status_code} 200
- [Return] ${resp.content}
+ ${resp1} CompareStream.Run_Keyword_If_At_Least_Boron TemplatedRequests.Post_To_Uri ${REST_CONTEXT}:get-node-bindings data=${DATA} accept=${ACCEPT_JSON} content_type=${HEADERS_XML}
+ ... session=${session}
+ ${resp2} CompareStream.Run_Keyword_If_Less_Than_Boron TemplatedRequests.Get_As_Json_From_Uri /restconf/operational/network-topology:network-topology/topology/sxp/node/${node}/master-database/ session=${session}
+ ${resp} CompareStream.Set_Variable_If_At_Least_Boron ${resp1} ${resp2}
+ [Return] ${resp}
Clean Bindings
[Arguments] ${node}=127.0.0.1 ${session}=session ${domain}=global
[Documentation] Delete all bindings via RPC from Master DB of node
${resp} Get Bindings ${node} ${session} ${domain} local
- @{bindings} Run Keyword If '${ODL_STREAM}' not in ['beryllium', 'stable-lithium'] Parse Bindings ${resp}
+ @{bindings} CompareStream.Run_Keyword_If_At_Least_Else boron Parse Bindings ${resp}
... ELSE Parse Prefix Groups ${resp} local
: FOR ${binding} IN @{bindings}
- \ Run Keyword If '${ODL_STREAM}' not in ['beryllium', 'stable-lithium'] Clean Binding ${binding['sgt']} ${binding['ip-prefix']} ${node}
- \ ... ${session} ${domain}
- \ ... ELSE Clean Binding ${binding} ${binding['binding']} ${node}
- \ ... ${session} ${domain}
+ \ CompareStream.Run_Keyword_If_At_Least_Boron Clean Binding Default ${binding} ${node} ${session} ${domain}
+ \ CompareStream.Run_Keyword_If_At_Most_Beryllium Clean Binding At Most Be ${binding} ${node} ${session} ${domain}
+
+Clean Binding Default
+ [Arguments] ${binding} ${node} ${session} ${domain}
+ [Documentation] Clean binding
+ Clean Binding ${binding['sgt']} ${binding['ip-prefix']} ${node} ${session}
+
+Clean Binding At Most Be
+ [Arguments] ${binding} ${node} ${session} ${domain}
+ [Documentation] Clean binding
+ Clean Binding ${binding} ${binding['binding']} ${node} ${session}
Clean Binding
[Arguments] ${sgt} ${prefixes} ${node} ${session} ${domain}=global
[Documentation] Used for nester FOR loop
: FOR ${prefix} IN @{prefixes}
- \ Run Keyword If '${ODL_STREAM}' not in ['beryllium', 'stable-lithium'] Delete Binding ${sgt} ${prefix} ${node}
- \ ... ${domain} ${session}
- \ ... ELSE Delete Binding ${sgt['sgt']} ${prefix['ip-prefix']} ${node}
- \ ... ${domain} ${session}
+ \ CompareStream.Run_Keyword_If_At_Least_Boron Delete Binding Default ${sgt} ${prefix} ${node} ${domain}
+ \ ... ${session}
+ \ CompareStream.Run_Keyword_If_At_Most_Beryllium Delete Binding Be ${sgt} ${prefix} ${node} ${domain}
+ \ ... ${session}
Update Binding
[Arguments] ${sgtOld} ${prefixOld} ${sgtNew} ${prefixNew} ${node}=127.0.0.1 ${session}=session
... ${domain}
Post To Controller ${session} update-entry ${DATA}
+Delete Binding Default
+ [Arguments] ${sgt} ${prefix} ${node} ${domain} ${session}
+ [Documentation] Delete binding via RPC
+ Delete Binding ${sgt} ${prefix} ${node} ${domain} ${session}
+
+Delete Binding Be
+ [Arguments] ${sgt} ${prefix} ${node} ${domain} ${session}
+ [Documentation] Delete binding via RPC
+ Delete Binding ${sgt['sgt']} ${prefix['ip-prefix']} ${node} ${domain} ${session}
+
Delete Binding
[Arguments] ${sgt} ${prefix} ${node}=127.0.0.1 ${domain}=global ${session}=session
[Documentation] Delete binding via RPC from Master DB of node
Should Contain Binding
[Arguments] ${resp} ${sgt} ${prefix} ${db_source}=any
[Documentation] Tests if data contains specified binding
- ${out} Run Keyword If '${ODL_STREAM}' not in ['beryllium', 'stable-lithium'] Find Binding ${resp} ${sgt} ${prefix}
+ ${out} CompareStream.Run_Keyword_If_At_Least_Else boron Find Binding ${resp} ${sgt} ${prefix}
... ELSE Find Binding Legacy ${resp} ${sgt} ${prefix} ${db_source}
... add
Should Be True ${out} Doesn't have ${sgt} ${prefix}
Should Not Contain Binding
[Arguments] ${resp} ${sgt} ${prefix} ${db_source}=any
[Documentation] Tests if data doesn't contains specified binding
- ${out} Run Keyword If '${ODL_STREAM}' not in ['beryllium', 'stable-lithium'] Find Binding ${resp} ${sgt} ${prefix}
+ ${out} CompareStream.Run_Keyword_If_At_Least_Else boron Find Binding ${resp} ${sgt} ${prefix}
... ELSE Find Binding Legacy ${resp} ${sgt} ${prefix} ${db_source}
... add
Should Not Be True ${out} Should't have ${sgt} ${prefix}
Setup SXP Session
: FOR ${num} IN RANGE 1 ${node_range}
\ ${ip} Get Ip From Number ${num}
- \ Run Keyword If '${ODL_STREAM}' not in ['beryllium', 'stable-lithium'] Add Node ${ip}
- \ Run Keyword If '${ODL_STREAM}' not in ['beryllium', 'stable-lithium'] Wait Until Keyword Succeeds 20 1 Check Node Started
- \ ... ${ip}
+ \ CompareStream.Run_Keyword_If_At_Least_Boron Add Node ${ip}
+ \ CompareStream.Run_Keyword_If_At_Least_Boron Wait Until Keyword Succeeds 20 1 Check Node Started ${ip}
Check Node Started
[Arguments] ${node} ${port}=64999 ${system}=${ODL_SYSTEM_IP} ${session}=session ${ip}=${node}
[Documentation] Destroy created sessions
: FOR ${num} IN RANGE 1 ${node_range}
\ ${ip} Get Ip From Number ${num}
- \ Run Keyword If '${ODL_STREAM}' not in ['beryllium', 'stable-lithium'] Delete Node ${ip}
+ \ CompareStream.Run_Keyword_If_At_Least_Boron Delete Node ${ip}
Clean SXP Session