From: Madhusudhan Date: Sat, 18 Jan 2014 03:09:46 +0000 (-0800) Subject: Created RESTCONF for base edition with of13 plugin X-Git-Tag: release/helium~98 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=f7807e56041df7669a6c60d22f25fd9cbd7055d4;p=integration%2Ftest.git Created RESTCONF for base edition with of13 plugin Change-Id: I249e4cd37ae9086dba57637fc6e86ac48b29c623 Signed-off-by: Madhusudhan --- diff --git a/test/csit/libraries/RequestsLibrary.py b/test/csit/libraries/RequestsLibrary.py index cf66e369c1..f6191bd1dd 100644 --- a/test/csit/libraries/RequestsLibrary.py +++ b/test/csit/libraries/RequestsLibrary.py @@ -3,6 +3,7 @@ import json from urllib import urlencode + import robot from robot.libraries.BuiltIn import BuiltIn @@ -150,7 +151,7 @@ class RequestsLibrary(object): """ session = self._cache.switch(alias) - #data = json.dumps(self._utf8_urlencode(data)) + #data = self._utf8_urlencode(data) data = json.dumps(data) resp = session.put(self._get_url(session, uri), @@ -163,6 +164,32 @@ class RequestsLibrary(object): session.last_resp = resp return resp + def put_xml(self, alias, uri, data=None, headers=None): + """ Send a PUT_xml request on the session object found using the + given `alias` + + `alias` that will be used to identify the Session object in the cache + + `uri` to send the PUT_xml request to + + `headers` a dictionary of headers to use with the request + + """ + + session = self._cache.switch(alias) + data = self._utf8_urlencode(data) + #data = json.dumps(data) + + resp = session.put(self._get_url(session, uri), + data=data, headers=headers, + cookies=self.cookies, timeout=self.timeout) + + self.builtin.log("PUT response: %s DEBUG" % resp.content) + + # store the last response object + session.last_resp = resp + return resp + def delete(self, alias, uri, data=(), headers=None): """ Send a DELETE request on the session object found using the given `alias` @@ -185,6 +212,7 @@ class RequestsLibrary(object): session.last_resp = resp return resp + def head(self, alias, uri, headers=None): """ Send a HEAD request on the session object found using the given `alias` diff --git a/test/csit/suites/base-of13/005__restconf_inventory.txt b/test/csit/suites/base-of13/005__restconf_inventory.txt new file mode 100644 index 0000000000..09232afd59 --- /dev/null +++ b/test/csit/suites/base-of13/005__restconf_inventory.txt @@ -0,0 +1,31 @@ +*** Settings *** +Documentation Test suite for RESTCONF inventory +Suite Setup Create Session session http://${CONTROLLER}:8080 auth=${AUTH} headers=${HEADERS_XML} +Suite Teardown Delete All Sessions +Library Collections +Library ../../libraries/RequestsLibrary.py +Library ../../libraries/Common.py +Variables ../../variables/Variables.py + +*** Variables *** +${REST_CONTEXT} /restconf/datastore/opendaylight-inventory:nodes + +*** Test Cases *** +Get list of nodes + [Documentation] Get the inventory + ${resp} Get session ${REST_CONTEXT} + Should Be Equal As Strings ${resp.status_code} 200 + Should Contain ${resp.content} openflow:1 + Should Contain ${resp.content} openflow:2 + Should Contain ${resp.content} openflow:3 + +Get nodeconnector for a node + [Documentation] Get the inventory for a node + ${resp} Get session ${REST_CONTEXT}/node/openflow:2 + Should Be Equal As Strings ${resp.status_code} 200 + Should Contain ${resp.content} openflow:2:1 + Should Contain ${resp.content} openflow:2:2 + Should Contain ${resp.content} openflow:2:3 + + + diff --git a/test/csit/suites/base-of13/010__restconf_flows.txt b/test/csit/suites/base-of13/010__restconf_flows.txt new file mode 100644 index 0000000000..aac4e904b9 --- /dev/null +++ b/test/csit/suites/base-of13/010__restconf_flows.txt @@ -0,0 +1,53 @@ +*** Settings *** +Documentation Test suite for pushing/verify/remove a flow through RESTCONF +Suite Setup Create Session session http://${CONTROLLER}:8080 auth=${AUTH} headers=${HEADERS_XML} +Suite Teardown Delete All Sessions +Library Collections +Library ../../libraries/RequestsLibrary.py +Library ../../libraries/Common.py +Variables ../../variables/Variables.py + +*** Variables *** + +${REST_CON} /restconf/config/opendaylight-inventory:nodes +${REST_OPR} /restconf/operational/opendaylight-inventory:nodes +${BODY} 2Foo204810.0.10.2/24139200 + +*** Test Cases *** +Add a flow + [Documentation] Push a flow through REST-API + [Tags] Push + ${resp} Putxml session ${REST_CON}/node/openflow:1/table/2/flow/139 data=${BODY} + Should Be Equal As Strings ${resp.status_code} 200 + +Verify after adding flow config + [Documentation] Verify the flow + [Tags] Get + ${resp} Get session ${REST_CON}/node/openflow:1/table/2 + Should Be Equal As Strings ${resp.status_code} 200 + Should Contain ${resp.content} 10.0.10.2/24 + Should Contain ${resp.content} 2048 + +Verify after adding flow operational + [Documentation] Verify the flow + [Tags] Get + ${resp} Get session ${REST_OPR}/node/openflow:1/table/2 + Should Be Equal As Strings ${resp.status_code} 200 + Should Contain ${resp.content} "flow-node-inventory:id": 2 + +Remove a flow + [Documentation] Remove a flow + [Tags] remove + ${resp} Delete session ${REST_CON}/node/openflow:1/table/2/flow/139 + Should Be Equal As Strings ${resp.status_code} 200 + +Verify after deleting flow config + [Documentation] Verify the flow + [Tags] Get + ${resp} Get session ${REST_CON}/node/openflow:1/table/2 + Should Be Equal As Strings ${resp.status_code} 404 + Should Contain ${resp.content} No data exists + Should Not Contain ${resp.content} 10.0.10.2/24 + Should Not Contain ${resp.content} 2048 + + diff --git a/test/csit/suites/base-of13/100__restart_mininet_OF10.txt b/test/csit/suites/base-of13/100__restart_mininet_OF10.txt new file mode 100644 index 0000000000..68399a5507 --- /dev/null +++ b/test/csit/suites/base-of13/100__restart_mininet_OF10.txt @@ -0,0 +1,20 @@ +*** Settings *** +Documentation Restat Mininet with OF10 simulation +Library SSHLibrary + +*** Variables *** +${start}= sudo mn --controller=remote,ip=${CONTROLLER} --topo tree,2 + +*** Test Cases *** +Stop Mininet + Log Stop Mininet + Read + Write exit + Sleep 4 + Read +Start Mininet + Log Start Mininet + Write ${start} + Sleep 70 + Read + diff --git a/test/csit/suites/base-of13/105__restconf_inventory.txt b/test/csit/suites/base-of13/105__restconf_inventory.txt new file mode 100644 index 0000000000..09232afd59 --- /dev/null +++ b/test/csit/suites/base-of13/105__restconf_inventory.txt @@ -0,0 +1,31 @@ +*** Settings *** +Documentation Test suite for RESTCONF inventory +Suite Setup Create Session session http://${CONTROLLER}:8080 auth=${AUTH} headers=${HEADERS_XML} +Suite Teardown Delete All Sessions +Library Collections +Library ../../libraries/RequestsLibrary.py +Library ../../libraries/Common.py +Variables ../../variables/Variables.py + +*** Variables *** +${REST_CONTEXT} /restconf/datastore/opendaylight-inventory:nodes + +*** Test Cases *** +Get list of nodes + [Documentation] Get the inventory + ${resp} Get session ${REST_CONTEXT} + Should Be Equal As Strings ${resp.status_code} 200 + Should Contain ${resp.content} openflow:1 + Should Contain ${resp.content} openflow:2 + Should Contain ${resp.content} openflow:3 + +Get nodeconnector for a node + [Documentation] Get the inventory for a node + ${resp} Get session ${REST_CONTEXT}/node/openflow:2 + Should Be Equal As Strings ${resp.status_code} 200 + Should Contain ${resp.content} openflow:2:1 + Should Contain ${resp.content} openflow:2:2 + Should Contain ${resp.content} openflow:2:3 + + + diff --git a/test/csit/suites/base-of13/110__restconf_flows.txt b/test/csit/suites/base-of13/110__restconf_flows.txt new file mode 100644 index 0000000000..aac4e904b9 --- /dev/null +++ b/test/csit/suites/base-of13/110__restconf_flows.txt @@ -0,0 +1,53 @@ +*** Settings *** +Documentation Test suite for pushing/verify/remove a flow through RESTCONF +Suite Setup Create Session session http://${CONTROLLER}:8080 auth=${AUTH} headers=${HEADERS_XML} +Suite Teardown Delete All Sessions +Library Collections +Library ../../libraries/RequestsLibrary.py +Library ../../libraries/Common.py +Variables ../../variables/Variables.py + +*** Variables *** + +${REST_CON} /restconf/config/opendaylight-inventory:nodes +${REST_OPR} /restconf/operational/opendaylight-inventory:nodes +${BODY} 2Foo204810.0.10.2/24139200 + +*** Test Cases *** +Add a flow + [Documentation] Push a flow through REST-API + [Tags] Push + ${resp} Putxml session ${REST_CON}/node/openflow:1/table/2/flow/139 data=${BODY} + Should Be Equal As Strings ${resp.status_code} 200 + +Verify after adding flow config + [Documentation] Verify the flow + [Tags] Get + ${resp} Get session ${REST_CON}/node/openflow:1/table/2 + Should Be Equal As Strings ${resp.status_code} 200 + Should Contain ${resp.content} 10.0.10.2/24 + Should Contain ${resp.content} 2048 + +Verify after adding flow operational + [Documentation] Verify the flow + [Tags] Get + ${resp} Get session ${REST_OPR}/node/openflow:1/table/2 + Should Be Equal As Strings ${resp.status_code} 200 + Should Contain ${resp.content} "flow-node-inventory:id": 2 + +Remove a flow + [Documentation] Remove a flow + [Tags] remove + ${resp} Delete session ${REST_CON}/node/openflow:1/table/2/flow/139 + Should Be Equal As Strings ${resp.status_code} 200 + +Verify after deleting flow config + [Documentation] Verify the flow + [Tags] Get + ${resp} Get session ${REST_CON}/node/openflow:1/table/2 + Should Be Equal As Strings ${resp.status_code} 404 + Should Contain ${resp.content} No data exists + Should Not Contain ${resp.content} 10.0.10.2/24 + Should Not Contain ${resp.content} 2048 + + diff --git a/test/csit/suites/base-of13/__init__.txt b/test/csit/suites/base-of13/__init__.txt new file mode 100644 index 0000000000..8e277950e9 --- /dev/null +++ b/test/csit/suites/base-of13/__init__.txt @@ -0,0 +1,27 @@ +*** Settings *** +Documentation Test suite for the OpenDaylight base edition with of13 +Suite Setup Start Suite +Suite Teardown Stop Suite +Library SSHLibrary + +*** Variables *** +${start}= sudo mn --controller=remote,ip=${CONTROLLER} --topo tree,2 --switch ovsk,protocols=OpenFlow13 + +*** Keywords *** +Start Suite + Log Start the test on the base edition + Open Connection ${MININET} prompt=> + Login With Public Key ${MININET_USER} ${USER_HOME}/.ssh/id_rsa any + Write sudo ovs-vsctl set-manager ptcp:6640 + Write sudo mn -c + Sleep 2 + Write ${start} + Sleep 70 + Read +Stop Suite + Log Stop the test on the base edition + Read + Write exit + Sleep 4 + Read + Close Connection diff --git a/test/csit/variables/Variables.py b/test/csit/variables/Variables.py index 100f3bca31..7c7765f293 100644 --- a/test/csit/variables/Variables.py +++ b/test/csit/variables/Variables.py @@ -6,13 +6,14 @@ Updated: 2013-11-14 import collections # Global variables -CONTROLLER = '127.0.0.1' +CONTROLLER = '10.125.136.52' PORT = '8080' PREFIX = 'http://' + CONTROLLER + ':' + PORT CONTAINER = 'default' USER = 'admin' PWD = 'admin' AUTH = [u'admin',u'admin'] -HEADERS={'Content-Type':'application/json'} +HEADERS={'Content-Type': 'application/json'} +HEADERS_XML={'Content-Type': 'application/xml'} ODL_CONTROLLER_SESSION=None TOPO_TREE_LEVEL=2