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