From 2e703e6b7366bb93503cb38b0bfbce31ca164445 Mon Sep 17 00:00:00 2001 From: Nadav Har'El Date: Thu, 23 May 2019 16:18:30 +0300 Subject: [PATCH] alternator-test: drop "test_2_tables" fixture Creating and deleting tables is the slowest part of our tests, so we should lower the number of tables our tests create. We had a "test_2_tables" fixture as a way to create two tables, but since our tests already create other tables for testing different key types, it's faster to reuse those tables - instead of creating two more unused tables. On my system, a "pytest --local", running all 38 tests locally, drops from 25 seconds to 20 seconds. As a bonus, we also have one fewer fixture ;-) Signed-off-by: Nadav Har'El --- alternator-test/conftest.py | 12 ------------ alternator-test/test_table.py | 4 ++-- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/alternator-test/conftest.py b/alternator-test/conftest.py index fbb3c57ea7..facaf0cdc7 100644 --- a/alternator-test/conftest.py +++ b/alternator-test/conftest.py @@ -98,19 +98,7 @@ def test_table_s(dynamodb): AttributeDefinitions=[ { 'AttributeName': 'p', 'AttributeType': 'S' } ]) yield table table.delete() - @pytest.fixture(scope="session") -def test_2_tables(dynamodb): - tables = [create_test_table(dynamodb, - KeySchema=[ { 'AttributeName': 'p', 'KeyType': 'HASH' }, - { 'AttributeName': 'c', 'KeyType': 'RANGE' } - ], - AttributeDefinitions=[ - { 'AttributeName': 'p', 'AttributeType': 'S' }, - { 'AttributeName': 'c', 'AttributeType': 'S' }, - ]) for _ in range(2)] - yield tables - [table.delete() for table in tables] def test_table_b(dynamodb): table = create_test_table(dynamodb, KeySchema=[ { 'AttributeName': 'p', 'KeyType': 'HASH' }, ], diff --git a/alternator-test/test_table.py b/alternator-test/test_table.py index 22da0ce31f..8ae7ccc268 100644 --- a/alternator-test/test_table.py +++ b/alternator-test/test_table.py @@ -228,8 +228,8 @@ def list_tables(dynamodb, limit): # Note that the DyanamoDB setup we run this against may have hundreds of # other tables, for all we know. We just need to check that the tables we # created are indeed listed. -def test_list_tables_paginated(dynamodb, test_table, test_2_tables): - my_tables_set = set([table.name for table in test_2_tables + [test_table]]) +def test_list_tables_paginated(dynamodb, test_table, test_table_s, test_table_b): + my_tables_set = {table.name for table in [test_table, test_table_s, test_table_b]} for limit in [1, 2, 3, 4, 50, 100]: print("testing limit={}".format(limit)) list_tables_set = set(list_tables(dynamodb, limit))