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