summaryrefslogtreecommitdiffstats
path: root/testcases/Controllers/ODL/CI/libraries
diff options
context:
space:
mode:
Diffstat (limited to 'testcases/Controllers/ODL/CI/libraries')
-rw-r--r--testcases/Controllers/ODL/CI/libraries/Common.py81
-rw-r--r--testcases/Controllers/ODL/CI/libraries/RequestsLibrary.py264
-rw-r--r--testcases/Controllers/ODL/CI/libraries/Utils.txt106
3 files changed, 0 insertions, 451 deletions
diff --git a/testcases/Controllers/ODL/CI/libraries/Common.py b/testcases/Controllers/ODL/CI/libraries/Common.py
deleted file mode 100644
index e748caad8..000000000
--- a/testcases/Controllers/ODL/CI/libraries/Common.py
+++ /dev/null
@@ -1,81 +0,0 @@
-"""
-Library for the robot based system test tool of the OpenDaylight project.
-Authors: Baohua Yang@IBM, Denghui Huang@IBM
-Updated: 2013-11-14
-"""
-import collections
-import xml.etree.ElementTree as ET
-
-'''
-Common constants and functions for the robot framework.
-'''
-
-def collection_should_contain(collection, *members):
- """
- Fail if not every members is in the collection.
- """
- if not isinstance(collection, collections.Iterable):
- return False
- for m in members:
- if m not in collection:
- return False
- else:
- return True
-
-def combine_strings(*strings):
- """
- Combines the given `strings` together and returns the result.
- The given strings are not altered by this keyword.
- """
- result = ''
- for s in strings:
- if isinstance(s,str) or isinstance(s,unicode):
- result += s
- if result == '':
- return None
- else:
- return result
-
-
-def compare_xml(xml1, xml2):
- """
- compare the two XML files to see if they contain the same data
- but could be if different order.
- It just split the xml in to lines and just check the line is in
- the other file
- """
- for line in xml1.rstrip().split('\n'):
- if line not in xml2.rstrip().split('\n'):
- return False
-
- for line in xml2.rstrip().split('\n'):
- if line not in xml1.rstrip().split('\n'):
- return False
-
- return True
-
-def num_of_nodes(depth, fanout):
- '''returns num of switches of a mininet with tree topology
- with particular depth and fanout parameters
- '''
- result = 0
- for i in xrange(depth):
- result += fanout**i
- return result
-
-def num_of_links_for_node(nodeid, leaflist, fanout):
- '''
- If the given node is a leaf node, there will be an only one link for it
- and nodeid will be represented 2 times in topology
- If the given node is not a leaf node, then there will be fanout+1 links
- for it and nodeid will be represented (fanout+1)*2 times in topology
-
- p.s. root node is excluded.
- '''
- if nodeid in leaflist:
- return 1
- return (fanout+1)
-
-if __name__ == '__main__':
- print num_of_nodes(3,4)
- pass
diff --git a/testcases/Controllers/ODL/CI/libraries/RequestsLibrary.py b/testcases/Controllers/ODL/CI/libraries/RequestsLibrary.py
deleted file mode 100644
index 3ef4375d6..000000000
--- a/testcases/Controllers/ODL/CI/libraries/RequestsLibrary.py
+++ /dev/null
@@ -1,264 +0,0 @@
-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 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`
-
- `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 = 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 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`
-
- `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/testcases/Controllers/ODL/CI/libraries/Utils.txt b/testcases/Controllers/ODL/CI/libraries/Utils.txt
deleted file mode 100644
index 913ba22c0..000000000
--- a/testcases/Controllers/ODL/CI/libraries/Utils.txt
+++ /dev/null
@@ -1,106 +0,0 @@
-*** Settings ***
-Library SSHLibrary
-Library ./UtilLibrary.py
-
-*** Variables ***
-${start} sudo mn --controller=remote,ip=${CONTROLLER} --topo tree,1 --switch ovsk,protocols=OpenFlow13
-${linux_prompt} >
-
-*** Keywords ***
-Start Suite
- [Documentation] Basic setup/cleanup work that can be done safely before any system
- ... is run.
- Log Start the test on the base edition
- ${mininet_conn_id}= Open Connection ${MININET} prompt=${linux_prompt} timeout=30s
- Set Suite Variable ${mininet_conn_id}
- Login With Public Key ${MININET_USER} ${USER_HOME}/.ssh/id_rsa any
- Write sudo ovs-vsctl set-manager ptcp:6644
- Read Until ${linux_prompt}
- Write sudo mn -c
- Read Until ${linux_prompt}
- Write ${start}
- Read Until mininet>
- Sleep 6
-
-Stop Suite
- [Documentation] Cleanup/Shutdown work that should be done at the completion of all
- ... tests
- Log Stop the test on the base edition
- Switch Connection ${mininet_conn_id}
- Read
- Write exit
- Read Until ${linux_prompt}
- Close Connection
-
-Ensure All Nodes Are In Response
- [Arguments] ${URI} ${node_list}
- [Documentation] A GET is made to the supplied ${URI} and every item in the ${node_list}
- ... is verified to exist in the repsonse. This keyword currently implies that it's node
- ... specific but any list of strings can be given in ${node_list}. Refactoring of this
- ... to make it more generic should be done. (see keyword "Check For Elements At URI")
- : FOR ${node} IN @{node_list}
- \ ${resp} RequestsLibrary.Get session ${URI}
- \ Should Be Equal As Strings ${resp.status_code} 200
- \ Should Contain ${resp.content} ${node}
-
-Check Nodes Stats
- [Arguments] ${node}
- [Documentation] A GET on the /node/${node} API is made and specific flow stat
- ... strings are checked for existence.
- ${resp} RequestsLibrary.Get session ${REST_CONTEXT}/node/${node}
- Should Be Equal As Strings ${resp.status_code} 200
- Should Contain ${resp.content} flow-capable-node-connector-statistics
- Should Contain ${resp.content} flow-table-statistics
-
-Check That Port Count Is Ok
- [Arguments] ${node} ${count}
- [Documentation] A GET on the /port API is made and the specified port ${count} is
- ... verified. A more generic Keyword "Check For Specific Number Of Elements At URI"
- ... also does this work and further consolidation should be done.
- ${resp} RequestsLibrary.Get session ${REST_CONTEXT}/${CONTAINER}/port
- Log ${resp.content}
- Should Be Equal As Strings ${resp.status_code} 200
- Should Contain X Times ${resp.content} ${node} ${count}
-
-Check For Specific Number Of Elements At URI
- [Arguments] ${uri} ${element} ${expected_count}
- [Documentation] A GET is made to the specified ${URI} and the specific count of a
- ... given element is done (as supplied by ${element} and ${expected_count})
- ${resp} RequestsLibrary.Get session ${uri}
- Log ${resp.content}
- Should Be Equal As Strings ${resp.status_code} 200
- Should Contain X Times ${resp.content} ${element} ${expected_count}
-
-Check For Elements At URI
- [Arguments] ${uri} ${elements}
- [Documentation] A GET is made at the supplied ${URI} and every item in the list of
- ... ${elements} is verified to exist in the response
- ${resp} RequestsLibrary.Get session ${uri}
- Log ${resp.content}
- Should Be Equal As Strings ${resp.status_code} 200
- : FOR ${i} IN @{elements}
- \ Should Contain ${resp.content} ${i}
-
-Check For Elements Not At URI
- [Arguments] ${uri} ${elements}
- [Documentation] A GET is made at the supplied ${URI} and every item in the list of
- ... ${elements} is verified to NOT exist in the response
- ${resp} RequestsLibrary.Get session ${uri}
- Log ${resp.content}
- Should Be Equal As Strings ${resp.status_code} 200
- : FOR ${i} IN @{elements}
- \ Should Not Contain ${resp.content} ${i}
-
-Extract Value From Content
- [Arguments] ${content} ${index} ${strip}=nostrip
- [Documentation] Will take the given response content and return the value at the given index as a string
- ${value}= Get Json Value ${content} ${index}
- ${value}= Convert To String ${value}
- ${value}= Run Keyword If '${strip}' == 'strip' Strip Quotes ${value}
- [Return] ${value}
-
-Strip Quotes
- [Arguments] ${string_to_strip}
- [Documentation] Will strip ALL quotes from given string and return the new string
- ${string_to_return}= Replace String ${string_to_strip} " \ count=-1
- [Return] ${string_to_return}