blob: 42884d3df0b36a315cf24e1cfbc63abe63e625bf [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
5Library RequestsLibrary
6
7*** Variables ***
8${CORD_TESTER} %{HOME}/cord-tester/src/test/setup/cord-test.py
9${RESTPORT} 8181
10${NODES} 1
11
12*** Keywords ***
13Cord Setup
14 [Documentation] Setup the cord tester
15 Cord Teardown
16 ${rc}= Run and Return RC sudo ${CORD_TESTER} setup --olt --start-switch -n ${NODES}
17 Should Be Equal As Integers ${rc} 0
18 ${test_container}= Run sudo docker ps | grep cord-tester | tail -1 | tr -s ' ' | awk '{print $NF}'
19 ${controllers}= Run sudo docker ps | grep cord-onos | tr -s ' ' | awk '{print $NF}' | tr -s '\n' ' '
20 @{controller_names}= Create List ${controllers}
21 @{controller_list}= Create List
22 : FOR ${controller} IN @{controller_names}
23 \ ${ip}= Run sudo docker inspect -f '{{.NetworkSettings.Networks.bridge.IPAddress}}' ${controller}
24 \ Append To List ${controller_list} ${ip}
25
26 Set Suite Variable ${test_container}
27 Set Suite Variable @{controller_list}
28 Create HTTP Sessions
29 Wait Until Keyword Succeeds 30s 2s Verify If All Controllers Are Up
30
31Cord Teardown
32 [Documentation] Teardown the cord tester setup
33 ${output}= Run sudo ${CORD_TESTER} cleanup --olt
34
35Create HTTP Sessions
36 [Documentation] Create controller http sessions
37 ${AUTH}= Create List karaf karaf
38 : FOR ${ip} IN @{controller_list}
39 \ Create Session ${ip} http://${ip}:${RESTPORT} auth=${AUTH}
40
41Verify If All Controllers Are Up
42 [Documentation] Make a rest call to the controller to see if its responding
43 : FOR ${ip} IN @{controller_list}
44 \ ${resp}= ONOS Get ${ip} devices
45 \ Should Be Equal As Strings ${resp.status_code} 200
46
47ONOS Get
48 [Documentation] Make a rest call to ONOS controller
49 [Arguments] ${session} ${noun}
50 ${resp}= Get Request ${session} /onos/v1/${noun}
51 Log ${resp.content}
52 [Return] ${resp}
53
54Run Cord Tester
55 [Arguments] ${test_case}
56 ${status} ${output}= Run and Return RC and Output sudo ${CORD_TESTER} run --container=${test_container} -t ${test_case}
57 Log ${output}
58 [Return] ${status}