Merge "Updated Setup files for PM Mapper"
[integration/csit.git] / tests / vfc / nfvo-lcm / test.robot
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
12 ${create_ns_url}       /api/nslcm/v1/ns
13 ${delete_ns_url}       /api/nslcm/v1/ns
14 ${healthcheck_url}     /api/nslcm/v1/health_check
15
16 #json files
17 ${create_ns_json}    ${SCRIPTS}/../tests/vfc/nfvo-lcm/jsoninput/create_ns.json
18
19 #global variables
20 ${nsInstId}
21
22 *** Test Cases ***
23 NslcmSwaggerTest
24     [Documentation]    query swagger info of nslcm
25     ${headers}    Create Dictionary    Content-Type=application/json    Accept=application/json
26     Create Session    web_session    http://${NSLCM_IP}:8403    headers=${headers}
27     ${resp}=  Get Request    web_session    ${queryswagger_url}
28     ${responese_code}=     Convert To String      ${resp.status_code}
29     List Should Contain Value    ${return_ok_list}   ${responese_code}
30     ${response_json}    json.loads    ${resp.content}
31     ${swagger_version}=    Convert To String      ${response_json['swagger']}
32     Should Be Equal    ${swagger_version}    2.0
33
34 NslcmSwaggerByMSBTest
35     [Documentation]    query swagger info of nslcm by MSB
36     ${headers}    Create Dictionary    Content-Type=application/json    Accept=application/json
37     Create Session    web_session    http://${MSB_IAG_IP}:80    headers=${headers}
38     ${resp}=  Get Request    web_session    ${queryswagger_url}
39     ${responese_code}=     Convert To String      ${resp.status_code}
40     List Should Contain Value    ${return_ok_list}   ${responese_code}
41     ${response_json}    json.loads    ${resp.content}
42     ${swagger_version}=    Convert To String      ${response_json['swagger']}
43     Should Be Equal    ${swagger_version}    2.0
44
45 CreateNSTest
46     [Documentation]    Create NS function test
47     ${json_value}=     json_from_file      ${create_ns_json}
48     ${json_string}=     string_from_json   ${json_value}
49     ${headers}    Create Dictionary    Content-Type=application/json    Accept=application/json
50     Create Session    web_session    http://${MSB_IAG_IP}:80    headers=${headers}
51     Set Request Body    ${json_string}
52     ${resp}=    Post Request    web_session     ${create_ns_url}    ${json_string}
53     ${responese_code}=     Convert To String      ${resp.status_code}
54     List Should Contain Value    ${return_ok_list}   ${responese_code}
55     ${response_json}    json.loads    ${resp.content}
56     ${nsInstId}=    Convert To String      ${response_json['nsInstanceId']}
57     Set Global Variable     ${nsInstId}
58
59 DeleteNS Test
60     [Documentation]    Delete NS function test
61     ${headers}    Create Dictionary    Content-Type=application/json    Accept=application/json
62     Create Session    web_session    http://${MSB_IAG_IP}:80    headers=${headers}
63     ${resp}=    Delete Request    web_session     ${delete_ns_url}/${nsInstId}
64     ${responese_code}=     Convert To String      ${resp.status_code}
65     List Should Contain Value    ${return_ok_list}   ${responese_code}
66
67 LcmHealthCheckTest
68     [Documentation]    check health for nslcm by MSB
69     ${headers}    Create Dictionary    Content-Type=application/json    Accept=application/json
70     Create Session    web_session    http://${MSB_IAG_IP}:80    headers=${headers}
71     ${resp}=  Get Request    web_session    ${healthcheck_url}
72     ${responese_code}=     Convert To String      ${resp.status_code}
73     List Should Contain Value    ${return_ok_list}   ${responese_code}
74     ${response_json}    json.loads    ${resp.content}
75     ${health_status}=    Convert To String      ${response_json['status']}
76     Should Be Equal    ${health_status}    active