Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 1 | *** settings *** |
fujinhua | f2490e7 | 2019-04-28 10:32:40 +0800 | [diff] [blame] | 2 | Resource ../../common.robot |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 3 | Library Collections |
| 4 | Library RequestsLibrary |
| 5 | Library OperatingSystem |
| 6 | Library json |
fujinhua | f2490e7 | 2019-04-28 10:32:40 +0800 | [diff] [blame] | 7 | Library HttpLibrary.HTTP |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 8 | |
| 9 | *** Variables *** |
fujinhua | 73c7480 | 2019-04-28 16:27:22 +0800 | [diff] [blame] | 10 | @{return_ok_list}= 200 201 202 204 |
| 11 | ${catalog_port} 8806 |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 12 | ${queryswagger_url} /api/catalog/v1/swagger.json |
| 13 | ${queryVNFPackage_url} /api/catalog/v1/vnfpackages |
| 14 | ${queryNSPackages_url} /api/catalog/v1/nspackages |
fujinhua | e23e047 | 2019-04-04 16:24:48 +0800 | [diff] [blame] | 15 | ${healthcheck_url} /api/catalog/v1/health_check |
fujinhua | f2490e7 | 2019-04-28 10:32:40 +0800 | [diff] [blame] | 16 | ${create_subs_url} /api/vnfpkgm/v1/subscriptions |
fujinhua | 73c7480 | 2019-04-28 16:27:22 +0800 | [diff] [blame] | 17 | ${delete_subs_url} /api/vnfpkgm/v1/subscriptions |
fujinhua | f2490e7 | 2019-04-28 10:32:40 +0800 | [diff] [blame] | 18 | |
| 19 | #json files |
| 20 | ${vnf_subscription_json} ${SCRIPTS}/../tests/vfc/nfvo-catalog/jsons/vnf_subscription.json |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 21 | |
fujinhua | 73c7480 | 2019-04-28 16:27:22 +0800 | [diff] [blame] | 22 | #global variables |
| 23 | ${subscriptionId} |
| 24 | |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 25 | *** Test Cases *** |
| 26 | GetVNFPackages |
| 27 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json |
fujinhua | 73c7480 | 2019-04-28 16:27:22 +0800 | [diff] [blame] | 28 | Create Session web_session http://${CATALOG_IP}:${catalog_port} headers=${headers} |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 29 | ${resp}= Get Request web_session ${queryVNFPackage_url} |
| 30 | ${responese_code}= Convert To String ${resp.status_code} |
| 31 | List Should Contain Value ${return_ok_list} ${responese_code} |
fujinhua | e23e047 | 2019-04-04 16:24:48 +0800 | [diff] [blame] | 32 | |
| 33 | CatalogHealthCheckTest |
| 34 | [Documentation] check health for catalog by MSB |
| 35 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json |
fujinhua | 73c7480 | 2019-04-28 16:27:22 +0800 | [diff] [blame] | 36 | Create Session web_session http://${CATALOG_IP}:${catalog_port} headers=${headers} |
fujinhua | e23e047 | 2019-04-04 16:24:48 +0800 | [diff] [blame] | 37 | ${resp}= Get Request web_session ${healthcheck_url} |
| 38 | ${responese_code}= Convert To String ${resp.status_code} |
| 39 | List Should Contain Value ${return_ok_list} ${responese_code} |
| 40 | ${response_json} json.loads ${resp.content} |
| 41 | ${health_status}= Convert To String ${response_json['status']} |
| 42 | Should Be Equal ${health_status} active |
fujinhua | f2490e7 | 2019-04-28 10:32:40 +0800 | [diff] [blame] | 43 | |
| 44 | CreateVnfSubscriptionTest |
| 45 | [Documentation] Create Vnf Subscription function test |
| 46 | ${json_value}= json_from_file ${vnf_subscription_json} |
| 47 | ${json_string}= string_from_json ${json_value} |
| 48 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json |
fujinhua | 73c7480 | 2019-04-28 16:27:22 +0800 | [diff] [blame] | 49 | Create Session web_session http://${CATALOG_IP}:${catalog_port} headers=${headers} |
fujinhua | f2490e7 | 2019-04-28 10:32:40 +0800 | [diff] [blame] | 50 | Set Request Body ${json_string} |
| 51 | ${resp}= Post Request web_session ${create_subs_url} ${json_string} |
| 52 | ${responese_code}= Convert To String ${resp.status_code} |
| 53 | List Should Contain Value ${return_ok_list} ${responese_code} |
| 54 | ${response_json} json.loads ${resp.content} |
| 55 | ${callback_uri}= Convert To String ${response_json['callbackUri']} |
fujinhua | 73c7480 | 2019-04-28 16:27:22 +0800 | [diff] [blame] | 56 | Should Be Equal ${callback_uri} http://127.0.0.1:${catalog_port}/api/catalog/v1/callback_sample |
| 57 | ${subscriptionId}= Convert To String ${response_json['id']} |
| 58 | Set Global Variable ${subscriptionId} |
| 59 | |
| 60 | DeleteVnfSubscriptionTest |
| 61 | [Documentation] Delete Vnf Subscription function test |
| 62 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json |
| 63 | Create Session web_session http://${CATALOG_IP}:${catalog_port} headers=${headers} |
| 64 | ${resp}= Delete Request web_session ${delete_subs_url}/${subscriptionId} |
| 65 | ${responese_code}= Convert To String ${resp.status_code} |
| 66 | List Should Contain Value ${return_ok_list} ${responese_code} |