Fix gate issues

Issue 1:
The os-testr 1.0.0 release had a couple of required config changes due
to it's internal usage of stestr.

This change to stestr changed the way tests were discovered by
os-testr and as a result the unit test run was picking up tempest
tests.

A regex is added to the py3base environment call of ostestr because
the use of --serial and --blacklist-file together is broken in stestr
and adding the regex parameter allows the blacklist-file to be
processed. The stestr issue is documented here [1].

Issue 2:

Cache dirs for PKI tokens have been removed for all services in
devstack under I5680376e70e74882e9fdb87ee1b95d5f40570ad7.

We must also remove the use here to pass the right parameters to
configure_auth_token_middleware.

Issue 3:
Keystone V2 APIs have been removed.  When creating Nova and Glance
clients, the test code was either hard coding v2 Keystone or not
providing enough information for the V3 auth.

Issue 4:
Oslo context has deprecated parameters such as 'tenant', has removed
them from its constructor and is using a rename decorator to handle
them. As such, the code and test case to check for unrecognized
parameters to TroveContext and Context is erroneously removing the
tenant parameter.  Oslo context has also changed the from_dict method
since the original code to remove parameters was introduced into
Trove. The new method signature and code should already provide most
or all of the protections against incompatibility the original code
was attempting to provide. The fix for this issue is to change
TroveContext's from_dict method to use the kwargs to handle its own
__init__ parameters and be more in line with what Nova is doing in
its RequestContext subclass.

Issue 5:
Jobs run as jenkins on Zuul v2 but run as user zuul on Zuul v3.

Issue 6:
Ignore one case of pylint E1101 in the Ceilometer notification
code base.

[1] https://github.com/mtreinish/stestr/issues/103

Change-Id: Ic55187b0d73d4c572d7f8332882b4f455a6177c8
This commit is contained in:
Samuel Matzek 2017-09-25 07:49:32 -05:00
parent 0fb67d459b
commit 9ec134996a
13 changed files with 49 additions and 63 deletions

1
.gitignore vendored
View File

