blob: 19720e804c14577547ee2450e34499d05ca5c63d [file] [log] [blame]
Katarzyna Wasield1bc6cb2021-02-10 08:50:57 +01001*** Settings ***
2Library ONAPLibrary.Templating WITH NAME Templating
3Library ONAPLibrary.Utilities
4Library RequestsLibrary
5Library Collections
6Library String
7Library OperatingSystem
8Resource ../resources/global_properties.robot
Krzysztof Kuzmicki83837dc2022-03-23 10:29:20 +01009Resource chart_museum.robot
Katarzyna Wasield1bc6cb2021-02-10 08:50:57 +010010
11
12*** Variables ***
13
14${CLIENT_ID} robot123
15${SESSION_NAME} nifi-api
16${DCAEMOD_SERVER} http://dcaemod.simpledemo.onap.org
17${IS_PROCESS_GROUP_SET} False
18${IS_FLOW_DISTRIBUTED} False
19${IS_SERVICE_DEPLOYED} False
20${PROCESS_GROUP_ID} ${EMPTY}
21${TYPE_ID} ${EMPTY}
22${BLUEPRINT_NAME} ${EMPTY}
23${DISTRIBUTION_TARGET_ID} ${EMPTY}
24${REGISTRY_CLIENT_ID} ${EMPTY}
25${DCAEMOD_ONBOARDING_API_SERVER} ${GLOBAL_DCAEMOD_ONBOARDING_API_SERVER_PROTOCOL}://${GLOBAL_DCAEMOD_ONBOARDING_API_SERVER_NAME}:${GLOBAL_DCAEMOD_ONBOARDING_API_SERVER_PORT}
26${DCAEMOD_DESIGNTOOL_SERVER} ${GLOBAL_DCAEMOD_DESIGNTOOL_SERVER_PROTOCOL}://${GLOBAL_DCAEMOD_DESIGNTOOL_SERVER_NAME}:${GLOBAL_DCAEMOD_DESIGNTOOL_SERVER_PORT}
27${DCAEMOD_DISTRIBUTOR_API_SERVER} ${GLOBAL_DCAEMOD_DISTRIBUTOR_API_SERVER_PROTOCOL}://${GLOBAL_DCAEMOD_DISTRIBUTOR_API_SERVER_NAME}:${GLOBAL_DCAEMOD_DISTRIBUTOR_API_SERVER_PORT}
Krzysztof Kuzmicki83837dc2022-03-23 10:29:20 +010028${HELM_RELEASE} kubectl --namespace onap get pods | sed 's/ .*//' | grep robot | sed 's/-.*//'
29
Katarzyna Wasield1bc6cb2021-02-10 08:50:57 +010030
31*** Keywords ***
32
33Deploy DCAE Application
34 [Arguments] ${componentSpec} ${dict_values} ${compSpecName} ${processGroupName}
35
36 Onboard Component Spec ${componentSpec} ${dict_values} ${compSpecName}
37 ${processGroupId} = Create Process Group ${processGroupName}
38 Set Test Variable ${IS_PROCESS_GROUP_SET} True
39 Set Test Variable ${PROCESS_GROUP_ID} ${processGroupId}
40
41 Create Processor ${PROCESS_GROUP_ID} ${compSpecName}
42 Save Flow By Version Controlling ${processGroupName} ${PROCESS_GROUP_ID}
43 Distribute The Flow ${PROCESS_GROUP_ID}
44 Set Test Variable ${IS_FLOW_DISTRIBUTED} True
45
Krzysztof Kuzmicki83837dc2022-03-23 10:29:20 +010046 Deploy Applictaion ${processGroupName} ${compSpecName}
47 Set Test Variable ${CHART_NAME} ${compSpecName}
48
Katarzyna Wasield1bc6cb2021-02-10 08:50:57 +010049
50
51Delete Config Map With Mounted Config File
52 ${configMapStatus} = Run Keyword And Return Status Config Map Exists ${CONFIG_MAP_NAME}
53 Run Keyword If ${configMapStatus} Delete Config Map ${CONFIG_MAP_NAME}
54 Remove File ${CONFIG_MAP_FILE}
55
56Delete Config Map
57 [Arguments] ${configMapName}
58 ${configMapDelete} = Run And Return Rc kubectl -n onap delete configmap ${configMapName}
59 Should Be Equal As Integers ${configMapDelete} 0
60
61Create Config Map From File
62 [Arguments] ${configMapName} ${configMapFilePath}
63
64 ${createConfigMapRC} = Run And Return Rc kubectl -n onap create configmap ${configMapName} --from-file=${configMapFilePath}
65 Should Be Equal As Integers ${createConfigMapRC} 0
66 Wait Until Keyword Succeeds 1 min 5s Config Map Exists ${configMapName}
67
68Config Map Exists
69 [Arguments] ${configMapName}
70 ${configMapExists} = Run And Return Rc kubectl -n onap get configmap | grep ${configMapName}
71 Should Be Equal As Integers ${configMapExists} 0
72
73Get Pod Yaml
74 [Arguments] ${compSpecName}
75 ${podYaml} = Run And Return Rc And Output kubectl -n onap get pod $(kubectl get pod -n onap | grep ${compSpecName} | awk '{print $1}') -o yaml
76 Should Be Equal As Integers ${podYaml[0]} 0
77 ${podYaml} = Set Variable ${podYaml[1]}
78
79 [Return] ${podYaml}
80
81Get Content Of Mounted Folder Inside Container
82 [Arguments] ${compSpecName} ${volumeMountPath}
Andreas Geisslerd9fa0c02022-11-09 09:53:40 +010083 ${mountedFolderContent} = Run And Return Rc And Output kubectl -n onap exec $(kubectl get pod -n onap | grep ${compSpecName} | awk '{print $1}') -c ${compSpecName} -- ls ${volumeMountPath}
Katarzyna Wasield1bc6cb2021-02-10 08:50:57 +010084 Should Be Equal As Integers ${mountedFolderContent[0]} 0
85 ${mountedFolderContent} = Set Variable ${mountedFolderContent[1]}
86
87 [Return] ${mountedFolderContent}
88
89Verify If Volume Is Mounted
90 [Arguments] ${podYaml} ${volumeMountPath}
91 Should Contain ${podYaml} ${volumeMountPath}
92
93Verify If Config Map Is Mounted As Volume
94 [Arguments] ${podYaml} ${configMapName}
95 Should Contain ${podYaml} ${configMapName}
96
97Verify If Mounted Folder Is Empty
98 [Arguments] ${mountedFolderContent}
99 Should Be Empty ${mountedFolderContent}
100
101Verify If Mounted Folder Contains File
102 [Arguments] ${compSpecName} ${fileName} ${configMapDir}
103
Andreas Geisslerd9fa0c02022-11-09 09:53:40 +0100104 ${dirContent} = Run And Return Rc And Output kubectl -n onap exec $(kubectl get pod -n onap | grep ${compSpecName} | awk '{print $1}') -c ${compSpecName} -- ls ${configMapDir}
Katarzyna Wasield1bc6cb2021-02-10 08:50:57 +0100105 Should Be Equal As Integers ${dirContent[0]} 0
106 Should Contain ${dirContent[1]} ${fileName}
107
108Verify File Content
109 [Arguments] ${compSpecName} ${configMapFilePath} ${content}
110
Andreas Geisslerd9fa0c02022-11-09 09:53:40 +0100111 ${fileContent} = Run And Return Rc And Output kubectl -n onap exec $(kubectl get pod -n onap | grep ${compSpecName} | awk '{print $1}') -c ${compSpecName} -- cat ${configMapFilePath}
Katarzyna Wasield1bc6cb2021-02-10 08:50:57 +0100112 Should Be Equal As Integers ${fileContent[0]} 0
113 Should Contain ${fileContent[1]} ${content}
114
115Verify If Component Is Onboarded
116 [Arguments] ${compSpecName}
117 ${session}= Create Session ${SESSION_NAME} ${DCAEMOD_ONBOARDING_API_SERVER}
118 ${headers}= Create Dictionary content-type=application/json
119 ${resp} = Get Request ${SESSION_NAME} /onboarding/components?name=${compSpecName} headers=${headers}
120 Log ${resp.json()}
121 Should Not Be Empty ${resp.json().get('components')}
122
123
124Onboard Component Spec
125 [Arguments] ${componentSpec} ${dict_values} ${compSpecName}
126 ${session}= Create Session ${SESSION_NAME} ${DCAEMOD_ONBOARDING_API_SERVER}
127 ${headers}= Create Dictionary content-type=application/json
128 Templating.Create Environment dcaemod ${GLOBAL_TEMPLATE_FOLDER}
129 ${componentSpec}= Templating.Apply Template dcaemod ${componentSpec} ${dict_values}
130 ${resp} = Post Request ${SESSION_NAME} /onboarding/components data=${componentSpec} headers=${headers}
131 Should Be True ${resp.status_code} < 300
132
133 Wait Until Keyword Succeeds 2 min 5s Verify If Component Is Onboarded ${compSpecName}
134
135 Log ${resp.json()}
136
137Add Registry Client
138
139 ${session}= Create Session ${SESSION_NAME} ${DCAEMOD_DESIGNTOOL_SERVER}
140 ${headers}= Create Dictionary content-type=application/json
141 ${data} = Set Variable {"revision": {"version": 0}, "component": {"name": "registry_test", "uri": "http://dcaemod-nifi-registry:18080"}}
142 ${resp} = Post Request ${SESSION_NAME} /nifi-api/controller/registry-clients data=${data} headers=${headers}
143 Should Be True ${resp.status_code} < 300
144
145 Set Global Variable ${REGISTRY_CLIENT_ID} ${resp.json().get('id')}
146 Set Global Variable ${REGISTRY_CLIENT_VERSION} ${resp.json().get('revision').get('version')}
147
148Add Distribution Target
149
150 ${session}= Create Session distributor ${DCAEMOD_DISTRIBUTOR_API_SERVER}
151 ${headers}= Create Dictionary content-type=application/json
152 ${data} = Set Variable {"name": "runtime_test", "runtimeApiUrl": "http://dcaemod-runtime-api:9090"}
153 ${resp} = Post Request distributor /distributor/distribution-targets data=${data} headers=${headers}
154 Should Be True ${resp.status_code} < 300
155 Set Global Variable ${DISTRIBUTION_TARGET_ID} ${resp.json().get('id')}
156
157Create Process Group
158 [Arguments] ${name}
159 ${session}= Create Session ${SESSION_NAME} ${DCAEMOD_DESIGNTOOL_SERVER}
160 ${headers}= Create Dictionary content-type=application/json
161 ${resp} = Get Request ${SESSION_NAME} /nifi-api/flow/process-groups/root/ headers=${headers}
162 Should Be True ${resp.status_code} < 300
163 Log ${resp.json()}
164 ${parentGroupId} = Set Variable ${resp.json().get('processGroupFlow').get('id')}
165
166 ${data} = Set Variable {"revision": {"clientId": "${CLIENT_ID}", "version": 0}, "component" : {"parentGroupId" : "${parentGroupId}", "name" : "${name}"}}
167 ${resp} = Post Request ${SESSION_NAME} /nifi-api/process-groups/${parentGroupId}/process-groups data=${data} headers=${headers}
168 Should Be True ${resp.status_code} < 300
169 Log ${resp.json()}
170
171 ${processGroupId} = Set Variable ${resp.json().get('id')}
172
173 [Return] ${processGroupId}
174
175
176Verify If NIFI Processor Is Created
177 [Arguments] ${typeName}
178 ${session}= Create Session ${SESSION_NAME} ${DCAEMOD_DESIGNTOOL_SERVER}
179 ${headers}= Create Dictionary content-type=application/json
180 ${resp} = Get Request ${SESSION_NAME} /nifi-api/flow/processor-types?type=org.onap.dcae.${typeName} headers=${headers}
181 Log ${resp.json()}
182 Should Not Be Empty ${resp.json().get('processorTypes')}
183
184Create Processor
185 [Arguments] ${processGroupId} ${compSpecName}
186 ${session}= Create Session ${SESSION_NAME} ${DCAEMOD_DESIGNTOOL_SERVER}
187 ${headers}= Create Dictionary content-type=application/json
188 ${typeName} = Evaluate $compSpecName.title()
Katarzyna Wasiel106bde32021-03-01 15:38:14 +0100189 ${typeName} = Remove String ${typeName} -
Katarzyna Wasield1bc6cb2021-02-10 08:50:57 +0100190 ${data} = Set Variable {"revision": {"clientId": "${CLIENT_ID}", "version": 0},"component": {"parentGroupId": "${processGroupId}", "name": "${compSpecName}", "type": "org.onap.dcae.${typeName}"}}
191 Wait Until Keyword Succeeds 60s 5s Verify If NIFI Processor Is Created ${typeName}
192 ${resp} = Post Request ${SESSION_NAME} /nifi-api/process-groups/${processGroupId}/processors data=${data} headers=${headers}
193 Should Be True ${resp.status_code} < 300
194
195
196Save Flow By Version Controlling
197 [Arguments] ${flowName} ${processGroupId}
198
199 ${session}= Create Session ${SESSION_NAME} ${DCAEMOD_DESIGNTOOL_SERVER}
200 ${headers}= Create Dictionary content-type=application/json
201
202 ${resp} = Get Request ${SESSION_NAME} /nifi-api/flow/registries/${REGISTRY_CLIENT_ID}/buckets headers=${headers}
203 Should Be True ${resp.status_code} < 300
204 Log ${resp.json()}
205 ${bucketId} = Set Variable ${resp.json().get('buckets')[0].get('id')}
206
207 ${processGrVersion} ${_}= Get Process Group Revision ${processGroupId}
208
209 ${data} = Set Variable {"versionedFlow": {"flowName": "${flowName}", "bucketId": "${bucketId}", "registryId": "${REGISTRY_CLIENT_ID}"}, "processGroupRevision": {"clientId": "${CLIENT_ID}", "version": ${processGrVersion}}}
210 ${resp} = Post Request ${SESSION_NAME} /nifi-api/versions/process-groups/${processGroupId} data=${data} headers=${headers}
211 Should Be True ${resp.status_code} < 300
212
213Distribute The Flow
214 [Arguments] ${processGroupId}
215 ${session}= Create Session ${SESSION_NAME} ${DCAEMOD_DESIGNTOOL_SERVER}
216 ${session}= Create Session distributor ${DCAEMOD_DISTRIBUTOR_API_SERVER}
217 ${headers}= Create Dictionary content-type=application/json
218 ${resp} = Get Request ${SESSION_NAME} /nifi-api/process-groups/${processGroupId} headers=${headers}
219 Should Be True ${resp.status_code} < 300
220 Log ${resp.json()}
221 ${flowId} = Set Variable ${resp.json().get('component').get('versionControlInformation').get('flowId')}
222 ${data} = Set Variable {"processGroupId": "${flowId}"}
223 ${resp} = Post Request distributor /distributor/distribution-targets/${DISTRIBUTION_TARGET_ID}/process-groups data=${data} headers=${headers}
224 Should Be True ${resp.status_code} < 300
225
Krzysztof Kuzmicki83837dc2022-03-23 10:29:20 +0100226Deploy Applictaion
227 [Arguments] ${processGroupName} ${compSpecName}
228 ${command_output} = Run And Return Rc And Output helm repo update
229 Should Be Equal As Integers ${command_output[0]} 0
Andreas Geisslerc6e56f12022-11-10 10:51:08 +0100230 ${helm_install}= Set Variable helm -n onap install ${ONAP_HELM_RELEASE}-${compSpecName} chart-museum/${compSpecName} --set global.repository=${registry_ovveride}
Krzysztof Kuzmicki83837dc2022-03-23 10:29:20 +0100231 ${helm_install_command_output} = Run And Return Rc And Output ${helm_install}
232 Log ${helm_install_command_output[1]}
233 Should Be Equal As Integers ${helm_install_command_output[0]} 0
234 Set Test Variable ${IS_SERVICE_DEPLOYED} True
Andreas Geisslerc6e56f12022-11-10 10:51:08 +0100235 ${kubectl_patch}= Set Variable kubectl -n onap patch deployment ${ONAP_HELM_RELEASE}-${compSpecName} -p '{"spec":{"template":{"spec":{"containers":[{"name": "${compSpecName}","image":"docker.io/nginx:latest"}]}}}}'
Krzysztof Kuzmicki83837dc2022-03-23 10:29:20 +0100236 ${kubectl_patch_command_output}= Run And Return Rc And Output ${kubectl_patch}
237 Log ${kubectl_patch_command_output[1]}
238 Should Be Equal As Integers ${kubectl_patch_command_output[0]} 0
239 Wait Until Keyword Succeeds 4 min 15s Check NGINX Applictaion ${compSpecName}
Katarzyna Wasield1bc6cb2021-02-10 08:50:57 +0100240
Krzysztof Kuzmicki83837dc2022-03-23 10:29:20 +0100241Check NGINX Applictaion
242 [Arguments] ${compSpecName}
Andreas Geissler633768a2022-10-24 13:16:29 +0200243 ${check_command}= Set Variable kubectl get deployment -n onap | grep ${compSpecName} | grep 1/1
Krzysztof Kuzmicki83837dc2022-03-23 10:29:20 +0100244 ${check_command_command_output}= Run And Return Rc And Output ${check_command}
245 Log ${check_command_command_output[1]}
246 Should Be Equal As Integers ${check_command_command_output[0]} 0
247
248Undeploy Application
249 [Arguments] ${CHART_NAME}
250 Uninstall helm charts ${ONAP_HELM_RELEASE}-${CHART_NAME}
Katarzyna Wasield1bc6cb2021-02-10 08:50:57 +0100251
252Get Process Group Revision
253 [Arguments] ${processGroupId}
254 ${session}= Create Session ${SESSION_NAME} ${DCAEMOD_DESIGNTOOL_SERVER}
255 ${headers}= Create Dictionary content-type=application/json
256 ${resp} = Get Request ${SESSION_NAME} /nifi-api/versions/process-groups/${processGroupId} headers=${headers}
257 Should Be True ${resp.status_code} < 300
258 ${currentProcessGrVersion} = Set Variable ${resp.json().get('processGroupRevision').get('version')}
259 ${clientId} = Set Variable ${resp.json().get('processGroupRevision').get('clientId')}
260
261 [Return] ${currentProcessGrVersion} ${clientId}
262
263Delete Distribution Target
264 ${session}= Create Session distributor ${DCAEMOD_DISTRIBUTOR_API_SERVER}
265 ${resp} = Delete Request distributor /distributor/distribution-targets/${DISTRIBUTION_TARGET_ID}
266 Should Be True ${resp.status_code} < 300
267
268Delete Process Group
269 [Arguments] ${processGroupId}
270 ${session}= Create Session ${SESSION_NAME} ${DCAEMOD_DESIGNTOOL_SERVER}
271 ${processGrVersion} ${clientId}= Get Process Group Revision ${processGroupId}
272 ${resp} = Delete Request ${SESSION_NAME} /nifi-api/process-groups/${processGroupId}?version=${processGrVersion}&clientId=${clientId}
273 Should Be True ${resp.status_code} < 300
274
275Delete Registry Client
276 ${session}= Create Session ${SESSION_NAME} ${DCAEMOD_DESIGNTOOL_SERVER}
277 ${resp} = Delete Request ${SESSION_NAME} /nifi-api/controller/registry-clients/${REGISTRY_CLIENT_ID}?version=${REGISTRY_CLIENT_VERSION}
278 Should Be True ${resp.status_code} < 300
279
280Configure Nifi Registry And Distribution Target
Krzysztof Kuzmicki83837dc2022-03-23 10:29:20 +0100281 Restart Runtime API
Katarzyna Wasield1bc6cb2021-02-10 08:50:57 +0100282 Add Registry Client
283 Add Distribution Target
Krzysztof Kuzmicki83837dc2022-03-23 10:29:20 +0100284 Add chart repository chart-museum http://chart-museum:80 onapinitializer demo123456!
285 ${command_output} = Run And Return Rc And Output ${HELM_RELEASE}
286 Should Be Equal As Integers ${command_output[0]} 0
287 Set Global Variable ${ONAP_HELM_RELEASE} ${command_output[1]}
288
289Restart Runtime API
290 ${restart_command}= Set Variable kubectl delete pod $(kubectl get pods -n onap | grep dcaemod-runtime-api | awk '{print $1}') -n onap
291 ${restart_command_command_output}= Run And Return Rc And Output ${restart_command}
292 Log ${restart_command_command_output[1]}
293 Should Be Equal As Integers ${restart_command_command_output[0]} 0
294 Wait Until Keyword Succeeds 2 min 5s Check Runtime API
295
296Check Runtime API
Andreas Geissler9bbdb492022-11-07 10:08:20 +0100297 ${check_command}= Set Variable kubectl get deployment -n onap | grep dcaemod-runtime-api | grep 1/1
Krzysztof Kuzmicki83837dc2022-03-23 10:29:20 +0100298 ${check_command_command_output}= Run And Return Rc And Output ${check_command}
299 Log ${check_command_command_output[1]}
300 Should Be Equal As Integers ${check_command_command_output[0]} 0
Katarzyna Wasield1bc6cb2021-02-10 08:50:57 +0100301
302Delete Nifi Registry And Distribution Target
303 Run Keyword If '${DISTRIBUTION_TARGET_ID}' != '${EMPTY}' Wait Until Keyword Succeeds 2 min 5s Delete Distribution Target
304 Run Keyword If '${REGISTRY_CLIENT_ID}' != '${EMPTY}' Wait Until Keyword Succeeds 2 min 5s Delete Registry Client
305
Krzysztof Kuzmicki83837dc2022-03-23 10:29:20 +0100306Delete Process Group And Deployment
Katarzyna Wasield1bc6cb2021-02-10 08:50:57 +0100307 Run Keyword If ${IS_PROCESS_GROUP_SET} Run Keywords Delete Process Group ${PROCESS_GROUP_ID}
308 ... AND Set Suite Variable ${IS_PROCESS_GROUP_SET} False
Krzysztof Kuzmicki83837dc2022-03-23 10:29:20 +0100309 Run Keyword If ${IS_SERVICE_DEPLOYED} Run Keywords Undeploy Application ${CHART_NAME}
Andreas Geissler633768a2022-10-24 13:16:29 +0200310 ... AND Set Suite Variable ${IS_SERVICE_DEPLOYED} False