Remove kong. Fixes bug 1052511.
Change-Id: I5e027c9539fd2c594d24447866e79c8caad9aa40changes/18/14618/1
parent
e62b9f020e
commit
1301f8d026
@ -1,13 +0,0 @@
|
||||
# Copyright 2011 OpenStack LLC.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
@ -1,54 +0,0 @@
|
||||
from kong import exceptions
|
||||
|
||||
import httplib2
|
||||
import os
|
||||
import time
|
||||
|
||||
|
||||
class Client(object):
|
||||
|
||||
USER_AGENT = 'python-nova_test_client'
|
||||
|
||||
def __init__(self, host='localhost', port=80, base_url=''):
|
||||
#TODO: join these more robustly
|
||||
self.base_url = "http://%s:%s/%s" % (host, port, base_url)
|
||||
|
||||
def poll_request(self, method, url, check_response, **kwargs):
|
||||
timeout = kwargs.pop('timeout', 180)
|
||||
interval = kwargs.pop('interval', 2)
|
||||
# Start timestamp
|
||||
start_ts = int(time.time())
|
||||
|
||||
while True:
|
||||
resp, body = self.request(method, url, **kwargs)
|
||||
if (check_response(resp, body)):
|
||||
break
|
||||
if (int(time.time()) - start_ts >= timeout):
|
||||
raise exceptions.TimeoutException
|
||||
time.sleep(interval)
|
||||
|
||||
def poll_request_status(self, method, url, status=200, **kwargs):
|
||||
def check_response(resp, body):
|
||||
return resp['status'] == str(status)
|
||||
|
||||
self.poll_request(method, url, check_response, **kwargs)
|
||||
|
||||
def request(self, method, url, **kwargs):
|
||||
# Default to management_url, but can be overridden here
|
||||
# (for auth requests)
|
||||
base_url = kwargs.get('base_url', self.management_url)
|
||||
|
||||
self.http_obj = httplib2.Http()
|
||||
|
||||
params = {}
|
||||
params['headers'] = {'User-Agent': self.USER_AGENT}
|
||||
params['headers'].update(kwargs.get('headers', {}))
|
||||
if 'Content-Type' not in params.get('headers',{}):
|
||||
params['headers']['Content-Type'] = 'application/json'
|
||||
|
||||
if 'body' in kwargs:
|
||||
params['body'] = kwargs.get('body')
|
||||
|
||||
req_url = os.path.join(base_url, url.strip('/'))
|
||||
resp, body = self.http_obj.request(req_url, method, **params)
|
||||
return resp, body
|
@ -1,79 +0,0 @@
|
||||
import time
|
||||
import socket
|
||||
import warnings
|
||||
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore")
|
||||
import paramiko
|
||||
|
||||
|
||||
class Client(object):
|
||||
|
||||
def __init__(self, host, username, password, timeout=300):
|
||||
self.host = host
|
||||
self.username = username
|
||||
self.password = password
|
||||
self.timeout = int(timeout)
|
||||
|
||||
def _get_ssh_connection(self):
|
||||
"""Returns an ssh connection to the specified host"""
|
||||
_timeout = True
|
||||
ssh = paramiko.SSHClient()
|
||||
ssh.set_missing_host_key_policy(
|
||||
paramiko.AutoAddPolicy())
|
||||
_start_time = time.time()
|
||||
|
||||
while not self._is_timed_out(self.timeout, _start_time):
|
||||
try:
|
||||
ssh.connect(self.host, username=self.username,
|
||||
password=self.password, look_for_keys=False,
|
||||
timeout=self.timeout)
|
||||
_timeout = False
|
||||
break
|
||||
except socket.error:
|
||||
continue
|
||||
except paramiko.AuthenticationException:
|
||||
time.sleep(15)
|
||||
continue
|
||||
if _timeout:
|
||||
raise socket.error("SSH connect timed out")
|
||||
return ssh
|
||||
|
||||
def _is_timed_out(self, timeout, start_time):
|
||||
return (time.time() - timeout) > start_time
|
||||
|
||||
def connect_until_closed(self):
|
||||
"""Connect to the server and wait until connection is lost"""
|
||||
try:
|
||||
ssh = self._get_ssh_connection()
|
||||
_transport = ssh.get_transport()
|
||||
_start_time = time.time()
|
||||
_timed_out = self._is_timed_out(self.timeout, _start_time)
|
||||
while _transport.is_active() and not _timed_out:
|
||||
time.sleep(5)
|
||||
_timed_out = self._is_timed_out(self.timeout, _start_time)
|
||||
ssh.close()
|
||||
except (EOFError, paramiko.AuthenticationException, socket.error):
|
||||
return
|
||||
|
||||
def exec_command(self, cmd):
|
||||
"""Execute the specified command on the server.
|
||||
|
||||
:returns: data read from standard output of the command
|
||||
|
||||
"""
|
||||
ssh = self._get_ssh_connection()
|
||||
stdin, stdout, stderr = ssh.exec_command(cmd)
|
||||
output = stdout.read()
|
||||
ssh.close()
|
||||
return output
|
||||
|
||||
def test_connection_auth(self):
|
||||
""" Returns true if ssh can connect to server"""
|
||||
try:
|
||||
connection = self._get_ssh_connection()
|
||||
connection.close()
|
||||
except paramiko.AuthenticationException:
|
||||
return False
|
||||
|
||||
return True
|
@ -1,15 +0,0 @@
|
||||
import datetime
|
||||
|
||||
|
||||
#TODO(bcwaldon): expand this to support more iso-compliant formats
|
||||
ISO_TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
|
||||
|
||||
|
||||
def load_isotime(time_str):
|
||||
"""Convert formatted time stjring to a datetime object."""
|
||||
return datetime.datetime.strptime(time_str, ISO_TIME_FORMAT)
|
||||
|
||||
|
||||
def dump_isotime(datetime_obj):
|
||||
"""Format a datetime object as an iso-8601 string."""
|
||||
return datetime_obj.strftime(ISO_TIME_FORMAT)
|
@ -1,112 +0,0 @@
|
||||
import ConfigParser
|
||||
|
||||
|
||||
class NovaConfig(object):
|
||||
"""Provides configuration information for connecting to Nova."""
|
||||
|
||||
def __init__(self, conf):
|
||||
"""Initialize a Nova-specific configuration object."""
|
||||
self.conf = conf
|
||||
|
||||
def get(self, item_name, default_value):
|
||||
try:
|
||||
return self.conf.get("nova", item_name)
|
||||
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
|
||||
return default_value
|
||||
|
||||
@property
|
||||
def host(self):
|
||||
"""Host for the Nova HTTP API. Defaults to 127.0.0.1."""
|
||||
return self.get("host", "127.0.0.1")
|
||||
|
||||
@property
|
||||
def port(self):
|
||||
"""Port for the Nova HTTP API. Defaults to 8774."""
|
||||
return int(self.get("port", 8774))
|
||||
|
||||
@property
|
||||
def username(self):
|
||||
"""Username to use for Nova API requests. Defaults to 'admin'."""
|
||||
return self.get("user", "admin")
|
||||
|
||||
@property
|
||||
def base_url(self):
|
||||
"""Base of the HTTP API URL. Defaults to '/v1.1'."""
|
||||
return self.get("base_url", "/v1.1")
|
||||
|
||||
@property
|
||||
def project_id(self):
|
||||
"""Base of the HTTP API URL. Defaults to '/v1.1'."""
|
||||
return self.get("project_id", "admin")
|
||||
|
||||
@property
|
||||
def api_key(self):
|
||||
"""API key to use when authenticating. Defaults to 'admin_key'."""
|
||||
return self.get("api_key", "admin_key")
|
||||
|
||||
@property
|
||||
def ssh_timeout(self):
|
||||
"""Timeout in seconds to use when connecting via ssh."""
|
||||
return float(self.get("ssh_timeout", 300))
|
||||
|
||||
@property
|
||||
def build_timeout(self):
|
||||
"""Timeout in seconds to use when connecting via ssh."""
|
||||
return float(self.get("build_timeout", 300))
|
||||
|
||||
|
||||
|
||||
class EnvironmentConfig(object):
|
||||
def __init__(self, conf):
|
||||
"""Initialize a Environment-specific configuration object."""
|
||||
self.conf = conf
|
||||
|
||||
def get(self, item_name, default_value):
|
||||
try:
|
||||
return self.conf.get("environment", item_name)
|
||||
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
|
||||
return default_value
|
||||
|
||||
@property
|
||||
def image_ref(self):
|
||||
"""Valid imageRef to use """
|
||||
return self.get("image_ref", 3);
|
||||
|
||||
@property
|
||||
def image_ref_alt(self):
|
||||
"""Valid imageRef to rebuild images with"""
|
||||
return self.get("image_ref_alt", 3);
|
||||
|
||||
@property
|
||||
def flavor_ref(self):
|
||||
"""Valid flavorRef to use"""
|
||||
return self.get("flavor_ref", 1);
|
||||
|
||||
@property
|
||||
def flavor_ref_alt(self):
|
||||
"""Valid flavorRef to resize images with"""
|
||||
return self.get("flavor_ref_alt", 2);
|
||||
|
||||
@property
|
||||
def multi_node(self):
|
||||
""" Does the test environment have more than one compute node """
|
||||
return self.get("multi_node", 'false') != 'false'
|
||||
|
||||
|
||||
class StackConfig(object):
|
||||
"""Provides `kong` configuration information."""
|
||||
|
||||
_path = None
|
||||
|
||||
def __init__(self, path=None):
|
||||
"""Initialize a configuration from a path."""
|
||||
self._path = path or self._path
|
||||
self._conf = self.load_config(self._path)
|
||||
self.nova = NovaConfig(self._conf)
|
||||
self.env = EnvironmentConfig(self._conf)
|
||||
|
||||
def load_config(self, path=None):
|
||||
"""Read configuration from given path and return a config object."""
|
||||
config = ConfigParser.SafeConfigParser()
|
||||
config.read(path)
|
||||
return config
|
@ -1,9 +0,0 @@
|
||||
|
||||
class TimeoutException(Exception):
|
||||
""" Exception on timeout """
|
||||
def __repr__(self):
|
||||
return "Request Timed Out"
|
||||
|
||||
|
||||
class ServerNotFound(KeyError):
|
||||
pass
|
@ -1,25 +0,0 @@
|
||||
import re
|
||||
|
||||
|
||||
class KnownIssuesFinder(object):
|
||||
|
||||
def __init__(self):
|
||||
self.count = 0
|
||||
self._pattern = re.compile('# *KNOWN-ISSUE')
|
||||
|
||||
def find_known_issues(self, package):
|
||||
for file in self._find_test_module_files(package):
|
||||
self._count_known_issues(file)
|
||||
|
||||
def _find_test_module_files(self, package):
|
||||
for name in dir(package):
|
||||
if name.startswith('test'):
|
||||
module = getattr(package, name)
|
||||
yield module.__file__
|
||||
|
||||
def _count_known_issues(self, file):
|
||||
if file.endswith('.pyc') or file.endswith('.pyo'):
|
||||
file = file[0:-1]
|
||||
for line in open(file):
|
||||
if self._pattern.search(line) is not None:
|
||||
self.count += 1
|
@ -1,34 +0,0 @@
|
||||
import json
|
||||
|
||||
import kong.common.http
|
||||
from kong import exceptions
|
||||
|
||||
|
||||
class API(kong.common.http.Client):
|
||||
"""Barebones Keystone HTTP API client."""
|
||||
|
||||
def __init__(self, service_host, service_port):
|
||||
super(API, self).__init__(service_host, service_port, 'v2.0')
|
||||
|
||||
#TODO(bcwaldon): This is a hack, we should clean up the superclass
|
||||
self.management_url = self.base_url
|
||||
|
||||
def get_token(self, user, password, tenant_id):
|
||||
headers = {'content-type': 'application/json'}
|
||||
|
||||
body = {
|
||||
"auth": {
|
||||
"passwordCredentials":{
|
||||
"username": user,
|
||||
"password": password,
|
||||
},
|
||||
"tenantId": tenant_id,
|
||||
},
|
||||
}
|
||||
|
||||
response, content = self.request('POST', '/tokens',
|
||||
headers=headers,
|
||||
body=json.dumps(body))
|
||||
|
||||
res_body = json.loads(content)
|
||||
return res_body['access']['token']['id']
|
@ -1,153 +0,0 @@
|
||||
import json
|
||||
|
||||
import kong.common.http
|
||||
from kong import exceptions
|
||||
|
||||
|
||||
class API(kong.common.http.Client):
|
||||
"""Barebones Nova HTTP API client."""
|
||||
|
||||
def __init__(self, host, port, base_url, user, api_key, project_id=''):
|
||||
"""Initialize Nova HTTP API client.
|
||||
|
||||
:param host: Hostname/IP of the Nova API to test.
|
||||
:param port: Port of the Nova API to test.
|
||||
:param base_url: Version identifier (normally /v1.0 or /v1.1)
|
||||
:param user: The username to use for tests.
|
||||
:param api_key: The API key of the user.
|
||||
:returns: None
|
||||
|
||||
"""
|
||||
super(API, self).__init__(host, port, base_url)
|
||||
self.user = user
|
||||
self.api_key = api_key
|
||||
self.project_id = project_id
|
||||
# Default to same as base_url, but will be changed for auth
|
||||
self.management_url = self.base_url
|
||||
|
||||
def authenticate(self, user, api_key, project_id):
|
||||
"""Request and return an authentication token from Nova.
|
||||
|
||||
:param user: The username we're authenticating.
|
||||
:param api_key: The API key for the user we're authenticating.
|
||||
:returns: Authentication token (string)
|
||||
:raises: KeyError if authentication fails.
|
||||
|
||||
"""
|
||||
headers = {
|
||||
'X-Auth-User': user,
|
||||
'X-Auth-Key': api_key,
|
||||
'X-Auth-Project-Id': project_id,
|
||||
}
|
||||
resp, body = super(API, self).request('GET', '', headers=headers,
|
||||
base_url=self.base_url)
|
||||
|
||||
try:
|
||||
self.management_url = resp['x-server-management-url']
|
||||
return resp['x-auth-token']
|
||||
except KeyError:
|
||||
print "Failed to authenticate user"
|
||||
raise
|
||||
|
||||
def _wait_for_entity_status(self, url, entity_name, status, **kwargs):
|
||||
"""Poll the provided url until expected entity status is returned"""
|
||||
|
||||
def check_response(resp, body):
|
||||
try:
|
||||
data = json.loads(body)
|
||||
return data[entity_name]['status'] == status
|
||||
except (ValueError, KeyError):
|
||||
return False
|
||||
|
||||
try:
|
||||
self.poll_request('GET', url, check_response, **kwargs)
|
||||
except exceptions.TimeoutException:
|
||||
msg = "%s failed to reach status %s" % (entity_name, status)
|
||||
raise AssertionError(msg)
|
||||
|
||||
def wait_for_server_status(self, server_id, status='ACTIVE', **kwargs):
|
||||
"""Wait for the server status to be equal to the status passed in.
|
||||
|
||||
:param server_id: Server ID to query.
|
||||
:param status: The status string to look for.
|
||||
:returns: None
|
||||
:raises: AssertionError if request times out
|
||||
|
||||
"""
|
||||
url = '/servers/%s' % server_id
|
||||
return self._wait_for_entity_status(url, 'server', status, **kwargs)
|
||||
|
||||
def wait_for_image_status(self, image_id, status='ACTIVE', **kwargs):
|
||||
"""Wait for the image status to be equal to the status passed in.
|
||||
|
||||
:param image_id: Image ID to query.
|
||||
:param status: The status string to look for.
|
||||
:returns: None
|
||||
:raises: AssertionError if request times out
|
||||
|
||||
"""
|
||||
url = '/images/%s' % image_id
|
||||
return self._wait_for_entity_status(url, 'image', status, **kwargs)
|
||||
|
||||
def request(self, method, url, **kwargs):
|
||||
"""Generic HTTP request on the Nova API.
|
||||
|
||||
:param method: Request verb to use (GET, PUT, POST, etc.)
|
||||
:param url: The API resource to request.
|
||||
:param kwargs: Additional keyword arguments to pass to the request.
|
||||
:returns: HTTP response object.
|
||||
|
||||
"""
|
||||
headers = kwargs.get('headers', {})
|
||||
project_id = kwargs.get('project_id', self.project_id)
|
||||
|
||||
headers['X-Auth-Token'] = self.authenticate(self.user, self.api_key,
|
||||
project_id)
|
||||
kwargs['headers'] = headers
|
||||
return super(API, self).request(method, url, **kwargs)
|
||||
|
||||
def get_server(self, server_id):
|
||||
"""Fetch a server by id
|
||||
|
||||
:param server_id: dict of server attributes
|
||||
:returns: dict of server attributes
|
||||
:raises: ServerNotFound if server does not exist
|
||||
|
||||
"""
|
||||
resp, body = self.request('GET', '/servers/%s' % server_id)
|
||||
try:
|
||||
assert resp['status'] == '200'
|
||||
data = json.loads(body)
|
||||
return data['server']
|
||||
except (AssertionError, ValueError, TypeError, KeyError):
|
||||
raise exceptions.ServerNotFound(server_id)
|
||||
|
||||
def create_server(self, entity):
|
||||
"""Attempt to create a new server.
|
||||
|
||||
:param entity: dict of server attributes
|
||||
:returns: dict of server attributes after creation
|
||||
:raises: AssertionError if server creation fails
|
||||
|
||||
"""
|
||||
post_body = json.dumps({
|
||||
'server': entity,
|
||||
})
|
||||
|
||||
resp, body = self.request('POST', '/servers', body=post_body)
|
||||
try:
|
||||
assert resp['status'] == '202'
|
||||
data = json.loads(body)
|
||||
return data['server']
|
||||
except (AssertionError, ValueError, TypeError, KeyError):
|
||||
raise AssertionError("Failed to create server")
|
||||
|
||||
def delete_server(self, server_id):
|
||||
"""Attempt to delete a server.
|
||||
|
||||
:param server_id: server identifier
|
||||
:returns: None
|
||||
|
||||
"""
|
||||
url = '/servers/%s' % server_id
|
||||
response, body = self.request('DELETE', url)
|
@ -1,14 +0,0 @@
|
||||
import kong.config
|
||||
import kong.nova
|
||||
|
||||
|
||||
class Manager(object):
|
||||
"""Top-level object to access OpenStack resources."""
|
||||
|
||||
def __init__(self, nova):
|
||||
self.nova = kong.nova.API(nova['host'],
|
||||
nova['port'],
|
||||
nova['ver'],
|
||||
nova['user'],
|
||||
nova['key'],
|
||||
nova['project'])
|
@ -1,299 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
import heapq
|
||||
import os
|
||||
import unittest
|
||||
import sys
|
||||
import time
|
||||
|
||||
from nose import config
|
||||
from nose import result
|
||||
from nose import core
|
||||
|
||||
|
||||
class _AnsiColorizer(object):
|
||||
"""
|
||||
A colorizer is an object that loosely wraps around a stream, allowing
|
||||
callers to write text to the stream in a particular color.
|
||||
|
||||
Colorizer classes must implement C{supported()} and C{write(text, color)}.
|
||||
"""
|
||||
_colors = dict(black=30, red=31, green=32, yellow=33,
|
||||
blue=34, magenta=35, cyan=36, white=37)
|
||||
|
||||
def __init__(self, stream):
|
||||
self.stream = stream
|
||||
|
||||
def supported(cls, stream=sys.stdout):
|
||||
"""
|
||||
A class method that returns True if the current platform supports
|
||||
coloring terminal output using this method. Returns False otherwise.
|
||||
"""
|
||||
if not stream.isatty():
|
||||
return False # auto color only on TTYs
|
||||
try:
|
||||
import curses
|
||||
except ImportError:
|
||||
return False
|
||||
else:
|
||||
try:
|
||||
try:
|
||||
return curses.tigetnum("colors") > 2
|
||||
except curses.error:
|
||||
curses.setupterm()
|
||||
return curses.tigetnum("colors") > 2
|
||||
except:
|
||||
raise
|
||||
# guess false in case of error
|
||||
return False
|
||||
supported = classmethod(supported)
|
||||
|
||||
def write(self, text, color):
|
||||
"""
|
||||
Write the given text to the stream in the given color.
|
||||
|
||||
@param text: Text to be written to the stream.
|
||||
|
||||
@param color: A string label for a color. e.g. 'red', 'white'.
|
||||
"""
|
||||
color = self._colors[color]
|
||||
self.stream.write('\x1b[%s;1m%s\x1b[0m' % (color, text))
|
||||
|
||||
|
||||
class _Win32Colorizer(object):
|
||||
"""
|
||||
See _AnsiColorizer docstring.
|
||||
"""
|
||||
def __init__(self, stream):
|
||||
from win32console import GetStdHandle, STD_OUT_HANDLE, \
|
||||
FOREGROUND_RED, FOREGROUND_BLUE, FOREGROUND_GREEN, \
|
||||
FOREGROUND_INTENSITY
|
||||
red, green, blue, bold = (FOREGROUND_RED, FOREGROUND_GREEN,
|
||||
FOREGROUND_BLUE, FOREGROUND_INTENSITY)
|
||||
self.stream = stream
|
||||
self.screenBuffer = GetStdHandle(STD_OUT_HANDLE)
|
||||
self._colors = {
|
||||
'normal': red | green | blue,
|
||||
'red': red | bold,
|
||||
'green': green | bold,
|
||||
'blue': blue | bold,
|
||||
'yellow': red | green | bold,
|
||||
'magenta': red | blue | bold,
|
||||
'cyan': green | blue | bold,
|
||||
'white': red | green | blue | bold
|
||||
}
|
||||
|
||||
def supported(cls, stream=sys.stdout):
|
||||
try:
|
||||
import win32console
|
||||
screenBuffer = win32console.GetStdHandle(
|
||||
win32console.STD_OUT_HANDLE)
|
||||
except ImportError:
|
||||
return False
|
||||
import pywintypes
|
||||
try:
|
||||
screenBuffer.SetConsoleTextAttribute(
|
||||
win32console.FOREGROUND_RED |
|
||||
win32console.FOREGROUND_GREEN |
|
||||
win32console.FOREGROUND_BLUE)
|
||||
except pywintypes.error:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
supported = classmethod(supported)
|
||||
|
||||
def write(self, text, color):
|
||||
color = self._colors[color]
|
||||
self.screenBuffer.SetConsoleTextAttribute(color)
|
||||
self.stream.write(text)
|
||||
self.screenBuffer.SetConsoleTextAttribute(self._colors['normal'])
|
||||
|
||||
|
||||
class _NullColorizer(object):
|
||||
"""
|
||||
See _AnsiColorizer docstring.
|
||||
"""
|
||||
def __init__(self, stream):
|
||||
self.stream = stream
|
||||
|
||||
def supported(cls, stream=sys.stdout):
|
||||
return True
|
||||
supported = classmethod(supported)
|
||||
|
||||
def write(self, text, color):
|
||||
self.stream.write(text)
|
||||
|
||||
|
||||
def get_elapsed_time_color(elapsed_time):
|
||||
if elapsed_time > 1.0:
|
||||
return 'red'
|
||||
elif elapsed_time > 0.25:
|
||||
return 'yellow'
|
||||
else:
|
||||
return 'green'
|
||||
|
||||
|
||||
class KongTestResult(result.TextTestResult):
|
||||
def __init__(self, *args, **kw):
|
||||
self.show_elapsed = kw.pop('show_elapsed')
|
||||
result.TextTestResult.__init__(self, *args, **kw)
|
||||
self.num_slow_tests = 5
|
||||
self.slow_tests = [] # this is a fixed-sized heap
|
||||
self._last_case = None
|
||||
self.colorizer = None
|
||||
# NOTE(vish, tfukushima): reset stdout for the terminal check
|
||||
stdout = sys.__stdout__
|
||||
sys.stdout = sys.__stdout__
|
||||
for colorizer in [_Win32Colorizer, _AnsiColorizer, _NullColorizer]:
|
||||
if colorizer.supported():
|
||||
self.colorizer = colorizer(self.stream)
|
||||
break
|
||||
sys.stdout = stdout
|
||||
|
||||
# NOTE(lorinh): Initialize start_time in case a sqlalchemy-migrate
|
||||
# error results in it failing to be initialized later. Otherwise,
|
||||
# _handleElapsedTime will fail, causing the wrong error message to
|
||||
# be outputted.
|
||||
self.start_time = time.time()
|
||||
|
||||
def getDescription(self, test):
|
||||
return str(test)
|
||||
|
||||
def _handleElapsedTime(self, test):
|
||||
self.elapsed_time = time.time() - self.start_time
|
||||
item = (self.elapsed_time, test)
|
||||
# Record only the n-slowest tests using heap
|
||||
if len(self.slow_tests) >= self.num_slow_tests:
|
||||
heapq.heappushpop(self.slow_tests, item)
|
||||
else:
|
||||
heapq.heappush(self.slow_tests, item)
|
||||
|
||||
def _writeElapsedTime(self, test):
|
||||
color = get_elapsed_time_color(self.elapsed_time)
|
||||
self.colorizer.write(" %.2f" % self.elapsed_time, color)
|
||||
|
||||
def _writeResult(self, test, long_result, color, short_result, success):
|
||||
if self.showAll:
|
||||
self.colorizer.write(long_result, color)
|
||||
if self.show_elapsed and success:
|
||||
self._writeElapsedTime(test)
|
||||
self.stream.writeln()
|
||||
elif self.dots:
|
||||
self.stream.write(short_result)
|
||||
self.stream.flush()
|
||||
|
||||
# NOTE(vish, tfukushima): copied from unittest with edit to add color
|
||||
def addSuccess(self, test):
|
||||
unittest.TestResult.addSuccess(self, test)
|
||||
self._handleElapsedTime(test)
|
||||
self._writeResult(test, 'OK', 'green', '.', True)
|
||||
|
||||
# NOTE(vish, tfukushima): copied from unittest with edit to add color
|
||||
def addFailure(self, test, err):
|
||||
unittest.TestResult.addFailure(self, test, err)
|
||||
self._handleElapsedTime(test)
|
||||
self._writeResult(test, 'FAIL', 'red', 'F', False)
|
||||
|
||||
# NOTE(vish, tfukushima): copied from unittest with edit to add color
|
||||
def addError(self, test, err):
|
||||
"""Overrides normal addError to add support for errorClasses.
|
||||
If the exception is a registered class, the error will be added
|
||||
to the list for that class, not errors.
|
||||
"""
|
||||
self._handleElapsedTime(test)
|
||||
stream = getattr(self, 'stream', None)
|
||||
ec, ev, tb = err
|
||||
try:
|
||||
exc_info = self._exc_info_to_string(err, test)
|
||||
except TypeError:
|
||||
# This is for compatibility with Python 2.3.
|
||||
exc_info = self._exc_info_to_string(err)
|
||||
for cls, (storage, label, isfail) in self.errorClasses.items():
|
||||
if result.isclass(ec) and issubclass(ec, cls):
|
||||
if isfail:
|
||||
test.passwd = False
|
||||
storage.append((test, exc_info))
|
||||
# Might get patched into a streamless result
|
||||
if stream is not None:
|
||||
if self.showAll:
|
||||
message = [label]
|
||||
detail = result._exception_detail(err[1])
|
||||
if detail:
|
||||
message.append(detail)
|
||||
stream.writeln(": ".join(message))
|
||||
elif self.dots:
|
||||
stream.write(label[:1])
|
||||
return
|
||||
self.errors.append((test, exc_info))
|
||||
test.passed = False
|
||||
if stream is not None:
|
||||
self._writeResult(test, 'ERROR', 'red', 'E', False)
|
||||
|
||||
def startTest(self, test):
|
||||
unittest.TestResult.startTest(self, test)
|
||||
self.start_time = time.time()
|
||||
current_case = test.test.__class__.__name__
|
||||
|
||||
if self.showAll:
|
||||
if current_case != self._last_case:
|
||||
self.stream.writeln(current_case)
|
||||
self._last_case = current_case
|
||||
|
||||
self.stream.write(
|
||||
' %s' % str(test.test._testMethodName).ljust(60))
|
||||
self.stream.flush()
|
||||
|
||||
|
||||
class KongTestRunner(core.TextTestRunner):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.show_elapsed = kwargs.pop('show_elapsed')
|
||||
core.TextTestRunner.__init__(self, *args, **kwargs)
|
||||
|
||||
def _makeResult(self):
|
||||
return KongTestResult(self.stream,
|
||||
self.descriptions,
|
||||
self.verbosity,
|
||||
self.config,
|
||||
show_elapsed=self.show_elapsed)
|
||||
|
||||
def _writeSlowTests(self, result_):
|
||||
# Pare out 'fast' tests
|
||||
slow_tests = [item for item in result_.slow_tests
|
||||
if get_elapsed_time_color(item[0]) != 'green']
|
||||
if slow_tests:
|
||||
slow_total_time = sum(item[0] for item in slow_tests)
|
||||
self.stream.writeln("Slowest %i tests took %.2f secs:"
|
||||
% (len(slow_tests), slow_total_time))
|
||||
for elapsed_time, test in sorted(slow_tests, reverse=True):
|
||||
time_str = "%.2f" % elapsed_time
|
||||
self.stream.writeln(" %s %s" % (time_str.ljust(10), test))
|
||||
|
||||
def run(self, test):
|
||||
result_ = core.TextTestRunner.run(self, test)
|
||||
if self.show_elapsed:
|
||||
self._writeSlowTests(result_)
|
||||
return result_
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
show_elapsed = True
|
||||
argv = []
|
||||
for x in sys.argv:
|
||||
if x.startswith('test_'):
|
||||
argv.append('nova.tests.%s' % x)
|
||||
elif x.startswith('--hide-elapsed'):
|
||||
show_elapsed = False
|
||||
else:
|
||||
argv.append(x)
|
||||
|
||||
c = config.Config(stream=sys.stdout,
|
||||
env=os.environ,
|
||||
verbosity=3,
|
||||
plugins=core.DefaultPluginManager())
|
||||
|
||||
runner = KongTestRunner(stream=c.stream,
|
||||
verbosity=c.verbosity,
|
||||
config=c,
|
||||
show_elapsed=show_elapsed)
|
||||
sys.exit(not core.run(config=c, testRunner=runner, argv=argv))
|
@ -1,99 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
function usage {
|
||||
echo "Usage: $0 [OPTION]..."
|
||||
echo "Run the Kong test suite(s)"
|
||||
echo ""
|
||||
echo " -V, --virtual-env Always use virtualenv. Install automatically if not present"
|
||||
echo " -N, --no-virtual-env Don't use virtualenv. Run tests in local environment"
|
||||
echo " -f, --force Force a clean re-build of the virtual environment. Useful when dependencies have been added."
|
||||
echo " -p, --pep8 Just run pep8"
|
||||
echo " --nova Run all tests tagged as \"nova\"."
|
||||
echo " --swift Run all tests tagged as \"swift\"."
|
||||
echo " --glance Run all tests tagged as \"glance\"."
|
||||
echo " --auth Run all tests tagged as \"auth\"."
|
||||
echo " -h, --help Print this usage message"
|
||||
echo ""
|
||||
echo "Note: with no options specified, the script will try to run the tests in a virtual environment,"
|
||||
echo " If no virtualenv is found, the script will ask if you would like to create one. If you "
|
||||
echo " prefer to run tests NOT in a virtual environment, simply pass the -N option."
|
||||
exit
|
||||
}
|
||||
|
||||
function process_option {
|
||||
case "$1" in
|
||||
-h|--help) usage;;
|
||||
-V|--virtual-env) let always_venv=1; let never_venv=0;;
|
||||
-N|--no-virtual-env) let always_venv=0; let never_venv=1;;
|
||||
-f|--force) let force=1;;
|
||||
-p|--pep8) let just_pep8=1;;
|
||||
--nova) noseargs="$noseargs -a tags=nova";;
|
||||
--glance) noseargs="$noseargs -a tags=glance";;
|
||||
--swift) noseargs="$noseargs -a tags=swift";;
|
||||
--auth) noseargs="$noseargs -a tags=auth";;
|
||||
*) noseargs="$noseargs $1"
|
||||
esac
|
||||
}
|
||||
|
||||
base_dir=$(dirname $0)
|
||||
venv=.kong-venv
|
||||
with_venv=../tools/with_venv.sh
|
||||
always_venv=0
|
||||
never_venv=0
|
||||
force=0
|
||||
noseargs=
|
||||
wrapper=""
|
||||
just_pep8=0
|
||||
|
||||
for arg in "$@"; do
|
||||
process_option $arg
|
||||
done
|
||||
|
||||
function run_tests {
|
||||
# Just run the test suites in current environment
|
||||
${wrapper} $NOSETESTS 2> run_tests.err.log
|
||||
}
|
||||
|
||||
function run_pep8 {
|
||||
echo "Running pep8 ..."
|
||||
PEP8_EXCLUDE=vcsversion.y
|
||||
PEP8_OPTIONS="--exclude=$PEP8_EXCLUDE --repeat --show-pep8 --show-source"
|
||||
PEP8_INCLUDE="tests tools run_tests.py"
|
||||
${wrapper} pep8 $PEP8_OPTIONS $PEP8_INCLUDE || exit 1
|
||||
}
|
||||
NOSETESTS="env python run_tests.py $noseargs"
|
||||
function setup_venv {
|
||||
if [ $never_venv -eq 0 ]
|
||||
then
|
||||
# Remove the virtual environment if --force used
|
||||
if [ $force -eq 1 ]; then
|
||||
echo "Cleaning virtualenv..."
|
||||
rm -rf ${venv}
|
||||
fi
|
||||
if [ -e "../${venv}" ]; then
|
||||
wrapper="${with_venv}"
|
||||
else
|
||||
if [ $always_venv -eq 1 ]; then
|
||||
# Automatically install the virtualenv
|
||||
use_ve='y'
|
||||
else
|
||||
echo -e "No virtual environment found...create one? (Y/n) \c"
|
||||
read use_ve
|
||||
fi
|
||||
if [ "x$use_ve" = "xY" -o "x$use_ve" = "x" -o "x$use_ve" = "xy" ]; then
|
||||
# Install the virtualenv and run the test suite in it
|
||||
env python ../tools/install_venv.py
|
||||
wrapper=${with_venv}
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
if [ $just_pep8 -eq 1 ]; then
|
||||
run_pep8
|
||||
exit
|
||||
fi
|
||||
|
||||
cd $base_dir
|
||||
setup_venv
|
||||
run_tests || exit
|
@ -1,54 +0,0 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright 2011 OpenStack, LLC
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""
|
||||
Functional test case to check the status of gepetto and
|
||||
set information of hosts etc..
|
||||
"""
|
||||
|
||||
import os
|
||||
from kong import tests
|
||||
|
||||
|
||||
class TestSkipExamples(tests.FunctionalTest):
|
||||
@tests.skip_test("testing skipping")
|
||||
def test_absolute_skip(self):
|
||||
x = 1
|
||||
|
||||
@tests.skip_unless(os.getenv("BLAH"),
|
||||
"Skipping -- Environment variable BLAH does not exist")
|
||||
def test_skip_unless_env_blah_exists(self):
|
||||
x = 1
|
||||
|
||||
@tests.skip_unless(os.getenv("USER"),
|
||||
"Not Skipping -- Environment variable USER does not exist")
|
||||
def test_skip_unless_env_user_exists(self):
|
||||
x = 1
|
||||
|
||||
@tests.skip_if(os.getenv("USER"),
|
||||
"Skiping -- Environment variable USER exists")
|
||||
def test_skip_if_env_user_exists(self):
|
||||
x = 1
|
||||
|
||||
@tests.skip_if(os.getenv("BLAH"),
|
||||
"Not Skipping -- Environment variable BLAH exists")
|
||||
def test_skip_if_env_blah_exists(self):
|
||||
x = 1
|
||||
|
||||
def test_tags_example(self):
|
||||
pass
|
||||
test_tags_example.tags = ['kvm', 'olympus']
|
@ -1,106 +0,0 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright 2011 OpenStack, LLC
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""Functional test case to check RabbitMQ """
|
||||
try:
|
||||
import pika
|
||||
except ImportError:
|
||||
pika = None
|
||||
from kong import tests
|
||||
|
||||
from pprint import pprint
|
||||
#RABBITMQ_HOST = get_config("rabbitmq/host")
|
||||
#RABBITMQ_USERNAME = get_config("rabbitmq/user")
|
||||
#RABBITMQ_PASSWORD = get_config("rabbitmq/password")
|
||||
|
||||
|
||||
class TestRabbitMQ(tests.FunctionalTest):
|
||||
@tests.skip_unless(pika, "pika not available")
|
||||
def test_000_ghetto(self):
|
||||
"""
|
||||
This sets the host, user, and pass self variables so they
|
||||
are accessible by all other methods
|
||||
"""
|
||||
self.rabbitmq['host'] = self.config['rabbitmq']['host']
|
||||
self.rabbitmq['user'] = self.config['rabbitmq']['user']
|
||||
self.rabbitmq['pass'] = self.config['rabbitmq']['password']
|
||||
test_000_ghetto.tags = ['rabbitmq']
|
||||
|
||||
def _cnx(self):
|
||||
creds = pika.credentials.PlainCredentials(
|
||||
self.rabbitmq['user'], self.rabbitmq['pass'])
|
||||
connection = pika.BlockingConnection(pika.ConnectionParameters(
|
||||
host=self.rabbitmq['host'],credentials=creds))
|
||||
channel = connection.channel()
|
||||
return (channel, connection)
|
||||
|
||||
@tests.skip_unless(pika, "pika not available")
|
||||
def test_001_connect(self):
|
||||
channel, connection = self._cnx()
|
||||
self.assert_(channel)
|
||||
connection.close()
|
||||
test_001_connect.tags = ['rabbitmq']
|
||||
|
||||
@tests.skip_unless(pika, "pika not available")
|
||||
def test_002_send_receive_msg(self):
|
||||
unitmsg = 'Hello from unittest'
|
||||
channel, connection = self._cnx()
|
||||
channel.queue_declare(queue='u1')
|
||||
channel.basic_publish(exchange='',
|
||||
routing_key='u1',
|
||||
body=unitmsg)
|
||||
connection.close()
|
||||
|
||||
channel, connection = self._cnx()
|
||||
|
||||
def callback(ch, method, properties, body):
|
||||
self.assertEquals(body, unitmsg)
|
||||
ch.stop_consuming()
|
||||
|
||||
channel.basic_consume(callback,
|
||||
queue='u1',
|
||||
no_ack=True)
|
||||
channel.start_consuming()
|
||||
test_002_send_receive_msg.tags = ['rabbitmq']
|
||||
|
||||
@tests.skip_unless(pika, "pika not available")
|
||||
def test_003_send_receive_msg_with_persistense(self):
|
||||
unitmsg = 'Hello from unittest with Persistense'
|
||||
channel, connection = self._cnx()
|
||||
channel.queue_declare(queue='u2', durable=True)
|
||||
prop = pika.BasicProperties(delivery_mode=2)
|
||||
channel.basic_publish(exchange='',
|
||||
routing_key='u2',
|
||||
body=unitmsg,
|
||||
properties=prop,
|
||||
)
|
||||
connection.close()
|
||||
|
||||
channel, connection = self._cnx()
|
||||
channel.queue_declare(queue='u2', durable=True)
|
||||
|
||||
def callback(ch, method, properties, body):
|
||||
self.assertEquals(body, unitmsg)
|
||||
ch.basic_ack(delivery_tag=method.delivery_tag)
|
||||
ch.stop_consuming()
|
||||
|
||||
channel.basic_qos(prefetch_count=1)
|
||||
channel.basic_consume(callback,
|
||||
queue='u2')
|
||||
|
||||
channel.start_consuming()
|
||||
test_003_send_receive_msg_with_persistense.tags = ['rabbitmq']
|
@ -1,185 +0,0 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright 2011 OpenStack, LLC
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""Functional test case for OpenStack Swift """
|
||||
|
||||
import httplib2
|
||||
import os
|
||||
|
||||
from pprint import pprint
|
||||
|
||||
from kong import tests
|
||||
|
||||
SMALL_OBJ = "include/swift_objects/swift_small"
|
||||
MED_OBJ = "include/swift_objects/swift_medium"
|
||||
LRG_OBJ = "include/swift_objects/swift_large"
|
||||
|
||||
|
||||
class TestSwift(tests.FunctionalTest):
|
||||
def test_000_auth(self):
|
||||
if self.swift['auth_ssl'] == "False":
|
||||
prot = "http://"
|
||||
else:
|
||||
prot = "https://"
|
||||
|
||||
path = "%s%s:%s%s%s" % (prot, self.swift['auth_host'],
|
||||
self.swift['auth_port'],
|
||||
self.swift['auth_prefix'],
|
||||
self.swift['ver'])
|
||||
|
||||
http = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
self.swift['auth_user'] = '%s:%s' % (self.swift['account'],
|
||||
self.swift['username'])
|
||||
headers = {'X-Auth-User': '%s' % (self.swift['auth_user']),
|
||||
'X-Auth-Key': '%s' % (self.swift['password'])}
|
||||
response, content = http.request(path, 'GET', headers=headers)
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertIsNotNone(response['x-auth-token'])
|
||||
self.assertIsNotNone(response['x-storage-token'])
|
||||
self.assertIsNotNone(response['x-storage-url'])
|
||||
|
||||
# TODO: there has got to be a better way to do this (jshepher)
|
||||
for k, v in response.items():
|
||||
if (k == 'x-auth-token'):
|
||||
self.swift['x-auth-token'] = v
|
||||
if (k == 'x-storage-token'):
|
||||
self.swift['x-storage-token'] = v
|
||||
|
||||
# Since we don't have DNS this is a bit of a hack, but works
|
||||
url = response['x-storage-url'].split('/')
|
||||
self.swift['storage_url'] = "%s//%s:%s/%s/%s" % (url[0],
|
||||
self.swift['auth_host'],
|
||||
self.swift['auth_port'],
|
||||
url[3],
|
||||
url[4])
|
||||
test_000_auth.tags = ['swift']
|
||||
|
||||
def test_001_create_container(self):
|
||||
path = "%s/%s/" % (self.swift['storage_url'], "test_container")
|
||||
http = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
headers = {'X-Storage-Token': '%s' % (self.swift['x-storage-token'])}
|
||||
response, content = http.request(path, 'PUT', headers=headers)
|
||||
self.assertEqual(response.status, 201)
|
||||
test_001_create_container.tags = ['swift']
|
||||
|
||||
def test_002_list_containers(self):
|
||||
http = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
headers = {'X-Auth-Token': '%s' % (self.swift['x-auth-token'])}
|
||||
response, content = http.request(self.swift['storage_url'], 'GET',
|
||||
headers=headers)
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertLessEqual('1', response['x-account-container-count'])
|
||||
test_002_list_containers.tags = ['swift']
|
||||
|
||||
def test_010_create_small_object(self):
|
||||
md5 = self._md5sum_file(SMALL_OBJ)
|
||||
path = "%s/%s/%s" % (self.swift['storage_url'],
|
||||
"test_container",
|
||||
"swift_small")
|
||||
http = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
headers = {'X-Auth-User': '%s:%s' % (self.swift['account'],
|
||||
self.swift['username']),
|
||||
'X-Storage-Token': '%s' % (self.swift['x-storage-token']),
|
||||
'ETag': '%s' % (md5),
|
||||
'Content-Length': '%d' % os.path.getsize(SMALL_OBJ),
|
||||
'Content-Type': 'application/octet-stream'}
|
||||
upload = open(SMALL_OBJ, "rb")
|
||||
response, content = http.request(path, 'PUT',
|
||||
headers=headers,
|
||||
body=upload)
|
||||
self.assertEqual(response.status, 201)
|
||||
test_010_create_small_object.tags = ['swift']
|
||||
|
||||
def test_011_create_medium_object(self):
|
||||
md5 = self._md5sum_file(MED_OBJ)
|
||||
path = "%s/%s/%s" % (self.swift['storage_url'],
|
||||
"test_container",
|
||||
"swift_medium")
|
||||
http = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
headers = {'X-Auth-User': '%s:%s' % (self.swift['account'],
|
||||
self.swift['username']),
|
||||
'X-Storage-Token': '%s' % (self.swift['x-storage-token']),
|
||||
'ETag': '%s' % (md5),
|
||||
'Content-Length': '%d' % (os.path.getsize(MED_OBJ)),
|
||||
'Content-Type': 'application/octet-stream',
|
||||
'Content-Encoding': 'gzip'}
|
||||
upload = ""
|
||||
for chunk in self._read_in_chunks(MED_OBJ):
|
||||
upload += chunk
|
||||
response, content = http.request(path, 'PUT',
|
||||
headers=headers,
|
||||
body=upload)
|
||||
self.assertEqual(response.status, 201)
|
||||
test_011_create_medium_object.tags = ['swift']
|
||||
|
||||
def test_013_get_small_object(self):
|
||||
path = "%s/%s/%s" % (self.swift['storage_url'],
|
||||
"test_container",
|
||||
"swift_small")
|
||||
http = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
headers = {'X-Auth-User': '%s:%s' % (self.swift['account'],
|
||||
self.swift['username']),
|
||||
'X-Storage-Token': '%s' % (self.swift['x-storage-token'])}
|
||||
response, content = http.request(path, 'GET',
|
||||
headers=headers)
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(response['etag'], self._md5sum_file(SMALL_OBJ))
|
||||
test_013_get_small_object.tags = ['swift']
|
||||
|
||||
def test_017_delete_small_object(self):
|
||||
path = "%s/%s/%s" % (self.swift['storage_url'], "test_container",
|
||||
"swift_small")
|
||||
http = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
headers = {'X-Auth-User': '%s:%s' % (self.swift['account'],
|
||||
self.swift['username']),
|
||||
'X-Storage-Token': '%s' % (
|
||||
self.swift['x-storage-token'])}
|
||||
response, content = http.request(path, 'DELETE', headers=headers)
|
||||
self.assertEqual(response.status, 204)
|
||||
test_017_delete_small_object.tags = ['swift']
|
||||
|
||||
def test_018_delete_medium_object(self):
|
||||
path = "%s/%s/%s" % (self.swift['storage_url'], "test_container",
|
||||
"swift_medium")
|
||||
http = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
headers = {'X-Auth-User': '%s:%s' % (self.swift['account'],
|
||||
self.swift['username']),
|
||||
'X-Storage-Token': '%s' % (
|
||||
self.swift['x-storage-token'])}
|
||||
response, content = http.request(path, 'DELETE', headers=headers)
|
||||
self.assertEqual(response.status, 204)
|
||||
test_018_delete_medium_object.tags = ['swift']
|
||||
|
||||
def test_030_check_container_metadata(self):
|
||||
path = "%s/%s" % (self.swift['storage_url'], "test_container")
|
||||
http = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
headers = {'X-Auth-User': '%s:%s' % (self.swift['account'],
|
||||
self.swift['username']),
|
||||
'X-Storage-Token': '%s' % (self.swift['x-storage-token'])}
|
||||
response, content = http.request(path, 'HEAD', headers=headers)
|
||||
self.assertEqual(response.status, 204)
|
||||
test_030_check_container_metadata.tags = ['swift']
|
||||
|
||||
def test_050_delete_container(self):
|
||||
path = "%s/%s" % (self.swift['storage_url'], "test_container")
|
||||
http = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
headers = {'X-Auth-User': '%s:%s' % (self.swift['account'],
|
||||
self.swift['username']),
|
||||
'X-Storage-Token': '%s' % (self.swift['x-storage-token'])}
|
||||
response, content = http.request(path, 'DELETE', headers=headers)
|
||||
self.assertEqual(response.status, 204)
|
||||
test_050_delete_container.tags = ['swift']
|
@ -1,91 +0,0 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright 2011 OpenStack, LLC
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""Functional test case that utilizes cURL against the API server"""
|
||||
|
||||
import httplib2
|
||||
|
||||
from pprint import pprint
|
||||
|
||||
from kong import tests
|
||||
|
||||
|
||||
class TestCleanUp(tests.FunctionalTest):
|
||||
def test_995_delete_server(self):
|
||||
path = "http://%s:%s/%s/servers/%s" % (self.nova['host'],
|
||||
self.nova['port'],
|
||||
self.nova['ver'],
|
||||
self.nova['single_server_id'])
|
||||
http = httplib2.Http()
|
||||
headers = {'X-Auth-User': '%s' % (self.nova['user']),
|
||||
'X-Auth-Token': '%s' % (self.nova['X-Auth-Token'])}
|
||||
response, content = http.request(path, 'DELETE', headers=headers)
|
||||
self.assertEqual(response.status, 202)
|
||||
test_995_delete_server.tags = ['nova']
|
||||
|
||||
def test_996_delete_multi_server(self):
|
||||
print "Deleting %s instances." % (len(self.nova['multi_server']))
|
||||
for k, v in self.nova['multi_server'].iteritems():
|
||||
path = "http://%s:%s/%s/servers/%s" % (self.nova['host'],
|
||||
self.nova['port'],
|
||||
self.nova['ver'],
|
||||
v)
|
||||
http = httplib2.Http()
|
||||
headers = {'X-Auth-User': '%s' % (self.nova['user']),
|
||||
'X-Auth-Token': '%s' % (self.nova['X-Auth-Token'])}
|
||||
response, content = http.request(path, 'DELETE', headers=headers)
|
||||
self.assertEqual(204, response.status)
|
||||
test_996_delete_multi_server.tags = ['nova']
|
||||
|
||||
def test_997_delete_kernel_from_glance(self):
|
||||
if 'apiver' in self.glance:
|
||||
path = "http://%s:%s/%s/images/%s" % (self.glance['host'],
|
||||
self.glance['port'], self.glance['apiver'],
|
||||
self.glance['kernel_id'])
|
||||
else:
|
||||
path = "http://%s:%s/images/%s" % (self.glance['host'],
|
||||
self.glance['port'], self.glance['kernel_id'])
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'DELETE')
|
||||
self.assertEqual(200, response.status)
|
||||
test_997_delete_kernel_from_glance.tags = ['glance', 'nova']
|
||||
|
||||
def test_998_delete_initrd_from_glance(self):
|
||||
if 'apiver' in self.glance:
|
||||
path = "http://%s:%s/%s/images/%s" % (self.glance['host'],
|
||||
self.glance['port'], self.glance['apiver'],
|
||||
self.glance['ramdisk_id'])
|
||||
else:
|
||||
path = "http://%s:%s/images/%s" % (self.glance['host'],
|
||||
self.glance['port'], self.glance['ramdisk_id'])
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'DELETE')
|
||||
self.assertEqual(200, response.status)
|
||||
test_998_delete_initrd_from_glance.tags = ['glance', 'nova']
|
||||
|
||||
def test_999_delete_image_from_glance(self):
|
||||
if 'apiver' in self.glance:
|
||||
path = "http://%s:%s/%s/images/%s" % (self.glance['host'],
|
||||
self.glance['port'], self.glance['apiver'],
|
||||
self.glance['image_id'])
|
||||
else:
|
||||
path = "http://%s:%s/images/%s" % (self.glance['host'],
|
||||
self.glance['port'], self.glance['image_id'])
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'DELETE')
|
||||
self.assertEqual(200, response.status)
|
||||
test_999_delete_image_from_glance.tags = ['glance', 'nova']
|
@ -1,146 +0,0 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright 2010-2011 OpenStack LLC.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import ConfigParser
|
||||
from hashlib import md5
|
||||
import nose.plugins.skip
|
||||
import os
|
||||
import unittest2
|
||||
|
||||
NOVA_DATA = {}
|
||||
GLANCE_DATA = {}
|
||||
SWIFT_DATA = {}
|
||||
RABBITMQ_DATA = {}
|
||||
CONFIG_DATA = {}
|
||||
KEYSTONE_DATA = {}
|
||||
|
||||
|
||||
class skip_test(object):
|
||||
"""Decorator that skips a test."""
|
||||
def __init__(self, msg):
|
||||
self.message = msg
|
||||
|
||||
def __call__(self, func):
|
||||
def _skipper(*args, **kw):
|
||||
"""Wrapped skipper function."""
|
||||
raise nose.SkipTest(self.message)
|
||||
_skipper.__name__ = func.__name__
|
||||
_skipper.__doc__ = func.__doc__
|
||||
return _skipper
|
||||
|
||||
|
||||
class skip_if(object):
|
||||
"""Decorator that skips a test."""
|
||||
def |