Added hacking checks to tox

Fixed all places where hacking rules (v0.7) was failing
Replaced ''' with """ to make them consistent

Change-Id: I9c1c20f910df696056d2a6a91c33ff7bad266b9f
Related-Bug: #1404892
Closes-Bug: #1408240
This commit is contained in:
Sebastian Kalinowski
2015-01-14 13:55:28 +01:00
committed by Sebastian Kalinowski
parent 92ad9f8e4c
commit cbe0ea30d9
62 changed files with 354 additions and 387 deletions

21
fabfile.py vendored
View File

@@ -1,3 +1,19 @@
# -*- coding: utf-8 -*-
# Copyright 2015 Mirantis, Inc.
#
# 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 fabric.api import local from fabric.api import local
@@ -46,10 +62,9 @@ def startnailgunmimic():
def createmigration(comment): def createmigration(comment):
''' """Supply comment for new alembic revision as a value
Supply comment for new alembic revision as a value
for comment argument for comment argument
''' """
config_path = 'fuel_plugin/ostf_adapter/storage/alembic.ini' config_path = 'fuel_plugin/ostf_adapter/storage/alembic.ini'
local( local(
'alembic --config {0} revision --autogenerate -m \"{1}\"' 'alembic --config {0} revision --autogenerate -m \"{1}\"'

View File

@@ -89,9 +89,7 @@ class CeilometerBaseTest(fuel_health.nmanager.PlatformServicesBaseClass):
self.skipTest('There are no compute nodes') self.skipTest('There are no compute nodes')
def create_alarm(self, **kwargs): def create_alarm(self, **kwargs):
""" """This method provides creation of alarm."""
This method provides creation of alarm
"""
if 'name' in kwargs: if 'name' in kwargs:
kwargs['name'] = rand_name(kwargs['name']) kwargs['name'] = rand_name(kwargs['name'])
alarm = self.ceilometer_client.alarms.create(**kwargs) alarm = self.ceilometer_client.alarms.create(**kwargs)
@@ -100,15 +98,11 @@ class CeilometerBaseTest(fuel_health.nmanager.PlatformServicesBaseClass):
return alarm return alarm
def get_state(self, alarm_id): def get_state(self, alarm_id):
""" """This method provides getting state."""
This method provides getting state
"""
return self.ceilometer_client.alarms.get_state(alarm_id=alarm_id) return self.ceilometer_client.alarms.get_state(alarm_id=alarm_id)
def verify_state(self, alarm_id, state): def verify_state(self, alarm_id, state):
""" """This method provides getting state."""
This method provides getting state
"""
alarm_state_resp = self.get_state(alarm_id) alarm_state_resp = self.get_state(alarm_id)
if not alarm_state_resp == state: if not alarm_state_resp == state:
self.fail('State was not setted') self.fail('State was not setted')
@@ -117,9 +111,7 @@ class CeilometerBaseTest(fuel_health.nmanager.PlatformServicesBaseClass):
self.status_timeout(self.compute_client.servers, server.id, status) self.status_timeout(self.compute_client.servers, server.id, status)
def wait_for_alarm_status(self, alarm_id, status=None): def wait_for_alarm_status(self, alarm_id, status=None):
""" """The method is a customization of test.status_timeout()."""
The method is a customization of test.status_timeout().
"""
def check_status(): def check_status():
alarm_state_resp = self.get_state(alarm_id) alarm_state_resp = self.get_state(alarm_id)
@@ -140,8 +132,7 @@ class CeilometerBaseTest(fuel_health.nmanager.PlatformServicesBaseClass):
act_status=actual_status)) act_status=actual_status))
def wait_for_sample_of_metric(self, metric, query=None, limit=100): def wait_for_sample_of_metric(self, metric, query=None, limit=100):
""" """This method is to wait for sample to add it to database.
This method is to wait for sample to add it to database.
query example: query example:
query=[ query=[
{'field':'resource', {'field':'resource',
@@ -166,9 +157,7 @@ class CeilometerBaseTest(fuel_health.nmanager.PlatformServicesBaseClass):
def wait_for_statistic_of_metric(self, meter_name, query=None, def wait_for_statistic_of_metric(self, meter_name, query=None,
period=None): period=None):
""" """The method is a customization of test.status_timeout()."""
The method is a customization of test.status_timeout().
"""
def check_status(): def check_status():
stat_state_resp = self.ceilometer_client.statistics.list( stat_state_resp = self.ceilometer_client.statistics.list(

View File

@@ -32,8 +32,7 @@ LOG = logging.getLogger(__name__)
class CleanUpClientManager(fuel_health.nmanager.OfficialClientManager): class CleanUpClientManager(fuel_health.nmanager.OfficialClientManager):
""" """Manager that provides access to the official python clients for
Manager that provides access to the official python clients for
calling various OpenStack APIs. calling various OpenStack APIs.
""" """
@@ -57,8 +56,7 @@ class CleanUpClientManager(fuel_health.nmanager.OfficialClientManager):
def cleanup(cluster_deployment_info): def cleanup(cluster_deployment_info):
''' """Function performs cleaning up for current cluster.
Function performs cleaning up for current cluster.
Because clusters can be deployed in different way Because clusters can be deployed in different way
function uses cluster_deployment_info argument which function uses cluster_deployment_info argument which
@@ -71,7 +69,7 @@ def cleanup(cluster_deployment_info):
More better way is to create separate functions for each More better way is to create separate functions for each
set of tests so refactoring of this chunk of code is higly set of tests so refactoring of this chunk of code is higly
appreciated. appreciated.
''' """
manager = CleanUpClientManager() manager = CleanUpClientManager()
if 'sahara' in cluster_deployment_info: if 'sahara' in cluster_deployment_info:
@@ -120,7 +118,7 @@ def cleanup(cluster_deployment_info):
try: try:
LOG.info('Start flavor deletion.') LOG.info('Start flavor deletion.')
compute_client.flavors.delete(flavor.id) compute_client.flavors.delete(flavor.id)
except: except Exception:
LOG.warning('Failed to delete flavor') LOG.warning('Failed to delete flavor')
LOG.debug(traceback.format_exc()) LOG.debug(traceback.format_exc())

View File

@@ -55,7 +55,7 @@ def _load_log_config():
log_config = os.path.join(conf_dir, conf_file) log_config = os.path.join(conf_dir, conf_file)
try: try:
logging.config.fileConfig(log_config) logging.config.fileConfig(log_config)
except ConfigParser.Error, exc: except ConfigParser.Error as exc:
raise cfg.ConfigFileParseError(log_config, str(exc)) raise cfg.ConfigFileParseError(log_config, str(exc))
return True return True

View File

@@ -88,8 +88,7 @@ class Client(object):
return ssh return ssh
def exec_longrun_command(self, cmd): def exec_longrun_command(self, cmd):
""" """Execute the specified command on the server.
Execute the specified command on the server.
Unlike exec_command and exec_command_on_vm, this method allows Unlike exec_command and exec_command_on_vm, this method allows
to start a process on VM in background and leave it alive to start a process on VM in background and leave it alive
@@ -123,8 +122,7 @@ class Client(object):
return return
def exec_command(self, cmd): def exec_command(self, cmd):
""" """Execute the specified command on the server.
Execute the specified command on the server.
Note that this method is reading whole command outputs to memory, thus Note that this method is reading whole command outputs to memory, thus
shouldn't be used for large outputs. shouldn't be used for large outputs.
@@ -187,7 +185,8 @@ class Client(object):
:returns: data read from standard output of the command. :returns: data read from standard output of the command.
:raises: SSHExecCommandFailed if command returns nonzero :raises: SSHExecCommandFailed if command returns nonzero
status. The exception contains command status stderr content.""" status. The exception contains command status stderr content.
"""
ssh = self._get_ssh_connection() ssh = self._get_ssh_connection()
_intermediate_transport = ssh.get_transport() _intermediate_transport = ssh.get_transport()
_intermediate_channel = \ _intermediate_channel = \

View File

@@ -23,16 +23,13 @@ LOG = logging.getLogger(__name__)
class FuelTestAssertMixin(object): class FuelTestAssertMixin(object):
""" """Mixin class with a set of assert methods created to abstract
Mixin class with a set of assert methods created to abstract
from unittest assertion methods and provide human from unittest assertion methods and provide human
readable descriptions where possible readable descriptions where possible
""" """
def verify_response_status(self, status, def verify_response_status(self, status,
appl='Application', msg='', failed_step=''): appl='Application', msg='', failed_step=''):
""" """Method provides human readable message
Method provides human readable message
for the HTTP response status verification for the HTTP response status verification
:param appl: the name of application requested :param appl: the name of application requested
@@ -82,8 +79,7 @@ class FuelTestAssertMixin(object):
status=status), status_msg, '\n', msg))) status=status), status_msg, '\n', msg)))
def verify_response_body(self, body, content='', msg='', failed_step=''): def verify_response_body(self, body, content='', msg='', failed_step=''):
""" """Method provides human readable message for the verification if
Method provides human readable message for the verification if
HTTP response body contains desired keyword HTTP response body contains desired keyword
:param body: response body :param body: response body
@@ -98,8 +94,7 @@ class FuelTestAssertMixin(object):
def verify_response_body_value(self, body_structure, value='', msg='', def verify_response_body_value(self, body_structure, value='', msg='',
failed_step=''): failed_step=''):
""" """Method provides human readable message for verification if
Method provides human readable message for verification if
HTTP response body element contains desired keyword. HTTP response body element contains desired keyword.
:param body_structure: body element value (e.g. body['name'], body); :param body_structure: body element value (e.g. body['name'], body);
@@ -134,8 +129,7 @@ class FuelTestAssertMixin(object):
actual_content=act_content), '\n', msg)) actual_content=act_content), '\n', msg))
def verify_elements_list(self, elements, attrs, msg='', failed_step=''): def verify_elements_list(self, elements, attrs, msg='', failed_step=''):
""" """Method provides human readable message for the verification of
Method provides human readable message for the verification of
list of elements with specific parameters list of elements with specific parameters
:param elements: the list of elements from response :param elements: the list of elements from response
:param attrs: required attributes for each element :param attrs: required attributes for each element
@@ -173,8 +167,7 @@ class FuelTestAssertMixin(object):
self.fail(message.format(failed_step_msg, msg)) self.fail(message.format(failed_step_msg, msg))
def verify(self, secs, func, step='', msg='', action='', *args, **kwargs): def verify(self, secs, func, step='', msg='', action='', *args, **kwargs):
""" """Arguments:
Arguments:
:secs: timeout time; :secs: timeout time;
:func: function to be verified; :func: function to be verified;
:step: number of test step; :step: number of test step;
@@ -204,8 +197,7 @@ def _raise_TimeOut(sig, stack):
class timeout(object): class timeout(object):
""" """Timeout context that will stop code running within context
Timeout context that will stop code running within context
if timeout is reached if timeout is reached
>>with timeout(2): >>with timeout(2):

View File

@@ -63,9 +63,8 @@ def build_url(host, port, api_version=None, path=None,
def arbitrary_string(size=4, base_text=None): def arbitrary_string(size=4, base_text=None):
""" """Return size characters from base_text, repeating
Return size characters from base_text, repeating the base_text infinitely the base_text infinitely if needed.
if needed.
""" """
if not base_text: if not base_text:
base_text = 'ost1_test-' base_text = 'ost1_test-'

View File

@@ -15,6 +15,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from __future__ import print_function
import os import os
import sys import sys
@@ -390,7 +391,7 @@ def register_heat_opts(conf):
def process_singleton(cls): def process_singleton(cls):
"""Wrapper for classes... To be instantiated only one time per process""" """Wrapper for classes... To be instantiated only one time per process."""
instances = {} instances = {}
def wrapper(*args, **kwargs): def wrapper(*args, **kwargs):
@@ -438,8 +439,8 @@ class FileConfig(object):
LOG.info("Using fuel config file %s" % path) LOG.info("Using fuel config file %s" % path)
if not os.path.exists(path): if not os.path.exists(path):
msg = "Config file %(path)s not found" % locals() msg = "Config file {0} not found".format(path)
print >> sys.stderr, RuntimeError(msg) print(RuntimeError(msg), file=sys.stderr)
else: else:
config_files.append(path) config_files.append(path)
@@ -670,9 +671,6 @@ class NailgunConfig(object):
self.volume.ceph_exist = storage self.volume.ceph_exist = storage
def _parse_ostf_api(self): def _parse_ostf_api(self):
"""
will leave this
"""
api_url = '/api/ostf/%s' % self.cluster_id api_url = '/api/ostf/%s' % self.cluster_id
response = self.req_session.get(self.nailgun_url + api_url) response = self.req_session.get(self.nailgun_url + api_url)
data = response.json() data = response.json()

View File

@@ -19,8 +19,7 @@ import unittest2
class FuelException(Exception): class FuelException(Exception):
""" """Base Exception
Base Exception
To correctly use this class, inherit from it and define To correctly use this class, inherit from it and define
a 'message' property. That message will get printf'd a 'message' property. That message will get printf'd

View File

@@ -19,8 +19,8 @@
import logging import logging
import os import os
from fuel_health.common.utils.data_utils import rand_name
import fuel_health.common.ssh import fuel_health.common.ssh
from fuel_health.common.utils.data_utils import rand_name
import fuel_health.nmanager import fuel_health.nmanager
import fuel_health.test import fuel_health.test
@@ -29,9 +29,7 @@ LOG = logging.getLogger(__name__)
class HeatBaseTest(fuel_health.nmanager.NovaNetworkScenarioTest): class HeatBaseTest(fuel_health.nmanager.NovaNetworkScenarioTest):
""" """Base class for Heat openstack sanity and smoke tests."""
Base class for Heat openstack sanity and smoke tests.
"""
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
@@ -93,8 +91,7 @@ class HeatBaseTest(fuel_health.nmanager.NovaNetworkScenarioTest):
def _wait_for_stack_status(self, stack_id, expected_status, def _wait_for_stack_status(self, stack_id, expected_status,
timeout=None, interval=None): timeout=None, interval=None):
""" """The method is a customization of test.status_timeout().
The method is a customization of test.status_timeout().
It addresses `stack_status` instead of `status` field and It addresses `stack_status` instead of `status` field and
checks for FAILED instead of ERROR status. checks for FAILED instead of ERROR status.
The rest is the same. The rest is the same.
@@ -148,8 +145,7 @@ class HeatBaseTest(fuel_health.nmanager.NovaNetworkScenarioTest):
count_instances, timeout, interval, reduced_stack_name) count_instances, timeout, interval, reduced_stack_name)
def _wait_for_vm_ready_for_load(self, conn_string, timeout, interval): def _wait_for_vm_ready_for_load(self, conn_string, timeout, interval):
""" """Wait for fake file to be created on the instance
Wait for fake file to be created on the instance
to make sure that vm is ready. to make sure that vm is ready.
""" """
cmd = (conn_string + cmd = (conn_string +
@@ -219,9 +215,7 @@ class HeatBaseTest(fuel_health.nmanager.NovaNetworkScenarioTest):
@staticmethod @staticmethod
def _load_template(file_name): def _load_template(file_name):
""" """Load specified template file from etc directory."""
Load specified template file from etc directory.
"""
filepath = os.path.join( filepath = os.path.join(
os.path.dirname(os.path.realpath(__file__)), "etc", file_name) os.path.dirname(os.path.realpath(__file__)), "etc", file_name)
with open(filepath) as f: with open(filepath) as f:
@@ -229,8 +223,7 @@ class HeatBaseTest(fuel_health.nmanager.NovaNetworkScenarioTest):
@staticmethod @staticmethod
def _customize_template(template): def _customize_template(template):
""" """By default, heat templates expect neutron subnets to be available.
By default, heat templates expect neutron subnets to be available.
But if nova-network is used instead of neutron then But if nova-network is used instead of neutron then
subnet usage should be removed from the template. subnet usage should be removed from the template.
""" """

View File

@@ -24,9 +24,7 @@ LOG = logging.getLogger(__name__)
class Manager(object): class Manager(object):
"""Base manager class
"""
Base manager class
Manager objects are responsible for providing a configuration object Manager objects are responsible for providing a configuration object
and a client object for a test case to use in performing actions. and a client object for a test case to use in performing actions.

View File

@@ -15,11 +15,12 @@
import json import json
import logging import logging
import requests
import time import time
import traceback import traceback
import muranoclient.common.exceptions as exceptions import muranoclient.common.exceptions as exceptions
import requests
from fuel_health.common.utils.data_utils import rand_name from fuel_health.common.utils.data_utils import rand_name
import fuel_health.nmanager import fuel_health.nmanager
@@ -27,8 +28,7 @@ LOG = logging.getLogger(__name__)
class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass): class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
""" """Manager that provides access to the Murano python client for
Manager that provides access to the Murano python client for
calling Murano API. calling Murano API.
""" """
@@ -56,8 +56,7 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
self.skipTest("Murano service is not available") self.skipTest("Murano service is not available")
def tearDown(self): def tearDown(self):
""" """This method allows to clean up the OpenStack environment
This method allows to clean up the OpenStack environment
after the Murano OSTF tests. after the Murano OSTF tests.
""" """
@@ -66,14 +65,13 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
if self.env_name in env["name"]: if self.env_name in env["name"]:
try: try:
self.delete_environment(env["id"]) self.delete_environment(env["id"])
except: except Exception:
LOG.warning(traceback.format_exc()) LOG.warning(traceback.format_exc())
super(MuranoTest, self).tearDown() super(MuranoTest, self).tearDown()
def find_murano_image(self, image_type): def find_murano_image(self, image_type):
""" """This method allows to find Windows images with Murano tag.
This method allows to find Windows images with Murano tag.
Returns the image object or None Returns the image object or None
@@ -89,8 +87,7 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
return image return image
def list_environments(self): def list_environments(self):
""" """This method allows to get the list of environments.
This method allows to get the list of environments.
Returns the list of environments. Returns the list of environments.
""" """
@@ -100,8 +97,7 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
return resp.json() return resp.json()
def create_environment(self, name): def create_environment(self, name):
""" """This method allows to create environment.
This method allows to create environment.
Input parameters: Input parameters:
name - Name of new environment name - Name of new environment
@@ -116,8 +112,7 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
return resp.json() return resp.json()
def get_environment(self, environment_id): def get_environment(self, environment_id):
""" """This method allows to get specific environment by ID.
This method allows to get specific environment by ID.
Input parameters: Input parameters:
environment_id - ID of environment environment_id - ID of environment
@@ -131,8 +126,7 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
headers=self.headers).json() headers=self.headers).json()
def update_environment(self, environment_id, new_name): def update_environment(self, environment_id, new_name):
""" """This method allows to update specific environment by ID.
This method allows to update specific environment by ID.
Input parameters: Input parameters:
environment_id - ID of environment environment_id - ID of environment
@@ -144,8 +138,7 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
return self.murano_client.environments.update(environment_id, new_name) return self.murano_client.environments.update(environment_id, new_name)
def delete_environment(self, environment_id): def delete_environment(self, environment_id):
""" """This method allows to delete specific environment by ID.
This method allows to delete specific environment by ID.
Input parameters: Input parameters:
environment_id - ID of environment environment_id - ID of environment
@@ -158,8 +151,7 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
return resp return resp
def create_session(self, environment_id): def create_session(self, environment_id):
""" """This method allows to create session for environment.
This method allows to create session for environment.
Input parameters: Input parameters:
environment_id - ID of environment environment_id - ID of environment
@@ -174,8 +166,7 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
headers=self.headers).json() headers=self.headers).json()
def get_session(self, environment_id, session_id): def get_session(self, environment_id, session_id):
""" """This method allows to get specific session.
This method allows to get specific session.
Input parameters: Input parameters:
environment_id - ID of environment environment_id - ID of environment
@@ -187,8 +178,7 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
return self.murano_client.sessions.get(environment_id, session_id) return self.murano_client.sessions.get(environment_id, session_id)
def delete_session(self, environment_id, session_id): def delete_session(self, environment_id, session_id):
""" """This method allows to delete session for environment.
This method allows to delete session for environment.
Input parameters: Input parameters:
environment_id - ID of environment environment_id - ID of environment
@@ -200,8 +190,7 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
return self.murano_client.sessions.delete(environment_id, session_id) return self.murano_client.sessions.delete(environment_id, session_id)
def deploy_session(self, environment_id, session_id): def deploy_session(self, environment_id, session_id):
""" """This method allows to deploy session for environment.
This method allows to deploy session for environment.
Input parameters: Input parameters:
environment_id - ID of environment environment_id - ID of environment
@@ -215,8 +204,7 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
return requests.post(endpoint, data=None, headers=self.headers) return requests.post(endpoint, data=None, headers=self.headers)
def create_service(self, environment_id, session_id, json_data): def create_service(self, environment_id, session_id, json_data):
""" """This method allows to create service.
This method allows to create service.
Input parameters: Input parameters:
environment_id - ID of environment environment_id - ID of environment
@@ -233,8 +221,7 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
headers=headers).json() headers=headers).json()
def list_services(self, environment_id, session_id=None): def list_services(self, environment_id, session_id=None):
""" """This method allows to get list of services.
This method allows to get list of services.
Input parameters: Input parameters:
environment_id - ID of environment environment_id - ID of environment
@@ -246,8 +233,7 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
return self.murano_client.services.get(environment_id, '/', session_id) return self.murano_client.services.get(environment_id, '/', session_id)
def get_service(self, environment_id, session_id, service_id): def get_service(self, environment_id, session_id, service_id):
""" """This method allows to get service by ID.
This method allows to get service by ID.
Input parameters: Input parameters:
environment_id - ID of environment environment_id - ID of environment
@@ -262,8 +248,7 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
session_id) session_id)
def delete_service(self, environment_id, session_id, service_id): def delete_service(self, environment_id, session_id, service_id):
""" """This method allows to delete specific service.
This method allows to delete specific service.
Input parameters: Input parameters:
environment_id - ID of environment environment_id - ID of environment
@@ -278,8 +263,7 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
session_id) session_id)
def deploy_check(self, environment_id): def deploy_check(self, environment_id):
""" """This method allows to wait for deployment of Murano evironments.
This method allows to wait for deployment of Murano evironments.
Input parameters: Input parameters:
environment_id - ID of environment environment_id - ID of environment
@@ -301,8 +285,7 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
return environment return environment
def deployments_status_check(self, environment_id): def deployments_status_check(self, environment_id):
""" """This method allows to check that deployment status is 'success'.
This method allows to check that deployment status is 'success'.
Input parameters: Input parameters:
environment_id - ID of environment environment_id - ID of environment
@@ -325,8 +308,7 @@ class MuranoTest(fuel_health.nmanager.PlatformServicesBaseClass):
return 'OK' return 'OK'
def ports_check(self, environment, ports): def ports_check(self, environment, ports):
""" """This method allows to check that needed ports are opened.
This method allows to check that needed ports are opened.
Input parameters: Input parameters:
environment - Murano environment environment - Murano environment

View File

@@ -25,25 +25,25 @@ LOG = logging.getLogger(__name__)
# Default client libs # Default client libs
try: try:
import heatclient.v1.client import heatclient.v1.client
except: except Exception:
LOG.warning('Heatclient could not be imported.') LOG.warning('Heatclient could not be imported.')
try: try:
import muranoclient.v1.client import muranoclient.v1.client
except: except Exception:
LOG.debug(traceback.format_exc()) LOG.debug(traceback.format_exc())
LOG.warning('Muranoclient could not be imported.') LOG.warning('Muranoclient could not be imported.')
try: try:
import saharaclient.client import saharaclient.client
except: except Exception:
LOG.debug(traceback.format_exc()) LOG.debug(traceback.format_exc())
LOG.warning('Sahara client could not be imported.') LOG.warning('Sahara client could not be imported.')
try: try:
import ceilometerclient.v2.client import ceilometerclient.v2.client
except: except Exception:
LOG.warning('Ceilometer client could not be imported.') LOG.warning('Ceilometer client could not be imported.')
try: try:
import neutronclient.neutron.client import neutronclient.neutron.client
except: except Exception:
LOG.warning('Neutron client could not be imported.') LOG.warning('Neutron client could not be imported.')
import cinderclient.client import cinderclient.client
@@ -51,16 +51,15 @@ import keystoneclient
import novaclient.client import novaclient.client
from fuel_health.common.ssh import Client as SSHClient from fuel_health.common.ssh import Client as SSHClient
from fuel_health.common.utils.data_utils import rand_name
from fuel_health.common.utils.data_utils import rand_int_id from fuel_health.common.utils.data_utils import rand_int_id
from fuel_health.common.utils.data_utils import rand_name
from fuel_health import exceptions from fuel_health import exceptions
import fuel_health.manager import fuel_health.manager
import fuel_health.test import fuel_health.test
class OfficialClientManager(fuel_health.manager.Manager): class OfficialClientManager(fuel_health.manager.Manager):
""" """Manager that provides access to the official python clients for
Manager that provides access to the official python clients for
calling various OpenStack APIs. calling various OpenStack APIs.
""" """
@@ -120,9 +119,13 @@ class OfficialClientManager(fuel_health.manager.Manager):
tenant_name = self.config.identity.admin_tenant_name tenant_name = self.config.identity.admin_tenant_name
if None in (username, password, tenant_name): if None in (username, password, tenant_name):
msg = ("Missing required credentials for compute client. " msg = ("Missing required credentials for identity client. "
"username: %(username)s, password: %(password)s, " "username: {username}, password: {password}, "
"tenant_name: %(tenant_name)s") % locals() "tenant_name: {tenant_name}").format(
username=username,
password=password,
tenant_name=tenant_name,
)
raise exceptions.InvalidConfiguration(msg) raise exceptions.InvalidConfiguration(msg)
auth_url = self.config.identity.uri auth_url = self.config.identity.uri
@@ -165,8 +168,12 @@ class OfficialClientManager(fuel_health.manager.Manager):
if None in (username, password, tenant_name): if None in (username, password, tenant_name):
msg = ("Missing required credentials for identity client. " msg = ("Missing required credentials for identity client. "
"username: %(username)s, password: %(password)s, " "username: {username}, password: {password}, "
"tenant_name: %(tenant_name)s") % locals() "tenant_name: {tenant_name}").format(
username=username,
password=password,
tenant_name=tenant_name,
)
raise exceptions.InvalidConfiguration(msg) raise exceptions.InvalidConfiguration(msg)
auth_url = self.config.identity.uri auth_url = self.config.identity.uri
@@ -215,8 +222,7 @@ class OfficialClientManager(fuel_health.manager.Manager):
password=password) password=password)
def _get_murano_client(self): def _get_murano_client(self):
""" """This method returns Murano API client
This method returns Murano API client
""" """
# Get xAuth token from Keystone # Get xAuth token from Keystone
self.token_id = self._get_identity_client( self.token_id = self._get_identity_client(
@@ -433,9 +439,7 @@ class OfficialClientTest(fuel_health.test.TestCase):
class NovaNetworkScenarioTest(OfficialClientTest): class NovaNetworkScenarioTest(OfficialClientTest):
""" """Base class for nova network scenario tests."""
Base class for nova network scenario tests
"""
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
@@ -461,9 +465,7 @@ class NovaNetworkScenarioTest(OfficialClientTest):
self.check_clients_state() self.check_clients_state()
def _run_ssh_cmd(self, cmd): def _run_ssh_cmd(self, cmd):
""" """Open SSH session with Controller and and execute command."""
Open SSH session with Controller and and execute command.
"""
if not self.host: if not self.host:
self.fail('Wrong test configuration: ' self.fail('Wrong test configuration: '
'"online_controllers" parameter is empty.') '"online_controllers" parameter is empty.')
@@ -652,7 +654,7 @@ class NovaNetworkScenarioTest(OfficialClientTest):
'parameters are empty controller_node_name or ' 'parameters are empty controller_node_name or '
'controller_node_ip ') 'controller_node_ip ')
# TODO Allow configuration of execution and sleep duration. # TODO(???) Allow configuration of execution and sleep duration.
return fuel_health.test.call_until_true(ping, 40, 1) return fuel_health.test.call_until_true(ping, 40, 1)
def _ping_ip_address_from_instance(self, ip_address, timeout, def _ping_ip_address_from_instance(self, ip_address, timeout,
@@ -683,7 +685,7 @@ class NovaNetworkScenarioTest(OfficialClientTest):
password='cubswin:)', password='cubswin:)',
vm=ip_address) vm=ip_address)
# TODO Allow configuration of execution and sleep duration. # TODO(???) Allow configuration of execution and sleep duration.
return fuel_health.test.call_until_true(ping, 40, 1) return fuel_health.test.call_until_true(ping, 40, 1)
def _check_vm_connectivity(self, ip_address, timeout, retries): def _check_vm_connectivity(self, ip_address, timeout, retries):
@@ -766,9 +768,7 @@ class PlatformServicesBaseClass(NovaNetworkScenarioTest):
class SanityChecksTest(OfficialClientTest): class SanityChecksTest(OfficialClientTest):
""" """Base class for openstack sanity tests."""
Base class for openstack sanity tests
"""
_enabled = True _enabled = True
@@ -849,9 +849,7 @@ class SanityChecksTest(OfficialClientTest):
class SmokeChecksTest(OfficialClientTest): class SmokeChecksTest(OfficialClientTest):
""" """Base class for openstack smoke tests."""
Base class for openstack smoke tests
"""
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):

View File

@@ -30,10 +30,7 @@ LOG = logging.getLogger(__name__)
class SaharaTest(nmanager.PlatformServicesBaseClass): class SaharaTest(nmanager.PlatformServicesBaseClass):
"""Base class for openstack sanity tests for Sahara."""
"""
Base class for openstack sanity tests for Sahara
"""
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
super(SaharaTest, cls).setUpClass() super(SaharaTest, cls).setUpClass()

View File

@@ -21,9 +21,9 @@ import time
import testresources import testresources
import unittest2 import unittest2
from fuel_health import config
from fuel_health.common import log as logging from fuel_health.common import log as logging
from fuel_health.common.test_mixins import FuelTestAssertMixin from fuel_health.common.test_mixins import FuelTestAssertMixin
from fuel_health import config
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@@ -44,8 +44,7 @@ class BaseTestCase(unittest2.TestCase,
def call_until_true(func, duration, sleep_for, arg=None): def call_until_true(func, duration, sleep_for, arg=None):
""" """Call the given function until it returns True (and return True) or
Call the given function until it returns True (and return True) or
until the specified duration (in seconds) elapses (and return until the specified duration (in seconds) elapses (and return
False). False).
@@ -105,8 +104,7 @@ class TestCase(BaseTestCase):
del self.resource_keys[key] del self.resource_keys[key]
def status_timeout(self, things, thing_id, expected_status): def status_timeout(self, things, thing_id, expected_status):
""" """Given a thing and an expected status, do a loop, sleeping
Given a thing and an expected status, do a loop, sleeping
for a configurable amount of time, checking for the for a configurable amount of time, checking for the
expected status to show. At any time, if the returned expected status to show. At any time, if the returned
status of the thing is ERROR, fail out. status of the thing is ERROR, fail out.

View File

@@ -14,12 +14,12 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
''' """
Main purpose of following attribute is Main purpose of following attribute is
to supply general information about test set. to supply general information about test set.
This information will be stored in ostf database This information will be stored in ostf database
in test_sets table. in test_sets table.
''' """
__profile__ = { __profile__ = {
"test_runs_ordering_priority": 3, "test_runs_ordering_priority": 3,
"id": "ha", "id": "ha",

View File

@@ -25,9 +25,7 @@ LOG = logging.getLogger(__name__)
class RabbitSmokeTest(BaseTestCase): class RabbitSmokeTest(BaseTestCase):
""" """TestClass contains RabbitMQ test checks."""
TestClass contains RabbitMQ test checks.
"""
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):

View File

@@ -14,12 +14,12 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
''' """
Main purpose of following attribute is Main purpose of following attribute is
to supply general information about test set. to supply general information about test set.
This information will be stored in ostf database This information will be stored in ostf database
in test_sets table. in test_sets table.
''' """
__profile__ = { __profile__ = {
"test_runs_ordering_priority": 4, "test_runs_ordering_priority": 4,
"id": "platform_tests", "id": "platform_tests",

View File

@@ -17,9 +17,7 @@ from fuel_health.common.utils.data_utils import rand_name
class CeilometerApiPlatformTests(ceilometermanager.CeilometerBaseTest): class CeilometerApiPlatformTests(ceilometermanager.CeilometerBaseTest):
""" """TestClass contains tests that check basic Ceilometer functionality."""
TestClass contains tests that check basic Ceilometer functionality.
"""
def test_check_alarm_state(self): def test_check_alarm_state(self):
"""Ceilometer test to check alarm status and get Nova notifications. """Ceilometer test to check alarm status and get Nova notifications.

View File

@@ -17,9 +17,7 @@ from fuel_health.common.utils.data_utils import rand_name
class CeilometerApiSmokeTests(ceilometermanager.CeilometerBaseTest): class CeilometerApiSmokeTests(ceilometermanager.CeilometerBaseTest):
""" """TestClass contains tests that check basic Ceilometer functionality."""
TestClass contains tests that check basic Ceilometer functionality.
"""
def test_create_alarm(self): def test_create_alarm(self):
"""Ceilometer create, update, check, delete alarm """Ceilometer create, update, check, delete alarm

View File

@@ -21,8 +21,8 @@ LOG = logging.getLogger(__name__)
class HeatSmokeTests(heatmanager.HeatBaseTest): class HeatSmokeTests(heatmanager.HeatBaseTest):
""" """Test class verifies Heat API calls, rollback and
Test class verifies Heat API calls, rollback and autoscaling use-cases. autoscaling use-cases.
""" """
def setUp(self): def setUp(self):
super(HeatSmokeTests, self).setUp() super(HeatSmokeTests, self).setUp()

View File

@@ -24,8 +24,8 @@ LOG = logging.getLogger(__name__)
class MuranoDeployLinuxServicesTests(muranomanager.MuranoTest): class MuranoDeployLinuxServicesTests(muranomanager.MuranoTest):
""" """TestClass contains verifications of full Murano functionality.
TestClass contains verifications of full Murano functionality.
Special requirements: Special requirements:
1. Murano component should be installed. 1. Murano component should be installed.
2. Internet access for virtual machines in OpenStack. 2. Internet access for virtual machines in OpenStack.
@@ -154,7 +154,7 @@ class MuranoDeployLinuxServicesTests(muranomanager.MuranoTest):
self.environment['id']) self.environment['id'])
def test_deploy_wordpress_app(self): def test_deploy_wordpress_app(self):
"""Check that user can deploy WordPress application in Murano environment """Check that user can deploy WordPress app in Murano environment
Target component: Murano Target component: Murano
Scenario: Scenario:

View File

@@ -22,9 +22,7 @@ LOG = logging.getLogger(__name__)
class PlatformSaharaTests(saharamanager.SaharaTest): class PlatformSaharaTests(saharamanager.SaharaTest):
""" """TestClass contains tests that check basic Sahara functionality."""
TestClass contains tests that check basic Sahara functionality.
"""
def setUp(self): def setUp(self):
super(PlatformSaharaTests, self).setUp() super(PlatformSaharaTests, self).setUp()

View File

@@ -14,12 +14,12 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
''' """
Main purpose of following attribute is Main purpose of following attribute is
to supply general information about test set. to supply general information about test set.
This information will be stored in ostf database This information will be stored in ostf database
in test_sets table. in test_sets table.
''' """
__profile__ = { __profile__ = {
"test_runs_ordering_priority": 1, "test_runs_ordering_priority": 1,
"id": "sanity", "id": "sanity",

View File

@@ -18,9 +18,7 @@ from fuel_health import ceilometermanager
class CeilometerApiTests(ceilometermanager.CeilometerBaseTest): class CeilometerApiTests(ceilometermanager.CeilometerBaseTest):
""" """TestClass contains tests that check basic Ceilometer functionality."""
TestClass contains tests that check basic Ceilometer functionality.
"""
def test_list_meters(self): def test_list_meters(self):
"""List ceilometer availability """List ceilometer availability

View File

@@ -22,9 +22,7 @@ LOG = logging.getLogger(__name__)
class SanityComputeTest(nmanager.SanityChecksTest): class SanityComputeTest(nmanager.SanityChecksTest):
""" """TestClass contains tests that check basic Compute functionality."""
TestClass contains tests that check basic Compute functionality.
"""
def test_list_instances(self): def test_list_instances(self):
"""Request instance list """Request instance list

View File

@@ -22,8 +22,7 @@ LOG = logging.getLogger(__name__)
class SanityHeatTest(nmanager.SanityChecksTest): class SanityHeatTest(nmanager.SanityChecksTest):
""" """Class contains tests that check basic Heat functionality.
Class contains tests that check basic Heat functionality.
Special requirements: Special requirements:
1. Heat component should be installed. 1. Heat component should be installed.
""" """

View File

@@ -22,8 +22,7 @@ LOG = logging.getLogger(__name__)
class SanityIdentityTest(nmanager.SanityChecksTest): class SanityIdentityTest(nmanager.SanityChecksTest):
""" """TestClass contains tests that check basic authentication functionality.
TestClass contains tests that check basic authentication functionality.
Special requirements: OS admin user permissions are needed Special requirements: OS admin user permissions are needed
""" """

View File

@@ -15,7 +15,7 @@
# under the License. # under the License.
import logging import logging
from time import sleep import time
import traceback import traceback
from fuel_health.common.ssh import Client as SSHClient from fuel_health.common.ssh import Client as SSHClient
@@ -73,10 +73,10 @@ class SanityInfrastructureTest(nmanager.SanityChecksTest):
self.verify_response_true( self.verify_response_true(
u'XXX' not in output, 'Step 2 failed: Some nova services ' u'XXX' not in output, 'Step 2 failed: Some nova services '
'have not been started.') 'have not been started.')
except: except Exception:
LOG.info("Will sleep for 60 seconds and try again") LOG.info("Will sleep for 60 seconds and try again")
LOG.debug(traceback.format_exc()) LOG.debug(traceback.format_exc())
sleep(60) time.sleep(60)
self.verify_response_true( self.verify_response_true(
u'XXX' not in output, 'Step 2 failed: Some nova services ' u'XXX' not in output, 'Step 2 failed: Some nova services '
'have not been started.') 'have not been started.')

View File

@@ -18,8 +18,7 @@ from fuel_health import muranomanager
class MuranoSanityTests(muranomanager.MuranoTest): class MuranoSanityTests(muranomanager.MuranoTest):
""" """TestClass contains verifications of basic Murano functionality.
TestClass contains verifications of basic Murano functionality.
Special requirements: Special requirements:
1. Murano API service should be installed. 1. Murano API service should be installed.
""" """

View File

@@ -22,9 +22,7 @@ LOG = logging.getLogger(__name__)
class NetworksTest(nmanager.SanityChecksTest): class NetworksTest(nmanager.SanityChecksTest):
""" """TestClass contains tests check base networking functionality."""
TestClass contains tests check base networking functionality
"""
def test_list_networks_nova_network(self): def test_list_networks_nova_network(self):
"""Request list of networks """Request list of networks

View File

@@ -22,9 +22,7 @@ LOG = logging.getLogger(__name__)
class SanitySaharaTests(saharamanager.SaharaTest): class SanitySaharaTests(saharamanager.SaharaTest):
""" """TestClass contains tests that check basic Sahara functionality."""
TestClass contains tests that check basic Sahara functionality.
"""
def test_sanity_sahara(self): def test_sanity_sahara(self):
"""Sahara tests to create/list/delete node group and cluster templates """Sahara tests to create/list/delete node group and cluster templates

View File

@@ -14,12 +14,12 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
''' """
Main purpose of following attribute is Main purpose of following attribute is
to supply general information about test set. to supply general information about test set.
This information will be stored in ostf database This information will be stored in ostf database
in test_sets table. in test_sets table.
''' """
__profile__ = { __profile__ = {
"test_runs_ordering_priority": 2, "test_runs_ordering_priority": 2,
"id": "smoke", "id": "smoke",

View File

@@ -22,8 +22,7 @@ LOG = logging.getLogger(__name__)
class TestNeutron(neutronmanager.NeutronBaseTest): class TestNeutron(neutronmanager.NeutronBaseTest):
""" """Test suite verifies:
Test suite verifies:
- router creation - router creation
- network creation - network creation
- subnet creation - subnet creation

View File

@@ -25,8 +25,7 @@ LOG = logging.getLogger(__name__)
class TestNovaNetwork(nmanager.NovaNetworkScenarioTest): class TestNovaNetwork(nmanager.NovaNetworkScenarioTest):
""" """Test suit verifies:
Test suit verifies:
- keypairs creation - keypairs creation
- security groups creation - security groups creation
- Network creation - Network creation

View File

@@ -26,8 +26,7 @@ LOG = logging.getLogger(__name__)
class TestImageAction(nmanager.SmokeChecksTest): class TestImageAction(nmanager.SmokeChecksTest):
""" """Test class verifies the following:
Test class verifies the following:
- verify that image can be created; - verify that image can be created;
- verify that instance can be booted from created image; - verify that instance can be booted from created image;
- verify that snapshot can be created from an instance; - verify that snapshot can be created from an instance;

View File

@@ -25,8 +25,7 @@ LOG = logging.getLogger(__name__)
class TestUserTenantRole(nmanager.SmokeChecksTest): class TestUserTenantRole(nmanager.SmokeChecksTest):
""" """Test class verifies the following:
Test class verifies the following:
- verify that a tenant can be created; - verify that a tenant can be created;
- verify that a user can be created based on the new tenant; - verify that a user can be created based on the new tenant;
- verify that a user role can be created. - verify that a user role can be created.

View File

@@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import os
import logging import logging
import os
from oslo.config import cfg from oslo.config import cfg

View File

@@ -12,9 +12,9 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import os
import logging import logging
import logging.handlers import logging.handlers
import os
_LOG_TIME_FORMAT = "%Y-%m-%d %H:%M:%S" _LOG_TIME_FORMAT = "%Y-%m-%d %H:%M:%S"

View File

@@ -12,15 +12,14 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import requests
from sqlalchemy.orm import joinedload
import logging import logging
from oslo.config import cfg from oslo.config import cfg
import requests
from sqlalchemy.orm import joinedload
from fuel_plugin.ostf_adapter.storage import models
from fuel_plugin.ostf_adapter.nose_plugin import nose_utils from fuel_plugin.ostf_adapter.nose_plugin import nose_utils
from fuel_plugin.ostf_adapter.storage import models
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@@ -13,28 +13,28 @@
# under the License. # under the License.
import fcntl import fcntl
import os
import logging import logging
import os
import signal import signal
from oslo.config import cfg from oslo.config import cfg
from fuel_plugin.ostf_adapter.logger import ResultsLogger from fuel_plugin.ostf_adapter.logger import ResultsLogger
from fuel_plugin.ostf_adapter.nose_plugin import nose_storage_plugin
from fuel_plugin.ostf_adapter.nose_plugin import nose_test_runner from fuel_plugin.ostf_adapter.nose_plugin import nose_test_runner
from fuel_plugin.ostf_adapter.nose_plugin import nose_utils from fuel_plugin.ostf_adapter.nose_plugin import nose_utils
from fuel_plugin.ostf_adapter.storage import engine, models from fuel_plugin.ostf_adapter.storage import engine
from fuel_plugin.ostf_adapter.nose_plugin import nose_storage_plugin from fuel_plugin.ostf_adapter.storage import models
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
class InterruptTestRunException(KeyboardInterrupt): class InterruptTestRunException(KeyboardInterrupt):
''' Current class exception is used for cleanup action """Current class exception is used for cleanup action
as KeyboardInterrupt is the only exception that is reraised by as KeyboardInterrupt is the only exception that is reraised by
unittest (and nose correspondingly) into outside environment unittest (and nose correspondingly) into outside environment
''' """
pass
class NoseDriver(object): class NoseDriver(object):

View File

@@ -12,11 +12,11 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from time import time
import logging import logging
import os import os
from nose import plugins import time
from nose import plugins
from oslo.config import cfg from oslo.config import cfg
from fuel_plugin.ostf_adapter.nose_plugin import nose_utils from fuel_plugin.ostf_adapter.nose_plugin import nose_utils
@@ -122,7 +122,7 @@ class StoragePlugin(plugins.Plugin):
self._add_message(test, err=err, status='error') self._add_message(test, err=err, status='error')
def beforeTest(self, test): def beforeTest(self, test):
self._start_time = time() self._start_time = time.time()
self._add_message(test, status='running') self._add_message(test, status='running')
def describeTest(self, test): def describeTest(self, test):
@@ -131,5 +131,5 @@ class StoragePlugin(plugins.Plugin):
@property @property
def taken(self): def taken(self):
if self._start_time: if self._start_time:
return time() - self._start_time return time.time() - self._start_time
return 0 return 0

View File

@@ -13,13 +13,12 @@
# under the License. # under the License.
import itertools import itertools
import traceback
import re
import json import json
import os
import multiprocessing
import logging import logging
import multiprocessing
import os
import re
import traceback
from nose import case from nose import case
from nose.suite import ContextSuite from nose.suite import ContextSuite
@@ -36,8 +35,9 @@ def parse_json_file(file_path):
def get_exc_message(exception_value): def get_exc_message(exception_value):
""" """Gets message from exception
@exception_value - Exception type object
:param exception_value: Exception type object
""" """
_exc_long = str(exception_value) _exc_long = str(exception_value)
if isinstance(_exc_long, basestring): if isinstance(_exc_long, basestring):
@@ -58,15 +58,14 @@ def _process_docstring(docstring, pattern):
def get_description(test_obj): def get_description(test_obj):
''' """Parses docstring of test object in order
Parses docstring of test object in order
to get necessary data. to get necessary data.
test_obj.test._testMethodDoc is using directly test_obj.test._testMethodDoc is using directly
instead of calling test_obj.shortDescription() instead of calling test_obj.shortDescription()
for the sake of compability with python 2.6 where for the sake of compability with python 2.6 where
this method works pretty buggy. this method works pretty buggy.
''' """
if isinstance(test_obj, case.Test): if isinstance(test_obj, case.Test):
docstring = test_obj.test._testMethodDoc docstring = test_obj.test._testMethodDoc
@@ -145,15 +144,14 @@ def get_module(module_path):
def get_tests_to_update(test): def get_tests_to_update(test):
''' """Sometimes (e.g. unhandles exception is occured in
Sometimes (e.g. unhandles exception is occured in
setUpClass of test case) tests can be packed in setUpClass of test case) tests can be packed in
separate ContextSuite each. At the moment of following code separate ContextSuite each. At the moment of following code
creation depth of this packaging was unknown so creation depth of this packaging was unknown so
current function is implemented with recursion current function is implemented with recursion
(which is not good by any means and you are free to (which is not good by any means and you are free to
modify that if you can) modify that if you can)
''' """
tests = [] tests = []
if isinstance(test, case.Test): if isinstance(test, case.Test):
@@ -166,11 +164,10 @@ def get_tests_to_update(test):
def process_deployment_tags(cluster_depl_tags, test_depl_tags): def process_deployment_tags(cluster_depl_tags, test_depl_tags):
''' """Process alternative deployment tags for testsets and tests
Process alternative deployment tags for testsets and tests
and determines whether current test entity (testset or test) and determines whether current test entity (testset or test)
is appropriate for cluster. is appropriate for cluster.
''' """
test_depl_tags = [ test_depl_tags = [
[alt_tag.strip() for alt_tag in tag.split('|')] [alt_tag.strip() for alt_tag in tag.split('|')]

View File

@@ -13,21 +13,21 @@
# under the License. # under the License.
import os
import sys
import logging import logging
import os
import signal import signal
import sys
from oslo.config import cfg
from gevent import pywsgi from gevent import pywsgi
from oslo.config import cfg
from fuel_plugin.ostf_adapter import config as ostf_config from fuel_plugin.ostf_adapter import config as ostf_config
from fuel_plugin.ostf_adapter import nailgun_hooks
from fuel_plugin.ostf_adapter import logger from fuel_plugin.ostf_adapter import logger
from fuel_plugin.ostf_adapter.wsgi import app from fuel_plugin.ostf_adapter import mixins
from fuel_plugin.ostf_adapter import nailgun_hooks
from fuel_plugin.ostf_adapter.nose_plugin import nose_discovery from fuel_plugin.ostf_adapter.nose_plugin import nose_discovery
from fuel_plugin.ostf_adapter.storage import engine from fuel_plugin.ostf_adapter.storage import engine
from fuel_plugin.ostf_adapter import mixins from fuel_plugin.ostf_adapter.wsgi import app
CONF = cfg.CONF CONF = cfg.CONF

View File

@@ -12,13 +12,12 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import os
import logging import logging
import os
from oslo.config import cfg
from alembic import command from alembic import command
from alembic import config from alembic import config
from oslo.config import cfg
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View File

@@ -12,19 +12,19 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import contextlib
import logging import logging
from contextlib import contextmanager
from sqlalchemy import create_engine, orm from sqlalchemy import create_engine, orm
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@contextmanager @contextlib.contextmanager
def contexted_session(dbpath): def contexted_session(dbpath):
'''Allows to handle session via context manager """Allows to handle session via context manager
''' """
LOG.debug('Starting session with dbpath={0}'.format(dbpath)) LOG.debug('Starting session with dbpath={0}'.format(dbpath))
engine = create_engine(dbpath) engine = create_engine(dbpath)
session = orm.Session(bind=engine) session = orm.Session(bind=engine)

View File

@@ -13,7 +13,7 @@
# under the License. # under the License.
from __future__ import with_statement from __future__ import with_statement
from logging.config import fileConfig import logging
from sqlalchemy import engine_from_config, pool from sqlalchemy import engine_from_config, pool
@@ -26,7 +26,7 @@ config = context.config
# Interpret the config file for Python logging. # Interpret the config file for Python logging.
# This line sets up loggers basically. # This line sets up loggers basically.
fileConfig(config.config_file_name) logging.config.fileConfig(config.config_file_name)
# add your model's MetaData object here # add your model's MetaData object here
# for 'autogenerate' support # for 'autogenerate' support

View File

@@ -1,3 +1,19 @@
# -*- coding: utf-8 -*-
# Copyright 2015 Mirantis, Inc.
#
# 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.
"""pid_field_for_testrun """pid_field_for_testrun
Revision ID: 5133b1e66258 Revision ID: 5133b1e66258

View File

@@ -1,3 +1,19 @@
# -*- coding: utf-8 -*-
# Copyright 2015 Mirantis, Inc.
#
# 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.
"""initial """initial
Revision ID: 53af7c2d9ccc Revision ID: 53af7c2d9ccc

View File

@@ -1,3 +1,19 @@
# -*- coding: utf-8 -*-
# Copyright 2015 Mirantis, Inc.
#
# 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.
"""list_of_excl_testsets """list_of_excl_testsets
Revision ID: 54904076d82d Revision ID: 54904076d82d

View File

@@ -12,18 +12,19 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from datetime import datetime import datetime
import logging import logging
import sqlalchemy as sa import sqlalchemy as sa
from sqlalchemy import desc from sqlalchemy import desc
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.ext.associationproxy import association_proxy
from sqlalchemy.orm import joinedload, relationship, object_mapper
from sqlalchemy.dialects.postgresql import ARRAY from sqlalchemy.dialects.postgresql import ARRAY
from sqlalchemy.ext.associationproxy import association_proxy
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import joinedload, relationship, object_mapper
from fuel_plugin.ostf_adapter import nose_plugin from fuel_plugin.ostf_adapter import nose_plugin
from fuel_plugin.ostf_adapter.storage import fields, engine from fuel_plugin.ostf_adapter.storage import engine
from fuel_plugin.ostf_adapter.storage import fields
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@@ -33,8 +34,7 @@ BASE = declarative_base()
class ClusterState(BASE): class ClusterState(BASE):
''' """Represents clusters currently
Represents clusters currently
present in the system. Holds info present in the system. Holds info
about deployment type which is using in about deployment type which is using in
redeployment process. redeployment process.
@@ -42,7 +42,7 @@ class ClusterState(BASE):
Is linked with TestSetToCluster entity Is linked with TestSetToCluster entity
that implements many-to-many relationship with that implements many-to-many relationship with
TestSet. TestSet.
''' """
__tablename__ = 'cluster_state' __tablename__ = 'cluster_state'
@@ -51,9 +51,7 @@ class ClusterState(BASE):
class ClusterTestingPattern(BASE): class ClusterTestingPattern(BASE):
''' """Stores cluster's pattern for testsets and tests."""
Stores cluster's pattern for testsets and tests
'''
__tablename__ = 'cluster_testing_pattern' __tablename__ = 'cluster_testing_pattern'
@@ -191,10 +189,9 @@ class Test(BASE):
synchronize_session=False) synchronize_session=False)
def copy_test(self, test_run, predefined_tests): def copy_test(self, test_run, predefined_tests):
''' """Performs copying of tests for newly created
Performs copying of tests for newly created
test_run. test_run.
''' """
new_test = self.__class__() new_test = self.__class__()
mapper = object_mapper(self) mapper = object_mapper(self)
primary_keys = set([col.key for col in mapper.primary_key]) primary_keys = set([col.key for col in mapper.primary_key])
@@ -223,7 +220,7 @@ class TestRun(BASE):
status = sa.Column(sa.Enum(*STATES, name='test_run_states'), status = sa.Column(sa.Enum(*STATES, name='test_run_states'),
nullable=False) nullable=False)
meta = sa.Column(fields.JsonField()) meta = sa.Column(fields.JsonField())
started_at = sa.Column(sa.DateTime, default=datetime.utcnow) started_at = sa.Column(sa.DateTime, default=datetime.datetime.utcnow)
ended_at = sa.Column(sa.DateTime) ended_at = sa.Column(sa.DateTime)
pid = sa.Column(sa.Integer) pid = sa.Column(sa.Integer)
@@ -255,7 +252,7 @@ class TestRun(BASE):
def update(self, status): def update(self, status):
self.status = status self.status = status
if status == 'finished': if status == 'finished':
self.ended_at = datetime.utcnow() self.ended_at = datetime.datetime.utcnow()
@property @property
def enabled_tests(self): def enabled_tests(self):
@@ -284,12 +281,11 @@ class TestRun(BASE):
@classmethod @classmethod
def add_test_run(cls, session, test_set, cluster_id, status='running', def add_test_run(cls, session, test_set, cluster_id, status='running',
tests=None): tests=None):
''' """Creates new test_run object with given data
Creates new test_run object with given data
and makes copy of tests that will be bound and makes copy of tests that will be bound
with this test_run. Copying is performed by with this test_run. Copying is performed by
copy_test method of Test class. copy_test method of Test class.
''' """
predefined_tests = tests or [] predefined_tests = tests or []
tests_names = session.query(ClusterTestingPattern.tests)\ tests_names = session.query(ClusterTestingPattern.tests)\
.filter_by(test_set_id=test_set, cluster_id=cluster_id)\ .filter_by(test_set_id=test_set, cluster_id=cluster_id)\
@@ -338,7 +334,7 @@ class TestRun(BASE):
@classmethod @classmethod
def update_test_run(cls, session, test_run_id, updated_data): def update_test_run(cls, session, test_run_id, updated_data):
if updated_data.get('status') in ['finished']: if updated_data.get('status') in ['finished']:
updated_data['ended_at'] = datetime.utcnow() updated_data['ended_at'] = datetime.datetime.utcnow()
session.query(cls). \ session.query(cls). \
filter(cls.id == test_run_id). \ filter(cls.id == test_run_id). \
@@ -346,11 +342,10 @@ class TestRun(BASE):
@classmethod @classmethod
def is_last_running(cls, session, test_set, cluster_id): def is_last_running(cls, session, test_set, cluster_id):
''' """Checks whether there one can perform creation of new
Checks whether there one can perform creation of new
test_run by testing of existing of test_run object test_run by testing of existing of test_run object
with given data or test_run with 'finished' status. with given data or test_run with 'finished' status.
''' """
test_run = cls.get_last_test_run(session, test_set, cluster_id) test_run = cls.get_last_test_run(session, test_set, cluster_id)
return not bool(test_run) or test_run.is_finished() return not bool(test_run) or test_run.is_finished()

View File

@@ -15,19 +15,18 @@
from oslo.config import cfg from oslo.config import cfg
import pecan import pecan
from fuel_plugin.ostf_adapter.storage import engine
from fuel_plugin.ostf_adapter.wsgi import access_control from fuel_plugin.ostf_adapter.wsgi import access_control
from fuel_plugin.ostf_adapter.wsgi import hooks from fuel_plugin.ostf_adapter.wsgi import hooks
from fuel_plugin.ostf_adapter.storage import engine
CONF = cfg.CONF CONF = cfg.CONF
def setup_config(custom_pecan_config): def setup_config(custom_pecan_config):
''' """Updates defaults values for pecan server
Updates defaults values for pecan server
by those supplied via command line arguments by those supplied via command line arguments
when ostf-server is started when ostf-server is started
''' """
config_to_use = { config_to_use = {
'server': { 'server': {
'host': CONF.adapter.server_host, 'host': CONF.adapter.server_host,

View File

@@ -15,11 +15,13 @@
import json import json
import logging import logging
from oslo.config import cfg
from pecan import abort
from pecan import expose
from pecan import request
from pecan import rest
from sqlalchemy import func from sqlalchemy import func
from sqlalchemy.orm import joinedload from sqlalchemy.orm import joinedload
from pecan import rest, expose, request, abort
from oslo.config import cfg
from fuel_plugin.ostf_adapter import mixins from fuel_plugin.ostf_adapter import mixins
from fuel_plugin.ostf_adapter.storage import models from fuel_plugin.ostf_adapter.storage import models

View File

@@ -12,15 +12,12 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from pecan import expose
from fuel_plugin.ostf_adapter.wsgi import controllers from fuel_plugin.ostf_adapter.wsgi import controllers
from pecan import expose
class V1Controller(object): class V1Controller(object):
""" # TODO(???) Rewrite it with wsme expose
TODO Rewrite it with wsme expose
"""
tests = controllers.TestsController() tests = controllers.TestsController()
testsets = controllers.TestsetsController() testsets = controllers.TestsetsController()
testruns = controllers.TestrunsController() testruns = controllers.TestrunsController()

View File

@@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import json
import requests import requests
from json import dumps
import time import time
@@ -38,7 +38,7 @@ class TestingAdapterClient(object):
else: else:
data_el['ostf_os_access_creds'] = ostf_os_access_creds data_el['ostf_os_access_creds'] = ostf_os_access_creds
data = dumps({'objects': data}) data = json.dumps({'objects': data})
r = requests.request( r = requests.request(
method, method,
@@ -146,9 +146,9 @@ class TestingAdapterClient(object):
def _with_timeout(self, action, testset, cluster_id, def _with_timeout(self, action, testset, cluster_id,
timeout, polling=5, polling_hook=None): timeout, polling=5, polling_hook=None):
start_time = time.time() start_time = time.time()
json = action().json() decoded_json = action().json()
if json == [{}]: if decoded_json == [{}]:
self.stop_testrun_last(testset, cluster_id) self.stop_testrun_last(testset, cluster_id)
time.sleep(1) time.sleep(1)
action() action()

View File

@@ -12,14 +12,14 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from unittest import TestCase
from oslo.config import cfg from oslo.config import cfg
import unittest
opts = [ opts = [
cfg.StrOpt('quantum', default='fake') cfg.StrOpt('quantum', default='fake')
] ]
class Config(TestCase): class Config(unittest.TestCase):
def test_config(self): def test_config(self):
cfg.CONF cfg.CONF

View File

@@ -22,8 +22,8 @@ __profile__ = {
"exclusive_testsets": [] "exclusive_testsets": []
} }
import time
import httplib import httplib
import time
import unittest2 import unittest2

View File

@@ -28,17 +28,16 @@ import unittest
class FakeTests(unittest.TestCase): class FakeTests(unittest.TestCase):
def test_successfully_passed(self): def test_successfully_passed(self):
'''imitation of work """imitation of work
''' """
self.assertTrue(True) self.assertTrue(True)
class WithErrorTest(unittest.TestCase): class WithErrorTest(unittest.TestCase):
''' """This is supoused to introduce errorness behaviour
This is supoused to introduce errorness behaviour
in means that it have exception raised in setUp method for in means that it have exception raised in setUp method for
testing purposes. testing purposes.
''' """
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
raise Exception('Unhandled exception in setUpClass') raise Exception('Unhandled exception in setUpClass')
@@ -47,8 +46,8 @@ class WithErrorTest(unittest.TestCase):
raise Exception('Error in setUp method') raise Exception('Error in setUp method')
def test_supposed_to_be_success(self): def test_supposed_to_be_success(self):
'''test in errorness class """test in errorness class
''' """
self.assertTrue(True) self.assertTrue(True)
def test_supposed_to_be_fail(self): def test_supposed_to_be_fail(self):

View File

@@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from functools import wraps import functools
from unittest import TestCase import unittest
from fuel_plugin.ostf_client.client import TestingAdapterClient from fuel_plugin.ostf_client.client import TestingAdapterClient
@@ -23,7 +23,7 @@ class EmptyResponseError(Exception):
class Response(object): class Response(object):
"""This is testing_adapter response object""" """This is testing_adapter response object."""
test_name_mapping = {} test_name_mapping = {}
def __init__(self, response): def __init__(self, response):
@@ -74,7 +74,7 @@ class AdapterClientProxy(object):
return self._decorate_call(call) return self._decorate_call(call)
def _decorate_call(self, call): def _decorate_call(self, call):
@wraps(call) @functools.wraps(call)
def inner(*args, **kwargs): def inner(*args, **kwargs):
r = call(*args, **kwargs) r = call(*args, **kwargs)
return Response(r) return Response(r)
@@ -85,7 +85,7 @@ class SubsetException(Exception):
pass pass
class BaseAdapterTest(TestCase): class BaseAdapterTest(unittest.TestCase):
def compare(self, response, comparable): def compare(self, response, comparable):
if response.is_empty: if response.is_empty:
msg = '{0} is empty'.format(response.request) msg = '{0} is empty'.format(response.request)

View File

@@ -13,15 +13,14 @@
# under the License. # under the License.
import os import os
import time
from sqlalchemy import create_engine from sqlalchemy import create_engine
import time
from fuel_plugin.testing.tests.functional.base import \
BaseAdapterTest, Response
from fuel_plugin.ostf_client import client from fuel_plugin.ostf_client import client
from fuel_plugin.testing.tests.functional import base
class AdapterTests(BaseAdapterTest): class AdapterTests(base.BaseAdapterTest):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
@@ -136,7 +135,7 @@ class AdapterTests(BaseAdapterTest):
resp = self.client.testruns_last(cluster_id) resp = self.client.testruns_last(cluster_id)
assertions = Response( assertions = base.Response(
[ [
{ {
'testset': 'general_test', 'testset': 'general_test',
@@ -180,7 +179,7 @@ class AdapterTests(BaseAdapterTest):
resp = self.client.testruns_last(cluster_id) resp = self.client.testruns_last(cluster_id)
assertions = Response([ assertions = base.Response([
{ {
'testset': 'stopped_test', 'testset': 'stopped_test',
'status': 'running', 'status': 'running',
@@ -240,12 +239,12 @@ class AdapterTests(BaseAdapterTest):
msg = '{0} was empty'.format(resp.request) msg = '{0} was empty'.format(resp.request)
self.assertFalse(resp.is_empty, msg) self.assertFalse(resp.is_empty, msg)
'''TODO: Rewrite assertions to verity that all """TODO: Rewrite assertions to verity that all
5 testruns ended with appropriate status 5 testruns ended with appropriate status
''' """
def test_run_single_test(self): def test_run_single_test(self):
"""Verify that you can run individual tests from given testset""" """Verify that you can run individual tests from given testset."""
testset = "general_test" testset = "general_test"
tests = [ tests = [
('fuel_plugin.testing.fixture.dummy_tests.' ('fuel_plugin.testing.fixture.dummy_tests.'
@@ -260,7 +259,7 @@ class AdapterTests(BaseAdapterTest):
resp = self.client.start_testrun_tests(testset, tests, cluster_id) resp = self.client.start_testrun_tests(testset, tests, cluster_id)
assertions = Response([ assertions = base.Response([
{ {
'testset': 'general_test', 'testset': 'general_test',
'status': 'running', 'status': 'running',
@@ -328,7 +327,7 @@ class AdapterTests(BaseAdapterTest):
self.compare(resp, assertions) self.compare(resp, assertions)
def test_single_test_restart(self): def test_single_test_restart(self):
"""Verify that you restart individual tests for given testrun""" """Verify that you restart individual tests for given testrun."""
testset = "general_test" testset = "general_test"
tests = [ tests = [
('fuel_plugin.testing.fixture.dummy_tests.' ('fuel_plugin.testing.fixture.dummy_tests.'
@@ -345,7 +344,7 @@ class AdapterTests(BaseAdapterTest):
resp = self.client.restart_tests_last(testset, tests, cluster_id) resp = self.client.restart_tests_last(testset, tests, cluster_id)
assertions = Response([ assertions = base.Response([
{ {
'testset': 'general_test', 'testset': 'general_test',
'status': 'running', 'status': 'running',
@@ -413,7 +412,8 @@ class AdapterTests(BaseAdapterTest):
def test_restart_combinations(self): def test_restart_combinations(self):
"""Verify that you can restart both tests that """Verify that you can restart both tests that
ran and did not run during single test start""" ran and did not run during single test start
"""
testset = "general_test" testset = "general_test"
tests = [ tests = [
('fuel_plugin.testing.fixture.dummy_tests.' ('fuel_plugin.testing.fixture.dummy_tests.'
@@ -436,7 +436,7 @@ class AdapterTests(BaseAdapterTest):
resp = self.client.restart_tests_last(testset, disabled_test, resp = self.client.restart_tests_last(testset, disabled_test,
cluster_id) cluster_id)
assertions = Response([ assertions = base.Response([
{ {
'testset': 'general_test', 'testset': 'general_test',
'status': 'running', 'status': 'running',
@@ -533,7 +533,7 @@ class AdapterTests(BaseAdapterTest):
resp = self.client.testruns_last(cluster_id) resp = self.client.testruns_last(cluster_id)
assertions = Response([ assertions = base.Response([
{ {
'testset': 'test_with_error', 'testset': 'test_with_error',
'status': 'finished', 'status': 'finished',
@@ -574,7 +574,7 @@ class AdapterTests(BaseAdapterTest):
resp = self.client.testruns() resp = self.client.testruns()
assertions = Response([ assertions = base.Response([
{ {
'testset': 'gemini_first', 'testset': 'gemini_first',
'status': 'running', 'status': 'running',
@@ -628,7 +628,7 @@ class AdapterTests(BaseAdapterTest):
self.compare(resp, assertions) self.compare(resp, assertions)
def test_env_variables_are_set(self): def test_env_variables_are_set(self):
assertions = Response([ assertions = base.Response([
{ {
'testset': 'environment_variables', 'testset': 'environment_variables',
'status': 'finished', 'status': 'finished',

View File

@@ -2,7 +2,6 @@
WebTest>=2.0.17 WebTest>=2.0.17
mock==1.0.1 mock==1.0.1
requests-mock>=0.5.1 requests-mock>=0.5.1
flake8
tox>=1.7.1 tox>=1.7.1
coverage==3.6 coverage==3.6
fabric fabric

View File

@@ -20,6 +20,7 @@ deps = -r{toxinidir}/requirements.txt
commands = {posargs:} commands = {posargs:}
[testenv:pep8] [testenv:pep8]
deps = hacking==0.7
usedevelop = False usedevelop = False
commands = commands =
flake8 {posargs} flake8 {posargs}