Kailash Khalasi | bbef138 | 2018-10-09 14:36:49 -0700 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Library KafkaLibrary |
| 3 | Library RequestsLibrary |
| 4 | Library HttpLibrary.HTTP |
| 5 | Library Collections |
| 6 | Library String |
| 7 | Library OperatingSystem |
| 8 | Suite Setup Setup |
| 9 | Suite Teardown Teardown |
| 10 | |
| 11 | *** Variables *** |
| 12 | ${cord_kafka} cord-kafka |
| 13 | ${xos_tosca} xos-tosca |
Kailash Khalasi | 31308e4 | 2018-10-09 17:54:54 -0700 | [diff] [blame] | 14 | ${xos_tosca_port} 9102 |
Kailash Khalasi | bbef138 | 2018-10-09 14:36:49 -0700 | [diff] [blame] | 15 | ${server_ip} xos-chameleon |
| 16 | ${server_port} 9101 |
| 17 | |
| 18 | *** Test Cases *** |
| 19 | Validate Kubernetes Service Instance |
| 20 | [Documentation] Modify the demo-simpleexampleservice instance and validate webserver |
| 21 | Wait Until Keyword Succeeds 120s 2s Obtain SimpleExampleService SI |
Kailash Khalasi | 79418ea | 2018-10-10 08:59:27 -0700 | [diff] [blame] | 22 | Wait Until Keyword Succeeds 300s 2s Get Kubernetes SI Pod IP |
Kailash Khalasi | bbef138 | 2018-10-09 14:36:49 -0700 | [diff] [blame] | 23 | Send Kafka Event SimpleExampleEvent {"service_instance": "My Simple Example Service Instance", "tenant_message": "world"} |
| 24 | Wait Until Keyword Succeeds 60s 2s Validate SI Message world |
| 25 | Wait Until Keyword Succeeds 120s 2s Validate WebService Message world |
| 26 | Send Kafka Event SimpleExampleEvent {"service_instance": "My Simple Example Service Instance", "tenant_message": "Earth"} |
| 27 | Wait Until Keyword Succeeds 60s 2s Validate SI Message Earth |
| 28 | Wait Until Keyword Succeeds 120s 2s Validate WebService Message Earth |
| 29 | #Delete Simpleexamplesi and verify webserver goes down |
| 30 | CORD Delete /xosapi/v1/simpleexampleservice/simpleexampleserviceinstances ${demo_si_id} |
| 31 | Wait Until Keyword Succeeds 300s 2s Validate Webserver Gone |
| 32 | |
| 33 | *** Keywords *** |
| 34 | Setup |
| 35 | Connect Producer ${cord_kafka}:9092 SimpleExampleEvent |
| 36 | ${auth} = Create List admin@opencord.org letmein |
| 37 | ${HEADERS} Create Dictionary Content-Type=application/json |
| 38 | Create Session ${server_ip} http://${server_ip}:${server_port} auth=${AUTH} headers=${HEADERS} |
| 39 | #Create SimpleExampleServiceInstance from provided tosca recipes |
| 40 | Run git clone https://github.com/opencord/simpleexampleservice |
Kailash Khalasi | 31308e4 | 2018-10-09 17:54:54 -0700 | [diff] [blame] | 41 | ${output}= Run curl -H "xos-username:admin@opencord.org" -H "xos-password:letmein" -X POST --data-binary @simpleexampleservice/xos/examples/SimpleExampleServiceInstance.yaml http://${xos_tosca}:${xos_tosca_port}/run |
Kailash Khalasi | bbef138 | 2018-10-09 14:36:49 -0700 | [diff] [blame] | 42 | Should Contain ${output} Created models |
| 43 | |
| 44 | Teardown |
| 45 | [Documentation] Delete all models created |
| 46 | Log Tearing down |
| 47 | Delete All Sessions |
| 48 | |
| 49 | Validate Webserver Gone |
| 50 | ${output}= Run http ${k8_pod_ip} |
Kailash Khalasi | fe60c7b | 2018-10-10 09:34:51 -0700 | [diff] [blame] | 51 | Should Contain ${output} Request timed out |
Kailash Khalasi | bbef138 | 2018-10-09 14:36:49 -0700 | [diff] [blame] | 52 | |
| 53 | Obtain SimpleExampleService SI |
| 54 | ${resp}= CORD Get /xosapi/v1/simpleexampleservice/simpleexampleserviceinstances |
| 55 | ${jsondata}= To Json ${resp.content} |
| 56 | ${simpleexampleserviceinstance}= Get From List ${jsondata['items']} 0 |
| 57 | ${k8_si_id}= Get From Dictionary ${simpleexampleserviceinstance} compute_instance_id |
| 58 | ${demo_si_id}= Get From Dictionary ${simpleexampleserviceinstance} id |
| 59 | Set Suite Variable ${k8_si_id} |
| 60 | Set Suite Variable ${demo_si_id} |
| 61 | |
Kailash Khalasi | 79418ea | 2018-10-10 08:59:27 -0700 | [diff] [blame] | 62 | Get Kubernetes SI Pod IP |
| 63 | ${resp}= CORD Get /xosapi/v1/kubernetes/kubernetesserviceinstances/${k8_si_id} |
| 64 | ${k8_pod_ip}= Get Json Value ${resp.content} /pod_ip |
| 65 | Set Suite Variable ${k8_pod_ip} |
| 66 | |
Kailash Khalasi | bbef138 | 2018-10-09 14:36:49 -0700 | [diff] [blame] | 67 | Validate SI Message |
| 68 | [Arguments] ${message} |
| 69 | ${resp}= CORD Get /xosapi/v1/simpleexampleservice/simpleexampleserviceinstances |
| 70 | ${jsondata}= To Json ${resp.content} |
| 71 | ${simpleexampleserviceinstance}= Get From List ${jsondata['items']} 0 |
| 72 | ${si_message}= Get From Dictionary ${simpleexampleserviceinstance} tenant_message |
| 73 | Should Be Equal As Strings ${si_message} ${message} |
| 74 | |
| 75 | Validate WebService Message |
| 76 | [Arguments] ${message} |
| 77 | ${output}= Run http ${k8_pod_ip} | grep ${message} |
| 78 | Should Contain ${output} Tenant Message: "${message}" |
| 79 | |
| 80 | Send Kafka Event |
| 81 | [Documentation] Send event |
| 82 | [Arguments] ${topic} ${message} |
| 83 | Log Sending event |
| 84 | ${event}= evaluate json.dumps(${message}) json |
| 85 | Send ${topic} ${event} |
| 86 | Flush |
| 87 | |
| 88 | CORD Get |
| 89 | [Documentation] Make a GET call to XOS |
| 90 | [Arguments] ${service} |
| 91 | ${resp}= Get Request ${server_ip} ${service} |
| 92 | Log ${resp.content} |
| 93 | Should Be Equal As Strings ${resp.status_code} 200 |
| 94 | [Return] ${resp} |
| 95 | |
| 96 | CORD Post |
| 97 | [Documentation] Make a POST call to XOS |
| 98 | [Arguments] ${service} ${data} |
| 99 | ${data}= Evaluate json.dumps(${data}) json |
| 100 | ${resp}= Post Request ${server_ip} uri=${service} data=${data} |
| 101 | Log ${resp.content} |
| 102 | Should Be Equal As Strings ${resp.status_code} 200 |
| 103 | ${id}= Get Json Value ${resp.content} /id |
| 104 | Set Suite Variable ${id} |
| 105 | [Return] ${resp} |
| 106 | |
| 107 | CORD Delete |
| 108 | [Documentation] Make a DELETE call to the CORD controller |
| 109 | [Arguments] ${service} ${data_id} |
| 110 | ${resp}= Delete Request ${SERVER_IP} uri=${service}/${data_id} |
| 111 | Log ${resp.content} |
| 112 | Should Be Equal As Strings ${resp.status_code} 200 |
| 113 | [Return] ${resp} |