blob: b4870636063185a96b72882460c0578677a81813 [file] [log] [blame]
A.R Karthickc3eb12b2016-10-20 17:39:47 -07001*** Settings ***
2Documentation Common definitions of variables and keywords for running cord tester
3Library OperatingSystem
4Library Collections
A R Karthick9ee92522016-11-29 14:59:11 -08005Library String
A.R Karthickc3eb12b2016-10-20 17:39:47 -07006Library RequestsLibrary
7
8*** Variables ***
9${CORD_TESTER} %{HOME}/cord-tester/src/test/setup/cord-test.py
10${RESTPORT} 8181
11${NODES} 1
A R Karthick51e6fd82016-11-22 14:39:19 -080012${EXTRA_OPTS}
A.R Karthickc3eb12b2016-10-20 17:39:47 -070013
14*** Keywords ***
15Cord Setup
16 [Documentation] Setup the cord tester
17 Cord Teardown
A R Karthick51e6fd82016-11-22 14:39:19 -080018 ${rc}= Run and Return RC sudo ${CORD_TESTER} setup --olt --start-switch -n ${NODES} ${EXTRA_OPTS}
A.R Karthickc3eb12b2016-10-20 17:39:47 -070019 Should Be Equal As Integers ${rc} 0
20 ${test_container}= Run sudo docker ps | grep cord-tester | tail -1 | tr -s ' ' | awk '{print $NF}'
21 ${controllers}= Run sudo docker ps | grep cord-onos | tr -s ' ' | awk '{print $NF}' | tr -s '\n' ' '
A R Karthick9ee92522016-11-29 14:59:11 -080022 @{controller_names}= Split String ${controllers}
A.R Karthickc3eb12b2016-10-20 17:39:47 -070023 @{controller_list}= Create List
24 : FOR ${controller} IN @{controller_names}
25 \ ${ip}= Run sudo docker inspect -f '{{.NetworkSettings.Networks.bridge.IPAddress}}' ${controller}
26 \ Append To List ${controller_list} ${ip}
27
28 Set Suite Variable ${test_container}
29 Set Suite Variable @{controller_list}
30 Create HTTP Sessions
31 Wait Until Keyword Succeeds 30s 2s Verify If All Controllers Are Up
32
33Cord Teardown
34 [Documentation] Teardown the cord tester setup
35 ${output}= Run sudo ${CORD_TESTER} cleanup --olt
36
37Create HTTP Sessions
38 [Documentation] Create controller http sessions
39 ${AUTH}= Create List karaf karaf
40 : FOR ${ip} IN @{controller_list}
41 \ Create Session ${ip} http://${ip}:${RESTPORT} auth=${AUTH}
42
43Verify If All Controllers Are Up
44 [Documentation] Make a rest call to the controller to see if its responding
45 : FOR ${ip} IN @{controller_list}
46 \ ${resp}= ONOS Get ${ip} devices
47 \ Should Be Equal As Strings ${resp.status_code} 200
48
49ONOS Get
50 [Documentation] Make a rest call to ONOS controller
51 [Arguments] ${session} ${noun}
52 ${resp}= Get Request ${session} /onos/v1/${noun}
53 Log ${resp.content}
54 [Return] ${resp}
55
56Run Cord Tester
57 [Arguments] ${test_case}
A R Karthick51e6fd82016-11-22 14:39:19 -080058 ${status} ${output}= Run and Return RC and Output sudo ${CORD_TESTER} run --onos-instances=${NODES} --container=${test_container} -t ${test_case}
A.R Karthickc3eb12b2016-10-20 17:39:47 -070059 Log ${output}
60 [Return] ${status}