Skip to content

Commit 0aeffae

Browse files
Add new e2e test case for creating GSI's with already existing attributes (#88)
Issue aws-controllers-k8s/community#1920 Description of changes: Add e2e test for table GSIs
1 parent 78ec5b0 commit 0aeffae

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

test/e2e/tests/test_table.py

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def all_in_table():
128128
except:
129129
pass
130130

131-
@pytest.fixture(scope="module")
131+
@pytest.fixture(scope="function")
132132
def table_basic():
133133
resource_name = random_suffix_name("table-basic", 32)
134134
(ref, cr) = create_table(resource_name, "table_basic")
@@ -838,4 +838,50 @@ def test_create_gsi_pay_per_request(self, table_basic_pay_per_request):
838838
timeout_seconds=MODIFY_WAIT_AFTER_SECONDS*40,
839839
interval_seconds=15,
840840
)
841+
def test_create_gsi_same_attributes(self, table_basic):
842+
(ref, res) = table_basic
843+
844+
table_name = res["spec"]["tableName"]
845+
846+
# Check DynamoDB Table exists
847+
assert self.table_exists(table_name)
848+
849+
# Get CR latest revision
850+
cr = k8s.wait_resource_consumed_by_controller(ref)
851+
852+
# Creating two GSI using the same attributes
853+
gsi = {
854+
"indexName": "total-bill",
855+
"keySchema": [
856+
{
857+
"attributeName": "Total",
858+
"keyType": "HASH",
859+
},
860+
{
861+
"attributeName": "Bill",
862+
"keyType": "RANGE",
863+
}
864+
],
865+
"projection": {
866+
"projectionType": "ALL",
867+
}
868+
}
869+
870+
cr["spec"]['globalSecondaryIndexes'] = [
871+
gsi,
872+
]
873+
874+
# Patch k8s resource
875+
k8s.patch_custom_resource(ref, cr)
876+
k8s.wait_resource_consumed_by_controller(ref)
877+
table.wait_until(
878+
table_name,
879+
table.gsi_matches(
880+
[
881+
gsi
882+
],
883+
),
884+
timeout_seconds=MODIFY_WAIT_AFTER_SECONDS*40,
885+
interval_seconds=15,
886+
)
841887

0 commit comments

Comments
 (0)