diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-06-20 17:18:59 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-06-20 17:41:14 -0400 |
commit | 0ad64da3971bd4ac42699cf891fd689e7291cd2f (patch) | |
tree | b1bf3b7b1e9ff70b77797cae9a79cc27654a330e | |
parent | 190e0139e834e4271268652e058c280787ae69eb (diff) | |
download | sqlalchemy-0ad64da3971bd4ac42699cf891fd689e7291cd2f.tar.gz |
Add option for "sparse" backend tests and apply to memusage
The memusage tests are extremely time and memory intensive,
and when CI runs against MySQL or Postgresql there are many
database/driver combinations for which the "backend" tests
repeatedly run; as these tests are more oriented towards
basic dialect interaction, add a new "sparse" backend option
that will run the tests only once per base dialect.
Change-Id: I312aa0332d7ec1ff4e2faa15f6b189d6f0f68393
-rw-r--r-- | lib/sqlalchemy/testing/plugin/plugin_base.py | 36 | ||||
-rw-r--r-- | test/aaa_profiling/test_memusage.py | 2 |
2 files changed, 31 insertions, 7 deletions
diff --git a/lib/sqlalchemy/testing/plugin/plugin_base.py b/lib/sqlalchemy/testing/plugin/plugin_base.py index ef44a5906..8f79b4163 100644 --- a/lib/sqlalchemy/testing/plugin/plugin_base.py +++ b/lib/sqlalchemy/testing/plugin/plugin_base.py @@ -93,7 +93,7 @@ def setup_options(make_option): "--backend-only", action="store_true", dest="backend_only", - help="Run only tests marked with __backend__", + help="Run only tests marked with __backend__ or __sparse_backend__", ) make_option( "--nomemory", @@ -483,8 +483,10 @@ def want_class(cls): return False elif cls.__name__.startswith("_"): return False - elif config.options.backend_only and not getattr( - cls, "__backend__", False + elif ( + config.options.backend_only + and not getattr(cls, "__backend__", False) + and not getattr(cls, "__sparse_backend__", False) ): return False else: @@ -519,8 +521,11 @@ def want_method(cls, fn): def generate_sub_tests(cls, module): - if getattr(cls, "__backend__", False): - for cfg in _possible_configs_for_cls(cls): + if getattr(cls, "__backend__", False) or getattr( + cls, "__sparse_backend__", False + ): + sparse = getattr(cls, "__sparse_backend__", False) + for cfg in _possible_configs_for_cls(cls, sparse=sparse): orig_name = cls.__name__ # we can have special chars in these names except for the @@ -589,7 +594,7 @@ def after_test(test): engines.testing_reaper._after_test_ctx() -def _possible_configs_for_cls(cls, reasons=None): +def _possible_configs_for_cls(cls, reasons=None, sparse=False): all_configs = set(config.Config.all_configs()) if cls.__unsupported_on__: @@ -632,6 +637,25 @@ def _possible_configs_for_cls(cls, reasons=None): if all_configs.difference(non_preferred): all_configs.difference_update(non_preferred) + if sparse: + # pick only one config from each base dialect + # sorted so we get the same backend each time selecting the highest + # server version info. + per_dialect = {} + for cfg in reversed( + sorted( + all_configs, + key=lambda cfg: ( + cfg.db.name, + cfg.db.dialect.server_version_info, + ), + ) + ): + db = cfg.db.name + if db not in per_dialect: + per_dialect[db] = cfg + return per_dialect.values() + return all_configs diff --git a/test/aaa_profiling/test_memusage.py b/test/aaa_profiling/test_memusage.py index bcd48e71c..d172c4a87 100644 --- a/test/aaa_profiling/test_memusage.py +++ b/test/aaa_profiling/test_memusage.py @@ -264,7 +264,7 @@ class MemUsageWBackendTest(EnsureZeroed): __tags__ = ("memory_intensive",) __requires__ = "cpython", "memory_process_intensive" - __backend__ = True + __sparse_backend__ = True # ensure a pure growing test trips the assertion @testing.fails_if(lambda: True) |