fujinhua | 79b58a9 | 2017-09-04 19:12:01 +0800 | [diff] [blame] | 1 | *** settings *** |
fujinhua | a12f3bb | 2017-09-14 16:28:50 +0800 | [diff] [blame] | 2 | Resource ../../common.robot |
fujinhua | 79b58a9 | 2017-09-04 19:12:01 +0800 | [diff] [blame] | 3 | Library Collections |
| 4 | Library RequestsLibrary |
| 5 | Library OperatingSystem |
| 6 | Library json |
fujinhua | c37933b | 2017-09-14 17:08:59 +0800 | [diff] [blame] | 7 | Library HttpLibrary.HTTP |
fujinhua | 79b58a9 | 2017-09-04 19:12:01 +0800 | [diff] [blame] | 8 | |
| 9 | *** Variables *** |
fujinhua | 57c2398 | 2017-09-14 11:17:30 +0800 | [diff] [blame] | 10 | @{return_ok_list}= 200 201 202 204 |
fujinhua | 79b58a9 | 2017-09-04 19:12:01 +0800 | [diff] [blame] | 11 | ${queryswagger_url} /api/nslcm/v1/swagger.json |
fujinhua | 57c2398 | 2017-09-14 11:17:30 +0800 | [diff] [blame] | 12 | ${create_ns_url} /api/nslcm/v1/ns |
| 13 | ${delete_ns_url} /api/nslcm/v1/ns |
| 14 | |
| 15 | #json files |
fujinhua | c37933b | 2017-09-14 17:08:59 +0800 | [diff] [blame] | 16 | ${create_ns_json} ${SCRIPTS}/../tests/vfc/nfvo-lcm/jsoninput/create_ns.json |
fujinhua | 57c2398 | 2017-09-14 11:17:30 +0800 | [diff] [blame] | 17 | |
| 18 | #global variables |
| 19 | ${nsInstId} |
fujinhua | 79b58a9 | 2017-09-04 19:12:01 +0800 | [diff] [blame] | 20 | |
| 21 | *** Test Cases *** |
| 22 | NslcmSwaggerTest |
fujinhua | bbb154e | 2017-09-09 16:29:59 +0800 | [diff] [blame] | 23 | [Documentation] query swagger info of nslcm |
fujinhua | 8fea9bb | 2017-09-08 09:26:34 +0800 | [diff] [blame] | 24 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json |
fujinhua | fef3f74 | 2017-09-09 15:55:18 +0800 | [diff] [blame] | 25 | Create Session web_session http://${NSLCM_IP}:8403 headers=${headers} |
fujinhua | 8fea9bb | 2017-09-08 09:26:34 +0800 | [diff] [blame] | 26 | ${resp}= Get Request web_session ${queryswagger_url} |
| 27 | ${responese_code}= Convert To String ${resp.status_code} |
| 28 | List Should Contain Value ${return_ok_list} ${responese_code} |
| 29 | ${response_json} json.loads ${resp.content} |
| 30 | ${swagger_version}= Convert To String ${response_json['swagger']} |
| 31 | Should Be Equal ${swagger_version} 2.0 |
fujinhua | bbb154e | 2017-09-09 16:29:59 +0800 | [diff] [blame] | 32 | |
| 33 | NslcmSwaggerByMSBTest |
| 34 | [Documentation] query swagger info of nslcm by MSB |
| 35 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json |
| 36 | Create Session web_session http://${MSB_IAG_IP}:80 headers=${headers} |
| 37 | ${resp}= Get Request web_session ${queryswagger_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 | ${swagger_version}= Convert To String ${response_json['swagger']} |
fujinhua | 57c2398 | 2017-09-14 11:17:30 +0800 | [diff] [blame] | 42 | Should Be Equal ${swagger_version} 2.0 |
| 43 | |
| 44 | CreateNSTest |
| 45 | [Documentation] Create NS function test |
| 46 | ${json_value}= json_from_file ${create_ns_json} |
| 47 | ${json_string}= string_from_json ${json_value} |
| 48 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json |
| 49 | Create Session web_session http://${MSB_IAG_IP}:80 headers=${headers} |
| 50 | Set Request Body ${json_string} |
| 51 | ${resp}= Post Request web_session ${create_ns_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 | ${nsInstId}= Convert To String ${response_json['nsInstanceId']} |
| 56 | Set Global Variable ${nsInstId} |
| 57 | |
| 58 | DeleteNS Test |
| 59 | [Documentation] Delete NS function test |
| 60 | ${headers} Create Dictionary Content-Type=application/json Accept=application/json |
| 61 | Create Session web_session http://${MSB_IAG_IP}:80 headers=${headers} |
| 62 | ${resp}= Delete Request web_session ${delete_ns_url}/${nsInstId} |
| 63 | ${responese_code}= Convert To String ${resp.status_code} |
| 64 | List Should Contain Value ${return_ok_list} ${responese_code} |