Removed deprecation warning from 'tempest --help'

Deprecation warning of stress test runner should not show up when
running 'tempest --help'.  Warning show be shown only when
we run the stress command.

Change-Id: I6135559b6103f56542b611074ec81d29091e40b5
Closes-Bug: #1552863
This commit is contained in:
Tin Lam 2016-03-07 18:51:44 -06:00
parent 22dd1c9d94
commit 336aca762b
2 changed files with 12 additions and 22 deletions

12
tempest/cmd/run_stress.py Normal file → Executable file
View File

@ -23,6 +23,7 @@ except ImportError:
# unittest in python 2.6 does not contain loader, so uses unittest2
from unittest2 import loader
import traceback
import warnings
from cliff import command
from oslo_log import log as logging
@ -74,7 +75,17 @@ def discover_stress_tests(path="./", filter_attr=None, call_inherited=False):
class TempestRunStress(command.Command):
@staticmethod
def display_deprecation_warning():
warnings.simplefilter('once', category=DeprecationWarning)
warnings.warn(
'Stress tests are deprecated and will be removed from Tempest '
'in the Newton release.',
DeprecationWarning)
warnings.resetwarnings()
def get_parser(self, prog_name):
self.display_deprecation_warning()
pa = super(TempestRunStress, self).get_parser(prog_name)
pa = add_arguments(pa)
return pa
@ -146,6 +157,7 @@ def action(ns):
def main():
TempestRunStress.display_deprecation_warning()
parser = argparse.ArgumentParser(description='Run stress tests')
pa = add_arguments(parser)
ns = pa.parse_args()

View File

@ -1,22 +0,0 @@
# Copyright 2016 NEC Corporation. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import warnings
warnings.simplefilter('once', category=DeprecationWarning)
warnings.warn(
'Stress tests are deprecated and will be removed from Tempest '
'in the Newton release.',
DeprecationWarning)
warnings.resetwarnings()