@@ -626,6 +626,48 @@ public void createTable_WhenMetadataTableExists_ShouldCreateOnlyTable()
626626 .isInstanceOf (IllegalArgumentException .class );
627627 }
628628
629+ @ Test
630+ public void createTable_WhenActualMetadataTableCreationIsDelayed_ShouldFailAfterRetries () {
631+ // Arrange
632+ // prepare tableIsActiveResponse
633+ DescribeTableResponse tableIsActiveResponse = mock (DescribeTableResponse .class );
634+ TableDescription tableDescription = mock (TableDescription .class );
635+ when (tableIsActiveResponse .table ()).thenReturn (tableDescription );
636+ when (tableDescription .tableStatus ()).thenReturn (TableStatus .ACTIVE );
637+ when (client .describeTable (any (DescribeTableRequest .class ))).thenReturn (tableIsActiveResponse );
638+ // prepare backupIsEnabledResponse
639+ DescribeContinuousBackupsResponse backupIsEnabledResponse =
640+ mock (DescribeContinuousBackupsResponse .class );
641+ when (client .describeContinuousBackups (any (DescribeContinuousBackupsRequest .class )))
642+ .thenReturn (backupIsEnabledResponse );
643+ ContinuousBackupsDescription continuousBackupsDescription =
644+ mock (ContinuousBackupsDescription .class );
645+ when (backupIsEnabledResponse .continuousBackupsDescription ())
646+ .thenReturn (continuousBackupsDescription );
647+ when (continuousBackupsDescription .continuousBackupsStatus ())
648+ .thenReturn (ContinuousBackupsStatus .ENABLED );
649+ when (client .putItem (any (PutItemRequest .class ))).thenThrow (ResourceNotFoundException .class );
650+ TableMetadata metadata =
651+ TableMetadata .newBuilder ()
652+ .addPartitionKey ("c1" )
653+ .addClusteringKey ("c2" , Order .DESC )
654+ .addClusteringKey ("c3" , Order .ASC )
655+ .addColumn ("c1" , DataType .TEXT )
656+ .addColumn ("c2" , DataType .BIGINT )
657+ .addColumn ("c3" , DataType .BOOLEAN )
658+ .addColumn ("c4" , DataType .INT )
659+ .addColumn ("c5" , DataType .BLOB )
660+ .addColumn ("c6" , DataType .DOUBLE )
661+ .addColumn ("c7" , DataType .FLOAT )
662+ .addSecondaryIndex ("c4" )
663+ .build ();
664+
665+ // Act Assert
666+ assertThatThrownBy (() -> admin .createTable (NAMESPACE , TABLE , metadata ))
667+ .isInstanceOf (ExecutionException .class );
668+ verify (client , times (DynamoAdmin .MAX_RETRY_COUNT + 1 )).putItem (any (PutItemRequest .class ));
669+ }
670+
629671 @ Test
630672 public void dropTable_WithNoMetadataLeft_ShouldDropTableAndDeleteMetadata ()
631673 throws ExecutionException {
0 commit comments