-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BigTable: Add truncate table and drop by prefix on top of GAPIC integration #5360
BigTable: Add truncate table and drop by prefix on top of GAPIC integration #5360
Conversation
@@ -386,6 +386,47 @@ def sample_row_keys(self): | |||
self.name) | |||
return response_iterator | |||
|
|||
def truncate(self, timeout=60): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
delete_all_data_from_table=True, | ||
timeout=timeout) | ||
|
||
def drop_by_prefix(self, row_key_prefix, timeout=60): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
…into feature/add_truncate_table_and_drop_by_prefix
@sduskis Fixed please review |
bigtable/tests/unit/test_table.py
Outdated
|
||
result = table.truncate() | ||
|
||
self.assertEqual(result, expected_result) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
bigtable/tests/unit/test_table.py
Outdated
|
||
self.assertEqual(result, expected_result) | ||
|
||
def test_drop_by_prefix_w_timestamp(self): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
bigtable/tests/unit/test_table.py
Outdated
|
||
data_api = bigtable_client.BigtableClient(mock.Mock()) | ||
table_api = bigtable_table_admin_client.BigtableTableAdminClient( | ||
mock.Mock()) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
bigtable/tests/unit/test_table.py
Outdated
|
||
data_api = bigtable_client.BigtableClient(mock.Mock()) | ||
table_api = bigtable_table_admin_client.BigtableTableAdminClient( | ||
mock.Mock()) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
bigtable/tests/unit/test_table.py
Outdated
|
||
data_api = bigtable_client.BigtableClient(mock.Mock()) | ||
table_api = bigtable_table_admin_client.BigtableTableAdminClient( | ||
mock.Mock()) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
…into feature/add_truncate_table_and_drop_by_prefix
bigtable/tests/system.py
Outdated
@@ -84,7 +84,7 @@ def setUpModule(): | |||
credentials = EmulatorCreds() | |||
Config.CLIENT = Client(admin=True, credentials=credentials) | |||
else: | |||
Config.CLIENT = Client(admin=True) | |||
Config.CLIENT = Client(project='grass-clump-479', admin=True) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm good to go when @tseaver is
bigtable/tests/system.py
Outdated
row_keys = [ | ||
'row_key_1', 'row_key_2', 'row_key_3', 'row_key_4', 'row_key_5', | ||
'row_key_pr_1', 'row_key_pr_2', 'row_key_pr_3', 'row_key_pr_4', | ||
'row_key_pr_5'] |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
bigtable/tests/system.py
Outdated
row_keys = [ | ||
'row_key_1', 'row_key_2', 'row_key_3', 'row_key_4', 'row_key_5', | ||
'row_key_pr_1', 'row_key_pr_2', 'row_key_pr_3', 'row_key_pr_4', | ||
'row_key_pr_5'] |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@tseaver Ready to merge? Thanks. |
@aneepct One of the system tests added by this PR is failing on CI this morning 1 2 3 4: ____________________ TestDataAPI.test_drop_by_prefix_table _____________________
self = <tests.system.TestDataAPI testMethod=test_drop_by_prefix_table>
def test_drop_by_prefix_table(self):
row_keys = [
b'row_key_1', b'row_key_2', b'row_key_3', b'row_key_4',
b'row_key_5', b'row_key_pr_1', b'row_key_pr_2', b'row_key_pr_3',
b'row_key_pr_4', b'row_key_pr_5']
for row_key in row_keys:
row = self._table.row(row_key)
row.set_cell(COLUMN_FAMILY_ID1, COL_NAME1, CELL_VAL1)
row.commit()
self.rows_to_delete.append(row)
self._table.drop_by_prefix(row_key_prefix='row_key_pr', timeout=200)
read_rows = self._table.yield_rows()
expected_rows_count = 5
read_rows_count = 0
for row in read_rows:
if row.row_key.decode('utf-8') in row_keys:
read_rows_count += 1
> self.assertEqual(expected_rows_count, read_rows_count)
E AssertionError: 5 != 0 |
Add methods on Table to delete rows by prefix and truncate all rows.