cleaning up system variables
[integration/test.git] / csit / suites / bgpcep / throughpcep / cases.robot
1 *** Settings ***
2 Documentation     PCEP performance suite, uses restconf with configurable authentication.
3 ...
4 ...               Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
5 ...
6 ...               This program and the accompanying materials are made available under the
7 ...               terms of the Eclipse Public License v1.0 which accompanies this distribution,
8 ...               and is available at http://www.eclipse.org/legal/epl-v10.html
9 ...
10 ...
11 ...               General Overview:
12 ...
13 ...               This is a suite which has both scale and performance aspects.
14 ...               Given scale target, suite reports failures if functional error
15 ...               is detected, or if various time limits expire.
16 ...               For passing test cases, their duration is the performance metric.
17 ...
18 ...               ODL acts as a translation layer between PCEP capable devices
19 ...               and users employing RESTCONF.
20 ...               Performance measurement focuses on two different workflows.
21 ...
22 ...               The first workflow is initial synchronization, when ODL learns
23 ...               the state of PCEP topology as devices connect to it,
24 ...               while restconf user reads the state repeatedly.
25 ...               The second workflow is mass update, when restconf users issue RPCs
26 ...               to updale Layer Switched Paths on Path Computation Clients.
27 ...
28 ...               This suite uses pcc-mock (downloaded from Nexus) to simulate PCCs.
29 ...               It needs segment of bindable IP addresses,
30 ...               one for each simulated PCC; so running pcc-mock from remote machine
31 ...               is only viable when just single PCC is simulated.
32 ...               Testing with multiple PCCs works best when pcc-mock
33 ...               runs on the same VM as ODL, so 127.0.0.0/8 subnet can be used.
34 ...
35 ...               Library AuthStandalone is used directly for restconf reads
36 ...               in the first workflow. That library transparently handles several
37 ...               http authentication methods, based on credentials and pybot arguments.
38 ...
39 ...               In the second workflow, updater.py utility is used for issuing
40 ...               rapid restconf requests. It can use multiple worker threads,
41 ...               as http requests are blocking.
42 ...               Due to CPython interpreter itself being single threaded,
43 ...               amounts of threads above 8-16 are actually slightly slower
44 ...               (which may roughly correspond to network traffic
45 ...               being more limiting factor than CPU).
46 ...               This suite starts updater utility bound to single CPU,
47 ...               as this setup was the most performant in other tests.
48 ...
49 ...               In case of failed test case, other tests are skipped (unless
50 ...               this is overriden by [Setup]) to finish test run sooner.
51 ...
52 ...               Variables and test case names refer to Controller and Mininet,
53 ...               those are assumed to be separate remote VMs, one to host ODL,
54 ...               other to host tools.
55 ...               In case updater and pcc-mock are desired to run
56 ...               from separate machines, their parameters use Mininet
57 ...               values as default.
58 ...               If both updater VM and pcc-mock VM parameters are specified,
59 ...               Mininet parameters may be skipped.
60 ...
61 ...               Some launch scripts put restrictions on how pybot options
62 ...               can be specified, so there are utility variables to help with
63 ...               copying Controller related value to apply fo updater of pccmock.
64 ...               Having a tool co-located with ODL reduces network latency,
65 ...               but puts more pressure on CPU and memory on Controller VM.
66 ...
67 ...               In some environments, issues with TIME-WAIT prevent high restconf rates,
68 ...               so TCP reuse is temporarily allowed during the suite run, if possible
69 ...               (and if not disabled by UPDATERVM_ENABLE_TCP_RW_REUSE option value).
70 ...               See http://vincent.bernat.im/en/blog/2014-tcp-time-wait-state-linux.html
71 ...               This suite ignores possible failures when changing reuse.
72 ...
73 ...               Similarly, in some environments, handling of requests.Session object matters
74 ...               try changing RESTCONF_REUSE value to see if it helps.
75 ...
76 ...               Variables to override (only if needed) in pybot command:
77 ...               (Look into Variables table to see the default values.)
78 ...
79 ...               CONTROLLER: Numeric IP address of VM where ODL runs.
80 ...               CONTROLLER_USER: Username for ssh login to ODL VM.
81 ...               CONTROLLER_PASSWORD: Ssh password, empty means public keys are used instead.
82 ...               CONTROLLER_PROMPT: Substring to identify Linux prompt on ODL VM.
83 ...               CONTROLLER_WORKSPACE: Path to where files can be written on ODL VM.
84 ...               FIRST_PCC_IP: Set in case bind address is different from public pcc-mock VM address.
85 ...               LOG_NAME: Filename (without path) to save pcc-mock output into.
86 ...               LOG_PATH: Override if not the same as pccmock VM workspace.
87 ...               LSPS: Number of LSPs per PCC to simulate and test.
88 ...               TOOLS_SYSTEM_IP: Numeric IP address of VM to run pcc-mock and updater from by default.
89 ...               TOOLS_SYSTEM_PASSWORD: Linux password to go with the username (empty means keys).
90 ...               TOOLS_SYSTEM_PROMPT: Substring to identify Linux prompt on Mininet VM.
91 ...               TOOLS_SYSTEM_USER: Linux username to SSH to on Mininet VM.
92 ...               MININET_WORKSPACE: Path to where files may be created on Mininet VM.
93 ...               MOCK_FILE: Filename to use for mock-pcc executable instead of the timestamped one.
94 ...               PCCDOWNLOAD_HOSTHEADER: Download server may check checks this header before showing content.
95 ...               PCCDOWNLOAD_URLBASE: URL to pcep-pcc-mock folder in Nexus (use numberic IP if DNS has problems).
96 ...               PCCMOCK_COLOCATED: If True, set PCCMOCKVM* to mirror CONTROLLER*
97 ...               PCCMOCKVM_IP: Override MININET for pcc-mock usage.
98 ...               PCCMOCKVM_*: Override corresponding MININET_* for pcc-mock usage.
99 ...               PCCS: Number of PCCs to simulate and test.
100 ...               PCEP_READY_VERIFY_TIMEOUT: Grace period for pcep-topology to appear. Lower if ODL is ready.
101 ...               RESTCONF_*: USER, PASSWORD and SCOPE to authenticate with, REUSE session.
102 ...               (Note: If SCOPE is not empty, token-based authentication is used.)
103 ...               UPDATER_COLOCATED: If True, overrides UPDATERVM_* parameters to point at Controller
104 ...               (The purpose is to provide an option without ability to unpack CONTROLLER value.)
105 ...               UPDATER_ODLADDRESS: Override if public CONTROLLER address is not best fit.
106 ...               UPDATER_REFRESH: Main updater thread may sleep this long. Balance precision with overhead.
107 ...               UPDATER_TIMEOUT: If updater stops itself if running more than this time.
108 ...               (Set this limit according to your performance target.)
109 ...               UPDATERVM_ENABLE_TCP_RW_REUSE: Set to false if changing Linux configuration is not desired.
110 ...               UPDATERVM_IP: Override MININET for updater.py usage.
111 ...               UPDATERVM_*: Override corresponding MININET_* for updater.py usage.
112 Suite Setup       FailFast.Do_Not_Fail_Fast_From_Now_On
113 Suite Teardown    Disconnect
114 Test Setup        FailFast.Fail_This_Fast_On_Previous_Error
115 Test Teardown     FailFast.Start_Failing_Fast_If_This_Failed
116 Variables         ${CURDIR}/../../../variables/Variables.py
117 Library           SSHLibrary    timeout=10s
118 Library           RequestsLibrary
119 Library           ${CURDIR}/../../../libraries/AuthStandalone.py
120 Resource          ${CURDIR}/../../../libraries/FailFast.robot
121 Resource          ${CURDIR}/../../../libraries/NexusKeywords.robot    # for Deploy_Artifact
122 Resource          ${CURDIR}/../../../libraries/SSHKeywords.robot    # for Require_* and Assure_*
123 Resource          ${CURDIR}/../../../libraries/Utils.robot    # for Flexible_SSH_Login
124
125 *** Variables ***
126 # This table acts as an exhaustive list of variables users can modify on pybot invocation.
127 # It also contains commented-out lines for variables defined elswhere.
128 # Keep this list in alphabetical order.
129 ${CONTROLLER_WORKSPACE}    /tmp
130 ${FIRST_PCC_IP}    ${PCCMOCKVM_IP}
131 # ${LOG_FILE} is reserved for location of pybot-created log.html
132 ${LOG_NAME}       throughpcep.log
133 ${LOG_PATH}       ${PCCMOCKVM_WORKSPACE}
134 ${LSPS}           65535
135 ${MININET}        127.0.0.1
136 ${MININET_USER}    mininet
137 ${MININET_WORKSPACE}    /tmp
138 ${PCCDOWNLOAD_HOSTHEADER}    nexus.opendaylight.org
139 ${PCCDOWNLOAD_URLBASE}    http://${PCCDOWNLOAD_HOSTHEADER}/content/repositories/opendaylight.snapshot/org/opendaylight/bgpcep/pcep-pcc-mock/
140 ${PCCMOCK_COLOCATED}    False
141 ${PCCMOCKVM_IP}    ${TOOLS_SYSTEM_IP}
142 ${PCCMOCKVM_PASSWORD}    ${TOOLS_SYSTEM_PASSWORD}
143 ${PCCMOCKVM_PROMPT}    ${TOOLS_SYSTEM_PROMPT}
144 ${PCCMOCKVM_USER}    ${TOOLS_SYSTEM_USER}
145 ${PCCMOCKVM_WORKSPACE}    ${MININET_WORKSPACE}
146 ${PCCS}           1
147 ${PCEP_READY_VERIFY_TIMEOUT}    300s
148 # Yes, the default timeout is 5 minutes, as this suite might be started eagerly just after ODL starts booting up.
149 ${RESTCONF_PASSWORD}    ${PWD}    # from Variables.py
150 ${RESTCONF_REUSE}    True
151 ${RESTCONF_SCOPE}    ${EMPTY}
152 ${RESTCONF_USER}    ${USER}    # from Variables.py
153 ${UPDATER_COLOCATED}    False
154 ${UPDATER_ODLADDRESS}    ${OLD_SYSTEM_IP}
155 ${UPDATER_REFRESH}    0.1
156 ${UPDATER_TIMEOUT}    300
157 ${UPDATERVM_ENABLE_TCP_RW_REUSE}    True
158 ${UPDATERVM_IP}    ${TOOLS_SYSTEM_IP}
159 ${UPDATERVM_PASSWORD}    ${TOOLS_SYSTEM_PASSWORD}
160 ${UPDATERVM_PROMPT}    ${TOOLS_SYSTEM_PROMPT}
161 ${UPDATERVM_USER}    ${MININET_USER}
162 ${UPDATERVM_WORKSPACE}    ${MININET_WORKSPACE}
163
164 *** TestCases ***
165 Download_Pcc_Mock
166     [Documentation]    SSH login to pcc-mock VM, download latest pcc-mock executable from Nexus.
167     BuiltIn.Run_Keyword_If    ${PCCMOCK_COLOCATED}    Pccmock_From_Controller
168     NexusKeywords.Initialize_Artifact_Deployment_And_Usage    tools_system_connect=False
169     SSHLibrary.Open_Connection    ${PCCMOCKVM_IP}    alias=pccmock
170     SSHLibrary.Set_Client_Configuration    timeout=10s
171     SSHLibrary.Set_Client_Configuration    prompt=${PCCMOCKVM_PROMPT}
172     Utils.Flexible_SSH_Login    ${PCCMOCKVM_USER}    ${PCCMOCKVM_PASSWORD}    delay=4s
173     ${file_name} =    NexusKeywords.Deploy_Test_Tool    bgpcep    pcep-pcc-mock
174     BuiltIn.Set_Suite_Variable    ${mock_location}    ${file_name}
175
176 Put_Updater
177     [Documentation]    Open SSH session to updater VM, copy the utility there, including dependencies, also prepare direct http session.
178     BuiltIn.Run_Keyword_If    ${UPDATER_COLOCATED}    Updater_From_Controller
179     SSHLibrary.Open_Connection    ${UPDATERVM_IP}    alias=updater
180     SSHLibrary.Set_Client_Configuration    timeout=20s
181     SSHLibrary.Set_Client_Configuration    prompt=${UPDATERVM_PROMPT}
182     Utils.Flexible_SSH_Login    ${UPDATERVM_USER}    ${UPDATERVM_PASSWORD}    delay=4s
183     SSHKeywords.Require_Python
184     SSHLibrary.Put_File    ${CURDIR}/../../../../tools/pcep_updater/updater.py    ${UPDATERVM_WORKSPACE}/
185     SSHLibrary.Put_File    ${CURDIR}/../../../libraries/AuthStandalone.py    ${UPDATERVM_WORKSPACE}/
186     SSHKeywords.Assure_Library_Counter    target_dir=${UPDATERVM_WORKSPACE}
187     SSHKeywords.Assure_Library_Ipaddr    target_dir=${UPDATERVM_WORKSPACE}
188     # Done preparation of Updater VM, now use AuthStandalone to create session from robot VM too.
189     BuiltIn.Log_Many    ${RESTCONF_USER}    ${RESTCONF_PASSWORD}    ${RESTCONF_SCOPE}    ${ODL_SYSTEM_IP}
190     ${session} =    AuthStandalone.Init_Session    ${ODL_SYSTEM_IP}    ${RESTCONF_USER}    ${RESTCONF_PASSWORD}    ${RESTCONF_SCOPE}
191     BuiltIn.Set_Suite_Variable    ${rest_session}    ${session}
192     # TODO: Define http timeouts.
193
194 Save_And_Enable_Tcp_Rw_Reuse
195     [Documentation]    If requested, temporarily enable TCP port reuse on Updater VM to allow for high rate of TCP connections. Do not start failing fast.
196     BuiltIn.Pass_Execution_If    not ${UPDATERVM_ENABLE_TCP_RW_REUSE}    Manipulation of tcp_rw_reuse is not requested.
197     ${old_value} =    SSHLibrary.Execute_Command    cat /proc/sys/net/ipv4/tcp_tw_reuse
198     # The next line may be skipped if the previous line failed.
199     BuiltIn.Set_Suite_Variable    ${tcp_rw_reuse}    ${old_value}
200     ${out}    ${rc} =    SSHLibrary.Execute_Command    sudo bash -c "echo 1 > /proc/sys/net/ipv4/tcp_tw_reuse"    return_rc=True
201     BuiltIn.Should_Be_Equal    ${rc}    ${0}
202     # Lack of sudo access should not prevent the rest of suite from trying without TCP reuse.
203     [Teardown]    Do_Not_Start_Failing_If_This_Failed
204
205 Topology_Precondition
206     [Documentation]    Verify that within timeout, PCEP topology is present, with no PCC connected.
207     [Tags]    critical
208     Set_Hop    0
209     Builtin.Wait_Until_Keyword_Succeeds    ${PCEP_READY_VERIFY_TIMEOUT}    1s    Pcep_Off
210     # Yes, timeout is 5 minutes, as this suite might be started eagerly just after ODL starts booting up.
211
212 Start_Pcc_Mock
213     [Documentation]    Launch pcc-mock on background so simulated PCCs start connecting to controller.
214     SSHLibrary.Switch_Connection    pccmock
215     ${command} =    NexusKeywords.Compose_Full_Java_Command    -jar ${mock_location} --local-address ${FIRST_PCC_IP} --remote-address ${ODL_SYSTEM_IP} --pcc ${PCCS} --lsp ${LSPS} &> ${LOG_PATH}/${LOG_NAME}
216     BuiltIn.Log    ${command}
217     SSHLibrary.Write    ${command}
218     # The pccmock SSH session is left alive, but no data will be exchanged for a while.
219     # We need this connection to stay alive to send ctrl+c later.
220     # SSHLibrary.Start_Command would not do that for us.
221
222 Topology_Intercondition
223     [Documentation]    Verify that within timeout, PCEP topology contains correct numbers of LSPs.
224     [Tags]    critical
225     ${localsize} =    Evaluate    int(${PCCS})*int(${LSPS})
226     Builtin.Set_Suite_Variable    ${size}    ${localsize}
227     BuiltIn.Log    ${size}
228     Builtin.Wait_Until_Keyword_Succeeds    120s    1s    Pcep_On
229     # TODO: Make timeout value scale with ${size}?
230
231 Updater_1
232     [Documentation]    Run updater tool to change hops, using 1 blocking http thread.
233     [Tags]    critical
234     Updater    1
235     [Teardown]    Do_Not_Start_Failing_If_This_Failed
236
237 Verify_1
238     [Documentation]    Verify that within timeout, the correct number of new hops is in PCEP topology.
239     [Tags]    critical
240     Verify    1
241
242 Updater_2
243     [Documentation]    Run updater tool to change hops again, using 2 blocking http threads.
244     [Tags]    critical
245     Updater    2
246     [Teardown]    Do_Not_Start_Failing_If_This_Failed
247
248 Verify_2
249     [Documentation]    Verify that within timeout, the correct number of new hops is in PCEP topology.
250     [Tags]    critical
251     Verify    2
252
253 Updater_3
254     [Documentation]    Run updater tool to change hops again, using 4 blocking http threads.
255     [Tags]    critical
256     Updater    3
257     [Teardown]    Do_Not_Start_Failing_If_This_Failed
258
259 Verify_3
260     [Documentation]    Verify that within timeout, the correct number of new hops is in PCEP topology.
261     [Tags]    critical
262     Verify    3
263
264 Updater_4
265     [Documentation]    Run updater tool to change hops again, using 8 blocking http threads.
266     [Tags]    critical
267     Updater    4
268     [Teardown]    Do_Not_Start_Failing_If_This_Failed
269
270 Verify_4
271     [Documentation]    Verify that within timeout, the correct number of new hops is in PCEP topology.
272     [Tags]    critical
273     Verify    4
274
275 Updater_5
276     [Documentation]    Run updater tool to change hops again, using 16 blocking http threads.
277     [Tags]    critical
278     Updater    5
279     [Teardown]    Do_Not_Start_Failing_If_This_Failed
280
281 Verify_5
282     [Documentation]    Verify that within timeout, the correct number of new hops is in PCEP topology.
283     [Tags]    critical
284     Verify    5
285
286 Updater_6
287     [Documentation]    Run updater tool to change hops again, using 32 blocking http threads.
288     [Tags]    critical
289     Updater    6
290     [Teardown]    Do_Not_Start_Failing_If_This_Failed
291
292 Verify_6
293     [Documentation]    Verify that within timeout, the correct number of new hops is in PCEP topology.
294     [Tags]    critical
295     Verify    6
296
297 Updater_7
298     [Documentation]    Run updater tool to change hops again, using 64 blocking http threads.
299     [Tags]    critical
300     Updater    7
301     [Teardown]    Do_Not_Start_Failing_If_This_Failed
302
303 Verify_7
304     [Documentation]    Verify that within timeout, the correct number of new hops is in PCEP topology.
305     [Tags]    critical
306     Verify    7
307
308 Updater_8
309     [Documentation]    Run updater tool to change hops again, using 128 blocking http threads.
310     [Tags]    critical
311     Updater    8
312     [Teardown]    Do_Not_Start_Failing_If_This_Failed
313
314 Verify_8
315     [Documentation]    Verify that within timeout, the correct number of new hops is in PCEP topology.
316     [Tags]    critical
317     Verify    8
318
319 Updater_9
320     [Documentation]    Run updater tool to change hops again, using 256 blocking http threads.
321     [Tags]    critical
322     Updater    9
323     [Teardown]    Do_Not_Start_Failing_If_This_Failed
324
325 Verify_9
326     [Documentation]    Verify that within timeout, the correct number of new hops is in PCEP topology.
327     [Tags]    critical
328     Verify    9
329
330 Updater_10
331     [Documentation]    Run updater tool to change hops again, using 512 blocking http threads.
332     [Tags]    critical
333     Updater    10
334     [Teardown]    Do_Not_Start_Failing_If_This_Failed
335
336 Verify_10
337     [Documentation]    Verify that within timeout, the correct number of new hops is in PCEP topology.
338     [Tags]    critical
339     Verify    10
340
341 Stop_Pcc_Mock
342     [Documentation]    Send ctrl+c to pcc-mock, see prompt again within timeout.
343     [Setup]    Run_Even_When_Failing_Fast
344     # TODO: This should be in a library similar to BGPSpeaker.robot
345     SSHLibrary.Switch_Connection    pccmock
346     # FIXME: send_ctrl should be in some library.
347     ${command} =    BuiltIn.Evaluate    chr(int(3))
348     BuiltIn.Log    ${command}
349     SSHLibrary.Write    ${command}
350     ${response} =    SSHLibrary.Read_Until_Prompt
351     BuiltIn.Log    ${response}
352
353 Download_Pccmock_Log
354     [Documentation]    Transfer pcc-mock output from pcc-mock VM to robot VM.
355     [Setup]    Run_Even_When_Failing_Fast
356     SSHLibrary.Get_File    ${LOG_PATH}/${LOG_NAME}    ${LOG_NAME}
357
358 Topology_Postcondition
359     [Documentation]    Verify that within timeout, PCEP topology contains no PCCs again.
360     [Tags]    critical
361     [Setup]    Run_Even_When_Failing_Fast
362     Builtin.Wait_Until_Keyword_Succeeds    30s    1s    Pcep_Off_Again
363
364 Restore_Tcp_Rw_Reuse
365     [Documentation]    If requested, restore the old value if enabling TCP reuse was successful on Updater VM.
366     [Setup]    Run_Even_When_Failing_Fast
367     BuiltIn.Pass_Execution_If    not ${UPDATERVM_ENABLE_TCP_RW_REUSE}    Manipulation of tcp_rw_reuse is not requested.
368     SSHLibrary.Switch_Connection    updater
369     BuiltIn.Variable_Should_Exist    ${tcp_rw_reuse}
370     ${out}    ${rc} =    SSHLibrary.Execute_Command    sudo bash -c "echo ${tcp_rw_reuse} > /proc/sys/net/ipv4/tcp_tw_reuse"    return_rc=True
371     BuiltIn.Should_Be_Equal    ${rc}    ${0}
372
373 *** Keywords ***
374 Pccmock_From_Controller
375     [Documentation]    Copy Controller values to Pccmock VM variables.
376     BuiltIn.Set_Suite_Variable    ${PCCMOCKVM_IP}    ${ODL_SYSTEM_IP}
377     BuiltIn.Set_Suite_Variable    ${PCCMOCKVM_PASSWORD}    ${ODL_SYSTEM_PASSWORD}
378     BuiltIn.Set_Suite_Variable    ${PCCMOCKVM_PROMPT}    ${ODL_SYSTEM_PROMPT}
379     BuiltIn.Set_Suite_Variable    ${PCCMOCKVM_WORKSPACE}    ${CONTROLLER_WORKSPACE}
380     BuiltIn.Set_Suite_Variable    ${LOG_PATH}    ${CONTROLLER_WORKSPACE}
381
382 Updater_From_Controller
383     [Documentation]    Copy Controller values to Uprater VM variables.
384     BuiltIn.Set_Suite_Variable    ${UPDATERVM_IP}    ${ODL_SYSTEM_IP}
385     BuiltIn.Set_Suite_Variable    ${UPDATERVM_PASSWORD}    ${ODL_SYSTEM_PASSWORD}
386     BuiltIn.Set_Suite_Variable    ${UPDATERVM_PROMPT}    ${ODL_SYSTEM_PROMPT}
387     BuiltIn.Set_Suite_Variable    ${UPDATERVM_WORKSPACE}    ${CONTROLLER_WORKSPACE}
388
389 Disconnect
390     [Documentation]    Explicitly close all SSH connections.
391     SSHLibrary.Close_All_Connections
392     # TODO: Make AuthStandalone session object closable?
393
394 Get_Pcep_Topology_Data
395     [Documentation]    Use session object to download PCEP topology JSON. Check status and return Response object.
396     ${resp} =    AuthStandalone.Get_Using_Session    ${rest_session}    operational/network-topology:network-topology/topology/pcep-topology
397     # Not Logging content, as it may be huge.
398     BuiltIn.Should_Be_Equal    ${resp.status_code}    ${200}
399     [Return]    ${resp}
400
401 Get_Pcep_Topology_Count
402     [Arguments]    ${pattern}
403     [Documentation]    Get topology data, return number of pattern matches.
404     ${resp} =    Get_Pcep_Topology_Data
405     # BuiltIn.Log    ${resp.text}
406     ${count} =    BuiltIn.Evaluate    len(re.findall('${pattern}', '''${resp.text}'''))    modules=re
407     BuiltIn.Log    ${count}
408     [Return]    ${count}
409
410 Pcep_Off
411     [Documentation]    Get topology data, Log content and assert the exact JSON of empty topology.
412     ${resp} =    Get_Pcep_Topology_Data
413     # Used before topology had chance to grow huge. Be aware when creating a longevity suite from this.
414     BuiltIn.Log    ${resp.text}
415     BuiltIn.Should_Be_Equal    ${resp.text}    {"topology":[{"topology-id":"pcep-topology","topology-types":{"network-topology-pcep:topology-pcep":{}}}]}
416
417 Pcep_On
418     [Documentation]    Get topology count of current hop, assert the number of matches.
419     # Suite variables ${size} and ${hop} are set elsewhere.
420     ${resp} =    Get_Pcep_Topology_Count    ${hop}
421     BuiltIn.Should_Be_Equal    ${resp}    ${size}
422
423 Pcep_Off_Again
424     [Documentation]    Get topology count of final hop, assert there is none.
425     ...    This is more log friendly than Pcep_Off keyword, as it does not Log possibly large content.
426     Set_Hop    0
427     ${resp} =    Get_Pcep_Topology_Count    ${hop}
428     BuiltIn.Should_Be_Equal    ${resp}    ${0}
429
430 Set_Hop
431     [Arguments]    ${iteration}
432     [Documentation]    Set pattern to match the currently expected hop.
433     ${i} =    BuiltIn.Evaluate    str(1 + int(${iteration}))
434     # Regular Expressions need a dot to be escaped to represent a dot.
435     BuiltIn.Set_Suite_Variable    ${hop}    ${i}\.${i}\.${i}\.${i}/32
436     BuiltIn.Log    ${hop}
437
438 Updater
439     [Arguments]    ${iteration}
440     [Documentation]    Compute number of workers, call updater.py, assert its response.
441     SSHLibrary.Switch_Connection    pccmock
442     # In some systems, inactive SSH sessions get severed.
443     ${command} =    BuiltIn.Set_Variable    echo "still alive"
444     ${output} =    SSHLibrary.Execute_Command    bash -c '${command}'
445     # The previous line relies on a fact that Execute_Command spawns separate shels, so running pcc-mock is not affected.
446     ${workers} =    Evaluate    2**int(${iteration} - 1)
447     # TODO: Provide ${workers} explicitly as an argument to avoid math?
448     BuiltIn.Log    ${workers}
449     Set_Hop    ${iteration}
450     SSHLibrary.Switch_Connection    updater
451     ${response} =    SSHLibrary.Execute_Command    bash -c "cd ${UPDATERVM_WORKSPACE}; taskset 0x00000001 python updater.py --workers '${workers}' --odladdress '${UPDATER_ODLADDRESS}' --user '${RESTCONF_USER}' --password '${RESTCONF_PASSWORD}' --scope '${RESTCONF_SCOPE}' --pccaddress '${FIRST_PCC_IP}' --pccs '${PCCS}' --lsps '${LSPS}' --hop '${hop}' --timeout '${UPDATER_TIMEOUT}' --refresh '${UPDATER_REFRESH}' --reuse '${RESTCONF_REUSE}' 2>&1"
452     BuiltIn.Log    ${response}
453     ${expected} =    BuiltIn.Set_Variable    Counter({'pass': ${size}})
454     BuiltIn.Log    ${expected}
455     BuiltIn.Should_Contain    ${response}    ${expected}
456
457 Verify
458     [Arguments]    ${iteration}
459     [Documentation]    Set hop and verify that within timeout, all LSPs in topology are updated.
460     Set_Hop    ${iteration}
461     Builtin.Wait_Until_Keyword_Succeeds    30s    1s    Pcep_On