Compare commits
17 Commits
queens-eol
...
kilo-eol
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e59a62ec3f | ||
|
|
68fc2b3db1 | ||
|
|
58d22de75d | ||
|
|
f6dca22bc6 | ||
|
|
2e0d641a55 | ||
|
|
98fa6fd1c8 | ||
|
|
ce05ad751d | ||
|
|
831604f2ed | ||
|
|
6635aa40a9 | ||
|
|
4b414a9cbe | ||
|
|
9c34bd21cf | ||
|
|
259d080d19 | ||
|
|
ca96a7cdc7 | ||
|
|
73344e7c8a | ||
|
|
cddc054359 | ||
|
|
c054d2583b | ||
|
|
dc62768c5b |
@@ -2,3 +2,5 @@
|
||||
host=review.openstack.org
|
||||
port=29418
|
||||
project=openstack/python-neutronclient.git
|
||||
defaultbranch=stable/kilo
|
||||
|
||||
|
||||
8
functional_creds.conf.sample
Normal file
8
functional_creds.conf.sample
Normal file
@@ -0,0 +1,8 @@
|
||||
# Credentials for functional testing
|
||||
[auth]
|
||||
uri = http://10.42.0.50:5000/v2.0
|
||||
|
||||
[admin]
|
||||
user = admin
|
||||
tenant = admin
|
||||
pass = secrete
|
||||
@@ -476,8 +476,9 @@ class CreateCommand(NeutronCommand, show.ShowOne):
|
||||
self.format_output_data(data)
|
||||
info = self.resource in data and data[self.resource] or None
|
||||
if info:
|
||||
print(_('Created a new %s:') % self.resource,
|
||||
file=self.app.stdout)
|
||||
if parsed_args.formatter == 'table':
|
||||
print(_('Created a new %s:') % self.resource,
|
||||
file=self.app.stdout)
|
||||
else:
|
||||
info = {'': ''}
|
||||
return zip(*sorted(six.iteritems(info)))
|
||||
|
||||
@@ -106,7 +106,8 @@ class CreateListener(neutronV20.CreateCommand):
|
||||
['connection-limit', 'description',
|
||||
'loadbalancer_id', 'name',
|
||||
'default_tls_container_id',
|
||||
'sni_container_ids'])
|
||||
'sni_container_ids',
|
||||
'tenant_id'])
|
||||
return body
|
||||
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ class CreateLoadBalancer(neutronV20.CreateCommand):
|
||||
}
|
||||
neutronV20.update_dict(parsed_args, body[self.resource],
|
||||
['description', 'provider', 'vip_address',
|
||||
'name'])
|
||||
'tenant_id', 'name'])
|
||||
return body
|
||||
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ class CreateMember(neutronV20.CreateCommand):
|
||||
},
|
||||
}
|
||||
neutronV20.update_dict(parsed_args, body[self.resource],
|
||||
['weight', 'subnet_id'])
|
||||
['weight', 'subnet_id', 'tenant_id'])
|
||||
return body
|
||||
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ class CreatePool(neutronV20.CreateCommand):
|
||||
}
|
||||
neutronV20.update_dict(parsed_args, body[self.resource],
|
||||
['description', 'name',
|
||||
'session_persistence'])
|
||||
'session_persistence', 'tenant_id'])
|
||||
return body
|
||||
|
||||
|
||||
|
||||
@@ -18,6 +18,13 @@ from neutronclient.i18n import _
|
||||
from neutronclient.neutron import v2_0 as neutronV20
|
||||
|
||||
|
||||
def _format_prefixes(subnetpool):
|
||||
try:
|
||||
return '\n'.join(pool for pool in subnetpool['prefixes'])
|
||||
except (TypeError, KeyError):
|
||||
return subnetpool['prefixes']
|
||||
|
||||
|
||||
def add_updatable_arguments(parser):
|
||||
parser.add_argument(
|
||||
'--min-prefixlen', type=int,
|
||||
@@ -43,6 +50,7 @@ def updatable_args2body(parsed_args, body, for_create=True):
|
||||
class ListSubnetPool(neutronV20.ListCommand):
|
||||
"""List subnetpools that belong to a given tenant."""
|
||||
|
||||
_formatters = {'prefixes': _format_prefixes, }
|
||||
resource = 'subnetpool'
|
||||
list_columns = ['id', 'name', 'prefixes',
|
||||
'default_prefixlen']
|
||||
|
||||
@@ -12,9 +12,44 @@
|
||||
|
||||
import os
|
||||
|
||||
from six.moves import configparser
|
||||
from tempest_lib.cli import base
|
||||
|
||||
|
||||
_CREDS_FILE = 'functional_creds.conf'
|
||||
|
||||
|
||||
def credentials():
|
||||
"""Retrieves credentials to run functional tests
|
||||
|
||||
Credentials are either read from the environment or from a config file
|
||||
('functional_creds.conf'). Environment variables override those from the
|
||||
config file.
|
||||
|
||||
The 'functional_creds.conf' file is the clean and new way to use (by
|
||||
default tox 2.0 does not pass environment variables).
|
||||
"""
|
||||
|
||||
username = os.environ.get('OS_USERNAME')
|
||||
password = os.environ.get('OS_PASSWORD')
|
||||
tenant_name = os.environ.get('OS_TENANT_NAME')
|
||||
auth_url = os.environ.get('OS_AUTH_URL')
|
||||
|
||||
config = configparser.RawConfigParser()
|
||||
if config.read(_CREDS_FILE):
|
||||
username = username or config.get('admin', 'user')
|
||||
password = password or config.get('admin', 'pass')
|
||||
tenant_name = tenant_name or config.get('admin', 'tenant')
|
||||
auth_url = auth_url or config.get('auth', 'uri')
|
||||
|
||||
return {
|
||||
'username': username,
|
||||
'password': password,
|
||||
'tenant_name': tenant_name,
|
||||
'auth_url': auth_url
|
||||
}
|
||||
|
||||
|
||||
class ClientTestBase(base.ClientTestBase):
|
||||
"""This is a first pass at a simple read only python-neutronclient test.
|
||||
This only exercises client commands that are read only.
|
||||
@@ -28,16 +63,15 @@ class ClientTestBase(base.ClientTestBase):
|
||||
"""
|
||||
|
||||
def _get_clients(self):
|
||||
creds = credentials()
|
||||
cli_dir = os.environ.get(
|
||||
'OS_NEUTRONCLIENT_EXEC_DIR',
|
||||
os.path.join(os.path.abspath('.'), '.tox/functional/bin'))
|
||||
|
||||
return base.CLIClient(
|
||||
username=os.environ.get('OS_USERNAME'),
|
||||
password=os.environ.get('OS_PASSWORD'),
|
||||
tenant_name=os.environ.get('OS_TENANT_NAME'),
|
||||
uri=os.environ.get('OS_AUTH_URL'),
|
||||
cli_dir=cli_dir)
|
||||
return base.CLIClient(username=creds['username'],
|
||||
password=creds['password'],
|
||||
tenant_name=creds['tenant_name'],
|
||||
uri=creds['auth_url'],
|
||||
cli_dir=cli_dir)
|
||||
|
||||
def neutron(self, *args, **kwargs):
|
||||
return self.clients.neutron(*args,
|
||||
|
||||
59
neutronclient/tests/functional/core/test_cli_formatter.py
Normal file
59
neutronclient/tests/functional/core/test_cli_formatter.py
Normal file
@@ -0,0 +1,59 @@
|
||||
# Copyright 2016 NEC Corporation
|
||||
#
|
||||
# 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.
|
||||
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import uuidutils
|
||||
import yaml
|
||||
|
||||
from neutronclient.tests.functional import base
|
||||
|
||||
|
||||
class TestCLIFormatter(base.ClientTestBase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestCLIFormatter, self).setUp()
|
||||
self.net_name = 'net-%s' % uuidutils.generate_uuid()
|
||||
self.addCleanup(self.neutron, 'net-delete %s' % self.net_name)
|
||||
|
||||
def _create_net(self, fmt, col_attrs):
|
||||
params = ['-c %s' % attr for attr in col_attrs]
|
||||
params.append('-f %s' % fmt)
|
||||
params.append(self.net_name)
|
||||
param_string = ' '.join(params)
|
||||
return self.neutron('net-create', params=param_string)
|
||||
|
||||
def test_net_create_with_json_formatter(self):
|
||||
result = self._create_net('json', ['name', 'admin_state_up'])
|
||||
self.assertDictEqual({'name': self.net_name,
|
||||
'admin_state_up': True},
|
||||
jsonutils.loads(result))
|
||||
|
||||
def test_net_create_with_yaml_formatter(self):
|
||||
result = self._create_net('yaml', ['name', 'admin_state_up'])
|
||||
self.assertDictEqual({'name': self.net_name,
|
||||
'admin_state_up': True},
|
||||
yaml.load(result))
|
||||
|
||||
def test_net_create_with_value_formatter(self):
|
||||
# NOTE(amotoki): In 'value' formatter, there is no guarantee
|
||||
# in the order of attribute, so we use one attribute in this test.
|
||||
result = self._create_net('value', ['name'])
|
||||
self.assertEqual(self.net_name, result.strip())
|
||||
|
||||
def test_net_create_with_shell_formatter(self):
|
||||
result = self._create_net('shell', ['name', 'admin_state_up'])
|
||||
result_lines = set(result.strip().split('\n'))
|
||||
self.assertSetEqual(set(['name="%s"' % self.net_name,
|
||||
'admin_state_up="True"']),
|
||||
result_lines)
|
||||
5
neutronclient/tests/functional/hooks/gate_hook.sh
Normal file
5
neutronclient/tests/functional/hooks/gate_hook.sh
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
|
||||
$BASE/new/devstack-gate/devstack-vm-gate.sh
|
||||
@@ -18,7 +18,7 @@ function generate_testr_results {
|
||||
if [ -f .testrepository/0 ]; then
|
||||
sudo .tox/functional/bin/testr last --subunit > $WORKSPACE/testrepository.subunit
|
||||
sudo mv $WORKSPACE/testrepository.subunit $BASE/logs/testrepository.subunit
|
||||
sudo .tox/functional/bin/python /usr/local/jenkins/slave_scripts/subunit2html.py $BASE/logs/testrepository.subunit $BASE/logs/testr_results.html
|
||||
sudo /usr/os-testr-env/bin/subunit2html $BASE/logs/testrepository.subunit $BASE/logs/testr_results.html
|
||||
sudo gzip -9 $BASE/logs/testrepository.subunit
|
||||
sudo gzip -9 $BASE/logs/testr_results.html
|
||||
sudo chown jenkins:jenkins $BASE/logs/testrepository.subunit.gz $BASE/logs/testr_results.html.gz
|
||||
@@ -28,15 +28,28 @@ function generate_testr_results {
|
||||
|
||||
export NEUTRONCLIENT_DIR="$BASE/new/python-neutronclient"
|
||||
|
||||
sudo chown -R jenkins:stack $NEUTRONCLIENT_DIR
|
||||
|
||||
# Get admin credentials
|
||||
cd $BASE/new/devstack
|
||||
source openrc admin admin
|
||||
|
||||
# Store these credentials into the config file
|
||||
CREDS_FILE=$NEUTRONCLIENT_DIR/functional_creds.conf
|
||||
cat <<EOF > $CREDS_FILE
|
||||
# Credentials for functional testing
|
||||
[auth]
|
||||
uri = $OS_AUTH_URL
|
||||
|
||||
[admin]
|
||||
user = $OS_USERNAME
|
||||
tenant = $OS_TENANT_NAME
|
||||
pass = $OS_PASSWORD
|
||||
EOF
|
||||
|
||||
# Go to the neutronclient dir
|
||||
cd $NEUTRONCLIENT_DIR
|
||||
|
||||
sudo chown -R jenkins:stack $NEUTRONCLIENT_DIR
|
||||
|
||||
# Run tests
|
||||
echo "Running neutronclient functional test suite"
|
||||
set +e
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
# The order of packages is significant, because pip processes them in the order
|
||||
# of appearance. Changing the order has an impact on the overall integration
|
||||
# process, which may cause wedges in the gate later.
|
||||
pbr>=0.6,!=0.7,<1.0
|
||||
pbr!=0.7,<1.0,>=0.6
|
||||
argparse
|
||||
cliff>=1.10.0,<1.11.0 # Apache-2.0
|
||||
cliff<1.11.0,>=1.10.0 # Apache-2.0
|
||||
iso8601>=0.1.9
|
||||
netaddr>=0.7.12
|
||||
oslo.i18n>=1.5.0,<1.6.0 # Apache-2.0
|
||||
oslo.serialization>=1.4.0,<1.5.0 # Apache-2.0
|
||||
oslo.utils>=1.4.0,<1.5.0 # Apache-2.0
|
||||
requests>=2.2.0,!=2.4.0
|
||||
python-keystoneclient>=1.1.0
|
||||
oslo.i18n<1.6.0,>=1.5.0 # Apache-2.0
|
||||
oslo.serialization<1.5.0,>=1.4.0 # Apache-2.0
|
||||
oslo.utils!=1.4.1,<1.5.0,>=1.4.0 # Apache-2.0
|
||||
requests!=2.4.0,<2.8.0,>=2.2.0
|
||||
python-keystoneclient<1.4.0,>=1.2.0
|
||||
simplejson>=2.2.0
|
||||
six>=1.9.0
|
||||
Babel>=1.3
|
||||
Babel!=2.3.0,!=2.3.1,!=2.3.2,!=2.3.3,>=1.3 # BSD
|
||||
|
||||
1
setup.py
1
setup.py
@@ -1,4 +1,3 @@
|
||||
#!/usr/bin/env python
|
||||
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
# The order of packages is significant, because pip processes them in the order
|
||||
# of appearance. Changing the order has an impact on the overall integration
|
||||
# process, which may cause wedges in the gate later.
|
||||
hacking>=0.10.0,<0.11
|
||||
hacking<0.11,>=0.10.0
|
||||
|
||||
cliff-tablib>=1.0
|
||||
cliff-tablib<2.0,>=1.0
|
||||
coverage>=3.6
|
||||
discover
|
||||
fixtures>=0.3.14
|
||||
mox3>=0.7.0
|
||||
mock>=1.0
|
||||
oslosphinx>=2.5.0,<2.6.0 # Apache-2.0
|
||||
oslotest>=1.5.1,<1.6.0 # Apache-2.0
|
||||
fixtures<1.3.0,>=0.3.14
|
||||
mox3<0.8.0,>=0.7.0
|
||||
mock<1.1.0,>=1.0
|
||||
oslosphinx<2.6.0,>=2.5.0 # Apache-2.0
|
||||
oslotest<1.6.0,>=1.5.1 # Apache-2.0
|
||||
python-subunit>=0.0.18
|
||||
requests-mock>=0.6.0 # Apache-2.0
|
||||
sphinx>=1.1.2,!=1.2.0,!=1.3b1,<1.3
|
||||
requests-mock>=0.6.0 # Apache-2.0
|
||||
sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2
|
||||
testrepository>=0.0.18
|
||||
testtools>=0.9.36,!=1.2.0
|
||||
tempest-lib>=0.4.0
|
||||
testtools!=1.2.0,<2.0.0,>=0.9.36
|
||||
tempest-lib<0.5.0,>=0.4.0
|
||||
|
||||
9
tox.ini
9
tox.ini
@@ -13,7 +13,14 @@ usedevelop = True
|
||||
install_command = pip install -U {opts} {packages}
|
||||
deps = -r{toxinidir}/requirements.txt
|
||||
-r{toxinidir}/test-requirements.txt
|
||||
commands = python setup.py testr --testr-args='{posargs}'
|
||||
# Delete bytecodes from normal directories before running tests.
|
||||
# Note that bytecodes in dot directories will not be deleted
|
||||
# to keep bytecodes of python modules installed into virtualenvs.
|
||||
commands = sh -c "find . -type d -name '.?*' -prune -o \
|
||||
\( -type d -name '__pycache__' -o -type f -name '*.py[co]' \) \
|
||||
-print0 | xargs -0 rm -rf"
|
||||
python setup.py testr --testr-args='{posargs}'
|
||||
whitelist_externals = sh
|
||||
|
||||
[testenv:pep8]
|
||||
commands = flake8
|
||||
|
||||
Reference in New Issue
Block a user