Add Node, Slice and Instance API tests
Change-Id: I3c3b9e8fbb7e485689bd8abac042b2264f6e51e3
diff --git a/src/test/cord-api/Properties/RestApiProperties.py b/src/test/cord-api/Properties/RestApiProperties.py
index e4568a9..fc96dc5 100644
--- a/src/test/cord-api/Properties/RestApiProperties.py
+++ b/src/test/cord-api/Properties/RestApiProperties.py
@@ -19,3 +19,4 @@
CORE_FLAVORS = '/api/core/flavors/'
CORE_SITES = '/api/core/sites/'
CORE_IMAGES = '/api/core/images/'
+CORE_SITEDEPLOYMENTS = '/api/core/sitedeployments'
diff --git a/src/test/cord-api/Tests/InstanceTest.txt b/src/test/cord-api/Tests/InstanceTest.txt
new file mode 100644
index 0000000..450ef43
--- /dev/null
+++ b/src/test/cord-api/Tests/InstanceTest.txt
@@ -0,0 +1,111 @@
+*** Settings ***
+Documentation Test suite for Instance API verification
+Suite Setup Read InputFile
+Test Template Verify Instance API functionality
+Library Collections
+Library String
+Library OperatingSystem
+Library XML
+Library RequestsLibrary
+Library ../Framework/utils/utils.py
+Library ../Framework/restApi.py
+| Variables | ../Properties/RestApiProperties.py
+
+*** Variables ***
+${USER} admin
+${PASSWORD} admin
+${PATHFILE} ${CURDIR}/data/Instance.json
+| ${IP} | ${SERVER_IP}
+| ${PORT} | ${SERVER_PORT}
+
+*** Test Cases *** TYPE LISTINDEX
+Test Add Instance-1
+ CREATE 0
+
+Test Get Instance-1
+ RETRIEVE 0
+
+Test Delete Instance-1
+ DELETE 0
+
+Test Add Instance-2
+ CREATE 1
+
+Test Get Instance-2
+ RETRIEVE 1
+
+Test Delete Instance-2
+ DELETE 1
+
+*** Keywords ***
+Read InputFile
+ ${instanceList} = utils.jsonToList ${PATHFILE} InstanceInfo
+ Set Suite Variable ${iList} ${instanceList}
+ ${image}= Catenate SEPARATOR= http:// ${IP} : ${PORT} /api/core/images/1/
+ Set Suite Variable ${image} ${image}
+ ${slice}= Catenate SEPARATOR= http:// ${IP} : ${PORT} /api/core/slices/1/
+ Set Suite Variable ${slice} ${slice}
+ ${deployment}= Catenate SEPARATOR= http:// ${IP} : ${PORT} /api/core/deployments/1/
+ Set Suite Variable ${deployment} ${deployment}
+ ${node}= Catenate SEPARATOR= http:// ${IP} : ${PORT} /api/core/nodes/1/
+ Set Suite Variable ${node} ${node}
+ ${creator}= Catenate SEPARATOR= http:// ${IP} : ${PORT} /api/core/users/1/
+ Set Suite Variable ${creator} ${creator}
+
+Verify Instance API functionality
+ [Arguments] ${type} ${listIndex}
+ Run Keyword If "${type}" == "CREATE" Test Post Instances ${listIndex}
+ Run Keyword If "${type}" == "RETRIEVE" Test Get Instances ${listIndex}
+ Run Keyword If "${type}" == "DELETE" Test Delete Instances ${listIndex}
+
+Test Post Instances
+ [Arguments] ${listIndex}
+ ${instanceList} = Get Variable Value ${iList}
+ ${instanceDict}= utils.listToDict ${instanceList} ${listIndex}
+ ${image}= Get Variable Value ${image}
+ ${instanceDict}= utils.setFieldValueInDict ${instanceDict} image ${image}
+ ${slice}= Get Variable Value ${slice}
+ ${instanceDict}= utils.setFieldValueInDict ${instanceDict} slice ${slice}
+ ${deployment}= Get Variable Value ${deployment}
+ ${instanceDict}= utils.setFieldValueInDict ${instanceDict} deployment ${deployment}
+ ${node}= Get Variable Value ${node}
+ ${instanceDict}= utils.setFieldValueInDict ${instanceDict} node ${node}
+ ${creator}= Get Variable Value ${creator}
+ ${instanceDict}= utils.setFieldValueInDict ${instanceDict} creator ${creator}
+ ${api_result}= restApi.ApiPost CORE_INSTANCES ${instanceDict}
+ Should Be True ${api_result}
+
+Test Get Instances
+ [Arguments] ${listIndex}
+ ${json_result}= restApi.ApiGet CORE_INSTANCES
+ Log ${json_result}
+ ${instanceList}= Get Variable Value ${iList}
+ ${instanceDict}= utils.listToDict ${instanceList} ${listIndex}
+ ${image}= Get Variable Value ${image}
+ ${instanceDict}= utils.setFieldValueInDict ${instanceDict} image ${image}
+ ${slice}= Get Variable Value ${slice}
+ ${instanceDict}= utils.setFieldValueInDict ${instanceDict} slice ${slice}
+ ${deployment}= Get Variable Value ${deployment}
+ ${instanceDict}= utils.setFieldValueInDict ${instanceDict} deployment ${deployment}
+ ${node}= Get Variable Value ${node}
+ ${instanceDict}= utils.setFieldValueInDict ${instanceDict} node ${node}
+ ${creator}= Get Variable Value ${creator}
+ ${instanceDict}= utils.setFieldValueInDict ${instanceDict} creator ${creator}
+ ${instanceName}= utils.getFieldValueFromDict ${instanceDict} name
+ ${getJsonDict}= utils.getDictFromListOfDict ${json_result} name ${instanceName}
+ ${test_result}= utils.compare_dict ${instanceDict} ${getJsonDict}
+ Should Be True ${json_result}
+
+Test Delete Instances
+ [Arguments] ${listIndex}
+ ${json_getresult}= restApi.ApiGet CORE_INSTANCES
+ ${instanceList}= Get Variable Value ${iList}
+ ${instanceDict}= utils.listToDict ${iList} ${listIndex}
+ ${instanceName}= utils.getFieldValueFromDict ${instanceDict} name
+ Log ${instanceName}
+ ${getInstanceDict}= utils.getDictFromListofDict ${json_getresult} name ${instanceName}
+ Log ${getInstanceDict}
+ ${instanceID}= utils.getFieldValueFromDict ${getInstanceDict} id
+ Log ${instanceID}
+ ${test_result}= restApi.ApiDelete CORE_INSTANCES ${instanceID}
+ Should be True ${test_result}
diff --git a/src/test/cord-api/Tests/NodeTest.txt b/src/test/cord-api/Tests/NodeTest.txt
new file mode 100644
index 0000000..fda6537
--- /dev/null
+++ b/src/test/cord-api/Tests/NodeTest.txt
@@ -0,0 +1,81 @@
+*** Settings ***
+Documentation Test suite for Node API verification
+Suite Setup Read InputFile
+Test Template Verify Node API functionality
+Library Collections
+Library String
+Library OperatingSystem
+Library XML
+Library RequestsLibrary
+Library ../Framework/utils/utils.py
+Library ../Framework/restApi.py
+| Variables | ../Properties/RestApiProperties.py
+
+*** Variables ***
+${USER} admin
+${PASSWORD} admin
+${PATHFILE} ${CURDIR}/data/Node.json
+| ${IP} | ${SERVER_IP}
+| ${PORT} | ${SERVER_PORT}
+
+*** Test Cases *** TYPE LISTINDEX
+Test Post Node-1 CREATE 0
+
+Test Get Node-1 RETRIEVE 0
+
+Test Delete Node-1 DELETE 0
+
+Test Post Node-2 CREATE 1
+
+Test Get Node-2 RETRIEVE 1
+
+Test Delete Node-2 DELETE 1
+
+*** Keywords ***
+Read InputFile
+ ${nodeList}= utils.jsonToList ${PATHFILE} NodeInfo
+ Set Suite Variable ${nlist} ${nodeList}
+ ${siteDeployment}= Catenate SEPARATOR= http:// ${IP} : ${PORT} /api/core/sitedeployments/1/
+ Set Suite Variable ${siteDeployment} ${siteDeployment}
+
+Verify Node API functionality
+ [Arguments] ${type} ${listIndex}
+ Run Keyword If "${type}" == "CREATE" Test Post Node API ${listIndex}
+ Run Keyword If "${type}" == "RETRIEVE" Test Get Node API ${listIndex}
+ Run Keyword If "${type}" == "DELETE" Test Delete Node API ${listIndex}
+
+Test Post Node API
+ [Arguments] ${listIndex}
+ ${nodeList}= Get Variable Value ${nlist}
+ ${nodeDict}= utils.listToDict ${nodeList} ${listIndex}
+ ${siteDeployment}= Get Variable Value ${siteDeployment}
+ ${nodeDict}= utils.setFieldValueInDict ${nodeDict} site_deployment ${siteDeployment}
+ ${api_result}= restApi.ApiPost CORE_NODES ${nodeDict}
+ Should Be True ${api_result}
+
+Test Get Node API
+ [Arguments] ${listIndex}
+ ${json_result}= restApi.ApiGet CORE_NODES
+ Log ${json_result}
+ ${nodeList}= Get Variable Value ${nlist}
+ ${nodeDict}= utils.listToDict ${nodeList} ${listIndex}
+ ${siteDeployment}= Get Variable Value ${siteDeployment}
+ ${nodeDict}= utils.setFieldValueInDict ${nodeDict} site_deployment ${siteDeployment}
+ ${name}= utils.getFieldValueFromDict ${nodeDict} name
+ ${getJsonDict}= utils.getDictFromListOfDict ${json_result} name ${name}
+ ${test_result}= utils.compare_dict ${nodeDict} ${getJsonDict}
+ Should Be True ${test_result}
+
+Test Delete Node API
+ [Arguments] ${listIndex}
+ ${json_result}= restApi.ApiGet CORE_NODES
+ ${nodeList}= Get Variable Value ${nlist}
+ ${nodeDict}= utils.listToDict ${nodeList} ${listIndex}
+ ${name}= utils.getFieldValueFromDict ${nodeDict} name
+ Log ${name}
+ ${nodeDict}= utils.getDictFromListofDict ${json_result} name ${name}
+ Log ${nodeDict}
+ ${nodeId}= utils.getFieldValueFromDict ${nodeDict} id
+ Log ${nodeId}
+ ${test_result}= restApi.ApiDelete CORE_NODES ${nodeId}
+ Should Be True ${test_result}
diff --git a/src/test/cord-api/Tests/SanityNode.txt b/src/test/cord-api/Tests/SanityNode.txt
index 7f57f9a..0bf27f8 100644
--- a/src/test/cord-api/Tests/SanityNode.txt
+++ b/src/test/cord-api/Tests/SanityNode.txt
@@ -1,5 +1,5 @@
*** Settings ***
-Documentation Test suite for Node verification
+Documentation Test suite for Sanity Test of Node API
Suite Setup Read InputFile
Test Template Verify Node functionality
Library Collections
diff --git a/src/test/cord-api/Tests/SanitySlice.txt b/src/test/cord-api/Tests/SanitySlice.txt
index 6a93361..454eba5 100644
--- a/src/test/cord-api/Tests/SanitySlice.txt
+++ b/src/test/cord-api/Tests/SanitySlice.txt
@@ -27,18 +27,18 @@
Verify Slice API functionality
[Arguments] ${type} ${listIndex}
- Run Keyword If "${type}" == "CREATE" Test Post Instances ${listIndex}
- Run Keyword If "${type}" == "RETRIEVE" Test Get Instances ${listIndex}
- Run Keyword If "${type}" == "DELETE" Test Delete Instances ${listIndex}
+ Run Keyword If "${type}" == "CREATE" Test Post Slices ${listIndex}
+ Run Keyword If "${type}" == "RETRIEVE" Test Get Slices ${listIndex}
+ Run Keyword If "${type}" == "DELETE" Test Delete Slices ${listIndex}
-Test Post Instances
+Test Post Slices
[Arguments] ${listIndex}
${sliceList} = Get Variable Value ${sList}
${sliceDict}= utils.listToDict ${sliceList} ${listIndex}
${api_result}= restApi.ApiPost CORE_SANITY_SLICES ${sliceDict}
Should Be True ${api_result}
-Test Get Instances
+Test Get Slices
[Arguments] ${listIndex}
${json_result}= restApi.ApiGet CORE_SLICES
Log ${json_result}
@@ -49,7 +49,7 @@
${test_result}= utils.compare_dict ${inputDict} ${getJsonDict}
Should Be True ${json_result}
-Test Delete Instances
+Test Delete Slices
[Arguments] ${listIndex}
${json_getresult}= restApi.ApiGet CORE_SLICES
${sliceList}= Get Variable Value ${sList}
diff --git a/src/test/cord-api/Tests/SliceTest.txt b/src/test/cord-api/Tests/SliceTest.txt
new file mode 100644
index 0000000..d1cd2e9
--- /dev/null
+++ b/src/test/cord-api/Tests/SliceTest.txt
@@ -0,0 +1,87 @@
+*** Settings ***
+Documentation Test suite for Slice API verification
+Suite Setup Read InputFile
+Test Template Verify Slice API functionality
+Library Collections
+Library String
+Library OperatingSystem
+Library XML
+Library RequestsLibrary
+Library ../Framework/utils/utils.py
+Library ../Framework/restApi.py
+| Variables | ../Properties/RestApiProperties.py
+
+*** Variables ***
+${USER} admin
+${PASSWORD} admin
+${PATHFILE} ${CURDIR}/data/Slice.json
+| ${IP} | ${SERVER_IP}
+| ${PORT} | ${SERVER_PORT}
+
+*** Test Cases *** TYPE LISTINDEX
+Test Add Slice-1 CREATE 0
+
+Test Get Slice-1 RETRIEVE 0
+
+Test Delete Slice-1 DELETE 0
+
+Test Add Slice-2 CREATE 1
+
+Test Get Slice-2 RETRIEVE 1
+
+Test Delete Slice-2 DELETE 1
+
+*** Keywords ***
+Read InputFile
+ ${sliceList} = utils.jsonToList ${PATHFILE} SliceInfo
+ Set Suite Variable ${sList} ${sliceList}
+ ${site}= Catenate SEPARATOR= http:// ${IP} : ${PORT} /api/core/sites/1/
+ Set Suite Variable ${site} ${site}
+ ${creator}= Catenate SEPARATOR= http:// ${IP} : ${PORT} /api/core/users/1/
+ Set Suite Variable ${creator} ${creator}
+
+Verify Slice API functionality
+ [Arguments] ${type} ${listIndex}
+ Run Keyword If "${type}" == "CREATE" Test Post Slice API ${listIndex}
+ Run Keyword If "${type}" == "RETRIEVE" Test Get Slice API ${listIndex}
+ Run Keyword If "${type}" == "DELETE" Test Delete Slice API ${listIndex}
+
+Test Post Slice API
+ [Arguments] ${listIndex}
+ ${sliceList} = Get Variable Value ${sList}
+ ${sliceDict}= utils.listToDict ${sliceList} ${listIndex}
+ ${site}= Get Variable Value ${site}
+ ${sliceDict}= utils.setFieldValueInDict ${sliceDict} site ${site}
+ ${creator}= Get Variable Value ${creator}
+ ${sliceDict}= utils.setFieldValueInDict ${sliceDict} creator ${creator}
+ ${api_result}= restApi.ApiPost CORE_SLICES ${sliceDict}
+ Should Be True ${api_result}
+
+Test Get Slice API
+ [Arguments] ${listIndex}
+ ${json_result}= restApi.ApiGet CORE_SLICES
+ Log ${json_result}
+ ${sliceList}= Get Variable Value ${sList}
+ ${sliceDict}= utils.listToDict ${sliceList} ${listIndex}
+ ${site}= Get Variable Value ${site}
+ ${sliceDict}= utils.setFieldValueInDict ${sliceDict} site ${site}
+ ${creator}= Get Variable Value ${creator}
+ ${sliceDict}= utils.setFieldValueInDict ${sliceDict} creator ${creator}
+ ${ID}= utils.getFieldValueFromDict ${sliceDict} id
+ ${getJsonDict}= utils.getDictFromListOfDict ${json_result} id ${ID}
+ ${test_result}= utils.compare_dict ${sliceDict} ${getJsonDict}
+ Should Be True ${json_result}
+
+Test Delete Slice API
+ [Arguments] ${listIndex}
+ ${json_getresult}= restApi.ApiGet CORE_SLICES
+ ${sliceList}= Get Variable Value ${sList}
+ ${sliceDict}= utils.listToDict ${sList} ${listIndex}
+ ${sliceName}= utils.getFieldValueFromDict ${sliceDict} name
+ Log ${sliceName}
+ ${getSliceDict}= utils.getDictFromListofDict ${json_getresult} name ${sliceName}
+ Log ${getSliceDict}
+ ${sliceID}= utils.getFieldValueFromDict ${getSliceDict} id
+ Log ${sliceID}
+ ${test_result}= restApi.ApiDelete CORE_SLICES ${sliceID}
+ Should be True ${test_result}
diff --git a/src/test/cord-api/Tests/data/Instance.json b/src/test/cord-api/Tests/data/Instance.json
new file mode 100644
index 0000000..9279d83
--- /dev/null
+++ b/src/test/cord-api/Tests/data/Instance.json
@@ -0,0 +1,20 @@
+{
+ "InstanceInfo": [
+ {
+ "name": "test-instance-1",
+ "image": 1,
+ "slice": 1,
+ "deployment": 1,
+ "node": 1,
+ "creator" : 1
+ },
+ {
+ "name": "test-instance-2",
+ "image": 2,
+ "slice": 2,
+ "deployment": 2,
+ "node": 2,
+ "creator" : 2
+ }
+ ]
+}
diff --git a/src/test/cord-api/Tests/data/Node.json b/src/test/cord-api/Tests/data/Node.json
new file mode 100644
index 0000000..d726f77
--- /dev/null
+++ b/src/test/cord-api/Tests/data/Node.json
@@ -0,0 +1,13 @@
+{
+ "NodeInfo":
+ [
+ {
+ "name": "test-node-1",
+ "site_deployment": "1"
+ },
+ {
+ "name": "test-node-2",
+ "site_deployment": "1"
+ }
+ ]
+}
diff --git a/src/test/cord-api/Tests/data/Slice.json b/src/test/cord-api/Tests/data/Slice.json
new file mode 100644
index 0000000..af932c5
--- /dev/null
+++ b/src/test/cord-api/Tests/data/Slice.json
@@ -0,0 +1,14 @@
+{
+ "SliceInfo": [
+ {
+ "name": "mysite_test-slice-1",
+ "site": 1,
+ "creator": 1
+ },
+ {
+ "name": "mysite_test-slice-2",
+ "site": 2,
+ "creator": 2
+ }
+ ]
+}