blob: 07003f99172ea8c812bc38d3dbb066789abbf1ab [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
Kailash Khalasi31308e42018-10-09 17:54:54 -070014${xos_tosca_port} 9102
Kailash Khalasibbef1382018-10-09 14:36:49 -070015${server_ip} xos-chameleon
16${server_port} 9101
17
18*** Test Cases ***
19Validate Kubernetes Service Instance
20 [Documentation] Modify the demo-simpleexampleservice instance and validate webserver
21 Wait Until Keyword Succeeds 120s 2s Obtain SimpleExampleService SI
Kailash Khalasi79418ea2018-10-10 08:59:27 -070022 Wait Until Keyword Succeeds 300s 2s Get Kubernetes SI Pod IP
Kailash Khalasibbef1382018-10-09 14:36:49 -070023 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 ***
34Setup
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 Khalasi31308e42018-10-09 17:54:54 -070041 ${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 Khalasibbef1382018-10-09 14:36:49 -070042 Should Contain ${output} Created models
43
44Teardown
45 [Documentation] Delete all models created
46 Log Tearing down
47 Delete All Sessions
48
49Validate Webserver Gone
50 ${output}= Run http ${k8_pod_ip}
Kailash Khalasife60c7b2018-10-10 09:34:51 -070051 Should Contain ${output} Request timed out
Kailash Khalasibbef1382018-10-09 14:36:49 -070052
53Obtain 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 Khalasi79418ea2018-10-10 08:59:27 -070062Get 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 Khalasibbef1382018-10-09 14:36:49 -070067Validate 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
75Validate WebService Message
76 [Arguments] ${message}
77 ${output}= Run http ${k8_pod_ip} | grep ${message}
78 Should Contain ${output} Tenant Message: "${message}"
79
80Send 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
88CORD 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
96CORD 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
107CORD 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}