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 | ${catalog_port} 8806 |
Olivia.Zhan | 4881bf3 | 2019-07-11 09:27:06 +0800 | [diff] [blame] | 11 | ${cataloghealthcheck_url} /api/catalog/v1/health_check |
| 12 | ${vnfpkgmhealthcheck_url} /api/vnfpkgm/v1/health_check |
| 13 | ${nsdhealthcheck_url} /api/nsd/v1/health_check |
| 14 | ${parserhealthcheck_url} /api/parser/v1/health_check |
zhaoliping123 | 39b397e | 2019-10-25 11:22:39 +0800 | [diff] [blame] | 15 | ${service_packages_url} /api/parser/v1/service_packages |
| 16 | ${vnfpackages_url} /api/catalog/v1/vnfpackages |
| 17 | ${nspackages_url} /api/catalog/v1/nspackages |
| 18 | ${jobs_url} /api/catalog/v1/jobs |
| 19 | |
| 20 | #json files |
| 21 | ${ns_packages_json} ${SCRIPTS}/../tests/vfc/nfvo-catalog/jsons/ns_packages.json |
| 22 | ${vnfpackages_catalog_json} ${SCRIPTS}/../tests/vfc/nfvo-catalog/jsons/vnf_packages.json |
| 23 | |
| 24 | #global variables |
| 25 | ${jobId} |
fujinhua | 73c7480 | 2019-04-28 16:27:22 +0800 | [diff] [blame] | 26 | |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 27 | *** Test Cases *** |
Olivia.Zhan | 4881bf3 | 2019-07-11 09:27:06 +0800 | [diff] [blame] | 28 | Check Health Catalog |
| 29 | Log Check Health Catalog |
fujinhua | e23e047 | 2019-04-04 16:24:48 +0800 | [diff] [blame] | 30 | [Documentation] check health for catalog by MSB |
Olivia.Zhan | 4881bf3 | 2019-07-11 09:27:06 +0800 | [diff] [blame] | 31 | Check Health ${cataloghealthcheck_url} |
fujinhua | f2490e7 | 2019-04-28 10:32:40 +0800 | [diff] [blame] | 32 | |
Olivia.Zhan | 4881bf3 | 2019-07-11 09:27:06 +0800 | [diff] [blame] | 33 | Check Health Vnfpkgm |
| 34 | Log Check Health Vnfpkgm |
| 35 | [Documentation] check health for Vnfpkgm by MSB |
| 36 | Check Health ${vnfpkgmhealthcheck_url} |
fujinhua | 73c7480 | 2019-04-28 16:27:22 +0800 | [diff] [blame] | 37 | |
Olivia.Zhan | 4881bf3 | 2019-07-11 09:27:06 +0800 | [diff] [blame] | 38 | Check Health Nsd |
| 39 | Log Check Health Nsd |
| 40 | [Documentation] check health for Nsd by MSB |
| 41 | Check Health ${nsdhealthcheck_url} |
| 42 | |
| 43 | Check Health Parser |
| 44 | Log Check Health Parser |
| 45 | [Documentation] check health for Parser by MSB |
| 46 | Check Health ${parserhealthcheck_url} |
| 47 | |
zhaoliping123 | 39b397e | 2019-10-25 11:22:39 +0800 | [diff] [blame] | 48 | Check distribute catalog NS pacakages |
| 49 | Log Check distribute catalog NS pacakages |
| 50 | [Documentation] check distribute catalog NS pacakages |
| 51 | Check distribute package ${ns_packages_json} ${nspackages_url} |
| 52 | |
| 53 | Check query catalog all NS package |
| 54 | Log Query catalog all NS package |
| 55 | [Documentation] check query catalog all NS package |
| 56 | Check query all packages ${nspackages_url} |
| 57 | |
| 58 | Check query all Service package |
| 59 | Log Query all Service packages |
| 60 | [Documentation] check query Service packages by MSB |
| 61 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json |
| 62 | Check query all packages ${service_packages_url} |
| 63 | |
| 64 | Check distribute VNF package |
| 65 | Log Check distribute VNF packagee |
| 66 | [Documentation] check distribute VNF package |
| 67 | ${json_value}= json_from_file ${vnfpackages_catalog_json} |
| 68 | ${json_string}= string_from_json ${json_value} |
| 69 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json |
| 70 | Create Session web_session http://${CATALOG_IP}:${catalog_port} headers=${headers} |
| 71 | Set Request Body ${json_string} |
| 72 | ${resp}= Post Request web_session ${vnfpackages_url} ${json_string} |
| 73 | Should Be Equal As Strings 202 ${resp.status_code} |
| 74 | ${response_json} json.loads ${resp.content} |
| 75 | ${jobId}= Convert To String ${response_json['jobId']} |
| 76 | Set Global Variable ${jobId} |
| 77 | |
| 78 | Check query job status |
| 79 | Log Check query job status |
| 80 | [Documentation] check query job status |
| 81 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json |
| 82 | Create Session web_session http://${CATALOG_IP}:${catalog_port} headers=${headers} |
| 83 | ${resp}= Get Request web_session ${jobs_url}/${jobId} |
| 84 | Should Be Equal As Strings 200 ${resp.status_code} |
| 85 | |
| 86 | Check query all VNF package |
| 87 | Log Query all VNF packages |
| 88 | [Documentation] check query VNF packages |
| 89 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json |
| 90 | Create Session web_session http://${CATALOG_IP}:${catalog_port} headers=${headers} |
| 91 | ${resp}= Get Request web_session ${vnfpackages_url} |
| 92 | Should Be Equal As Strings 200 ${resp.status_code} |
| 93 | ${response_json} json.loads ${resp.content} |
| 94 | |
Olivia.Zhan | 4881bf3 | 2019-07-11 09:27:06 +0800 | [diff] [blame] | 95 | *** Keywords *** |
| 96 | Check Health |
| 97 | [Arguments] ${url} |
fujinhua | 73c7480 | 2019-04-28 16:27:22 +0800 | [diff] [blame] | 98 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json |
| 99 | Create Session web_session http://${CATALOG_IP}:${catalog_port} headers=${headers} |
Olivia.Zhan | 4881bf3 | 2019-07-11 09:27:06 +0800 | [diff] [blame] | 100 | ${resp}= Get Request web_session ${url} |
| 101 | Should Be Equal As Strings 200 ${resp.status_code} |
zhaoliping123 | 39b397e | 2019-10-25 11:22:39 +0800 | [diff] [blame] | 102 | ${response_json} json.loads ${resp.content} |
Olivia.Zhan | 4881bf3 | 2019-07-11 09:27:06 +0800 | [diff] [blame] | 103 | Should Be Equal As Strings active ${response_json['status']} |
zhaoliping123 | 39b397e | 2019-10-25 11:22:39 +0800 | [diff] [blame] | 104 | |
| 105 | Check distribute package |
| 106 | [Arguments] ${json_file} ${url} |
| 107 | ${json_value}= json_from_file ${json_file} |
| 108 | ${json_string}= string_from_json ${json_value} |
| 109 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json |
| 110 | Create Session web_session http://${CATALOG_IP}:${catalog_port} headers=${headers} |
| 111 | Set Request Body ${json_string} |
| 112 | ${resp}= Post Request web_session ${url} ${json_string} |
| 113 | Should Be Equal As Strings 202 ${resp.status_code} |
| 114 | |
| 115 | Check query all packages |
| 116 | [Arguments] ${url} |
| 117 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json |
| 118 | Create Session web_session http://${CATALOG_IP}:${catalog_port} headers=${headers} |
| 119 | ${resp}= Get Request web_session ${url} |
| 120 | Should Be Equal As Strings 200 ${resp.status_code} |