A.R Karthick | c3eb12b | 2016-10-20 17:39:47 -0700 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Common definitions of variables and keywords for running cord tester |
| 3 | Library OperatingSystem |
| 4 | Library Collections |
A R Karthick | 9ee9252 | 2016-11-29 14:59:11 -0800 | [diff] [blame] | 5 | Library String |
A.R Karthick | c3eb12b | 2016-10-20 17:39:47 -0700 | [diff] [blame] | 6 | Library RequestsLibrary |
| 7 | |
| 8 | *** Variables *** |
| 9 | ${CORD_TESTER} %{HOME}/cord-tester/src/test/setup/cord-test.py |
| 10 | ${RESTPORT} 8181 |
| 11 | ${NODES} 1 |
A R Karthick | 51e6fd8 | 2016-11-22 14:39:19 -0800 | [diff] [blame] | 12 | ${EXTRA_OPTS} |
A.R Karthick | c3eb12b | 2016-10-20 17:39:47 -0700 | [diff] [blame] | 13 | |
| 14 | *** Keywords *** |
| 15 | Cord Setup |
| 16 | [Documentation] Setup the cord tester |
| 17 | Cord Teardown |
A R Karthick | 51e6fd8 | 2016-11-22 14:39:19 -0800 | [diff] [blame] | 18 | ${rc}= Run and Return RC sudo ${CORD_TESTER} setup --olt --start-switch -n ${NODES} ${EXTRA_OPTS} |
A.R Karthick | c3eb12b | 2016-10-20 17:39:47 -0700 | [diff] [blame] | 19 | 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 Karthick | 9ee9252 | 2016-11-29 14:59:11 -0800 | [diff] [blame] | 22 | @{controller_names}= Split String ${controllers} |
A.R Karthick | c3eb12b | 2016-10-20 17:39:47 -0700 | [diff] [blame] | 23 | @{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 | |
| 33 | Cord Teardown |
| 34 | [Documentation] Teardown the cord tester setup |
| 35 | ${output}= Run sudo ${CORD_TESTER} cleanup --olt |
| 36 | |
| 37 | Create 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 | |
| 43 | Verify 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 | |
| 49 | ONOS 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 | |
| 56 | Run Cord Tester |
| 57 | [Arguments] ${test_case} |
A R Karthick | 51e6fd8 | 2016-11-22 14:39:19 -0800 | [diff] [blame] | 58 | ${status} ${output}= Run and Return RC and Output sudo ${CORD_TESTER} run --onos-instances=${NODES} --container=${test_container} -t ${test_case} |
A.R Karthick | c3eb12b | 2016-10-20 17:39:47 -0700 | [diff] [blame] | 59 | Log ${output} |
| 60 | [Return] ${status} |