Update candidate list with capacity attributes and version update
[optf/has.git] / csit / tests / has / optf_has_test.robot
1 *** Settings ***
2 Library       OperatingSystem
3 Library       RequestsLibrary
4 Library       json
5
6 *** Variables ***
7 ${MESSAGE}    {"ping": "ok"}
8 ${BASIC}    Basic
9 ${Music_AUTHVALUE}    Y29uZHVjdG9yOmMwbmR1Y3Qwcg==
10 ${HAS_AUTHVALUE}    YWRtaW4xOnBsYW4uMTU=
11 ${Music_Auth}    ${BASIC} ${Music_AUTHVALUE}
12 ${HAS_Auth}    ${BASIC} ${HAS_AUTHVALUE}
13 ${RESP_STATUS}     "error"
14 ${RESP_MESSAGE_WRONG_VERSION}    "conductor_template_version must be one of: 2016-11-01"
15 ${RESP_MESSAGE_WITHOUT_DEMANDS}    Undefined Demand
16
17 #global variables
18 ${generatedPlanId}
19 ${generatedAID}
20 ${resultStatus}
21
22 *** Test Cases ***
23
24 Check ConductorApi Docker Container
25     [Documentation]    It checks conductor-api docker container is running
26     ${rc}    ${output}=    Run and Return RC and Output    docker ps
27     Log To Console              *********************
28     Log To Console              retrurn_code = ${rc}
29     Log To Console              output = ${output}
30     Should Be Equal As Integers    ${rc}    0
31     Should Contain    ${output}    cond-api
32
33 Check ConductorController Docker Container
34     [Documentation]    It checks conductor-controller docker container is running
35     ${rc}    ${output}=    Run and Return RC and Output    docker ps
36     Log To Console              *********************
37     Log To Console              retrurn_code = ${rc}
38     Log To Console              output = ${output}
39     Should Be Equal As Integers    ${rc}    0
40     Should Contain    ${output}    cond-cont
41
42 Check ConductorSolver Docker Container
43     [Documentation]    It checks conductor-solver docker container is running
44     ${rc}    ${output}=    Run and Return RC and Output    docker ps
45     Log To Console              *********************
46     Log To Console              retrurn_code = ${rc}
47     Log To Console              output = ${output}
48     Should Be Equal As Integers    ${rc}    0
49     Should Contain    ${output}    cond-solv
50
51 Check ConductorReservation Docker Container
52     [Documentation]    It checks conductor-reservation docker container is running
53     ${rc}    ${output}=    Run and Return RC and Output    docker ps
54     Log To Console              *********************
55     Log To Console              retrurn_code = ${rc}
56     Log To Console              output = ${output}
57     Should Be Equal As Integers    ${rc}    0
58     Should Contain    ${output}    cond-resv
59
60 Check ConductorData Docker Container
61     [Documentation]    It checks conductor-data docker container is running
62     ${rc}    ${output}=    Run and Return RC and Output    docker ps
63     Log To Console              *********************
64     Log To Console              retrurn_code = ${rc}
65     Log To Console              output = ${output}
66     Should Be Equal As Integers    ${rc}    0
67     Should Contain    ${output}    cond-data
68
69 Get Root Url
70     [Documentation]    It sends a REST GET request to root url
71     Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
72     &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
73     ${resp}=         Get Request        optf-cond   /     headers=${headers}
74     Log To Console              *********************
75     Log To Console              response = ${resp}
76     Log To Console              body = ${resp.text}
77     Should Be Equal As Integers    ${resp.status_code}    200
78     Sleep    10s    Wait For 10 seconds
79
80 Healthcheck
81     [Documentation]    It sends a REST GET request to healthcheck url
82     Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
83     &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
84     ${resp}=         Get Request        optf-cond   /v1/plans/healthcheck     headers=${headers}
85     Log To Console              *********************
86     Log To Console              response = ${resp}
87     Log To Console              body = ${resp.text}
88     Should Be Equal As Integers    ${resp.status_code}    200
89
90 SendPlanWithWrongVersion
91     [Documentation]    It sends a POST request to conductor
92     Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
93     ${data}=         Get Binary File     ${CURDIR}${/}data${/}plan_with_wrong_version.json
94     &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
95     ${resp}=         Post Request        optf-cond   /v1/plans     data=${data}     headers=${headers}
96     Log To Console              *********************
97     Log To Console              response = ${resp}
98     Log To Console              body = ${resp.text}
99     ${response_json}    json.loads    ${resp.content}
100     ${generatedPlanId}=    Convert To String      ${response_json['id']}
101     Set Global Variable     ${generatedPlanId}
102     Log To Console              generatedPlanId = ${generatedPlanId}
103     Should Be Equal As Integers    ${resp.status_code}    201
104     Sleep    10s    Wait Plan Resolution
105
106 GetPlanWithWrongVersion
107     [Documentation]    It sends a REST GET request to capture error
108     Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
109     &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
110     ${resp}=         Get Request        optf-cond   /v1/plans/${generatedPlanId}    headers=${headers}
111     Log To Console              *********************
112     Log To Console              response = ${resp}
113     ${response_json}    json.loads    ${resp.content}
114     ${resultStatus}=    Convert To String      ${response_json['plans'][0]['status']}
115     Set Global Variable     ${resultStatus}
116     Log To Console              resultStatus = ${resultStatus}
117     Log To Console              body = ${resp.text}
118     Should Be Equal As Integers    ${resp.status_code}    200
119     Should Be Equal    error    ${resultStatus}
120
121 SendPlanWithoutDemandSection
122     [Documentation]    It sends a POST request to conductor
123     Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
124     ${data}=         Get Binary File     ${CURDIR}${/}data${/}plan_without_demand_section.json
125     &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
126     ${resp}=         Post Request        optf-cond   /v1/plans     data=${data}     headers=${headers}
127     Log To Console              *********************
128     Log To Console              response = ${resp}
129     Log To Console              body = ${resp.text}
130     ${response_json}    json.loads    ${resp.content}
131     ${generatedPlanId}=    Convert To String      ${response_json['id']}
132     Set Global Variable     ${generatedPlanId}
133     Log To Console              generatedPlanId = ${generatedPlanId}
134     Should Be Equal As Integers    ${resp.status_code}    201
135     Sleep    10s    Wait Plan Resolution
136
137 GetPlanWithoutDemandSection
138     [Documentation]    It sends a REST GET request to capture error
139     Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
140     &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
141     ${resp}=         Get Request        optf-cond   /v1/plans/${generatedPlanId}    headers=${headers}
142     Log To Console              *********************
143     Log To Console              response = ${resp}
144     ${response_json}    json.loads    ${resp.content}
145     ${resultStatus}=    Convert To String      ${response_json['plans'][0]['status']}
146     Set Global Variable     ${resultStatus}
147     Log To Console              resultStatus = ${resultStatus}
148     Log To Console              body = ${resp.text}
149     Should Be Equal As Integers    ${resp.status_code}    200
150     Should Be Equal    error    ${resultStatus}
151
152 SendPlanWithWrongConstraint
153     [Documentation]    It sends a POST request to conductor
154     Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
155     ${data}=         Get Binary File     ${CURDIR}${/}data${/}plan_with_wrong_distance_constraint.json
156     &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
157     ${resp}=         Post Request        optf-cond   /v1/plans     data=${data}     headers=${headers}
158     Log To Console              *********************
159     Log To Console              response = ${resp}
160     Log To Console              body = ${resp.text}
161     ${response_json}    json.loads    ${resp.content}
162     ${generatedPlanId}=    Convert To String      ${response_json['id']}
163     Set Global Variable     ${generatedPlanId}
164     Log To Console              generatedPlanId = ${generatedPlanId}
165     Should Be Equal As Integers    ${resp.status_code}    201
166     Sleep    10s    Wait Plan Resolution
167
168 GetPlanWithWrongConstraint
169     [Documentation]    It sends a REST GET request to capture error
170     Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
171     &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
172     ${resp}=         Get Request        optf-cond   /v1/plans/${generatedPlanId}    headers=${headers}
173     Log To Console              *********************
174     Log To Console              response = ${resp}
175     ${response_json}    json.loads    ${resp.content}
176     ${resultStatus}=    Convert To String      ${response_json['plans'][0]['status']}
177     Set Global Variable     ${resultStatus}
178     Log To Console              resultStatus = ${resultStatus}
179     Log To Console              body = ${resp.text}
180     Should Be Equal As Integers    ${resp.status_code}    200
181     Should Be Equal    error    ${resultStatus}
182
183
184 SendPlanWithLatiAndLongi
185     [Documentation]    It sends a POST request to conductor
186     Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
187     ${data}=         Get Binary File     ${CURDIR}${/}data${/}plan_with_lati_and_longi.json
188     &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
189     ${resp}=         Post Request        optf-cond   /v1/plans     data=${data}     headers=${headers}
190     Log To Console              *********************
191     Log To Console              response = ${resp}
192     Log To Console              body = ${resp.text}
193     ${response_json}    json.loads    ${resp.content}
194     ${generatedPlanId}=    Convert To String      ${response_json['id']}
195     Set Global Variable     ${generatedPlanId}
196     Log To Console              generatedPlanId = ${generatedPlanId}
197     Should Be Equal As Integers    ${resp.status_code}    201
198     Sleep    60s    Wait Plan Resolution
199
200 GetPlanWithLatiAndLongi
201     [Documentation]    It sends a REST GET request to capture recommendations
202     Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
203     &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
204     ${resp}=         Get Request        optf-cond   /v1/plans/${generatedPlanId}    headers=${headers}
205     Log To Console              *********************
206     Log To Console              response = ${resp}
207     ${response_json}    json.loads    ${resp.content}
208     ${resultStatus}=    Convert To String      ${response_json['plans'][0]['status']}
209     Set Global Variable     ${resultStatus}
210     Log To Console              resultStatus = ${resultStatus}
211     Log To Console              body = ${resp.text}
212     Should Be Equal As Integers    ${resp.status_code}    200
213     Should Be Equal    done    ${resultStatus}
214
215 SendPlanWithShortDistanceConstraint
216     [Documentation]    It sends a POST request to conductor
217     Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
218     ${data}=         Get Binary File     ${CURDIR}${/}data${/}plan_with_short_distance_constraint.json
219     &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
220     ${resp}=         Post Request        optf-cond   /v1/plans     data=${data}     headers=${headers}
221     Log To Console              *********************
222     Log To Console              response = ${resp}
223     Log To Console              body = ${resp.text}
224     ${response_json}    json.loads    ${resp.content}
225     ${generatedPlanId}=    Convert To String      ${response_json['id']}
226     Set Global Variable     ${generatedPlanId}
227     Log To Console              generatedPlanId = ${generatedPlanId}
228     Should Be Equal As Integers    ${resp.status_code}    201
229     Sleep    60s    Wait Plan Resolution
230
231 GetPlanWithShortDistanceConstraint
232     [Documentation]    It sends a REST GET request to capture recommendations
233     Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
234     &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
235     ${resp}=         Get Request        optf-cond   /v1/plans/${generatedPlanId}    headers=${headers}
236     Log To Console              *********************
237     Log To Console              response = ${resp}
238     ${response_json}    json.loads    ${resp.content}
239     ${resultStatus}=    Convert To String      ${response_json['plans'][0]['status']}
240     Set Global Variable     ${resultStatus}
241     Log To Console              resultStatus = ${resultStatus}
242     Log To Console              body = ${resp.text}
243     Should Be Equal As Integers    ${resp.status_code}    200
244     Should Be Equal    not found    ${resultStatus}
245
246 SendPlanWithVimFit
247     [Documentation]    It sends a POST request to conductor
248     Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
249     ${data}=         Get Binary File     ${CURDIR}${/}data${/}plan_with_vim_fit.json
250     &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
251     ${resp}=         Post Request        optf-cond   /v1/plans     data=${data}     headers=${headers}
252     Log To Console              *********************
253     Log To Console              response = ${resp}
254     Log To Console              body = ${resp.text}
255     ${response_json}    json.loads    ${resp.content}
256     ${generatedPlanId}=    Convert To String      ${response_json['id']}
257     Set Global Variable     ${generatedPlanId}
258     Log To Console              generatedPlanId = ${generatedPlanId}
259     Should Be Equal As Integers    ${resp.status_code}    201
260     Sleep    60s    Wait Plan Resolution
261
262 GetPlanWithVimFit
263     [Documentation]    It sends a REST GET request to capture recommendations
264     Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
265     &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
266     ${resp}=         Get Request        optf-cond   /v1/plans/${generatedPlanId}    headers=${headers}
267     Log To Console              *********************
268     Log To Console              response = ${resp}
269     ${response_json}    json.loads    ${resp.content}
270     ${resultStatus}=    Convert To String      ${response_json['plans'][0]['status']}
271     Set Global Variable     ${resultStatus}
272     Log To Console              resultStatus = ${resultStatus}
273     Log To Console              body = ${resp.text}
274     Should Be Equal As Integers    ${resp.status_code}    200
275     Should Be Equal    done    ${resultStatus}
276
277 SendPlanWithHpa
278     [Documentation]    It sends a POST request to conductor
279     Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
280     ${data}=         Get Binary File     ${CURDIR}${/}data${/}plan_with_hpa.json
281     &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
282     ${resp}=         Post Request        optf-cond   /v1/plans     data=${data}     headers=${headers}
283     Log To Console              *********************
284     Log To Console              response = ${resp}
285     Log To Console              body = ${resp.text}
286     ${response_json}    json.loads    ${resp.content}
287     ${generatedPlanId}=    Convert To String      ${response_json['id']}
288     Set Global Variable     ${generatedPlanId}
289     Log To Console              generatedPlanId = ${generatedPlanId}
290     Should Be Equal As Integers    ${resp.status_code}    201
291     Sleep    60s    Wait Plan Resolution
292
293 GetPlanWithHpa
294     [Documentation]    It sends a REST GET request to capture recommendations
295     Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
296     &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
297     ${resp}=         Get Request        optf-cond   /v1/plans/${generatedPlanId}    headers=${headers}
298     Log To Console              *********************
299     Log To Console              response = ${resp}
300     ${response_json}    json.loads    ${resp.content}
301     ${resultStatus}=    Convert To String      ${response_json['plans'][0]['status']}
302     Set Global Variable     ${resultStatus}
303     Log To Console              resultStatus = ${resultStatus}
304     Log To Console              body = ${resp.text}
305     Should Be Equal As Integers    ${resp.status_code}    200
306     Should Be Equal    done    ${resultStatus}
307
308 SendPlanWithHpaSimple
309     [Documentation]    It sends a POST request to conductor
310     Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
311     ${data}=         Get Binary File     ${CURDIR}${/}data${/}plan_with_hpa_simple.json
312     &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
313     ${resp}=         Post Request        optf-cond   /v1/plans     data=${data}     headers=${headers}
314     Log To Console              *********************
315     Log To Console              response = ${resp}
316     Log To Console              body = ${resp.text}
317     ${response_json}    json.loads    ${resp.content}
318     ${generatedPlanId}=    Convert To String      ${response_json['id']}
319     Set Global Variable     ${generatedPlanId}
320     Log To Console              generatedPlanId = ${generatedPlanId}
321     Should Be Equal As Integers    ${resp.status_code}    201
322     Sleep    60s    Wait Plan Resolution
323
324 GetPlanWithHpaSimple
325     [Documentation]    It sends a REST GET request to capture recommendations
326     Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
327     &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
328     ${resp}=         Get Request        optf-cond   /v1/plans/${generatedPlanId}    headers=${headers}
329     Log To Console              *********************
330     Log To Console              response = ${resp}
331     ${response_json}    json.loads    ${resp.content}
332     ${resultStatus}=    Convert To String      ${response_json['plans'][0]['status']}
333     Set Global Variable     ${resultStatus}
334     Log To Console              resultStatus = ${resultStatus}
335     Log To Console              body = ${resp.text}
336     Should Be Equal As Integers    ${resp.status_code}    200
337     Should Be Equal    done    ${resultStatus}
338
339 SendPlanWithHpaMandatory
340     [Documentation]    It sends a POST request to conductor
341     Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
342     ${data}=         Get Binary File     ${CURDIR}${/}data${/}plan_with_hpa_requirements_mandatory.json
343     &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
344     ${resp}=         Post Request        optf-cond   /v1/plans     data=${data}     headers=${headers}
345     Log To Console              *********************
346     Log To Console              response = ${resp}
347     Log To Console              body = ${resp.text}
348     ${response_json}    json.loads    ${resp.content}
349     ${generatedPlanId}=    Convert To String      ${response_json['id']}
350     Set Global Variable     ${generatedPlanId}
351     Log To Console              generatedPlanId = ${generatedPlanId}
352     Should Be Equal As Integers    ${resp.status_code}    201
353     Sleep    60s    Wait Plan Resolution
354
355 GetPlanWithHpaMandatory
356     [Documentation]    It sends a REST GET request to capture recommendations
357     Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
358     &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
359     ${resp}=         Get Request        optf-cond   /v1/plans/${generatedPlanId}    headers=${headers}
360     Log To Console              *********************
361     Log To Console              response = ${resp}
362     ${response_json}    json.loads    ${resp.content}
363     ${resultStatus}=    Convert To String      ${response_json['plans'][0]['status']}
364     Set Global Variable     ${resultStatus}
365     Log To Console              resultStatus = ${resultStatus}
366     Log To Console              body = ${resp.text}
367     Should Be Equal As Integers    ${resp.status_code}    200
368     Should Be Equal    done    ${resultStatus}
369
370 SendPlanWithHpaOptionals
371     [Documentation]    It sends a POST request to conductor
372     Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
373     ${data}=         Get Binary File     ${CURDIR}${/}data${/}plan_with_hpa_requirements_optionals.json
374     &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
375     ${resp}=         Post Request        optf-cond   /v1/plans     data=${data}     headers=${headers}
376     Log To Console              *********************
377     Log To Console              response = ${resp}
378     Log To Console              body = ${resp.text}
379     ${response_json}    json.loads    ${resp.content}
380     ${generatedPlanId}=    Convert To String      ${response_json['id']}
381     Set Global Variable     ${generatedPlanId}
382     Log To Console              generatedPlanId = ${generatedPlanId}
383     Should Be Equal As Integers    ${resp.status_code}    201
384     Sleep    60s    Wait Plan Resolution
385
386 GetPlanWithHpaOptionals
387     [Documentation]    It sends a REST GET request to capture recommendations
388     Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
389     &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
390     ${resp}=         Get Request        optf-cond   /v1/plans/${generatedPlanId}    headers=${headers}
391     Log To Console              *********************
392     Log To Console              response = ${resp}
393     ${response_json}    json.loads    ${resp.content}
394     ${resultStatus}=    Convert To String      ${response_json['plans'][0]['status']}
395     Set Global Variable     ${resultStatus}
396     Log To Console              resultStatus = ${resultStatus}
397     Log To Console              body = ${resp.text}
398     Should Be Equal As Integers    ${resp.status_code}    200
399     Should Be Equal    done    ${resultStatus}
400
401 SendPlanWithHpaUnmatched
402     [Documentation]    It sends a POST request to conductor
403     Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
404     ${data}=         Get Binary File     ${CURDIR}${/}data${/}plan_with_hpa_unmatched.json
405     &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
406     ${resp}=         Post Request        optf-cond   /v1/plans     data=${data}     headers=${headers}
407     Log To Console              *********************
408     Log To Console              response = ${resp}
409     Log To Console              body = ${resp.text}
410     ${response_json}    json.loads    ${resp.content}
411     ${generatedPlanId}=    Convert To String      ${response_json['id']}
412     Set Global Variable     ${generatedPlanId}
413     Log To Console              generatedPlanId = ${generatedPlanId}
414     Should Be Equal As Integers    ${resp.status_code}    201
415     Sleep    60s    Wait Plan Resolution
416
417 GetPlanWithHpaUnmatched
418     [Documentation]    It sends a REST GET request to capture recommendations
419     Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
420     &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
421     ${resp}=         Get Request        optf-cond   /v1/plans/${generatedPlanId}    headers=${headers}
422     Log To Console              *********************
423     Log To Console              response = ${resp}
424     ${response_json}    json.loads    ${resp.content}
425     ${resultStatus}=    Convert To String      ${response_json['plans'][0]['status']}
426     Set Global Variable     ${resultStatus}
427     Log To Console              resultStatus = ${resultStatus}
428     Log To Console              body = ${resp.text}
429     Should Be Equal As Integers    ${resp.status_code}    200
430     Should Be Equal    not found    ${resultStatus}
431
432 # HPA Score Multi objective Optimization
433 SendPlanWithHpaScoreMultiObj
434     [Documentation]    It sends a POST request to conductor
435     Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
436     ${data}=         Get Binary File     ${CURDIR}${/}data${/}plan_with_hpa_score_multi_objective.json
437     &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
438     ${resp}=         Post Request        optf-cond   /v1/plans     data=${data}     headers=${headers}
439     Log To Console              *********************
440     Log To Console              response = ${resp}
441     Log To Console              body = ${resp.text}
442     ${response_json}    json.loads    ${resp.content}
443     ${generatedPlanId}=    Convert To String      ${response_json['id']}
444     Set Global Variable     ${generatedPlanId}
445     Log To Console              generatedPlanId = ${generatedPlanId}
446     Should Be Equal As Integers    ${resp.status_code}    201
447     Sleep    60s    Wait Plan Resolution
448
449 GetPlanWithHpaScoreMultiObj
450     [Documentation]    It sends a REST GET request to capture recommendations
451     Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
452     &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
453     ${resp}=         Get Request        optf-cond   /v1/plans/${generatedPlanId}    headers=${headers}
454     Log To Console              *********************
455     Log To Console              response = ${resp}
456     ${response_json}    json.loads    ${resp.content}
457     ${resultStatus}=    Convert To String      ${response_json['plans'][0]['status']}
458     ${vim-id}=    Convert To String      ${response_json['plans'][0]['recommendations'][0]['vG']['candidate']['vim-id']}
459     # ${hpa_score}=    Convert To String      ${response_json['plans'][0]['recommendations']['vG']['hpa_score']}
460     Set Global Variable     ${resultStatus}
461     Log To Console              resultStatus = ${resultStatus}
462     Log To Console              body = ${resp.text}
463     Should Be Equal As Integers    ${resp.status_code}    200
464     Should Be Equal    done    ${resultStatus}
465     Should Be Equal    HPA-cloud_cloud-region-1    ${vim-id}
466
467 # NSI selection template
468 SendPlanWithNsiSelection
469     [Documentation]    It sends a POST request to conductor
470     Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
471     ${data}=         Get Binary File     ${CURDIR}${/}data${/}nsi_selection_template_with_reuse.json
472     &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
473     ${resp}=         Post Request        optf-cond   /v1/plans     data=${data}     headers=${headers}
474     Log To Console              *********************
475     Log To Console              response = ${resp}
476     Log To Console              body = ${resp.text}
477     ${response_json}    json.loads    ${resp.content}
478     ${generatedPlanId}=    Convert To String      ${response_json['id']}
479     Set Global Variable     ${generatedPlanId}
480     Log To Console              generatedPlanId = ${generatedPlanId}
481     Should Be Equal As Integers    ${resp.status_code}    201
482     Sleep    60s    Wait Plan Resolution
483
484 #GetPlanWithNsiSelection
485 #    [Documentation]    It sends a REST GET request to capture recommendations
486 #    Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
487 #    &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
488 #    ${resp}=         Get Request        optf-cond   /v1/plans/${generatedPlanId}    headers=${headers}
489 #    Log To Console              *********************
490 #   Log To Console              response = ${resp}
491 #    ${response_json}    json.loads    ${resp.content}
492 #    ${resultStatus}=    Convert To String      ${response_json['plans'][0]['status']}
493 #    ${instance_name}=    Convert To String      ${response_json['plans'][0]['recommendations'][0]['URLLC']['candidate']['instance_name']}
494 #    Set Global Variable     ${resultStatus}
495 #    Log To Console              resultStatus = ${resultStatus}
496 #    Log To Console              body = ${resp.text}
497 #    Should Be Equal As Integers    ${resp.status_code}    200
498 #    Should Be Equal    done    ${resultStatus}
499 #    Should Be Equal    nsi_test_0211    ${instance_name}
500
501 SendPlanWithNsiSelectionSliceProfile
502     [Documentation]    It sends a POST request to conductor
503     Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
504     ${data}=         Get Binary File     ${CURDIR}${/}data${/}nsi_selection_template_with_create.json
505     &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
506     ${resp}=         Post Request        optf-cond   /v1/plans     data=${data}     headers=${headers}
507     Log To Console              *********************
508     Log To Console              response = ${resp}
509     Log To Console              body = ${resp.text}
510     ${response_json}    json.loads    ${resp.content}
511     ${generatedPlanId}=    Convert To String      ${response_json['id']}
512     Set Global Variable     ${generatedPlanId}
513     Log To Console              generatedPlanId = ${generatedPlanId}
514     Should Be Equal As Integers    ${resp.status_code}    201
515     Sleep    60s    Wait Plan Resolution
516
517 #GetPlanWithNsiSelectionSliceProfile
518 #    [Documentation]    It sends a REST GET request to capture recommendations
519 #    Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
520 #    &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
521 #    ${resp}=         Get Request        optf-cond   /v1/plans/${generatedPlanId}    headers=${headers}
522 #    Log To Console              *********************
523 #    Log To Console              response = ${resp}
524 #    ${response_json}    json.loads    ${resp.content}
525 #    ${resultStatus}=    Convert To String      ${response_json['plans'][0]['status']}
526 #    ${candidate_type}=    Convert To String      ${response_json['plans'][0]['recommendations'][0]['URLLC']['candidate']['inventory_type']}
527 #    Set Global Variable     ${resultStatus}
528 #    Log To Console              resultStatus = ${resultStatus}
529 #    Log To Console              body = ${resp.text}
530 #    Should Be Equal As Integers    ${resp.status_code}    200
531 #    Should Be Equal    done    ${resultStatus}
532 #    Should Be Equal    slice_profiles    ${candidate_type}
533
534 SendPlanWithNoNsi
535     [Documentation]    It sends a POST request to conductor
536     Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
537     ${data}=         Get Binary File     ${CURDIR}${/}data${/}nsi_selection_template_with_nonsi.json
538     &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
539     ${resp}=         Post Request        optf-cond   /v1/plans     data=${data}     headers=${headers}
540     Log To Console              *********************
541     Log To Console              response = ${resp}
542     Log To Console              body = ${resp.text}
543     ${response_json}    json.loads    ${resp.content}
544     ${generatedPlanId}=    Convert To String      ${response_json['id']}
545     Set Global Variable     ${generatedPlanId}
546     Log To Console              generatedPlanId = ${generatedPlanId}
547     Should Be Equal As Integers    ${resp.status_code}    201
548     Sleep    60s    Wait Plan Resolution
549
550 #GetPlanWithNoNsi
551 #    [Documentation]    It sends a REST GET request to capture recommendations
552 #    Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
553 #    &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
554 #    ${resp}=         Get Request        optf-cond   /v1/plans/${generatedPlanId}    headers=${headers}
555 #    Log To Console              *********************
556 #    Log To Console              response = ${resp}
557 #    ${response_json}    json.loads    ${resp.content}
558 #    ${resultStatus}=    Convert To String      ${response_json['plans'][0]['status']}
559 #    ${candidate_type}=    Convert To String      ${response_json['plans'][0]['recommendations'][0]['URLLC']['candidate']['inventory_type']}
560 #    Set Global Variable     ${resultStatus}
561 #    Log To Console              resultStatus = ${resultStatus}
562 #    Log To Console              body = ${resp.text}
563 #    Should Be Equal As Integers    ${resp.status_code}    200
564 #    Should Be Equal    done    ${resultStatus}
565 #    Should Be Equal    slice_profiles    ${candidate_type}
566
567 SendPlanWithNssiSelection
568     [Documentation]    It sends a POST request to conductor
569     Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
570     ${data}=         Get Binary File     ${CURDIR}${/}data${/}nssi_selection_template.json
571     &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
572     ${resp}=         Post Request        optf-cond   /v1/plans     data=${data}     headers=${headers}
573     Log To Console              *********************
574     Log To Console              response = ${resp}
575     Log To Console              body = ${resp.text}
576     ${response_json}    json.loads    ${resp.content}
577     ${generatedPlanId}=    Convert To String      ${response_json['id']}
578     Set Global Variable     ${generatedPlanId}
579     Log To Console              generatedPlanId = ${generatedPlanId}
580     Should Be Equal As Integers    ${resp.status_code}    201
581     Sleep    60s    Wait Plan Resolution
582
583 #GetPlanWithNssiSelection
584 #    [Documentation]    It sends a REST GET request to capture recommendations
585 #    Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
586 #    &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
587 #    ${resp}=         Get Request        optf-cond   /v1/plans/${generatedPlanId}    headers=${headers}
588 #    Log To Console              *********************
589 #    Log To Console              response = ${resp}
590 #    ${response_json}    json.loads    ${resp.content}
591 #    ${resultStatus}=    Convert To String      ${response_json['plans'][0]['status']}
592 #    ${instance_name}=    Convert To String      ${response_json['plans'][0]['recommendations'][0]['URLLC_core']['candidate']['instance_name']}
593 #    Set Global Variable     ${resultStatus}
594 #    Log To Console              resultStatus = ${resultStatus}
595 #    Log To Console              body = ${resp.text}
596 #    Should Be Equal As Integers    ${resp.status_code}    200
597 #    Should Be Equal    done    ${resultStatus}
598 #    Should Be Equal    nssi_test_0211    ${instance_name}
599
600 SendPlanWithNssiSelectionUnmatched
601     [Documentation]    It sends a POST request to conductor
602     Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
603     ${data}=         Get Binary File     ${CURDIR}${/}data${/}nssi_selection_template_unmatched.json
604     &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
605     ${resp}=         Post Request        optf-cond   /v1/plans     data=${data}     headers=${headers}
606     Log To Console              *********************
607     Log To Console              response = ${resp}
608     Log To Console              body = ${resp.text}
609     ${response_json}    json.loads    ${resp.content}
610     ${generatedPlanId}=    Convert To String      ${response_json['id']}
611     Set Global Variable     ${generatedPlanId}
612     Log To Console              generatedPlanId = ${generatedPlanId}
613     Should Be Equal As Integers    ${resp.status_code}    201
614     Sleep    60s    Wait Plan Resolution
615
616 #GetPlanWithNssiSelectionUnmatched
617 #    [Documentation]    It sends a REST GET request to capture recommendations
618 #    Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
619 #    &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
620 #    ${resp}=         Get Request        optf-cond   /v1/plans/${generatedPlanId}    headers=${headers}
621 #    Log To Console              *********************
622 #    Log To Console              response = ${resp}
623 #    ${response_json}    json.loads    ${resp.content}
624 #    ${resultStatus}=    Convert To String      ${response_json['plans'][0]['status']}
625 #    Set Global Variable     ${resultStatus}
626 #    Log To Console              resultStatus = ${resultStatus}
627 #    Log To Console              body = ${resp.text}
628 #    Should Be Equal As Integers    ${resp.status_code}    200
629 #    Should Be Equal    not found    ${resultStatus}
630
631 # NST selection template
632 SendPlanWithNSTSelection
633     [Documentation]    It sends a POST request to conductor
634     Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
635     ${data}=         Get Binary File     ${CURDIR}${/}data${/}nst_selection_template.json
636     &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
637     ${resp}=         Post Request        optf-cond   /v1/plans     data=${data}     headers=${headers}
638     Log To Console              *********************
639     Log To Console              response = ${resp}
640     Log To Console              body = ${resp.text}
641     ${response_json}    json.loads    ${resp.content}
642     ${generatedPlanId}=    Convert To String      ${response_json['id']}
643     Set Global Variable     ${generatedPlanId}
644     Log To Console              generatedPlanId = ${generatedPlanId}
645     Should Be Equal As Integers    ${resp.status_code}    201
646     Sleep    60s    Wait Plan Resolution
647
648 GetPlanWithNsTSelection
649     [Documentation]    It sends a REST GET request to capture recommendations
650     Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
651     &{headers}=      Create Dictionary    Authorization=${HAS_Auth}    Content-Type=application/json  Accept=application/json
652     ${resp}=         Get Request        optf-cond   /v1/plans/${generatedPlanId}    headers=${headers}
653     Log To Console              *********************
654     Log To Console              response = ${resp}
655     ${response_json}    json.loads    ${resp.content}
656     ${resultStatus}=    Convert To String      ${response_json['plans'][0]['status']}
657     ${instance_name}=    Convert To String      ${response_json['plans'][0]['recommendations'][0]['nst_demand']['candidate']['model_name']}
658     Set Global Variable     ${resultStatus}
659     Log To Console              resultStatus = ${resultStatus}
660     Log To Console              body = ${resp.text}
661     Should Be Equal As Integers    ${resp.status_code}    200
662     Should Be Equal    done    ${resultStatus}
663     Should Be Equal    EmbbNst    ${instance_name}
664
665
666 *** Keywords ***
667
668