Adapt 404 response when delete non-existent element
[integration/test.git] / csit / suites / sfc / SFC_Basic / 030__sfc_service_nodes.robot
index 1a9f1e56d24cda2b263c495519f13280a22e56cb..804f7dd5b39f638d449067d4db262e86f1d4b9f9 100644 (file)
@@ -2,6 +2,7 @@
 Documentation     Test suite for SFC Service Nodes, Operates Nodes from Restconf APIs.
 Suite Setup       Init Suite
 Suite Teardown    Delete All Sessions
+Test Setup        Remove All Elements If Exist    ${SERVICE_NODES_URI}
 Library           SSHLibrary
 Library           Collections
 Library           OperatingSystem
@@ -34,21 +35,18 @@ Delete All Service Nodes
 
 Get one Service Node
     [Documentation]    Get one Service Node
-    Remove All Elements At URI    ${SERVICE_NODES_URI}
     Add Elements To URI From File    ${SERVICE_NODES_URI}    ${SERVICE_NODES_FILE}
     ${elements}=    Create List    node-101    firewall-101-2    10.3.1.101
     Check For Elements At URI    ${SERVICE_NODES_URI}service-node/node-101    ${elements}
 
 Get A Non-existing Service Node
     [Documentation]    Get A Non-existing Service Node
-    Remove All Elements At URI    ${SERVICE_NODES_URI}
     Add Elements To URI From File    ${SERVICE_NODES_URI}    ${SERVICE_NODES_FILE}
     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_NODES_URI}service-node/non-existing-sf
     Should Be Equal As Strings    ${resp.status_code}    404
 
 Delete A Service Node
     [Documentation]    Delete A Service Node
-    Remove All Elements At URI    ${SERVICE_NODES_URI}
     Add Elements To URI From File    ${SERVICE_NODES_URI}    ${SERVICE_NODES_FILE}
     Remove All Elements At URI    ${SERVICE_NODES_URI}service-node/node-101
     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_NODES_URI}
@@ -57,12 +55,12 @@ Delete A Service Node
 
 Delete A Non-existing Service Node
     [Documentation]    Delete A Non existing Service Node
-    Remove All Elements At URI    ${SERVICE_NODES_URI}
     Add Elements To URI From File    ${SERVICE_NODES_URI}    ${SERVICE_NODES_FILE}
     ${body}    OperatingSystem.Get File    ${SERVICE_NODES_FILE}
     ${jsonbody}    To Json    ${body}
     ${nodes}    Get From Dictionary    ${jsonbody}    service-nodes
-    Remove All Elements At URI    ${SERVICE_NODES_URI}service-node/non-existing-sn
+    ${resp}    RequestsLibrary.Delete Request    session    ${SERVICE_NODES_URI}service-node/non-existing-sn
+    Should Be Equal As Strings    ${resp.status_code}    404
     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_NODES_URI}
     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
     ${result}    To JSON    ${resp.content}
@@ -71,16 +69,11 @@ Delete A Non-existing Service Node
 
 Put one Service Node
     [Documentation]    Put one Service Node
-    Remove All Elements At URI    ${SERVICE_NODES_URI}
     Add Elements To URI From File    ${SN_NODE100_URI}    ${SN_NODE100_FILE}
     ${elements}=    Create List    node-100    10.3.1.100    dpi-100-1    firewall-102-1
     Check For Elements At URI    ${SN_NODE100_URI}    ${elements}
     Check For Elements At URI    ${SERVICE_NODES_URI}    ${elements}
 
-Clean All Service Nodes After Tests
-    [Documentation]    Delete all Service Nodes From Datastore After Tests
-    Remove All Elements At URI    ${SERVICE_NODES_URI}
-
 *** keywords ***
 Init Suite
     [Documentation]    Initialize session and ODL version specific variables