@ -22,6 +22,7 @@ ChangeLog
trove.iml
.testrepository
.pid
.stestr/
# Sphinx
doc/build/*

3
.stestr.conf Normal file
View File

@ -0,0 +1,3 @@
[DEFAULT]
test_path=${OS_TEST_PATH:-./trove/tests}
top_dir=./

View File

@ -79,7 +79,6 @@ function _cleanup_trove_apache_wsgi {
# runs that a clean run would need to clean up
function cleanup_trove {
# Clean up dirs
rm -fr $TROVE_AUTH_CACHE_DIR/*
rm -fr $TROVE_CONF_DIR/*
if is_service_enabled horizon; then
@ -181,7 +180,7 @@ function configure_trove {
configure_keystone_token_life
# Create the trove conf dir and cache dirs if they don't exist
sudo install -d -o $STACK_USER ${TROVE_CONF_DIR} ${TROVE_AUTH_CACHE_DIR}
sudo install -d -o $STACK_USER ${TROVE_CONF_DIR}
# Copy api-paste file over to the trove conf dir
cp $TROVE_LOCAL_API_PASTE_INI $TROVE_API_PASTE_INI
@ -215,7 +214,7 @@ function configure_trove {
setup_trove_logging $TROVE_CONF
iniset $TROVE_CONF DEFAULT trove_api_workers "$API_WORKERS"
configure_auth_token_middleware $TROVE_CONF trove $TROVE_AUTH_CACHE_DIR
configure_auth_token_middleware $TROVE_CONF trove
iniset $TROVE_CONF DEFAULT trove_auth_url $TROVE_AUTH_ENDPOINT
fi

View File

@ -26,7 +26,6 @@ TROVE_POLICY_JSON=${TROVE_POLICY_JSON:-${TROVE_CONF_DIR}/policy.json}
TROVE_LOCAL_CONF_DIR=${TROVE_LOCAL_CONF_DIR:-${TROVE_DIR}/etc/trove}
TROVE_LOCAL_API_PASTE_INI=${TROVE_LOCAL_API_PASTE_INI:-${TROVE_LOCAL_CONF_DIR}/api-paste.ini}
TROVE_LOCAL_POLICY_JSON=${TROVE_LOCAL_POLICY_JSON:-${TROVE_LOCAL_CONF_DIR}/policy.json}
TROVE_AUTH_CACHE_DIR=${TROVE_AUTH_CACHE_DIR:-/var/cache/trove}
TROVE_DATASTORE_TYPE=${TROVE_DATASTORE_TYPE:-"mysql"}
TROVE_DATASTORE_VERSION=${TROVE_DATASTORE_VERSION:-"5.6"}
TROVE_DATASTORE_PACKAGE=${TROVE_DATASTORE_PACKAGE:-"mysql-server-5.6"}

View File

@ -1,20 +1,20 @@
{
"dbaas_url":"http://%service_host%:8779/v1.0",
"version_url":"http://%service_host%:8779",
"trove_auth_url":"http://%service_host%/identity/v2.0/tokens",
"trove_auth_url":"http://%service_host%/identity/v3/auth/tokens",
"trove_client_insecure":false,
"auth_strategy":null,
"trove_client_region_name": "%region_name%",
"nova_client": {
"url":"http://%service_host%:8774/v1.1",
"auth_url":"http://%service_host%/identity/v2.0",
"auth_url":"http://%service_host%/identity/v3",
"nova_service_type":"compute",
"volume_service_type":"volume"
},
"glance_client": {
"auth_url":"http://%service_host%/identity/v2.0"
"auth_url":"http://%service_host%/identity/v3"
},
"flavors": null,

View File

@ -7,7 +7,6 @@ SERVICE_PASSWORD=$SERVICE_PASSWORD
IP_VERSION=4
TROVE_LOGDIR=$TROVE_LOGDIR
TROVE_AUTH_CACHE_DIR=$TROVE_AUTH_CACHE_DIR
# Enable the Trove plugin for devstack
enable_plugin trove $TROVE_REPO $TROVE_BRANCH

View File

@ -105,7 +105,6 @@ GLANCE_SERVICE_PROTOCOL=${GLANCE_SERVICE_PROTOCOL:-http}
# This will escape them
ESCAPED_PATH_TROVE=$(echo $PATH_TROVE | sed 's/\//\\\//g')
ESCAPED_TROVESTACK_SCRIPTS=$(echo $TROVESTACK_SCRIPTS | sed 's/\//\\\//g')
TROVE_AUTH_CACHE_DIR=${TROVE_AUTH_CACHE_DIR:-/var/cache/trove}
TROVE_LOGDIR=${TROVE_LOGDIR:-$DEST/logs}
TROVE_DEVSTACK_SETTINGS="$DEST/trove/devstack/settings"
TROVE_DEVSTACK_PLUGIN="$DEST/trove/devstack/plugin.sh"
@ -1291,7 +1290,7 @@ function cmd_dsvm_gate_tests() {
local DATASTORE_TYPE=${1:-'mysql'}
local TEST_GROUP=${2:-${DATASTORE_TYPE}}
local HOST_SCP_USERNAME=${3:-'jenkins'}
local HOST_SCP_USERNAME=${3:-$USER}
local GUEST_USERNAME=${4:-'ubuntu'}
local CONTROLLER_IP=${5:-$ACTUAL_HOSTNAME}
local ESCAPED_PATH_TROVE=${6:-'\/opt\/stack\/new\/trove'}
@ -1330,8 +1329,8 @@ function cmd_dsvm_gate_tests() {
export TROVE_REPORT_DIR=$HOME/dsvm-report/
TROVESTACK_DUMP_ENV=true
# Devstack vm-gate runs as the jenkins user, but needs to connect to the guest image as ubuntu
echo "User=ubuntu" >> /home/jenkins/.ssh/config
# Devstack vm-gate runs as a non-ubuntu user, but needs to connect to the guest image as ubuntu
echo "User=ubuntu" >> /home/$USER/.ssh/config
# Fix iptables rules that prevent amqp connections from the devstack box to the guests
sudo iptables -D openstack-INPUT -j REJECT --reject-with icmp-host-prohibited || true

View File

@ -251,12 +251,12 @@ def run_main(test_importer):
# Turn off the following "feature" of the unittest module in case
# we want to start a REPL.
sys.exit = lambda x: None
print("Integration tests are temporarily disabled")
return 0
proboscis.TestProgram(argv=nose_args, groups=groups, config=c,
testRunner=MAIN_RUNNER).run_and_exit()
sys.stdout = sys.__stdout__
sys.stderr = sys.__stderr__
if __name__ == "__main__":
run_main(import_tests)

View File

@ -6,6 +6,10 @@ skipsdist = True
[testenv]
setenv = VIRTUAL_ENV={envdir}
PYTHONWARNINGS=default::DeprecationWarning
OS_TEST_PATH=./trove/tests/unittests
OS_STDOUT_CAPTURE=1
OS_STDERR_CAPTURE=1
usedevelop = True
install_command = pip install \
-c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} \
@ -35,7 +39,7 @@ commands = {[testenv]commands}
ostestr --slowest --serial
[py3base]
commands = ostestr --slowest --blacklist_file=blacklist-py3.txt --serial
commands = ostestr --slowest --blacklist-file=blacklist-py3.txt --serial --regex '.*'
[testenv:py34]
commands = {[testenv]commands}

View File

@ -23,9 +23,7 @@ context or provide additional information in their specific WSGI pipeline.
from oslo_context import context
from oslo_log import log as logging
from oslo_utils import reflection
from trove.common.i18n import _
from trove.common import local
from trove.common.serializable_notification import SerializableNotification
@ -58,6 +56,11 @@ class TroveContext(context.RequestContext):
'service_catalog': self.service_catalog
})
if hasattr(self, 'notification'):
# Disable E1101 to allow us to specify self.notification here.
# The ceilometer notification code relies on this being there but
# we can't have self.notification as some code does
# del context.notification.
# pylint: disable=E1101
serialized = SerializableNotification.serialize(self,
self.notification)
parent_dict['trove_notification'] = serialized
@ -66,29 +69,16 @@ class TroveContext(context.RequestContext):
def update_store(self):
local.store.context = self
@classmethod
def _remove_incompatible_context_args(cls, values):
realvalues = {}
args = (reflection.get_callable_args(context.RequestContext.__init__) +
reflection.get_callable_args(TroveContext.__init__))
for dict_key in values.keys():
if dict_key in args:
realvalues[dict_key] = values.get(dict_key)
else:
LOG.warning(_("Argument being removed before instantiating "
"TroveContext object - %(key)s = %(value)s"),
{'key': dict_key, 'value': values.get(dict_key)})
return realvalues
@classmethod
def from_dict(cls, values):
n_values = values.pop('trove_notification', None)
values = cls._remove_incompatible_context_args(values)
context = cls(**values)
ctx = super(TroveContext, cls).from_dict(
values,
limit=values.get('limit'),
marker=values.get('marker'),
service_catalog=values.get('service_catalog'))
if n_values:
context.notification = SerializableNotification.deserialize(
context, n_values)
return context
ctx.notification = SerializableNotification.deserialize(
ctx, n_values)
return ctx

View File

@ -248,7 +248,7 @@ class LogOnFail(type):
return fn(*args, **kwargs)
except proboscis.SkipTest:
raise
except Exception as test_ex:
except Exception:
msg_prefix = "*** LogOnFail: "
if inst_ids:
report.log(msg_prefix + "Exception detected, "
@ -276,7 +276,7 @@ class LogOnFail(type):
# Only report on the first error that occurs
mcs.reset_inst_ids()
raise test_ex
raise
return wrapper
@ -476,7 +476,7 @@ class TestRunner(object):
user=user.auth_user,
key=user.auth_key,
tenant_name=user.tenant,
auth_version='2.0',
auth_version='3.0',
os_options=os_options)
@property

View File

@ -13,7 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
#
import mock
from mock import Mock
from testtools.matchers import Equals, Is
@ -66,19 +65,11 @@ class TestTroveContext(trove_testtools.TestCase):
'DBaaSInstanceCreate'))
def test_create_with_bogus(self):
with mock.patch('trove.common.context.LOG') as mock_log:
ctx = context.TroveContext.from_dict(
{'user': 'test_user_id',
'request_id': 'test_req_id',
'tenant': 'abc',
'blah_blah': 'blah blah'})
mock_log.warning.assert_called()
mock_log.warning.assert_called_with('Argument being removed '
'before instantiating '
'TroveContext object - '
'%(key)s = %(value)s',
{'value': 'blah blah',
'key': 'blah_blah'})
ctx = context.TroveContext.from_dict(
{'user': 'test_user_id',
'request_id': 'test_req_id',
'tenant': 'abc',
'blah_blah': 'blah blah'})
self.assertThat(ctx.user, Equals('test_user_id'))
self.assertThat(ctx.request_id, Equals('test_req_id'))
self.assertThat(ctx.tenant, Equals('abc'))

View File

@ -167,13 +167,13 @@ def create_nova_client(user, service_type=None):
if not service_type:
service_type = test_config.nova_client['nova_service_type']
openstack = Client(CONF.nova_client_version,
user.auth_user,
user.auth_key,
project_name=user.tenant,
username=user.auth_user,
password=user.auth_key,
user_domain_name='Default',
project_id=user.tenant_id,
auth_url=test_config.nova_client['auth_url'],
service_type=service_type, os_cache=False,
cacert=test_config.values.get('cacert', None))
openstack.authenticate()
return TestClient(openstack)
@ -183,12 +183,13 @@ def create_glance_client(user):
raise SkipTest("No glance_client info specified in the Test Config "
"so this test will be skipped.")
from glanceclient import Client
from keystoneauth1.identity import v2
from keystoneauth1.identity import v3
from keystoneauth1 import session
auth = v2.Password(username=user.auth_user,
auth = v3.Password(username=user.auth_user,
password=user.auth_key,
tenant_name=user.tenant,
user_domain_name='Default',
project_id=user.tenant_id,
auth_url=test_config.glance_client['auth_url'])
session = session.Session(auth=auth)
glance = Client(CONF.glance_client_version, session=session)