@@ -3,7 +3,7 @@ package com.scylladb.migrator.alternator
33import software .amazon .awssdk .auth .credentials .{AwsBasicCredentials , StaticCredentialsProvider }
44import software .amazon .awssdk .regions .Region
55import software .amazon .awssdk .services .dynamodb .DynamoDbClient
6- import software .amazon .awssdk .services .dynamodb .model .{AttributeDefinition , AttributeValue , CreateTableRequest , DeleteTableRequest , DescribeTableRequest , GetItemRequest , KeySchemaElement , KeyType , ProvisionedThroughput , ResourceNotFoundException , ScalarAttributeType }
6+ import software .amazon .awssdk .services .dynamodb .model .{AttributeDefinition , AttributeValue , CreateTableRequest , DeleteTableRequest , DescribeTableRequest , GetItemRequest , GlobalSecondaryIndexDescription , KeySchemaElement , KeyType , LocalSecondaryIndex , LocalSecondaryIndexDescription , ProvisionedThroughput , ResourceNotFoundException , ScalarAttributeType }
77
88import java .net .URI
99import scala .util .chaining ._
@@ -57,7 +57,7 @@ trait MigratorSuite extends munit.FunSuite {
5757 .tableName(name)
5858 .keySchema(KeySchemaElement .builder().attributeName(" id" ).keyType(KeyType .HASH ).build())
5959 .attributeDefinitions(AttributeDefinition .builder().attributeName(" id" ).attributeType(ScalarAttributeType .S ).build())
60- .provisionedThroughput(ProvisionedThroughput .builder.readCapacityUnits(25L ).writeCapacityUnits(25L ).build())
60+ .provisionedThroughput(ProvisionedThroughput .builder() .readCapacityUnits(25L ).writeCapacityUnits(25L ).build())
6161 .build()
6262 sourceDDb.createTable(createTableRequest)
6363 val waiterResponse =
@@ -67,7 +67,7 @@ trait MigratorSuite extends munit.FunSuite {
6767 assert(waiterResponse.matched().response().isPresent, s " Failed to create table ${name}: ${waiterResponse.matched().exception().get()}" )
6868 } catch {
6969 case any : Throwable =>
70- fail(s " Failed to created table ${name} in database ${sourceDDb}" , any)
70+ fail(s " Failed to create table ${name} in database ${sourceDDb}" , any)
7171 }
7272 name
7373 },
@@ -112,18 +112,44 @@ trait MigratorSuite extends munit.FunSuite {
112112 checkSchemaWasMigrated(
113113 tableName,
114114 sourceTableDesc.keySchema,
115- sourceTableDesc.attributeDefinitions
115+ sourceTableDesc.attributeDefinitions,
116+ sourceTableDesc.localSecondaryIndexes,
117+ sourceTableDesc.globalSecondaryIndexes
116118 )
117119 }
118120
119121 /** Check that the table schema in the target database is equal to the provided schema */
120- def checkSchemaWasMigrated (tableName : String , keySchema : java.util.List [KeySchemaElement ], attributeDefinitions : java.util.List [AttributeDefinition ]): Unit = {
122+ def checkSchemaWasMigrated (
123+ tableName : String ,
124+ keySchema : java.util.List [KeySchemaElement ],
125+ attributeDefinitions : java.util.List [AttributeDefinition ],
126+ localSecondaryIndexes : java.util.List [LocalSecondaryIndexDescription ],
127+ globalSecondaryIndexes : java.util.List [GlobalSecondaryIndexDescription ]): Unit = {
121128 targetAlternator
122129 .describeTable(describeTableRequest(tableName))
123130 .table
124131 .tap { targetTableDesc =>
132+ // Partition key
125133 assertEquals(targetTableDesc.keySchema, keySchema)
126- assertEquals(targetTableDesc.attributeDefinitions, attributeDefinitions)
134+
135+ // Attribute definitions
136+ assertEquals(targetTableDesc.attributeDefinitions.asScala.toSet, attributeDefinitions.asScala.toSet)
137+
138+ // Local secondary indexes: do not compare their ARN, which always unique
139+ def localIndexRelevantProperties (index : LocalSecondaryIndexDescription ) =
140+ (index.indexName, index.keySchema, index.projection)
141+ assertEquals(
142+ targetTableDesc.localSecondaryIndexes.asScala.map(localIndexRelevantProperties),
143+ localSecondaryIndexes.asScala.map(localIndexRelevantProperties)
144+ )
145+
146+ // Global secondary indexes: do not compare ARN and provisioned throughput (see https://github.com/scylladb/scylladb/issues/19718)
147+ def globalIndexRelevantProperties (index : GlobalSecondaryIndexDescription ) =
148+ (index.indexName, index.keySchema, index.projection/* , index.provisionedThroughput*/ )
149+ assertEquals(
150+ targetTableDesc.globalSecondaryIndexes.asScala.map(globalIndexRelevantProperties),
151+ globalSecondaryIndexes.asScala.map(globalIndexRelevantProperties)
152+ )
127153 }
128154 }
129155
0 commit comments