-
Notifications
You must be signed in to change notification settings - Fork 40
Add wait for cache expiry #3040
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,9 @@ public static Properties getProperties(String testName) { | |
DatabaseConfig.SYSTEM_NAMESPACE_NAME, | ||
DatabaseConfig.DEFAULT_SYSTEM_NAMESPACE_NAME + "_" + testName); | ||
|
||
// Metadata cache expiration time | ||
properties.setProperty(DatabaseConfig.METADATA_CACHE_EXPIRATION_TIME_SECS, "1"); | ||
Comment on lines
+40
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The short expiration time (i.e., 1) can test both where the data is in cache and where it is not. |
||
|
||
return properties; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
import static org.assertj.core.api.Assertions.assertThatCode; | ||
import static org.assertj.core.api.Assertions.catchThrowable; | ||
|
||
import com.google.common.util.concurrent.Uninterruptibles; | ||
import com.scalar.db.api.DistributedTransactionManager; | ||
import com.scalar.db.api.Insert; | ||
import com.scalar.db.api.InsertBuilder; | ||
|
@@ -28,6 +29,7 @@ | |
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Properties; | ||
import java.util.concurrent.TimeUnit; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.condition.DisabledIf; | ||
import org.junit.jupiter.api.condition.EnabledIf; | ||
|
@@ -329,8 +331,8 @@ public void alterColumnType_WideningConversion_ShouldAlterColumnTypesCorrectly() | |
@Test | ||
@EnabledIf("isOracle") | ||
public void alterColumnType_Oracle_WideningConversion_ShouldAlterColumnTypesCorrectly() | ||
throws ExecutionException, IOException, TransactionException { | ||
try { | ||
throws ExecutionException, TransactionException { | ||
KodaiD marked this conversation as resolved.
Show resolved
Hide resolved
|
||
try (DistributedTransactionManager manager = transactionFactory.getTransactionManager()) { | ||
Comment on lines
-332
to
+335
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove unnecessary |
||
// Arrange | ||
Map<String, String> options = getCreationOptions(); | ||
TableMetadata.Builder currentTableMetadataBuilder = | ||
|
@@ -346,23 +348,24 @@ public void alterColumnType_Oracle_WideningConversion_ShouldAlterColumnTypesCorr | |
|
||
int expectedColumn3Value = 1; | ||
float expectedColumn4Value = 4.0f; | ||
try (DistributedTransactionManager manager = transactionFactory.getTransactionManager()) { | ||
InsertBuilder.Buildable insert = | ||
Insert.newBuilder() | ||
.namespace(namespace1) | ||
.table(TABLE4) | ||
.partitionKey(Key.ofInt("c1", 1)) | ||
.clusteringKey(Key.ofInt("c2", 2)) | ||
.intValue("c3", expectedColumn3Value) | ||
.floatValue("c4", expectedColumn4Value); | ||
transactionalInsert(manager, insert.build()); | ||
} | ||
InsertBuilder.Buildable insert = | ||
Insert.newBuilder() | ||
.namespace(namespace1) | ||
.table(TABLE4) | ||
.partitionKey(Key.ofInt("c1", 1)) | ||
.clusteringKey(Key.ofInt("c2", 2)) | ||
.intValue("c3", expectedColumn3Value) | ||
.floatValue("c4", expectedColumn4Value); | ||
transactionalInsert(manager, insert.build()); | ||
|
||
// Act | ||
admin.alterColumnType(namespace1, TABLE4, "c3", DataType.BIGINT); | ||
Throwable exception = | ||
catchThrowable(() -> admin.alterColumnType(namespace1, TABLE4, "c4", DataType.DOUBLE)); | ||
|
||
// Wait for cache expiry | ||
Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS); | ||
KodaiD marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// Assert | ||
assertThat(exception).isInstanceOf(UnsupportedOperationException.class); | ||
TableMetadata.Builder expectedTableMetadataBuilder = | ||
|
@@ -376,18 +379,16 @@ public void alterColumnType_Oracle_WideningConversion_ShouldAlterColumnTypesCorr | |
TableMetadata expectedTableMetadata = expectedTableMetadataBuilder.build(); | ||
assertThat(admin.getTableMetadata(namespace1, TABLE4)).isEqualTo(expectedTableMetadata); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix to use the same |
||
try (DistributedTransactionManager manager = transactionFactory.getTransactionManager()) { | ||
Scan scan = | ||
Scan.newBuilder() | ||
.namespace(namespace1) | ||
.table(TABLE4) | ||
.partitionKey(Key.ofInt("c1", 1)) | ||
.build(); | ||
List<Result> results = transactionalScan(manager, scan); | ||
assertThat(results).hasSize(1); | ||
Result result = results.get(0); | ||
assertThat(result.getBigInt("c3")).isEqualTo(expectedColumn3Value); | ||
} | ||
Scan scan = | ||
Scan.newBuilder() | ||
.namespace(namespace1) | ||
.table(TABLE4) | ||
.partitionKey(Key.ofInt("c1", 1)) | ||
.build(); | ||
List<Result> results = transactionalScan(manager, scan); | ||
assertThat(results).hasSize(1); | ||
Result result = results.get(0); | ||
assertThat(result.getBigInt("c3")).isEqualTo(expectedColumn3Value); | ||
} finally { | ||
admin.dropTable(namespace1, TABLE4, true); | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.