Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [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 | *** Variables *** |
| 10 | @{return_ok_list}= 200 201 202 204 |
| 11 | ${queryswagger_url} /api/nslcm/v1/swagger.json |
fujinhua | 7aa8cd3 | 2019-04-05 08:20:53 +0800 | [diff] [blame] | 12 | ${create_ns_url} /api/nslcm/v1/ns |
| 13 | ${delete_ns_url} /api/nslcm/v1/ns |
fujinhua | 898e2cb | 2019-04-18 19:29:04 +0800 | [diff] [blame] | 14 | ${get_ns_url} /api/nslcm/v1/ns |
fujinhua | d5a3283 | 2019-04-19 09:45:49 +0800 | [diff] [blame] | 15 | ${get_subscriptions_url} /api/nslcm/v1/subscriptions |
fujinhua | 7aa8cd3 | 2019-04-05 08:20:53 +0800 | [diff] [blame] | 16 | ${healthcheck_url} /api/nslcm/v1/health_check |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 17 | |
| 18 | #json files |
| 19 | ${create_ns_json} ${SCRIPTS}/../tests/vfc/nfvo-lcm/jsoninput/create_ns.json |
| 20 | |
| 21 | #global variables |
| 22 | ${nsInstId} |
| 23 | |
| 24 | *** Test Cases *** |
| 25 | NslcmSwaggerTest |
| 26 | [Documentation] query swagger info of nslcm |
| 27 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json |
| 28 | Create Session web_session http://${NSLCM_IP}:8403 headers=${headers} |
| 29 | ${resp}= Get Request web_session ${queryswagger_url} |
| 30 | ${responese_code}= Convert To String ${resp.status_code} |
| 31 | List Should Contain Value ${return_ok_list} ${responese_code} |
| 32 | ${response_json} json.loads ${resp.content} |
| 33 | ${swagger_version}= Convert To String ${response_json['swagger']} |
| 34 | Should Be Equal ${swagger_version} 2.0 |
| 35 | |
| 36 | NslcmSwaggerByMSBTest |
| 37 | [Documentation] query swagger info of nslcm by MSB |
| 38 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json |
| 39 | Create Session web_session http://${MSB_IAG_IP}:80 headers=${headers} |
| 40 | ${resp}= Get Request web_session ${queryswagger_url} |
| 41 | ${responese_code}= Convert To String ${resp.status_code} |
| 42 | List Should Contain Value ${return_ok_list} ${responese_code} |
| 43 | ${response_json} json.loads ${resp.content} |
| 44 | ${swagger_version}= Convert To String ${response_json['swagger']} |
| 45 | Should Be Equal ${swagger_version} 2.0 |
| 46 | |
| 47 | CreateNSTest |
| 48 | [Documentation] Create NS function test |
| 49 | ${json_value}= json_from_file ${create_ns_json} |
| 50 | ${json_string}= string_from_json ${json_value} |
| 51 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json |
| 52 | Create Session web_session http://${MSB_IAG_IP}:80 headers=${headers} |
| 53 | Set Request Body ${json_string} |
| 54 | ${resp}= Post Request web_session ${create_ns_url} ${json_string} |
| 55 | ${responese_code}= Convert To String ${resp.status_code} |
| 56 | List Should Contain Value ${return_ok_list} ${responese_code} |
| 57 | ${response_json} json.loads ${resp.content} |
| 58 | ${nsInstId}= Convert To String ${response_json['nsInstanceId']} |
| 59 | Set Global Variable ${nsInstId} |
| 60 | |
| 61 | DeleteNS Test |
| 62 | [Documentation] Delete NS function test |
| 63 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json |
| 64 | Create Session web_session http://${MSB_IAG_IP}:80 headers=${headers} |
| 65 | ${resp}= Delete Request web_session ${delete_ns_url}/${nsInstId} |
| 66 | ${responese_code}= Convert To String ${resp.status_code} |
| 67 | List Should Contain Value ${return_ok_list} ${responese_code} |
fujinhua | 7aa8cd3 | 2019-04-05 08:20:53 +0800 | [diff] [blame] | 68 | |
| 69 | LcmHealthCheckTest |
| 70 | [Documentation] check health for nslcm by MSB |
| 71 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json |
| 72 | Create Session web_session http://${MSB_IAG_IP}:80 headers=${headers} |
| 73 | ${resp}= Get Request web_session ${healthcheck_url} |
| 74 | ${responese_code}= Convert To String ${resp.status_code} |
| 75 | List Should Contain Value ${return_ok_list} ${responese_code} |
| 76 | ${response_json} json.loads ${resp.content} |
| 77 | ${health_status}= Convert To String ${response_json['status']} |
| 78 | Should Be Equal ${health_status} active |
fujinhua | 898e2cb | 2019-04-18 19:29:04 +0800 | [diff] [blame] | 79 | |
| 80 | LcmGetNsTest |
| 81 | [Documentation] get ns instances for nslcm by MSB |
| 82 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json |
| 83 | Create Session web_session http://${MSB_IAG_IP}:80 headers=${headers} |
| 84 | ${resp}= Get Request web_session ${get_ns_url} |
| 85 | ${responese_code}= Convert To String ${resp.status_code} |
| 86 | List Should Contain Value ${return_ok_list} ${responese_code} |
fujinhua | d5a3283 | 2019-04-19 09:45:49 +0800 | [diff] [blame] | 87 | |
| 88 | LcmGetSubscriptionsTest |
| 89 | [Documentation] get subscriptions for nslcm by MSB |
| 90 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json |
| 91 | Create Session web_session http://${MSB_IAG_IP}:80 headers=${headers} |
| 92 | ${resp}= Get Request web_session ${get_subscriptions_url} |
| 93 | ${responese_code}= Convert To String ${resp.status_code} |
| 94 | List Should Contain Value ${return_ok_list} ${responese_code} |