Merge "Add test case for update volume backup"
diff --git a/doc/source/conf.py b/doc/source/conf.py
index b9e22b5..23f732e 100644
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -55,7 +55,7 @@
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.todo',
'sphinx.ext.viewcode',
- 'oslosphinx',
+ 'openstackdocstheme',
'oslo_config.sphinxconfiggen',
]
@@ -64,6 +64,14 @@
todo_include_todos = True
+# openstackdocstheme options
+repository_name = 'openstack/tempest'
+bug_project = 'tempest'
+bug_tag = ''
+
+# Must set this variable to include year, month, day, hours, and minutes.
+html_last_updated_fmt = '%Y-%m-%d %H:%M'
+
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
@@ -127,7 +135,7 @@
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
-html_theme_path = [openstackdocstheme.get_html_theme_path()]
+#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
@@ -152,13 +160,6 @@
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
-git_cmd = ["git", "log", "--pretty=format:'%ad, commit %h'", "--date=local",
- "-n1"]
-try:
- html_last_updated_fmt = subprocess.check_output(git_cmd).decode('utf-8')
-except Exception:
- warnings.warn('Cannot get last updated time from git repository. '
- 'Not setting "html_last_updated_fmt".')
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
diff --git a/releasenotes/notes/add-save-state-option-5ea67858cbaca969.yaml b/releasenotes/notes/add-save-state-option-5ea67858cbaca969.yaml
new file mode 100644
index 0000000..8fdf4f0
--- /dev/null
+++ b/releasenotes/notes/add-save-state-option-5ea67858cbaca969.yaml
@@ -0,0 +1,4 @@
+---
+features:
+ - |
+ Add --save-state option to allow saving state of cloud before tempest run.
diff --git a/releasenotes/notes/pause_teardown-45c9d60ffa889f7f.yaml b/releasenotes/notes/pause_teardown-45c9d60ffa889f7f.yaml
new file mode 100644
index 0000000..a540c7d
--- /dev/null
+++ b/releasenotes/notes/pause_teardown-45c9d60ffa889f7f.yaml
@@ -0,0 +1,9 @@
+---
+features:
+ - |
+ Pause teardown
+ When pause_teardown flag in tempest.conf is set to True a pdb breakpoint
+ is added to tearDown and tearDownClass methods in test.py.
+ This allows to pause cleaning resources process, so that used resources
+ can be examined. Closer examination of used resources may lead to faster
+ debugging.
diff --git a/releasenotes/source/conf.py b/releasenotes/source/conf.py
index d240467..3137541 100644
--- a/releasenotes/source/conf.py
+++ b/releasenotes/source/conf.py
@@ -37,10 +37,18 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
- 'oslosphinx',
+ 'openstackdocstheme',
'reno.sphinxext',
]
+# openstackdocstheme options
+repository_name = 'openstack/tempest'
+bug_project = 'tempest'
+bug_tag = ''
+
+# Must set this variable to include year, month, day, hours, and minutes.
+html_last_updated_fmt = '%Y-%m-%d %H:%M'
+
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
@@ -119,9 +127,6 @@
# html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
-import openstackdocstheme
-
-html_theme_path = [openstackdocstheme.get_html_theme_path()]
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
diff --git a/tempest/api/compute/admin/test_auto_allocate_network.py b/tempest/api/compute/admin/test_auto_allocate_network.py
index ba8a214..83fe215 100644
--- a/tempest/api/compute/admin/test_auto_allocate_network.py
+++ b/tempest/api/compute/admin/test_auto_allocate_network.py
@@ -111,10 +111,12 @@
LOG.info('(%s) Found more than one router for tenant.',
test_utils.find_test_caller())
- # Let's just blindly remove any networks, duplicate or otherwise, that
- # the test might have created even though Neutron will cleanup
- # duplicate resources automatically (so ignore 404s).
- networks = cls.networks_client.list_networks().get('networks', [])
+ # Remove any networks, duplicate or otherwise, that these tests
+ # created. All such networks will be in the current tenant. Neutron
+ # will cleanup duplicate resources automatically, so ignore 404s.
+ search_opts = {'tenant_id': cls.networks_client.tenant_id}
+ networks = cls.networks_client.list_networks(
+ **search_opts).get('networks', [])
for router in routers:
# Disassociate the subnets from the router. Because of the race
diff --git a/tempest/cmd/run.py b/tempest/cmd/run.py
index b36bf5c..350dd0b 100644
--- a/tempest/cmd/run.py
+++ b/tempest/cmd/run.py
@@ -97,15 +97,19 @@
from cliff import command
from os_testr import regex_builder
from os_testr import subunit_trace
+from oslo_serialization import jsonutils as json
import six
from testrepository.commands import run_argv
+from tempest.cmd import cleanup_service
from tempest.cmd import init
from tempest.cmd import workspace
+from tempest.common import credentials_factory as credentials
from tempest import config
CONF = config.CONF
+SAVED_STATE_JSON = "saved_state.json"
class TempestRun(command.Command):
@@ -174,6 +178,11 @@
else:
print("No .testr.conf file was found for local execution")
sys.exit(2)
+ if parsed_args.state:
+ self._init_state()
+ else:
+ pass
+
if parsed_args.combine:
temp_stream = tempfile.NamedTemporaryFile()
return_code = run_argv(['tempest', 'last', '--subunit'], sys.stdin,
@@ -203,6 +212,25 @@
def get_description(self):
return 'Run tempest'
+ def _init_state(self):
+ print("Initializing saved state.")
+ data = {}
+ self.global_services = cleanup_service.get_global_cleanup_services()
+ self.admin_mgr = credentials.AdminManager()
+ admin_mgr = self.admin_mgr
+ kwargs = {'data': data,
+ 'is_dry_run': False,
+ 'saved_state_json': data,
+ 'is_preserve': False,
+ 'is_save_state': True}
+ for service in self.global_services:
+ svc = service(admin_mgr, **kwargs)
+ svc.run()
+
+ with open(SAVED_STATE_JSON, 'w+') as f:
+ f.write(json.dumps(data,
+ sort_keys=True, indent=2, separators=(',', ': ')))
+
def get_parser(self, prog_name):
parser = super(TempestRun, self).get_parser(prog_name)
parser = self._add_args(parser)
@@ -253,6 +281,10 @@
parallel.add_argument('--serial', '-t', dest='parallel',
action='store_false',
help='Run tests serially')
+ parser.add_argument('--save-state', dest='state',
+ action='store_true',
+ help="To save the state of the cloud before "
+ "running tempest.")
# output args
parser.add_argument("--subunit", action='store_true',
help='Enable subunit v2 output')
diff --git a/tempest/config.py b/tempest/config.py
index 7b96281..af9eefc 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -1070,6 +1070,15 @@
"prefix to ideintify resources which are "
"created by Tempest and no projects set "
"this option on OpenStack dev community."),
+ cfg.BoolOpt('pause_teardown',
+ default=False,
+ help="""Whether to pause a test in global teardown.
+
+The best use case is investigating used resources of one test.
+A test can be run as follows:
+ $ ostestr --pdb TEST_ID
+or
+ $ python -m testtools.run TEST_ID"""),
]
_opts = [
diff --git a/tempest/test.py b/tempest/test.py
index f07c071..a81b5d7 100644
--- a/tempest/test.py
+++ b/tempest/test.py
@@ -247,6 +247,9 @@
@classmethod
def tearDownClass(cls):
+ # insert pdb breakpoint when pause_teardown is enabled
+ if CONF.pause_teardown:
+ cls.insert_pdb_breakpoint()
at_exit_set.discard(cls)
# It should never be overridden by descendants
if hasattr(super(BaseTestCase, cls), 'tearDownClass'):
@@ -283,6 +286,22 @@
finally:
del trace # to avoid circular refs
+ def tearDown(self):
+ super(BaseTestCase, self).tearDown()
+ # insert pdb breakpoint when pause_teardown is enabled
+ if CONF.pause_teardown:
+ BaseTestCase.insert_pdb_breakpoint()
+
+ @classmethod
+ def insert_pdb_breakpoint(cls):
+ """Add pdb breakpoint.
+
+ This can help in debugging process, cleaning of resources is
+ paused, so they can be examined.
+ """
+ import pdb
+ pdb.set_trace()
+
@classmethod
def skip_checks(cls):
"""Class level skip checks.
diff --git a/tempest/tests/lib/services/base.py b/tempest/tests/lib/services/base.py
index 90c9f63..778c966 100644
--- a/tempest/tests/lib/services/base.py
+++ b/tempest/tests/lib/services/base.py
@@ -40,7 +40,7 @@
function.
:param body: Expected response body returned by the service client
function.
- :param to_utf: Whether to use UTF-8 encoding for request.
+ :param to_utf: Whether to use UTF-8 encoding for response.
:param status: Expected response status returned by the service client
function.
:param headers: Expected headers returned by the service client
diff --git a/test-requirements.txt b/test-requirements.txt
index f8793be..04fd878 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -4,10 +4,9 @@
hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
# needed for doc build
sphinx>=1.6.2 # BSD
-oslosphinx>=4.7.0 # Apache-2.0
+openstackdocstheme>=1.11.0 # Apache-2.0
reno!=2.3.1,>=1.8.0 # Apache-2.0
mock>=2.0 # BSD
coverage!=4.4,>=4.0 # Apache-2.0
oslotest>=1.10.0 # Apache-2.0
flake8-import-order==0.11 # LGPLv3
-openstackdocstheme>=1.11.0 # Apache-2.0