Fix checks in server listing only lok for an ID
The list server filter details checks were checking entire mappings against the list of mappings returned from a call to GET /servers/detail. Unfortunately, the mappings returned by the GET /servers/detail and the mapping returned by POST /servers are slightly different, resulting in the comparison failing. We really only are checking that the server instance we expect to be in the returned list of instances is there, so checking for the server ID in the returned list is fine. Change-Id: If9680f56a1ea06ffe93393d06b23bd231ccddd01 Fixes: LP Bug 1028465pep8 build for tempest.
This commit is contained in:
parent
28e35c56ba
commit
a6aa5f2107
34
setup.py
Normal file
34
setup.py
Normal file
@ -0,0 +1,34 @@
|
||||
#!/usr/bin/python
|
||||
# Copyright (c) 2012 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.
|
||||
|
||||
import setuptools
|
||||
|
||||
setuptools.setup(
|
||||
name='tempest',
|
||||
version="0.1",
|
||||
description='The OpenStack Integration Test Suite',
|
||||
license='Apache License (2.0)',
|
||||
author='OpenStack',
|
||||
author_email='openstack@lists.launchpad.net',
|
||||
url='http://github.com/openstack/tempest/',
|
||||
classifiers=[
|
||||
'Development Status :: 4 - Beta',
|
||||
'License :: OSI Approved :: Apache Software License',
|
||||
'Operating System :: POSIX :: Linux',
|
||||
'Programming Language :: Python :: 2.6',
|
||||
'Environment :: No Input/Output (Daemon)',
|
||||
],
|
||||
py_modules=[])
|
@ -87,6 +87,10 @@ class ListServerFiltersTest(BaseComputeTest):
|
||||
cls.client.delete_server(cls.s3['id'])
|
||||
super(ListServerFiltersTest, cls).tearDownClass()
|
||||
|
||||
def _server_id_in_results(self, server_id, results):
|
||||
ids = [row['id'] for row in results]
|
||||
return server_id in ids
|
||||
|
||||
@utils.skip_unless_attr('multiple_images', 'Only one image found')
|
||||
@attr(type='positive')
|
||||
def test_list_servers_filter_by_image(self):
|
||||
@ -95,9 +99,9 @@ class ListServerFiltersTest(BaseComputeTest):
|
||||
resp, body = self.client.list_servers(params)
|
||||
servers = body['servers']
|
||||
|
||||
self.assertTrue(self.s1_min in servers)
|
||||
self.assertTrue(self.s2_min not in servers)
|
||||
self.assertTrue(self.s3_min in servers)
|
||||
self.assertTrue(self._server_id_in_results(self.s1['id'], servers))
|
||||
self.assertFalse(self._server_id_in_results(self.s2['id'], servers))
|
||||
self.assertTrue(self._server_id_in_results(self.s3['id'], servers))
|
||||
|
||||
@attr(type='positive')
|
||||
def test_list_servers_filter_by_flavor(self):
|
||||
@ -106,9 +110,9 @@ class ListServerFiltersTest(BaseComputeTest):
|
||||
resp, body = self.client.list_servers(params)
|
||||
servers = body['servers']
|
||||
|
||||
self.assertTrue(self.s1_min not in servers)
|
||||
self.assertTrue(self.s2_min not in servers)
|
||||
self.assertTrue(self.s3_min in servers)
|
||||
self.assertFalse(self._server_id_in_results(self.s1['id'], servers))
|
||||
self.assertFalse(self._server_id_in_results(self.s2['id'], servers))
|
||||
self.assertTrue(self._server_id_in_results(self.s3['id'], servers))
|
||||
|
||||
@attr(type='positive')
|
||||
def test_list_servers_filter_by_server_name(self):
|
||||
@ -117,9 +121,9 @@ class ListServerFiltersTest(BaseComputeTest):
|
||||
resp, body = self.client.list_servers(params)
|
||||
servers = body['servers']
|
||||
|
||||
self.assertTrue(self.s1_min in servers)
|
||||
self.assertTrue(self.s2_min not in servers)
|
||||
self.assertTrue(self.s3_min not in servers)
|
||||
self.assertTrue(self._server_id_in_results(self.s1['id'], servers))
|
||||
self.assertFalse(self._server_id_in_results(self.s2['id'], servers))
|
||||
self.assertFalse(self._server_id_in_results(self.s3['id'], servers))
|
||||
|
||||
@attr(type='positive')
|
||||
def test_list_servers_filter_by_server_status(self):
|
||||
@ -128,9 +132,9 @@ class ListServerFiltersTest(BaseComputeTest):
|
||||
resp, body = self.client.list_servers(params)
|
||||
servers = body['servers']
|
||||
|
||||
self.assertTrue(self.s1_min in servers)
|
||||
self.assertTrue(self.s2_min in servers)
|
||||
self.assertTrue(self.s3_min in servers)
|
||||
self.assertTrue(self._server_id_in_results(self.s1['id'], servers))
|
||||
self.assertTrue(self._server_id_in_results(self.s2['id'], servers))
|
||||
self.assertTrue(self._server_id_in_results(self.s3['id'], servers))
|
||||
|
||||
@attr(type='positive')
|
||||
def test_list_servers_limit_results(self):
|
||||
@ -147,9 +151,9 @@ class ListServerFiltersTest(BaseComputeTest):
|
||||
resp, body = self.client.list_servers_with_detail(params)
|
||||
servers = body['servers']
|
||||
|
||||
self.assertTrue(self.s1 in servers)
|
||||
self.assertTrue(self.s2 not in servers)
|
||||
self.assertTrue(self.s3 in servers)
|
||||
self.assertTrue(self._server_id_in_results(self.s1['id'], servers))
|
||||
self.assertFalse(self._server_id_in_results(self.s2['id'], servers))
|
||||
self.assertTrue(self._server_id_in_results(self.s3['id'], servers))
|
||||
|
||||
@attr(type='positive')
|
||||
def test_list_servers_detailed_filter_by_flavor(self):
|
||||
@ -158,9 +162,9 @@ class ListServerFiltersTest(BaseComputeTest):
|
||||
resp, body = self.client.list_servers_with_detail(params)
|
||||
servers = body['servers']
|
||||
|
||||
self.assertTrue(self.s1 not in servers)
|
||||
self.assertTrue(self.s2 not in servers)
|
||||
self.assertTrue(self.s3 in servers)
|
||||
self.assertFalse(self._server_id_in_results(self.s1['id'], servers))
|
||||
self.assertFalse(self._server_id_in_results(self.s2['id'], servers))
|
||||
self.assertTrue(self._server_id_in_results(self.s3['id'], servers))
|
||||
|
||||
@attr(type='positive')
|
||||
def test_list_servers_detailed_filter_by_server_name(self):
|
||||
@ -169,9 +173,9 @@ class ListServerFiltersTest(BaseComputeTest):
|
||||
resp, body = self.client.list_servers_with_detail(params)
|
||||
servers = body['servers']
|
||||
|
||||
self.assertTrue(self.s1 in servers)
|
||||
self.assertTrue(self.s2 not in servers)
|
||||
self.assertTrue(self.s3 not in servers)
|
||||
self.assertTrue(self._server_id_in_results(self.s1['id'], servers))
|
||||
self.assertFalse(self._server_id_in_results(self.s2['id'], servers))
|
||||
self.assertFalse(self._server_id_in_results(self.s3['id'], servers))
|
||||
|
||||
@attr(type='positive')
|
||||
def test_list_servers_detailed_filter_by_server_status(self):
|
||||
@ -180,9 +184,9 @@ class ListServerFiltersTest(BaseComputeTest):
|
||||
resp, body = self.client.list_servers_with_detail(params)
|
||||
servers = body['servers']
|
||||
|
||||
self.assertTrue(self.s1 in servers)
|
||||
self.assertTrue(self.s2 in servers)
|
||||
self.assertTrue(self.s3 in servers)
|
||||
self.assertTrue(self._server_id_in_results(self.s1['id'], servers))
|
||||
self.assertTrue(self._server_id_in_results(self.s2['id'], servers))
|
||||
self.assertTrue(self._server_id_in_results(self.s3['id'], servers))
|
||||
|
||||
@attr(type='positive')
|
||||
def test_list_servers_detailed_limit_results(self):
|
||||
|
@ -1,137 +0,0 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
"""
|
||||
Installation script for Kong's testing virtualenv
|
||||
"""
|
||||
|
||||
import os
|
||||
import stat
|
||||
import string
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
ROOT = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
|
||||
VENV = os.path.join(ROOT, '.kong-venv')
|
||||
PIP_REQUIRES = os.path.join(ROOT, 'tools', 'pip-requires')
|
||||
|
||||
|
||||
def die(message, *args):
|
||||
print >> sys.stderr, message % args
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def whereis(executable):
|
||||
"""
|
||||
Detect whereis a binary and make sure it's executable we can execute.
|
||||
"""
|
||||
for d in string.split(os.environ['PATH'], \
|
||||
os.pathsep):
|
||||
f = os.path.join(d, executable)
|
||||
if os.path.isfile(f):
|
||||
try:
|
||||
st = os.stat(f)
|
||||
except OSError:
|
||||
continue
|
||||
if stat.S_IMODE(st[stat.ST_MODE]) & 0111:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def run_command(cmd, redirect_output=True, check_exit_code=True):
|
||||
"""
|
||||
Runs a command in an out-of-process shell, returning the
|
||||
output of that command. Working directory is ROOT.
|
||||
"""
|
||||
if redirect_output:
|
||||
stdout = subprocess.PIPE
|
||||
else:
|
||||
stdout = None
|
||||
|
||||
proc = subprocess.Popen(cmd, cwd=ROOT, stdout=stdout)
|
||||
output = proc.communicate()[0]
|
||||
if check_exit_code and proc.returncode != 0:
|
||||
die('Command "%s" failed.\n%s', ' '.join(cmd), output)
|
||||
return output
|
||||
|
||||
|
||||
HAS_EASY_INSTALL = bool(whereis("easy_install"))
|
||||
HAS_VIRTUALENV = bool(whereis("virtualenv"))
|
||||
|
||||
|
||||
def check_dependencies():
|
||||
"""Make sure virtualenv is in the path."""
|
||||
|
||||
if not HAS_VIRTUALENV:
|
||||
print 'not found.'
|
||||
# Try installing it via easy_install...
|
||||
if HAS_EASY_INSTALL:
|
||||
print 'Installing virtualenv via easy_install...',
|
||||
if not run_command(['easy_install', 'virtualenv']):
|
||||
die('ERROR: virtualenv not found.\n\n'
|
||||
'Glance development requires virtualenv, please install'
|
||||
' it using your favorite package management tool')
|
||||
print 'done.'
|
||||
print 'done.'
|
||||
|
||||
|
||||
def create_virtualenv(venv=VENV):
|
||||
"""Creates the virtual environment and installs PIP only into the
|
||||
virtual environment
|
||||
"""
|
||||
print 'Creating venv...',
|
||||
run_command(['virtualenv', '-q', '--no-site-packages', VENV])
|
||||
print 'done.'
|
||||
print 'Installing pip in virtualenv...',
|
||||
if not run_command(['tools/with_venv.sh', 'easy_install', 'pip']).strip():
|
||||
die("Failed to install pip.")
|
||||
print 'done.'
|
||||
|
||||
|
||||
def install_dependencies(venv=VENV):
|
||||
print 'Installing dependencies with pip (this can take a while)...'
|
||||
|
||||
# Install greenlet by hand - just listing it in the requires file does not
|
||||
# get it in stalled in the right order
|
||||
venv_tool = 'tools/with_venv.sh'
|
||||
run_command([venv_tool, 'pip', 'install', '-E', venv, '-r', PIP_REQUIRES],
|
||||
redirect_output=False)
|
||||
|
||||
python_version = "python%s.%s" % (sys.version_info[0], sys.version_info[1])
|
||||
|
||||
# Tell the virtual env how to "import glance"
|
||||
pthfile = os.path.join(venv, "lib", python_version, "site-packages",
|
||||
"glance.pth")
|
||||
f = open(pthfile, 'w')
|
||||
f.write("%s\n" % ROOT)
|
||||
|
||||
|
||||
def print_help():
|
||||
help = """
|
||||
Kong testing environment setup is complete.
|
||||
|
||||
Kong testing uses virtualenv to track and manage Python dependencies
|
||||
while in development and testing.
|
||||
|
||||
To activate the Kong virtualenv for the extent of your current shell
|
||||
session you can run:
|
||||
|
||||
$ source .kong-venv/bin/activate
|
||||
|
||||
Or, if you prefer, you can run commands in the virtualenv on a case by case
|
||||
basis by running:
|
||||
|
||||
$ tools/with_venv.sh <your command>
|
||||
|
||||
Also, make test will automatically use the virtualenv.
|
||||
"""
|
||||
print help
|
||||
|
||||
|
||||
def main(argv):
|
||||
check_dependencies()
|
||||
create_virtualenv()
|
||||
install_dependencies()
|
||||
print_help()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(sys.argv)
|
@ -1,5 +1,3 @@
|
||||
pep8>=0.5.0
|
||||
pylint==0.19
|
||||
anyjson
|
||||
nose
|
||||
argparse
|
||||
|
136
tools/rfc.sh
136
tools/rfc.sh
@ -1,136 +0,0 @@
|
||||
#!/bin/sh -e
|
||||
# Copyright (c) 2010-2011 Gluster, Inc. <http://www.gluster.com>
|
||||
# This initial version of this file was taken from the source tree
|
||||
# of GlusterFS. It was not directly attributed, but is assumed to be
|
||||
# Copyright (c) 2010-2011 Gluster, Inc and release GPLv3
|
||||
# Subsequent modifications are Copyright (c) 2011 OpenStack, LLC.
|
||||
#
|
||||
# GlusterFS is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published
|
||||
# by the Free Software Foundation; either version 3 of the License,
|
||||
# or (at your option) any later version.
|
||||
#
|
||||
# GlusterFS is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
branch="master";
|
||||
|
||||
set_hooks_commit_msg()
|
||||
{
|
||||
top_dir=`git rev-parse --show-toplevel`
|
||||
f="${top_dir}/.git/hooks/commit-msg";
|
||||
u="https://review.openstack.org/tools/hooks/commit-msg";
|
||||
|
||||
if [ -x "$f" ]; then
|
||||
return;
|
||||
fi
|
||||
|
||||
curl -o $f $u || wget -O $f $u;
|
||||
|
||||
chmod +x $f;
|
||||
|
||||
GIT_EDITOR=true git commit --amend
|
||||
}
|
||||
|
||||
add_remote()
|
||||
{
|
||||
username=$1
|
||||
project=$2
|
||||
|
||||
echo "No remote set, testing ssh://$username@review.openstack.org:29418"
|
||||
if ssh -p29418 -o StrictHostKeyChecking=no $username@review.openstack.org gerrit ls-projects >/dev/null 2>&1
|
||||
then
|
||||
echo "$username@review.openstack.org:29418 worked."
|
||||
echo "Creating a git remote called gerrit that maps to:"
|
||||
echo " ssh://$username@review.openstack.org:29418/$project"
|
||||
git remote add gerrit ssh://$username@review.openstack.org:29418/$project
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
check_remote()
|
||||
{
|
||||
if ! git remote | grep gerrit >/dev/null 2>&1
|
||||
then
|
||||
origin_project=`git remote show origin | grep 'Fetch URL' | perl -nle '@fields = split(m|[:/]|); $len = $#fields; print $fields[$len-1], "/", $fields[$len];'`
|
||||
if add_remote $USERNAME $origin_project
|
||||
then
|
||||
return 0
|
||||
else
|
||||
echo "Your local name doesn't work on Gerrit."
|
||||
echo -n "Enter Gerrit username (same as launchpad): "
|
||||
read gerrit_user
|
||||
if add_remote $gerrit_user $origin_project
|
||||
then
|
||||
return 0
|
||||
else
|
||||
echo "Can't infer where gerrit is - please set a remote named"
|
||||
echo "gerrit manually and then try again."
|
||||
echo
|
||||
echo "For more information, please see:"
|
||||
echo "\thttp://wiki.openstack.org/GerritWorkflow"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
rebase_changes()
|
||||
{
|
||||
git fetch;
|
||||
|
||||
GIT_EDITOR=true git rebase -i origin/$branch || exit $?;
|
||||
}
|
||||
|
||||
|
||||
assert_diverge()
|
||||
{
|
||||
if ! git diff origin/$branch..HEAD | grep -q .
|
||||
then
|
||||
echo "No changes between the current branch and origin/$branch."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
main()
|
||||
{
|
||||
set_hooks_commit_msg;
|
||||
|
||||
check_remote;
|
||||
|
||||
rebase_changes;
|
||||
|
||||
assert_diverge;
|
||||
|
||||
bug=$(git show --format='%s %b' | perl -nle 'if (/\b([Bb]ug|[Ll][Pp])\s*[#:]?\s*(\d+)/) {print "$2"; exit}')
|
||||
|
||||
bp=$(git show --format='%s %b' | perl -nle 'if (/\b([Bb]lue[Pp]rint|[Bb][Pp])\s*[#:]?\s*([0-9a-zA-Z-_]+)/) {print "$2"; exit}')
|
||||
|
||||
if [ "$DRY_RUN" = 1 ]; then
|
||||
drier='echo -e Please use the following command to send your commits to review:\n\n'
|
||||
else
|
||||
drier=
|
||||
fi
|
||||
|
||||
local_branch=`git branch | grep -Ei "\* (.*)" | cut -f2 -d' '`
|
||||
if [ -z "$bug" ]; then
|
||||
if [ -z "$bp" ]; then
|
||||
$drier git push gerrit HEAD:refs/for/$branch/$local_branch;
|
||||
else
|
||||
$drier git push gerrit HEAD:refs/for/$branch/bp/$bp;
|
||||
fi
|
||||
else
|
||||
$drier git push gerrit HEAD:refs/for/$branch/bug/$bug;
|
||||
fi
|
||||
}
|
||||
|
||||
main "$@"
|
@ -83,17 +83,21 @@ def find_skips_in_file(path):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO)
|
||||
logging.basicConfig(format='%(levelname)s: %(message)s',
|
||||
level=logging.INFO)
|
||||
results = find_skips()
|
||||
unique_bugs = sorted(set([bug for (method, bug) in results]))
|
||||
unskips = []
|
||||
info("Total bug skips found: %d", len(results))
|
||||
info("Total unique bugs causing skips: %d", len(unique_bugs))
|
||||
lp = launchpad.Launchpad.login_anonymously('grabbing bugs', 'production', LPCACHEDIR)
|
||||
lp = launchpad.Launchpad.login_anonymously('grabbing bugs',
|
||||
'production',
|
||||
LPCACHEDIR)
|
||||
for bug_no in unique_bugs:
|
||||
bug = lp.bugs[bug_no]
|
||||
for task in bug.bug_tasks:
|
||||
info("Bug #%7s (%12s - %12s)", bug_no, task.importance, task.status)
|
||||
info("Bug #%7s (%12s - %12s)", bug_no,
|
||||
task.importance, task.status)
|
||||
if task.status in ('Fix Released', 'Fix Committed'):
|
||||
unskips.append(bug_no)
|
||||
|
||||
|
2
tools/test-requires
Normal file
2
tools/test-requires
Normal file
@ -0,0 +1,2 @@
|
||||
pep8>=0.5.0
|
||||
pylint==0.19
|
18
tox.ini
Normal file
18
tox.ini
Normal file
@ -0,0 +1,18 @@
|
||||
[tox]
|
||||
envlist = pep8
|
||||
|
||||
[testenv]
|
||||
setenv = VIRTUAL_ENV={envdir}
|
||||
NOSE_WITH_OPENSTACK=1
|
||||
NOSE_OPENSTACK_COLOR=1
|
||||
NOSE_OPENSTACK_RED=15
|
||||
NOSE_OPENSTACK_YELLOW=3
|
||||
NOSE_OPENSTACK_SHOW_ELAPSED=1
|
||||
NOSE_OPENSTACK_STDOUT=1
|
||||
deps = -r{toxinidir}/tools/pip-requires
|
||||
-r{toxinidir}/tools/test-requires
|
||||
commands = nosetests {posargs}
|
||||
|
||||
[testenv:pep8]
|
||||
deps = pep8==1.1
|
||||
commands = pep8 --repeat --show-source --exclude=.venv,.tox,dist,doc,openstack,kong .
|
Loading…
Reference in New Issue
Block a user