2 Documentation Test suite for SFC Service Nodes, Operates Nodes from Restconf APIs.
4 Suite Teardown Delete All Sessions
7 Library OperatingSystem
8 Library RequestsLibrary
9 Variables ../../../variables/Variables.py
10 Resource ../../../libraries/Utils.robot
11 Resource ../../../libraries/TemplatedRequests.robot
15 [Documentation] Add Service Nodes from JSON file
16 Add Elements To URI From File ${SERVICE_NODES_URI} ${SERVICE_NODES_FILE}
17 ${body} OperatingSystem.Get File ${SERVICE_NODES_FILE}
18 ${jsonbody} To Json ${body}
19 ${nodes} Get From Dictionary ${jsonbody} service-nodes
20 ${resp} RequestsLibrary.Get Request session ${SERVICE_NODES_URI}
21 Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
22 ${result} To JSON ${resp.content}
23 ${node} Get From Dictionary ${result} service-nodes
24 Lists Should be Equal ${node} ${nodes}
26 Delete All Service Nodes
27 [Documentation] Delete all Service Nodes
28 Add Elements To URI From File ${SERVICE_NODES_URI} ${SERVICE_NODES_FILE}
29 ${resp} RequestsLibrary.Get Request session ${SERVICE_NODES_URI}
30 Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
31 Remove All Elements At URI ${SERVICE_NODES_URI}
32 ${resp} RequestsLibrary.Get Request session ${SERVICE_NODES_URI}
33 Should Be Equal As Strings ${resp.status_code} 404
36 [Documentation] Get one Service Node
37 Remove All Elements At URI ${SERVICE_NODES_URI}
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_NODES_URI}service-node/node-101 ${elements}
42 Get A Non-existing Service Node
43 [Documentation] Get A Non-existing Service Node
44 Remove All Elements At URI ${SERVICE_NODES_URI}
45 Add Elements To URI From File ${SERVICE_NODES_URI} ${SERVICE_NODES_FILE}
46 ${resp} RequestsLibrary.Get Request session ${SERVICE_NODES_URI}service-node/non-existing-sf
47 Should Be Equal As Strings ${resp.status_code} 404
50 [Documentation] Delete A Service Node
51 Remove All Elements At URI ${SERVICE_NODES_URI}
52 Add Elements To URI From File ${SERVICE_NODES_URI} ${SERVICE_NODES_FILE}
53 Remove All Elements At URI ${SERVICE_NODES_URI}service-node/node-101
54 ${resp} RequestsLibrary.Get Request session ${SERVICE_NODES_URI}
55 Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
56 Should Not Contain ${resp.content} node-101
58 Delete A Non-existing Service Node
59 [Documentation] Delete A Non existing Service Node
60 Remove All Elements At URI ${SERVICE_NODES_URI}
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 Remove All Elements At URI ${SERVICE_NODES_URI}service-node/non-existing-sn
66 ${resp} RequestsLibrary.Get Request session ${SERVICE_NODES_URI}
67 Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
68 ${result} To JSON ${resp.content}
69 ${node} Get From Dictionary ${result} service-nodes
70 Lists Should be Equal ${node} ${nodes}
73 [Documentation] Put one Service Node
74 Remove All Elements At URI ${SERVICE_NODES_URI}
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}
80 Clean All Service Nodes After Tests
81 [Documentation] Delete all Service Nodes From Datastore After Tests
82 Remove All Elements At URI ${SERVICE_NODES_URI}
86 [Documentation] Initialize session and ODL version specific variables
87 Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS}
89 Run Keyword If '${ODL_STREAM}' == 'stable-lithium' Set Suite Variable ${VERSION_DIR} lithium
90 ... ELSE Set Suite Variable ${VERSION_DIR} master
91 Set Suite Variable ${SERVICE_NODES_URI} /restconf/config/service-node:service-nodes/
92 Set Suite Variable ${SERVICE_NODES_FILE} ${CURDIR}/../../../variables/sfc/${VERSION_DIR}/service-nodes.json
93 Set Suite Variable ${SN_NODE100_URI} /restconf/config/service-node:service-nodes/service-node/node-100
94 Set Suite Variable ${SN_NODE100_FILE} ${CURDIR}/../../../variables/sfc/${VERSION_DIR}/sn_node_100.json