Bin Sun | 102cee6 | 2017-09-27 14:57:21 +0800 | [diff] [blame] | 1 | *** settings *** |
| 2 | Resource ../../common.robot |
| 3 | Library Collections |
| 4 | Library RequestsLibrary |
| 5 | Library OperatingSystem |
| 6 | Library json |
| 7 | Library 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 | |
| 15 | #json files |
| 16 | ${auth_info_json} ${SCRIPTS}/../tests/multicloud-vmware/provision/jsoninput/auth_info.json |
| 17 | ${multicloud_create_server_json} ${SCRIPTS}/../tests/multicloud-vmware/nova/jsoninput/multicloud_create_server.json |
| 18 | |
| 19 | #global vars |
| 20 | ${TOKEN} |
| 21 | ${TENANTID} |
| 22 | ${server1Id} |
| 23 | |
| 24 | *** Test Cases *** |
| 25 | |
| 26 | GetAuthToken |
| 27 | [Documentation] Sanity test - Get Auth Token |
| 28 | ${json_value}= json_from_file ${auth_info_json} |
| 29 | ${json_string}= string_from_json ${json_value} |
| 30 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json |
| 31 | Create Session web_session http://${VIO_IP}:9004 headers=${headers} |
| 32 | ${resp}= POST Request web_session ${get_token_url} ${json_string} |
| 33 | ${responese_code}= Convert To String ${resp.status_code} |
| 34 | List Should Contain Value ${return_ok_list} ${responese_code} |
| 35 | ${response_json} json.loads ${resp.content} |
| 36 | ${TOKEN}= Convert To String ${response_json['token']['value']} |
| 37 | ${TENANTID}= Convert To String ${response_json['token']['project']['id']} |
| 38 | Set Global Variable ${TOKEN} |
| 39 | Set Global Variable ${TENANTID} |
| 40 | |
| 41 | CreateServerFuncTest |
| 42 | [Documentation] Sanity Test - Create Server |
| 43 | ${json_value}= json_from_file ${multicloud_create_server_json} |
| 44 | ${json_string}= string_from_json ${json_value} |
| 45 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json X-Auth-Token=${TOKEN} |
| 46 | Create Session web_session http://${VIO_IP}:9004 headers=${headers} |
| 47 | Set Request Body ${json_string} |
| 48 | #Log To Console ${json_string} |
| 49 | ${resp}= Post Request web_session api/multicloud-vio/v0/vmware_fake/nova/${TENANTID}/servers ${json_string} |
| 50 | ${response_code}= Convert To String ${resp.status_code} |
| 51 | List Should Contain Value ${return_ok_list} ${response_code} |
| 52 | ${response_json} json.loads ${resp.content} |
| 53 | #Log To Console ${response_json} |
| 54 | ${server1Id}= Convert To String ${response_json['server']['id']} |
| 55 | Set Global Variable ${server1Id} |
| 56 | |
| 57 | |
| 58 | GetServersFuncTest |
| 59 | [Documentation] Sanity Test - Get Servers |
| 60 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json X-Auth-Token=${TOKEN} |
| 61 | Create Session web_session http://${VIO_IP}:9004 headers=${headers} |
| 62 | ${resp}= Get Request web_session api/multicloud-vio/v0/vmware_fake/nova/${TENANTID}/servers |
| 63 | ${response_code}= Convert To String ${resp.status_code} |
| 64 | List Should Contain Value ${return_ok_list} ${response_code} |
| 65 | ${response_json} json.loads ${resp.content} |
| 66 | #Log To Console ${response_json} |
| 67 | #Log To Console ${server1Id} |
| 68 | |
| 69 | GetServerDetailFuncTest |
| 70 | [Documentation] Sanity Test - Get Server Detail |
| 71 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json X-Auth-Token=${TOKEN} |
| 72 | Create Session web_session http://${VIO_IP}:9004 headers=${headers} |
| 73 | ${resp}= Get Request web_session api/multicloud-vio/v0/vmware_fake/nova/${TENANTID}/servers/detail |
| 74 | ${response_code}= Convert To String ${resp.status_code} |
| 75 | List Should Contain Value ${return_ok_list} ${response_code} |
| 76 | ${response_json} json.loads ${resp.content} |
| 77 | #Log To Console ${response_json} |
| 78 | |
| 79 | GetServerFuncTest |
| 80 | [Documentation] Sanity Test - Get Server |
| 81 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json X-Auth-Token=${TOKEN} |
| 82 | Create Session web_session http://${VIO_IP}:9004 headers=${headers} |
| 83 | ${resp}= Get Request web_session api/multicloud-vio/v0/vmware_fake/nova/${TENANTID}/servers/${server1Id} |
| 84 | ${response_code}= Convert To String ${resp.status_code} |
| 85 | List Should Contain Value ${return_ok_list} ${response_code} |
| 86 | ${response_json} json.loads ${resp.content} |
| 87 | #Log To Console ${response_json} |
| 88 | |
| 89 | ServerActionFuncTest |
| 90 | [Documentation] Sanity Test - Server Action |
| 91 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json X-Auth-Token=${TOKEN} |
| 92 | Create Session web_session http://${VIO_IP}:9004 headers=${headers} |
| 93 | ${resp}= Get Request web_session api/multicloud-vio/v0/vmware_fake/nova/${TENANTID}/servers/${server1Id}/action |
| 94 | ${response_code}= Convert To String ${resp.status_code} |
| 95 | List Should Contain Value ${return_ok_list} ${response_code} |
| 96 | ${response_json} json.loads ${resp.content} |
| 97 | #Log To Console ${response_json} |
| 98 | |
| 99 | DeleteServerFuncTest |
| 100 | [Documentation] Sanity Test - Delete Server |
| 101 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json X-Auth-Token=${TOKEN} |
| 102 | Create Session web_session http://${VIO_IP}:9004 headers=${headers} |
| 103 | ${resp}= Delete Request web_session api/multicloud-vio/v0/vmware_fake/nova/${TENANTID}/servers/${server1Id} |
| 104 | ${response_code}= Convert To String ${resp.status_code} |
| 105 | List Should Contain Value ${delete_ok_list} ${response_code} |