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