diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-06-02 17:42:51 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-06-02 17:42:51 -0400 |
| commit | eb28ebb0f8a48ba57f68f21d64479b56bf689d24 (patch) | |
| tree | 16455b33cf6c02f789d7c0bff45ce3bf1aec06cb /lib/sqlalchemy | |
| parent | dc9e35f08d3954fca82d042bf70f8275d51e6f80 (diff) | |
| download | sqlalchemy-eb28ebb0f8a48ba57f68f21d64479b56bf689d24.tar.gz | |
- limit oracle DB reaps to identifiers generated from this
run to prevent race conditions against concurrent runs
Change-Id: I065d1cec346ea7af03792c3cc2f30766f73c2bd3
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/testing/plugin/plugin_base.py | 3 | ||||
| -rw-r--r-- | lib/sqlalchemy/testing/plugin/pytestplugin.py | 11 | ||||
| -rw-r--r-- | lib/sqlalchemy/testing/provision.py | 10 |
3 files changed, 20 insertions, 4 deletions
diff --git a/lib/sqlalchemy/testing/plugin/plugin_base.py b/lib/sqlalchemy/testing/plugin/plugin_base.py index fd33c56a0..fc9d71165 100644 --- a/lib/sqlalchemy/testing/plugin/plugin_base.py +++ b/lib/sqlalchemy/testing/plugin/plugin_base.py @@ -67,6 +67,9 @@ def setup_options(make_option): dest="low_connections", help="Use a low number of distinct connections - " "i.e. for Oracle TNS") + make_option("--write-idents", type="string", dest="write_idents", + help="write out generated follower idents to <file>, " + "when -n<num> is used") make_option("--reversetop", action="store_true", dest="reversetop", default=False, help="Use a random-ordering set implementation in the ORM " diff --git a/lib/sqlalchemy/testing/plugin/pytestplugin.py b/lib/sqlalchemy/testing/plugin/pytestplugin.py index 0bd79eea0..d7da73828 100644 --- a/lib/sqlalchemy/testing/plugin/pytestplugin.py +++ b/lib/sqlalchemy/testing/plugin/pytestplugin.py @@ -9,7 +9,7 @@ import pytest import argparse import inspect import collections -import itertools +import os try: import xdist # noqa @@ -43,6 +43,14 @@ def pytest_configure(config): config.slaveinput["follower_ident"] ) + if config.option.write_idents: + with open(config.option.write_idents, "a") as file_: + file_.write(config.slaveinput["follower_ident"] + "\n") + else: + if config.option.write_idents and \ + os.path.exists(config.option.write_idents): + os.remove(config.option.write_idents) + plugin_base.pre_begin(config.option) plugin_base.set_coverage_flag(bool(getattr(config.option, @@ -58,6 +66,7 @@ def pytest_sessionstart(session): def pytest_sessionfinish(session): plugin_base.final_process_cleanup() + if has_xdist: import uuid diff --git a/lib/sqlalchemy/testing/provision.py b/lib/sqlalchemy/testing/provision.py index 65a3c10a6..23d504b84 100644 --- a/lib/sqlalchemy/testing/provision.py +++ b/lib/sqlalchemy/testing/provision.py @@ -40,7 +40,6 @@ class register(object): def create_follower_db(follower_ident): - for cfg in _configs_for_db_operation(): _create_db(cfg, cfg.db, follower_ident) @@ -271,9 +270,14 @@ def _oracle_drop_db(cfg, eng, ident): _ora_drop_ignore(conn, "%s_ts2" % ident) -def reap_oracle_dbs(eng): +def reap_oracle_dbs(eng, idents_file): log.info("Reaping Oracle dbs...") with eng.connect() as conn: + with open(idents_file) as file_: + idents = set(line.strip() for line in file_) + + log.info("identifiers in file: %s", ", ".join(idents)) + to_reap = conn.execute( "select u.username from all_users u where username " "like 'TEST_%' and not exists (select username " @@ -283,7 +287,7 @@ def reap_oracle_dbs(eng): for name in all_names: if name.endswith("_ts1") or name.endswith("_ts2"): continue - else: + elif name in idents: to_drop.add(name) if "%s_ts1" % name in all_names: to_drop.add("%s_ts1" % name) |
