blob: e8e36dc14124e6c6256fff2340cc1f89843ebadf [file] [log] [blame]
Gary Wu9abb61c2018-09-27 10:38:50 -07001*** settings ***
2Resource ../../common.robot
3Library Collections
4Library RequestsLibrary
5Library OperatingSystem
6Library json
7Library HttpLibrary.HTTP
8
9
10*** Variables ***
11@{return_ok_list}= 200 201 202
12@{delete_ok_list}= 200 204
13${get_token_url} /api/multicloud-vio/v0/vmware_fake/identity/v3/auth/tokens
14${get_image_url} /api/multicloud-vio/v0/vmware_fake/glance/v2/images
15${get_image_schema_url} /api/multicloud-vio/v0/vmware_fake/glance/v2/schemas/image
16${image_service} /api/multicloud-vio/v0/vmware_fake/glance/v2/image/file
17
18
19
20#json files
21${auth_info_json} ${SCRIPTS}/../tests/multicloud-vmware/provision/jsoninput/auth_info.json
22${image_file} ${SCRIPTS}/../tests/multicloud-vmware/provision/jsoninput/image_file.json
23
24#global vars
25${TOKEN}
26${IMAGEID}
27
28*** Test Cases ***
29
30GetAuthToken
31 [Documentation] Sanity test - Get Auth Token
32 ${json_value}= json_from_file ${auth_info_json}
33 ${json_string}= string_from_json ${json_value}
34 ${headers} Create Dictionary Content-Type=application/json Accept=application/json
35 Create Session web_session http://${VIO_IP}:9004 headers=${headers}
36 ${resp}= POST Request web_session ${get_token_url} ${json_string}
37 ${responese_code}= Convert To String ${resp.status_code}
38 List Should Contain Value ${return_ok_list} ${responese_code}
39 ${response_json} json.loads ${resp.content}
40 ${TOKEN}= Convert To String ${response_json['token']['value']}
41 ${TENANTID}= Convert To String ${response_json['token']['project']['id']}
42 Set Global Variable ${TOKEN}
43
44
45
46
47
48TestCaseShowImageSchema
49 [Documentation] Sanity test - Show Image Schema
50 ${headers} Create Dictionary Content-Type=application/json Accept=application/json X-Auth-Token=${TOKEN}
51 Create Session web_session http://${VIO_IP}:9004 headers=${headers}
52 ${resp}= Get Request web_session ${get_image_schema_url}
53 ${responese_code}= Convert To String ${resp.status_code}
54 List Should Contain Value ${return_ok_list} ${responese_code}
55
56
57
58
59TestCaseListImages
60 [Documentation] Sanity test - List Images
61 ${headers} Create Dictionary Content-Type=application/json Accept=application/json X-Auth-Token=${TOKEN}
62 Create Session web_session http://${VIO_IP}:9004 headers=${headers}
63 ${resp}= Get Request web_session ${get_image_url}
64 ${responese_code}= Convert To String ${resp.status_code}
65 List Should Contain Value ${return_ok_list} ${responese_code}
66 ${response_json} json.loads ${resp.content}
67 ${IMAGEID}= Convert To String ${response_json['images'][0]['id']}
68 Set Global Variable ${IMAGEID}
69
70
71
72
73TestCaseShowImage
74 [Documentation] Sanity test - Show Image
75 ${headers} Create Dictionary Content-Type=application/json Accept=application/json X-Auth-Token=${TOKEN}
76 Create Session web_session http://${VIO_IP}:9004 headers=${headers}
77 ${resp}= Get Request web_session ${get_image_url}/${IMAGEID}
78 ${responese_code}= Convert To String ${resp.status_code}
79 List Should Contain Value ${return_ok_list} ${responese_code}
80 ${response_json} json.loads ${resp.content}
81 Should Be Equal ${response_json['status']} active
82
83
84
85
86TestCaseUploadImage
87 [Documentation] Sanity test - Upload Image
88 ${json_value}= json_from_file ${image_file}
89 ${json_string}= string_from_json ${json_value}
90 ${headers} Create Dictionary Content-Type=application/json Accept=application/json X-Auth-Token=${TOKEN}
91 Create Session web_session http://${VIO_IP}:9004 headers=${headers}
92 ${resp}= POST Request web_session ${image_service} ${json_string}
93 ${responese_code}= Convert To String ${resp.status_code}
94 List Should Contain Value ${return_ok_list} ${responese_code}
95 ${response_json} json.loads ${resp.content}
96 ${IMAGEID}= Convert To String ${response_json['id']}
97 Set Global Variable ${IMAGEID}
98
99
100
101
102TestCaseDownloadImage
103 [Documentation] Sanity test - Download Image
104 ${headers} Create Dictionary Content-Type=application/json Accept=application/json X-Auth-Token=${TOKEN}
105 Create Session web_session http://${VIO_IP}:9004 headers=${headers}
106 ${resp}= Get Request web_session ${image_service}/${IMAGEID}
107 ${responese_code}= Convert To String ${resp.status_code}
108 List Should Contain Value ${return_ok_list} ${responese_code}
109 ${response_json} json.loads ${resp.content}
110 Should Be Equal ${response_json['status']} active