Remove variables for vpnservice
[integration/test.git] / csit / suites / sfc / SFC_Basic / 030__sfc_service_nodes.robot
1 *** Settings ***
2 Documentation       Test suite for SFC Service Nodes, Operates Nodes from Restconf APIs.
3
4 Library             SSHLibrary
5 Library             Collections
6 Library             OperatingSystem
7 Library             RequestsLibrary
8 Resource            ../../../variables/sfc/Variables.robot
9 Resource            ../../../libraries/Utils.robot
10 Resource            ../../../libraries/TemplatedRequests.robot
11
12 Suite Setup         Init Suite
13 Suite Teardown      Delete All Sessions
14 Test Setup          Remove All Elements If Exist    ${SERVICE_NODES_URI}
15
16
17 *** Test Cases ***
18 Put Service Nodes
19     [Documentation]    Add Service Nodes from JSON file
20     Add Elements To URI From File    ${SERVICE_NODES_URI}    ${SERVICE_NODES_FILE}
21     ${body}    OperatingSystem.Get File    ${SERVICE_NODES_FILE}
22     ${jsonbody}    To Json    ${body}
23     ${nodes}    Get From Dictionary    ${jsonbody}    service-nodes
24     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_NODES_URI}
25     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
26     ${result}    To JSON    ${resp.content}
27     ${node}    Get From Dictionary    ${result}    service-nodes
28     Lists Should be Equal    ${node}    ${nodes}
29
30 Delete All Service Nodes
31     [Documentation]    Delete all Service Nodes
32     Add Elements To URI From File    ${SERVICE_NODES_URI}    ${SERVICE_NODES_FILE}
33     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_NODES_URI}
34     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
35     Remove All Elements At URI    ${SERVICE_NODES_URI}
36     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_NODES_URI}
37     Should Be Equal As Strings    ${resp.status_code}    404
38
39 Get one Service Node
40     [Documentation]    Get one Service Node
41     Add Elements To URI From File    ${SERVICE_NODES_URI}    ${SERVICE_NODES_FILE}
42     ${elements}    Create List    node-101    firewall-101-2    10.3.1.101
43     Check For Elements At URI    ${SERVICE_NODE_URI}/node-101    ${elements}
44
45 Get A Non-existing Service Node
46     [Documentation]    Get A Non-existing Service Node
47     Add Elements To URI From File    ${SERVICE_NODES_URI}    ${SERVICE_NODES_FILE}
48     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_NODE_URI}/non-existing-sf
49     Should Be Equal As Strings    ${resp.status_code}    404
50
51 Delete A Service Node
52     [Documentation]    Delete A Service Node
53     Add Elements To URI From File    ${SERVICE_NODES_URI}    ${SERVICE_NODES_FILE}
54     Remove All Elements At URI    ${SERVICE_NODE_URI}/node-101
55     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_NODES_URI}
56     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
57     Should Not Contain    ${resp.text}    node-101
58
59 Delete A Non-existing Service Node
60     [Documentation]    Delete A Non existing Service Node
61     Add Elements To URI From File    ${SERVICE_NODES_URI}    ${SERVICE_NODES_FILE}
62     ${body}    OperatingSystem.Get File    ${SERVICE_NODES_FILE}
63     ${jsonbody}    To Json    ${body}
64     ${nodes}    Get From Dictionary    ${jsonbody}    service-nodes
65     ${resp}    RequestsLibrary.Delete Request    session    ${SERVICE_NODE_URI}/non-existing-sn
66     Should Be Equal As Strings    ${resp.status_code}    404
67     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_NODES_URI}
68     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
69     ${result}    To JSON    ${resp.content}
70     ${node}    Get From Dictionary    ${result}    service-nodes
71     Lists Should be Equal    ${node}    ${nodes}
72
73 Put one Service Node
74     [Documentation]    Put one Service Node
75     Add Elements To URI From File    ${SN_NODE100_URI}    ${SN_NODE100_FILE}
76     ${elements}    Create List    node-100    10.3.1.100    dpi-100-1    firewall-102-1
77     Check For Elements At URI    ${SN_NODE100_URI}    ${elements}
78     Check For Elements At URI    ${SERVICE_NODES_URI}    ${elements}
79
80
81 *** Keywords ***
82 Init Suite
83     [Documentation]    Initialize session and ODL version specific variables
84     Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
85     log    ${ODL_STREAM}
86     Set Suite Variable    ${VERSION_DIR}    master
87     Set Suite Variable    ${TEST_DIR}    ${CURDIR}/../../../variables/sfc/${VERSION_DIR}
88     Set Suite Variable    ${SERVICE_NODES_FILE}    ${TEST_DIR}/service-nodes.json
89     Set Suite Variable    ${SN_NODE100_URI}    ${SERVICE_NODE_URI}/node-100
90     Set Suite Variable    ${SN_NODE100_FILE}    ${TEST_DIR}/sn_node_100.json