Merge "Have modified the testcases for RESTCONF inventory and uncommented the failed...
authorLuis Gomez <luis.gomez@ericsson.com>
Thu, 20 Feb 2014 17:10:25 +0000 (17:10 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 20 Feb 2014 17:10:25 +0000 (17:10 +0000)
test/csit/libraries/RequestsLibrary.py
test/csit/suites/vtn/040__vtn_coordinator.txt [new file with mode: 0644]
test/csit/variables/Variables.py

index f6191bd1dd1b9807ff5b8e27768abf702b6205d6..3ef4375d6fc62ade4cf62597051f1312c28bb489 100644 (file)
@@ -138,6 +138,36 @@ class RequestsLibrary(object):
         self.builtin.log("Post response: " + resp.content, 'DEBUG')
         return resp
 
+    def postjson(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 = json.dumps(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`
diff --git a/test/csit/suites/vtn/040__vtn_coordinator.txt b/test/csit/suites/vtn/040__vtn_coordinator.txt
new file mode 100644 (file)
index 0000000..7bfc4c9
--- /dev/null
@@ -0,0 +1,159 @@
+*** Settings ***
+Documentation     Test suite for VTN Coordinator
+Suite Setup       Create Session    session    http://${CONTROLLER}:8081  headers=${VTNC_HEADERS}
+Suite Teardown    Delete All Sessions
+Library           SSHLibrary
+Library           Collections
+Library           ../../libraries/RequestsLibrary.py
+Library           ../../libraries/Common.py
+Library           ../../libraries/Topology.py
+Variables         ../../variables/Variables.py
+
+
+
+*** Test Cases ***
+Add a ODL Controller
+    [Documentation]    Add a Controller
+    [Tags]    vtnc
+    Add a Controller    odc_test     ${CONTROLLER}
+
+
+Verify the Controller Status is up
+    [Documentation]    Check Controller status
+    [Tags]   vtnc 
+    Check Controller Status    odc_test
+
+
+Add a Vtn Tenant1
+    [Documentation]   Create Vtn Tenant1
+    [Tags]   vtnc 
+    Add a VTN  Tenant1  VTN_TEST
+
+
+Create VBR in VTN Tenant1
+    [Documentation]   Create a VBR in Tenant1 as Vbridge1
+    [Tags]   vtnc 
+    Create VBR in VTN     Tenant1    Vbridge1    odc_test
+
+
+Create VBRIF in VBRIDGE Vbridge1 Interface1
+    [Documentation]   Create an interface to Vbridge1
+    [Tags]   vtnc 
+    Create VBRIF in VBR   Tenant1    Vbridge1   Interface1  Interface1
+
+
+Create VBRIF in VBRIDGE Vbridge1 Interface2
+    [Documentation]   Create an interface to Vbridge1
+    [Tags]   vtnc 
+    Create VBRIF in VBR   Tenant1    Vbridge1   Interface2  Interface2
+
+
+Define Portmap for Interface1
+    [Documentation]   Map Interface1 to a logical port
+    [Tags]   vtnc
+    Define Portmap for VBRIF    Tenant1    Vbridge1     Interface1    PP-OF:00:00:00:00:00:00:00:03-s3-eth1
+
+
+Define Portmap for Interface2
+    [Documentation]   Map Interface2 to a logical port
+    [Tags]   vtnc 
+    Define Portmap for VBRIF    Tenant1    Vbridge1     Interface2    PP-OF:00:00:00:00:00:00:00:02-s2-eth1
+
+
+Test Ping for Configuration1
+    [Documentation]   ping between hosts in mininet
+    [Tags]   vtnc 
+    Test Ping    h1    h3
+
+
+Delete a VTN Tenant1
+    [Documentation]   Delete Vtn Tenant1
+    [Tags]   vtnc
+    Delete a VTN  Tenant1
+
+
+Delete a Controller odc1
+    [Documentation]   Delete Controller odc1
+    [Tags]   vtnc
+    Remove Controller    odc_test
+
+
+
+*** Keywords ***
+Add a Controller
+   [Arguments]   ${ctrlname}   ${ctrlip}
+   [Documentation]    Create a controller
+   ${controllerinfo}    Create Dictionary   controller_id   ${ctrlname}   type    odc    ipaddr    ${CONTROLLER}    version    1.0    auditstatus    enable
+   ${controllercreate}    Create Dictionary   controller    ${controllerinfo}
+   ${resp}    PostJson    session    ${VTNWEBAPI}/${CTRLS_CREATE}    data=${controllercreate}
+   Should Be Equal As Strings    ${resp.status_code}    200
+
+
+Remove Controller
+   [Arguments]   ${ctrlname}
+   [Documentation]   Delete a Controller
+   ${resp}    Delete   session    ${VTNWEBAPI}/${CTRLS}/${ctrlname}.json
+   Should Be Equal As Strings    ${resp.status_code}    200
+
+
+Check Controller Status
+   [Arguments]   ${ctrlname}
+   [Documentation]    Get controller status
+   Sleep    15
+   ${resp}    Get   session    ${VTNWEBAPI}/${CTRLS}/${ctrlname}.json
+   ${contents}    To JSON    ${resp.content}
+   ${controllerblock}    Get From Dictionary    ${contents}   controller
+   ${status}    Get From Dictionary    ${controllerblock}     operstatus
+   Should Be Equal As Strings    ${status}    up
+
+
+Add a VTN
+   [Arguments]   ${vtnname}    ${vtndescription}
+   [Documentation]    Create VTN in Coordinator
+   ${vtninfo}    Create Dictionary    vtn_name    ${vtnname}    description    ${vtndescription}
+   ${vtncreate}    Create Dictionary    vtn    ${vtninfo}
+   ${resp}    PostJson    session    ${VTNWEBAPI}/${VTNS_CREATE}    data=${vtncreate}
+   Should Be Equal As Strings    ${resp.status_code}    200
+
+
+Delete a VTN
+   [Arguments]   ${vtnname}
+   [Documentation]  Delete a VTN Created
+   ${resp}    Delete    session    ${VTNWEBAPI}/${VTNS}/${vtnname}.json
+   Should Be Equal As Strings    ${resp.status_code}    200
+
+
+Create VBR in VTN
+   [Arguments]   ${vtnname}    ${vbrname}    ${ctrlname}
+   [Documentation]    Create VBR for VTN in Coordinator
+   ${vbrinfo}    Create Dictionary   vbr_name    ${vbrname}    controller_id   ${ctrlname}    domain_id    (DEFAULT)
+   ${vbrcreate}   Create Dictionary   vbridge    ${vbrinfo}
+   ${resp}    PostJson    session    ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS_CREATE}    data=${vbrcreate}
+   Should Be Equal As Strings    ${resp.status_code}    200
+
+
+Create VBRIF in VBR
+   [Arguments]   ${vtnname}    ${vbrname}    ${vbrifname}    ${ifdescription}
+   [Documentation]    Create VBR Interface in VBR
+   ${vbrifinfo}    Create Dictionary   if_name    ${vbrifname}    description    ${ifdescription}
+   ${vbrifcreate}    Create Dictionary   interface    ${vbrifinfo}
+   ${resp}    PostJson    session    ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${VBRIFS_CREATE}  data=${vbrifcreate}
+   Should Be Equal As Strings    ${resp.status_code}    200
+
+
+Define Portmap for VBRIF
+   [Arguments]   ${vtnname}    ${vbrname}    ${vbrifname}   ${logical_port_id}
+   [Documentation]   Map  Interface to a logical port
+   ${logical_port_info}    Create Dictionary    logical_port_id    ${logical_port_id}
+   ${portmapdefine}     Create Dictionary     portmap     ${logical_port_info}
+   ${resp}   Put     session      ${VTNWEBAPI}/${VTNS}/${vtnname}/${VBRS}/${vbrname}/${VBRIFS}/${vbrifname}/${PORTMAP_CREATE}    data=${portmapdefine}
+   Should Be Equal As Strings    ${resp.status_code}    200
+
+Test Ping
+   [Arguments]   ${host1}    ${host2}
+   [Documentation]  Ping hosts to check connectivity
+   Sleep   5
+   Write    ${host1} ping -c 10 ${host2}
+   Sleep    10
+   ${result}    Read
+   Should Contain    ${result}    64 bytes
index 7c7765f29315b99826b84661d5a03e71ca3c61a7..97b2da79367fdd009010b159f6268abcdea717aa 100644 (file)
@@ -17,3 +17,29 @@ HEADERS={'Content-Type': 'application/json'}
 HEADERS_XML={'Content-Type': 'application/xml'}
 ODL_CONTROLLER_SESSION=None
 TOPO_TREE_LEVEL=2
+
+# VTN Coordinator Variables
+VTNC = '127.0.0.1'
+VTNCPORT = '8081'
+VTNC_PREFIX = 'http://' + VTNC + ':' + VTNCPORT
+VTNC_HEADERS={'Content-Type': 'application/json', 'username' : 'admin' , 'password' : 'adminpass'}
+
+VTNWEBAPI='/vtn-webapi'
+#controllers URL
+CTRLS_CREATE='controllers.json'
+CTRLS='controllers'
+
+#vtn URL
+VTNS_CREATE='vtns.json'
+VTNS='vtns'
+
+#vbridge URL
+VBRS_CREATE='vbridges.json'
+VBRS='vbridges'
+
+#interfaces URL
+VBRIFS_CREATE='interfaces.json'
+VBRIFS='interfaces'
+
+#portmap URL
+PORTMAP_CREATE='portmap.json'