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 |
| 5 | Library 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 *** |
| 13 | Cord 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 | |
| 31 | Cord Teardown |
| 32 | [Documentation] Teardown the cord tester setup |
| 33 | ${output}= Run sudo ${CORD_TESTER} cleanup --olt |
| 34 | |
| 35 | Create 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 | |
| 41 | Verify 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 | |
| 47 | ONOS 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 | |
| 54 | Run 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} |