Skip to content

Commit

Permalink
Adding system tests for Table.rename and ColumnFamily.update.
Browse files Browse the repository at this point in the history
This was enabled in gRPC beta since we can now get information
from errors. This also revealed that ColumnFamily.update
was now implemented.
  • Loading branch information
dhermes committed Dec 22, 2015
1 parent f70871b commit 70be122
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 6 deletions.
8 changes: 2 additions & 6 deletions gcloud_bigtable/column_family.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,8 @@ def update(self, timeout_seconds=None):
.. note::
The Bigtable Table Admin API currently returns
``BigtableTableService.UpdateColumnFamily is not yet implemented``
when this method is used. It's unclear when this method will
actually be supported by the API.
Only the GC rule can be updated. By changing the column family ID,
you will simply be referring to a different column family.
:type timeout_seconds: int
:param timeout_seconds: Number of seconds for request time-out.
Expand Down
43 changes: 43 additions & 0 deletions system_tests/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,26 @@ def test_create_table(self):
sorted_tables = sorted(tables, key=name_attr)
self.assertEqual(sorted_tables, expected_tables)

def test_rename_table(self):
from grpc.beta.interfaces import StatusCode
from grpc.framework.interfaces.face.face import LocalError

temp_table_id = 'foo-bar-baz-table'
temp_table = CLUSTER.table(temp_table_id)
temp_table.create()
self.tables_to_delete.append(temp_table)

exc_caught = None
try:
temp_table.rename(temp_table_id + '-alt')
except LocalError as exc:
exc_caught = exc # Python 3 syntax issue.
self.assertNotEqual(exc_caught, None)
self.assertEqual(exc_caught.code, StatusCode.UNIMPLEMENTED)
self.assertEqual(
exc_caught.details,
'BigtableTableService.RenameTable is not yet implemented')

def test_create_column_family(self):
temp_table_id = 'foo-bar-baz-table'
temp_table = CLUSTER.table(temp_table_id)
Expand All @@ -224,6 +244,29 @@ def test_create_column_family(self):
column_family.column_family_id)
self.assertEqual(retrieved_col_fam.gc_rule, gc_rule)

def test_update_column_family(self):
temp_table_id = 'foo-bar-baz-table'
temp_table = CLUSTER.table(temp_table_id)
temp_table.create()
self.tables_to_delete.append(temp_table)

gc_rule = GarbageCollectionRule(max_num_versions=1)
column_family = temp_table.column_family(COLUMN_FAMILY_ID1,
gc_rule=gc_rule)
column_family.create()

# Check that our created table is as expected.
col_fams = temp_table.list_column_families()
self.assertEqual(col_fams, {COLUMN_FAMILY_ID1: column_family})

# Update the column family's GC rule and then try to update.
column_family.gc_rule = None
column_family.update()

# Check that the update has propagated.
col_fams = temp_table.list_column_families()
self.assertEqual(col_fams[COLUMN_FAMILY_ID1].gc_rule, None)

def test_delete_column_family(self):
temp_table_id = 'foo-bar-baz-table'
temp_table = CLUSTER.table(temp_table_id)
Expand Down

0 comments on commit 70be122

Please sign in to comment.