From f3440f2e4a3c7be1778062a350eb4bafdd767d4e Mon Sep 17 00:00:00 2001 From: Piotr Sarna Date: Wed, 15 May 2019 12:00:58 +0200 Subject: [PATCH] alternator-test: migrate filled_test_table to use batches Filled test table fixture now takes advantage of batch writes in order to run faster. Message-Id: --- alternator-test/conftest.py | 8 ++++---- alternator-test/test_item.py | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/alternator-test/conftest.py b/alternator-test/conftest.py index 5b822ce543..390d9dfe5b 100644 --- a/alternator-test/conftest.py +++ b/alternator-test/conftest.py @@ -135,9 +135,9 @@ def filled_test_table(dynamodb): 'another': "y" * 16 } for i in range(count)] - for item in items: - # TODO: eventually, when Alternator supports batch operations, - # use a batch write to make this fixture start faster. - table.put_item(Item=item) + with table.batch_writer() as batch: + for item in items: + batch.put_item(item) + yield table, items table.delete() diff --git a/alternator-test/test_item.py b/alternator-test/test_item.py index 275b105b04..4c71c92014 100644 --- a/alternator-test/test_item.py +++ b/alternator-test/test_item.py @@ -47,7 +47,6 @@ def test_basic_batch_write_item(dynamodb, test_table): for i in range(count): item = test_table.get_item(Key={'p': "batch{}".format(i), 'c': "batch_ck{}".format(i)}, ConsistentRead=True)['Item'] - print(item) assert item['p'] == "batch{}".format(i) assert item['c'] == "batch_ck{}".format(i) assert item['attribute'] == str(i)