Remove OVS passive mode in mininet until Andy fixes mininet
authorLuis Gomez <luis.gomez@ericsson.com>
Sat, 23 Nov 2013 04:56:25 +0000 (20:56 -0800)
committerLuis Gomez <luis.gomez@ericsson.com>
Tue, 26 Nov 2013 00:28:47 +0000 (16:28 -0800)
Change-Id: I8d83858a3d028db4bda7619cd7908962271b7699
Signed-off-by: Luis Gomez <luis.gomez@ericsson.com>
test/csit/libraries/RequestsLibrary.py [new file with mode: 0644]
test/csit/suites/base/010_topology_manager.txt [new file with mode: 0644]
test/csit/suites/base/015_forwarding_rules_manager.txt [new file with mode: 0644]
test/csit/suites/base/020_host_tracker.txt [new file with mode: 0644]
test/csit/suites/base/025_arp_handler.txt [new file with mode: 0644]
test/csit/suites/base/030_forwarding_manager.txt [new file with mode: 0644]
test/csit/suites/base/__init__.txt

diff --git a/test/csit/libraries/RequestsLibrary.py b/test/csit/libraries/RequestsLibrary.py
new file mode 100644 (file)
index 0000000..cf66e36
--- /dev/null
@@ -0,0 +1,206 @@
+import requests
+import json
+
+from urllib import urlencode
+
+import robot
+
+from robot.libraries.BuiltIn import BuiltIn
+
+
+class RequestsLibrary(object):
+    ROBOT_LIBRARY_SCOPE = 'Global'
+
+    def __init__(self):
+        self._cache = robot.utils.ConnectionCache('No sessions created')
+        self.builtin = BuiltIn()
+
+    def _utf8_urlencode(self, data):
+        if not type(data) is dict:
+            return data
+
+        utf8_data = {}
+        for k,v in data.iteritems():
+            utf8_data[k] = unicode(v).encode('utf-8')
+        return urlencode(utf8_data)
+
+    def create_session(self, alias, url, headers={}, cookies=None,
+                       auth=None, timeout=None, proxies=None,
+                       verify=False):
+
+        """ Create Session: create a HTTP session to a server
+
+        `url` Base url of the server
+
+        `alias` Robot Framework alias to identify the session
+
+        `headers` Dictionary of default headers
+
+        `auth` Dictionary of username & password for HTTP Basic Auth
+
+        `timeout` connection timeout
+
+        `proxies` proxy server url
+
+        `verify` set to True if Requests should verify the certificate
+        """
+
+        self.builtin.log('Creating session: %s' % alias, 'DEBUG')
+        auth = requests.auth.HTTPBasicAuth(*auth) if auth else None
+        s = session = requests.Session()
+        s.headers.update(headers)
+        s.auth = auth if auth else s.auth
+        s.proxies = proxies if proxies else  s.proxies
+
+        s.verify = self.builtin.convert_to_boolean(verify)
+
+        # cant pass these into the Session anymore
+        self.timeout = timeout
+        self.cookies = cookies
+        self.verify = verify
+
+        # cant use hooks :(
+        s.url = url
+
+        self._cache.register(session, alias=alias)
+        return session
+
+    def delete_all_sessions(self):
+        """ Removes all the session objects """
+
+        self._cache.empty_cache()
+
+    def to_json(self, content):
+        """ Convert a string to a JSON object
+
+        `content` String content to convert into JSON
+        """
+        return json.loads(content)
+
+    
+    def _get_url(self, session, uri):
+        ''' Helpere method to get the full url
+        '''
+        url = session.url
+        if uri:
+            slash = '' if uri.startswith('/') else '/'
+            url = "%s%s%s" %(session.url, slash, uri)
+        return url
+
+    def get(self, alias, uri, headers=None):
+        """ Send a GET 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 GET request to
+
+        `headers` a dictionary of headers to use with the request
+        """
+
+        session = self._cache.switch(alias)
+        resp = session.get(self._get_url(session, uri),
+                           headers=headers,
+                           cookies=self.cookies, timeout=self.timeout)
+
+        # store the last response object
+        session.last_resp = resp
+        return resp
+
+    def post(self, alias, uri, data={}, headers=None, files={}):
+        """ Send a POST 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 GET request to
+
+        `data` a dictionary of key-value pairs that will be urlencoded
+               and sent as POST data
+               or binary data that is sent as the raw body content
+
+        `headers` a dictionary of headers to use with the request
+
+        `files` a dictionary of file names containing file data to POST to the server
+        """
+
+        session = self._cache.switch(alias)
+        data = self._utf8_urlencode(data)
+
+        resp = session.post(self._get_url(session, uri),
+                       data=data, headers=headers,
+                       files=files,
+                       cookies=self.cookies, timeout=self.timeout)
+
+        # store the last response object
+        session.last_resp = resp
+        self.builtin.log("Post response: " + resp.content, 'DEBUG')
+        return resp
+
+    def put(self, alias, uri, data=None, headers=None):
+        """ Send a PUT 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 request to
+
+        `headers` a dictionary of headers to use with the request
+
+        """
+
+        session = self._cache.switch(alias)
+        #data = json.dumps(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`
+
+        `alias` that will be used to identify the Session object in the cache
+
+        `uri` to send the DELETE request to
+
+        `headers` a dictionary of headers to use with the request
+
+        """
+
+        session = self._cache.switch(alias)
+        args = "?%s" % urlencode(data) if data else ''
+        resp = session.delete("%s%s" % (self._get_url(session, uri), args),
+                            headers=headers, cookies=self.cookies,
+                            timeout=self.timeout)
+
+        # store the last response 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`
+
+        `alias` that will be used to identify the Session object in the cache
+
+        `uri` to send the HEAD request to
+
+        `headers` a dictionary of headers to use with the request
+
+        """
+
+        session = self._cache.switch(alias)
+        resp = session.head(self._get_url(session, uri), headers=headers,
+                           cookies=self.cookies, timeout=self.timeout)
+
+        # store the last response object
+        session.last_resp = resp
+        return resp
diff --git a/test/csit/suites/base/010_topology_manager.txt b/test/csit/suites/base/010_topology_manager.txt
new file mode 100644 (file)
index 0000000..1b12f4c
--- /dev/null
@@ -0,0 +1,59 @@
+*** Settings ***
+Documentation     Test suite for Topology Manager
+Suite Teardown    Delete All Sessions
+Library           Collections
+Library           ../../libraries/RequestsLibrary.py
+Library           ../../libraries/Common.py
+Variables         ../../variables/Variables.py
+
+*** Variables ***
+${nodeconn1}   NodeConnector":{"type":"OF","node":{"type":"OF","id":"00:00:00:00:00:00:00:01"},"id":"1"}
+${nodeconn2}   NodeConnector":{"type":"OF","node":{"type":"OF","id":"00:00:00:00:00:00:00:01"},"id":"2"}
+${nodeconn3}   NodeConnector":{"type":"OF","node":{"type":"OF","id":"00:00:00:00:00:00:00:02"},"id":"3"}
+${nodeconn4}   NodeConnector":{"type":"OF","node":{"type":"OF","id":"00:00:00:00:00:00:00:03"},"id":"3"}
+${name}           test_userlink1
+${key}            userLinks
+${REST_CONTEXT}    /controller/nb/v2/topology
+
+*** Test Cases ***
+Get Topology
+    [Documentation]    Get Topology and validate the result.
+    [Tags]    get
+    ${headers}    Create Dictionary    Content-Type    application/json
+    Create Session    session    http://${CONTROLLER}:8080   headers=${headers}    auth=${auth}
+    ${resp}    Get    session    ${REST_CONTEXT}/${CONTAINER}
+    Should Be Equal As Strings    ${resp.status_code}    200    Response    status code error
+    Log    ${resp.content}
+    Should Contain X Times  ${resp.content}   ${nodeconn1}   2
+    Should Contain X Times  ${resp.content}   ${nodeconn2}   2
+    Should Contain X Times  ${resp.content}   ${nodeconn3}   2
+    Should Contain X Times  ${resp.content}   ${nodeconn4}   2
+Add a userlink
+    [Documentation]    Add a userlink, list to validate the result.
+    [Tags]    add
+    ${body}    Create Dictionary    name    ${name}    status    Success    srcNodeConnector
+    ...    OF|1@OF|00:00:00:00:00:00:00:02    dstNodeConnector    OF|1@OF|00:00:00:00:00:00:00:03
+    ${headers}    Create Dictionary    Content-Type    application/json
+    Create Session    session    http://${CONTROLLER}:8080    headers=${headers}    auth=${auth}
+    ${resp}    Put    session    ${REST_CONTEXT}/${CONTAINER}/userLink/${name}    data=${body}
+    Should Be Equal As Strings    ${resp.status_code}    201    Response status code error
+    ${resp}    Get    session    ${REST_CONTEXT}/${CONTAINER}/userLinks
+    Should Be Equal As Strings    ${resp.status_code}    200    Response status code error
+    ${result}    To JSON    ${resp.content}
+    ${content}    Get From Dictionary    ${result}    ${key}
+    List Should Contain Value    ${content}    ${body}
+
+Remove a userlink
+    [Documentation]    Remove a userlink, list to validate the result.
+    [Tags]    remove
+    ${body}    Create Dictionary    name    ${name}    status    Success    srcNodeConnector
+    ...    OF|1@OF|00:00:00:00:00:00:00:02    dstNodeConnector    OF|1@OF|00:00:00:00:00:00:00:03
+    ${headers}    Create Dictionary    Content-Type    application/json
+    Create Session    session    http://${CONTROLLER}:8080    headers=${headers}    auth=${auth}
+    ${resp}    Delete    session    ${REST_CONTEXT}/${CONTAINER}/userLink/${name}
+    Should Be Equal As Strings    ${resp.status_code}    204    Response status code error
+    ${resp}    Get    session    ${REST_CONTEXT}/${CONTAINER}/userLinks
+    Should Be Equal As Strings    ${resp.status_code}    200    Response status code error
+    ${result}    To JSON    ${resp.content}
+    ${content}    Get From Dictionary    ${result}    ${key}
+    List Should Not Contain Value    ${content}    ${body}
diff --git a/test/csit/suites/base/015_forwarding_rules_manager.txt b/test/csit/suites/base/015_forwarding_rules_manager.txt
new file mode 100644 (file)
index 0000000..88c2fa5
--- /dev/null
@@ -0,0 +1,50 @@
+*** Settings ***
+Documentation     Test suite for the forwarding rule manager module.
+Suite Teardown    Delete All Sessions
+Library           Collections
+Library           ../../libraries/RequestsLibrary.py
+Library           ../../libraries/Common.py
+Variables         ../../variables/Variables.py
+
+*** Variables ***
+${name}           flow1
+${key}            flowConfig
+${node_id}        00:00:00:00:00:00:00:02
+${REST_CONTEXT}    /controller/nb/v2/flowprogrammer
+
+*** Test Cases ***
+Add a flow
+    [Documentation]    Add a flow, list to validate the result.
+    [Tags]    add
+    ${node}    Create Dictionary    type    OF    id    ${node_id}
+    ${actions}    Create List    OUTPUT=1
+    ${body}    Create Dictionary    name    ${name}    installInHw    true    node
+    ...    ${node}    priority    1    etherType    0x800    nwDst
+    ...    10.0.0.1/32    actions    ${actions}
+    ${headers}    Create Dictionary    Content-Type    application/json
+    Create Session    session    http://${CONTROLLER}:8080    headers=${headers}    auth=${auth}
+    ${resp}    Put    session    ${REST_CONTEXT}/${CONTAINER}/node/OF/${node_id}/staticFlow/${name}    data=${body}
+    Should Be Equal As Strings    ${resp.status_code}    201    Response status code error
+    ${resp}    Get    session    ${REST_CONTEXT}/${CONTAINER}
+    Should Be Equal As Strings    ${resp.status_code}    200    Response status code error
+    ${result}    To JSON    ${resp.content}
+    ${content}    Get From Dictionary    ${result}    ${key}
+    List Should Contain Value    ${content}    ${body}
+
+Remove a flow
+    [Documentation]    Remove a flow, list to validate the result.
+    [Tags]    remove
+    ${node}    Create Dictionary    type    OF    id    ${node_id}
+    ${actions}    Create List    OUTPUT=1
+    ${body}    Create Dictionary    name    ${name}    installInHw    true    node
+    ...    ${node}    priority    1    etherType    0x800    nwDst
+    ...    10.0.0.1/32    actions    ${actions}
+    ${headers}    Create Dictionary    Content-Type    application/json
+    Create Session    session    http://${CONTROLLER}:8080    headers=${headers}    auth=${auth}
+    ${resp}    Delete    session    ${REST_CONTEXT}/${CONTAINER}/node/OF/${node_id}/staticFlow/${name}
+    Should Be Equal As Strings    ${resp.status_code}    204    Response status code error
+    ${resp}    Get    session    ${REST_CONTEXT}/${CONTAINER}
+    Should Be Equal As Strings    ${resp.status_code}    200    Response status code error
+    ${result}    To JSON    ${resp.content}
+    ${content}    Get From Dictionary    ${result}    ${key}
+    List Should Not Contain Value    ${content}    ${body}
diff --git a/test/csit/suites/base/020_host_tracker.txt b/test/csit/suites/base/020_host_tracker.txt
new file mode 100644 (file)
index 0000000..a01f73b
--- /dev/null
@@ -0,0 +1,45 @@
+*** Settings ***
+Documentation     Test suite for the host tracker module.
+Suite Teardown    Delete All Sessions
+Library           Collections
+Library           ../../libraries/RequestsLibrary.py
+Library           ../../libraries/Common.py
+Variables         ../../variables/Variables.py
+
+*** Variables ***
+${name}           10.0.1.4
+${key}            hostConfig
+${REST_CONTEXT}    /controller/nb/v2/hosttracker
+
+*** Test Cases ***
+Add a host
+    [Documentation]    Add a host, list to validate the result.
+    [Tags]    add
+    ${body}    Create Dictionary    nodeType    OF    dataLayerAddress    5e:bf:79:84:10:a6    vlan
+    ...    1    nodeId    00:00:00:00:00:00:00:03    nodeConnectorId    9    networkAddress
+    ...    10.0.1.4    staticHost    ${True}    nodeConnectorType    OF
+    ${headers}    Create Dictionary    Content-Type    application/json
+    Create Session    session    http://${CONTROLLER}:8080    headers=${headers}    auth=${auth}
+    ${resp}    Put    session    ${REST_CONTEXT}/${CONTAINER}/address/${name}    data=${body}
+    Should Be Equal As Strings    ${resp.status_code}    201    Response status code error
+    ${resp}    Get    session    ${REST_CONTEXT}/${CONTAINER}/hosts/inactive
+    Should Be Equal As Strings    ${resp.status_code}    200    Response status code error
+    ${result}    To JSON    ${resp.content}
+    ${content}    Get From Dictionary    ${result}    ${key}
+    List Should Contain Value    ${content}    ${body}
+
+Remove a host
+    [Documentation]    Remove a host, list to validate the result.
+    [Tags]    remove
+    ${body}    Create Dictionary    nodeType    OF    dataLayerAddress    5e:bf:79:84:10:a6    vlan
+    ...    1    nodeId    00:00:00:00:00:00:00:03    nodeConnectorId    9    networkAddress
+    ...    10.0.1.4    staticHost    ${True}    nodeConnectorType    OF
+    ${headers}    Create Dictionary    Content-Type    application/json
+    Create Session    session    http://${CONTROLLER}:8080    headers=${headers}    auth=${auth}
+    ${resp}    Delete    session    ${REST_CONTEXT}/${CONTAINER}/address/${name}
+    Should Be Equal As Strings    ${resp.status_code}    204    Response status code error
+    ${resp}    Get    session    ${REST_CONTEXT}/${CONTAINER}/hosts/inactive
+    Should Be Equal As Strings    ${resp.status_code}    200    Response status code error
+    ${result}    To JSON    ${resp.content}
+    ${content}    Get From Dictionary    ${result}    ${key}
+    List Should Not Contain Value    ${content}    ${body}
diff --git a/test/csit/suites/base/025_arp_handler.txt b/test/csit/suites/base/025_arp_handler.txt
new file mode 100644 (file)
index 0000000..3b01649
--- /dev/null
@@ -0,0 +1,41 @@
+*** Settings ***
+Documentation     Test suite for the arp handler module.
+Suite Teardown    Delete All Sessions
+Library           Collections
+Library           ../../libraries/RequestsLibrary.py
+Library           ../../libraries/Common.py
+Variables         ../../variables/Variables.py
+
+*** Variables ***
+${name}           test
+${key}            subnetConfig
+${REST_CONTEXT}    /controller/nb/v2/subnetservice
+
+*** Test Cases ***
+Add a subnet
+    [Documentation]    Add a subnet, list to validate the result.
+    [Tags]    add
+    ${body}    Create Dictionary    name    ${name}    subnet    10.0.0.254/8
+    ${headers}    Create Dictionary    Content-Type    application/json
+    Create Session    session    http://${CONTROLLER}:8080    headers=${headers}    auth=${auth}
+    ${resp}    Put    session    ${REST_CONTEXT}/${CONTAINER}/subnet/${name}    data=${body}
+    Should Be Equal As Strings    ${resp.status_code}    201    Response status code error
+    ${resp}    Get    session    ${REST_CONTEXT}/${CONTAINER}/subnets
+    Should Be Equal As Strings    ${resp.status_code}    200    Response status code error
+    ${result}    To JSON    ${resp.content}
+    ${content}    Get From Dictionary    ${result}    ${key}
+    List Should Contain Value    ${content}    ${body}
+
+Remove a subnet
+    [Documentation]    Remove a subnet, list to validate the result.
+    [Tags]    remove
+    ${body}    Create Dictionary    name    ${name}    subnet    10.0.0.254/8
+    ${headers}    Create Dictionary    Content-Type    application/json
+    Create Session    session    http://${CONTROLLER}:8080    headers=${headers}    auth=${auth}
+    ${resp}    Delete    session    ${REST_CONTEXT}/${CONTAINER}/subnet/${name}
+    Should Be Equal As Strings    ${resp.status_code}    204    Response status code error
+    ${resp}    Get    session    ${REST_CONTEXT}/${CONTAINER}/subnets
+    Should Be Equal As Strings    ${resp.status_code}    200    Response status code error
+    ${result}    To JSON    ${resp.content}
+    ${content}    Get From Dictionary    ${result}    ${key}
+    List Should Not Contain Value    ${content}    ${body}
diff --git a/test/csit/suites/base/030_forwarding_manager.txt b/test/csit/suites/base/030_forwarding_manager.txt
new file mode 100644 (file)
index 0000000..0a2d3e9
--- /dev/null
@@ -0,0 +1,43 @@
+*** Settings ***
+Documentation     Test suite for the forwarding manager module.
+Suite Teardown    Delete All Sessions
+Library           Collections
+Library           ../../libraries/RequestsLibrary.py
+Library           ../../libraries/Common.py
+Variables         ../../variables/Variables.py
+
+*** Variables ***
+${name}           test_route1
+${key}            staticRoute
+${REST_CONTEXT}    /controller/nb/v2/staticroute
+
+*** Test Cases ***
+Add a static route
+    [Documentation]    Add a static route, list to validate the result.
+    [Tags]    add
+    ${body}    Create Dictionary    name    ${name}    prefix    192.168.1.0/24    nextHop
+    ...    10.0.0.2
+    ${headers}    Create Dictionary    Content-Type    application/json
+    Create Session    session    http://${CONTROLLER}:8080    headers=${headers}    auth=${auth}
+    ${resp}    Put    session    ${REST_CONTEXT}/${CONTAINER}/route/${name}    data=${body}
+    Should Be Equal As Strings    ${resp.status_code}    201    Response status code error
+    ${resp}    Get    session    ${REST_CONTEXT}/${CONTAINER}/routes
+    Should Be Equal As Strings    ${resp.status_code}    200    Response status code error
+    ${result}    To JSON    ${resp.content}
+    ${content}    Get From Dictionary    ${result}    ${key}
+    List Should Contain Value    ${content}    ${body}
+
+Remove a static route
+    [Documentation]    Remove a static route, list to validate the result.
+    [Tags]    remove
+    ${body}    Create Dictionary    name    ${name}    prefix    192.168.1.0/24    nextHop
+    ...    10.0.0.2
+    ${headers}    Create Dictionary    Content-Type    application/json
+    Create Session    session    http://${CONTROLLER}:8080    headers=${headers}    auth=${auth}
+    ${resp}    Delete    session    ${REST_CONTEXT}/${CONTAINER}/route/${name}
+    Should Be Equal As Strings    ${resp.status_code}    204    Response status code error
+    ${resp}    Get    session    ${REST_CONTEXT}/${CONTAINER}/routes
+    Should Be Equal As Strings    ${resp.status_code}    200    Response status code error
+    ${result}    To JSON    ${resp.content}
+    ${content}    Get From Dictionary    ${result}    ${key}
+    List Should Not Contain Value    ${content}    ${body}
index 1d6b8bb70169cf4be092af419eea052bcc2b0416..3d245238528b228bbe24ca9555827288f542e2f1 100644 (file)
@@ -1,6 +1,7 @@
 *** Settings ***
 Documentation     Test suite for the OpenDaylight base edition
 Suite Setup       Start Suite
+Suite Teardown    Stop Suite
 Library     SSHLibrary
 
 *** Variables ***
@@ -18,5 +19,7 @@ Stop Suite
     Log    Stop the test on the base edition
     Write    exit 
     Sleep    2
+    Write    sudo mn -c
+    Sleep    2
     Read 
     Close Connection