blob: f84711cdf13c0bb3370effd839bcec8aa1fc9f81 [file] [log] [blame]
Kailash Khalasibbef1382018-10-09 14:36:49 -07001*** Settings ***
2Library KafkaLibrary
3Library RequestsLibrary
Kailash Khalasibbef1382018-10-09 14:36:49 -07004Library Collections
5Library String
6Library OperatingSystem
7Suite Setup Setup
8Suite Teardown Teardown
9
10*** Variables ***
11${cord_kafka} cord-kafka
12${xos_tosca} xos-tosca
Kailash Khalasi31308e42018-10-09 17:54:54 -070013${xos_tosca_port} 9102
Kailash Khalasibbef1382018-10-09 14:36:49 -070014${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
Kailash Khalasi79418ea2018-10-10 08:59:27 -070021 Wait Until Keyword Succeeds 300s 2s Get Kubernetes SI Pod IP
Kailash Khalasibbef1382018-10-09 14:36:49 -070022 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 ***
33Setup
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 Khalasi31308e42018-10-09 17:54:54 -070040 ${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 -070041 Should Contain ${output} Created models
42
43Teardown
44 [Documentation] Delete all models created
45 Log Tearing down
46 Delete All Sessions
47
48Validate Webserver Gone
49 ${output}= Run http ${k8_pod_ip}
Kailash Khalasife60c7b2018-10-10 09:34:51 -070050 Should Contain ${output} Request timed out
Kailash Khalasibbef1382018-10-09 14:36:49 -070051
52Obtain 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 Khalasi79418ea2018-10-10 08:59:27 -070061Get Kubernetes SI Pod IP
62 ${resp}= CORD Get /xosapi/v1/kubernetes/kubernetesserviceinstances/${k8_si_id}
Zack Williams821c5022020-01-15 15:11:46 -070063 ${k8_pod_ip}= Get From Dictionary ${resp.json()} pod_ip
Kailash Khalasi79418ea2018-10-10 08:59:27 -070064 Set Suite Variable ${k8_pod_ip}
65
Kailash Khalasibbef1382018-10-09 14:36:49 -070066Validate 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
74Validate WebService Message
75 [Arguments] ${message}
76 ${output}= Run http ${k8_pod_ip} | grep ${message}
77 Should Contain ${output} Tenant Message: "${message}"
78
79Send 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
87CORD 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
95CORD 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 Williams821c5022020-01-15 15:11:46 -0700102 ${id}= Get From Dictionary ${resp.json()} id
Kailash Khalasibbef1382018-10-09 14:36:49 -0700103 Set Suite Variable ${id}
104 [Return] ${resp}
105
106CORD 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}