Created RESTCONF for base edition with of13 plugin 69/4369/3
authorMadhusudhan <madhusudhan.opendaylight@yahoo.com>
Sat, 18 Jan 2014 03:09:46 +0000 (19:09 -0800)
committerMadhusudhan <madhusudhan.opendaylight@yahoo.com>
Sat, 18 Jan 2014 03:48:06 +0000 (19:48 -0800)
Change-Id: I249e4cd37ae9086dba57637fc6e86ac48b29c623
Signed-off-by: Madhusudhan <madhusudhan.opendaylight@yahoo.com>
test/csit/libraries/RequestsLibrary.py
test/csit/suites/base-of13/005__restconf_inventory.txt [new file with mode: 0644]
test/csit/suites/base-of13/010__restconf_flows.txt [new file with mode: 0644]
test/csit/suites/base-of13/100__restart_mininet_OF10.txt [new file with mode: 0644]
test/csit/suites/base-of13/105__restconf_inventory.txt [new file with mode: 0644]
test/csit/suites/base-of13/110__restconf_flows.txt [new file with mode: 0644]
test/csit/suites/base-of13/__init__.txt [new file with mode: 0644]
test/csit/variables/Variables.py

index cf66e369c15e2dc5a392d62e2f5cd76363784a07..f6191bd1dd1b9807ff5b8e27768abf702b6205d6 100644 (file)
@@ -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 (file)
index 0000000..09232af
--- /dev/null
@@ -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 (file)
index 0000000..aac4e90
--- /dev/null
@@ -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}                   <flow xmlns="urn:opendaylight:flow:inventory"><priority>2</priority><flow-name>Foo</flow-name><match><ethernet-match><ethernet-type><type>2048</type></ethernet-type></ethernet-match><ipv4-destination>10.0.10.2/24</ipv4-destination></match><id>139</id><table_id>2</table_id><instructions><instruction><order>0</order><apply-actions><action><order>0</order><dec-nw-ttl/></action></apply-actions></instruction></instructions></flow>
+
+*** 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 (file)
index 0000000..68399a5
--- /dev/null
@@ -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 (file)
index 0000000..09232af
--- /dev/null
@@ -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 (file)
index 0000000..aac4e90
--- /dev/null
@@ -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}                   <flow xmlns="urn:opendaylight:flow:inventory"><priority>2</priority><flow-name>Foo</flow-name><match><ethernet-match><ethernet-type><type>2048</type></ethernet-type></ethernet-match><ipv4-destination>10.0.10.2/24</ipv4-destination></match><id>139</id><table_id>2</table_id><instructions><instruction><order>0</order><apply-actions><action><order>0</order><dec-nw-ttl/></action></apply-actions></instruction></instructions></flow>
+
+*** 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 (file)
index 0000000..8e27795
--- /dev/null
@@ -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 
index 100f3bca3187823a9355aa67a22de36b77a229b6..7c7765f29315b99826b84661d5a03e71ca3c61a7 100644 (file)
@@ -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