Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.scalar.db.storage.cassandra;

import com.scalar.db.api.DistributedStorageAdminCaseSensitivityIntegrationTestBase;
import com.scalar.db.util.AdminTestUtils;
import java.util.Collections;
import java.util.Map;
import java.util.Properties;

public class CassandraAdminCaseSensitivityIntegrationTest
extends DistributedStorageAdminCaseSensitivityIntegrationTestBase {
@Override
protected Properties getProperties(String testName) {
return CassandraEnv.getProperties(testName);
}

@Override
protected Map<String, String> getCreationOptions() {
return Collections.singletonMap(CassandraAdmin.REPLICATION_FACTOR, "1");
}

@Override
protected AdminTestUtils getAdminTestUtils(String testName) {
return new CassandraAdminTestUtils(getProperties(testName));
}

@Override
protected boolean isTimestampTypeSupported() {
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.scalar.db.storage.cassandra;

import com.scalar.db.api.DistributedStorageCaseSensitivityIntegrationTestBase;
import java.util.Collections;
import java.util.Map;
import java.util.Properties;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

public class CassandraCaseSensitivityIntegrationTest
extends DistributedStorageCaseSensitivityIntegrationTestBase {
@Override
protected Properties getProperties(String testName) {
return CassandraEnv.getProperties(testName);
}

@Override
protected Map<String, String> getCreationOptions() {
return Collections.singletonMap(CassandraAdmin.REPLICATION_FACTOR, "1");
}

@Disabled(
"In Cassandra, if an IS NULL condition is specified for a column in a non-existing record, "
+ "the condition is considered satisfied. This behavior differs from that of other adapters")
@Override
@Test
public void put_withPutIfIsNullWhenRecordDoesNotExist_shouldThrowNoMutationException() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.util.Collections;
import java.util.Map;
import java.util.Properties;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

public class CassandraWithReservedKeywordIntegrationTest
extends DistributedStorageWithReservedKeywordIntegrationTestBase {
Expand Down Expand Up @@ -58,4 +60,11 @@ protected String getColumnName5() {
protected Properties getProperties(String testName) {
return CassandraEnv.getProperties(testName);
}

@Disabled(
"In Cassandra, if an IS NULL condition is specified for a column in a non-existing record, "
+ "the condition is considered satisfied. This behavior differs from that of other adapters")
@Override
@Test
public void put_withPutIfIsNullWhenRecordDoesNotExist_shouldThrowNoMutationException() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.scalar.db.storage.cosmos;

import com.scalar.db.api.DistributedStorageAdminCaseSensitivityIntegrationTestBase;
import com.scalar.db.util.AdminTestUtils;
import java.util.Map;
import java.util.Properties;

public class CosmosAdminCaseSensitivityIntegrationTest
extends DistributedStorageAdminCaseSensitivityIntegrationTestBase {

@Override
protected Properties getProperties(String testName) {
return CosmosEnv.getProperties(testName);
}

@Override
protected Map<String, String> getCreationOptions() {
return CosmosEnv.getCreationOptions();
}

@Override
protected AdminTestUtils getAdminTestUtils(String testName) {
return new CosmosAdminTestUtils(getProperties(testName));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.scalar.db.storage.cosmos;

import com.scalar.db.api.DistributedStorageCaseSensitivityIntegrationTestBase;
import java.util.Map;
import java.util.Properties;

public class CosmosCaseSensitivityIntegrationTest
extends DistributedStorageCaseSensitivityIntegrationTestBase {

@Override
protected Properties getProperties(String testName) {
return CosmosEnv.getProperties(testName);
}

@Override
protected Map<String, String> getCreationOptions() {
return CosmosEnv.getCreationOptions();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.scalar.db.storage.dynamo;

import com.scalar.db.api.DistributedStorageAdminCaseSensitivityIntegrationTestBase;
import com.scalar.db.util.AdminTestUtils;
import java.util.Map;
import java.util.Properties;

public class DynamoAdminCaseSensitivityIntegrationTest
extends DistributedStorageAdminCaseSensitivityIntegrationTestBase {

@Override
protected Properties getProperties(String testName) {
return DynamoEnv.getProperties(testName);
}

@Override
protected Map<String, String> getCreationOptions() {
return DynamoEnv.getCreationOptions();
}

@Override
protected boolean isIndexOnBooleanColumnSupported() {
return false;
}

@Override
protected AdminTestUtils getAdminTestUtils(String testName) {
return new DynamoAdminTestUtils(getProperties(testName));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.scalar.db.storage.dynamo;

import com.scalar.db.api.DistributedStorageCaseSensitivityIntegrationTestBase;
import java.util.Map;
import java.util.Properties;
import org.junit.jupiter.api.Disabled;

public class DynamoCaseSensitivityIntegrationTest
extends DistributedStorageCaseSensitivityIntegrationTestBase {

@Override
protected Properties getProperties(String testName) {
return DynamoEnv.getProperties(testName);
}

@Override
protected Map<String, String> getCreationOptions() {
return DynamoEnv.getCreationOptions();
}

@Disabled("DynamoDB doesn't support putting a null value for a secondary index column")
@Override
public void put_PutGivenForIndexedColumnWithNullValue_ShouldPut() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ protected Map<String, String> getCreationOptions() {
return DynamoEnv.getCreationOptions();
}

// DynamoDB doesn't support putting a null value for a secondary index column
@Disabled
@Disabled("DynamoDB doesn't support putting a null value for a secondary index column")
@Override
public void put_PutGivenForIndexedColumnWithNullValue_ShouldPut() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.scalar.db.api.DistributedStorageWithReservedKeywordIntegrationTestBase;
import java.util.Map;
import java.util.Properties;
import org.junit.jupiter.api.Disabled;

public class DynamoWithReservedKeywordIntegrationTest
extends DistributedStorageWithReservedKeywordIntegrationTestBase {
Expand Down Expand Up @@ -58,4 +59,8 @@ protected Properties getProperties(String testName) {
protected Map<String, String> getCreationOptions() {
return DynamoEnv.getCreationOptions();
}

@Disabled("DynamoDB doesn't support putting a null value for a secondary index column")
@Override
public void put_PutGivenForIndexedColumnWithNullValue_ShouldPut() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.scalar.db.storage.jdbc;

import com.scalar.db.api.DistributedStorageAdminCaseSensitivityIntegrationTestBase;
import com.scalar.db.config.DatabaseConfig;
import com.scalar.db.util.AdminTestUtils;
import java.util.Properties;

public class JdbcAdminCaseSensitivityIntegrationTest
extends DistributedStorageAdminCaseSensitivityIntegrationTestBase {
private RdbEngineStrategy rdbEngine;

@Override
protected Properties getProperties(String testName) {
Properties properties = JdbcEnv.getProperties(testName);
rdbEngine = RdbEngineFactory.create(new JdbcConfig(new DatabaseConfig(properties)));
return properties;
}

@Override
protected AdminTestUtils getAdminTestUtils(String testName) {
return new JdbcAdminTestUtils(getProperties(testName));
}

@Override
protected boolean isCreateIndexOnTextAndBlobColumnsEnabled() {
// "admin.createIndex()" for TEXT and BLOB columns fails (the "create index" query runs
// indefinitely) on Db2 community edition version but works on Db2 hosted on IBM Cloud.
// So we disable these tests until the issue is resolved.
return !JdbcTestUtils.isDb2(rdbEngine);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
package com.scalar.db.storage.jdbc;

import static org.assertj.core.api.Assertions.assertThat;

import com.scalar.db.api.DistributedStorage;
import com.scalar.db.api.DistributedStorageCaseSensitivityIntegrationTestBase;
import com.scalar.db.api.Get;
import com.scalar.db.api.Put;
import com.scalar.db.api.Result;
import com.scalar.db.api.Scan;
import com.scalar.db.api.Scanner;
import com.scalar.db.config.DatabaseConfig;
import com.scalar.db.exception.storage.ExecutionException;
import com.scalar.db.io.Key;
import com.scalar.db.service.StorageFactory;
import java.io.IOException;
import java.util.List;
import java.util.Optional;
import java.util.Properties;
import org.junit.jupiter.api.Test;

public class JdbcDatabaseCaseSensitivityIntegrationTest
extends DistributedStorageCaseSensitivityIntegrationTestBase {

private RdbEngineStrategy rdbEngine;

@Override
protected Properties getProperties(String testName) {
Properties properties = JdbcEnv.getProperties(testName);
JdbcConfig config = new JdbcConfig(new DatabaseConfig(properties));
rdbEngine = RdbEngineFactory.create(config);
return properties;
}

@Override
protected int getLargeDataSizeInBytes() {
if (JdbcTestUtils.isOracle(rdbEngine)) {
// For Oracle, the max data size for BLOB is 2000 bytes
return 2000;
} else {
return super.getLargeDataSizeInBytes();
}
}

@Test
public void get_InStreamingMode_ShouldRetrieveSingleResult() throws ExecutionException {
if (!JdbcTestUtils.isMysql(rdbEngine) || JdbcTestUtils.isMariaDB(rdbEngine)) {
// MySQL is the only RDB engine that supports streaming mode
return;
}

try (DistributedStorage storage = getStorageInStreamingMode()) {
// Arrange
int pKey = 0;
int cKey = 1;
int value = 2;

storage.put(
Put.newBuilder()
.namespace(namespace)
.table(getTableName())
.partitionKey(Key.ofInt(getColumnName1(), pKey))
.clusteringKey(Key.ofInt(getColumnName4(), cKey))
.intValue(getColumnName3(), value)
.build());

// Act
Optional<Result> result =
storage.get(
Get.newBuilder()
.namespace(namespace)
.table(getTableName())
.partitionKey(Key.ofInt(getColumnName1(), pKey))
.clusteringKey(Key.ofInt(getColumnName4(), cKey))
.build());

// Assert
assertThat(result.isPresent()).isTrue();
assertThat(result.get().getInt(getColumnName1())).isEqualTo(pKey);
assertThat(result.get().getInt(getColumnName4())).isEqualTo(cKey);
assertThat(result.get().getInt(getColumnName3())).isEqualTo(value);
}
}

@Test
public void scan_InStreamingMode_ShouldRetrieveResults() throws IOException, ExecutionException {
if (!JdbcTestUtils.isMysql(rdbEngine) || JdbcTestUtils.isMariaDB(rdbEngine)) {
// MySQL is the only RDB engine that supports streaming mode
return;
}

try (DistributedStorage storage = getStorageInStreamingMode()) {
// Arrange
int pKey = 0;

storage.put(
Put.newBuilder()
.namespace(namespace)
.table(getTableName())
.partitionKey(Key.ofInt(getColumnName1(), pKey))
.clusteringKey(Key.ofInt(getColumnName4(), 0))
.intValue(getColumnName3(), 1)
.build());
storage.put(
Put.newBuilder()
.namespace(namespace)
.table(getTableName())
.partitionKey(Key.ofInt(getColumnName1(), pKey))
.clusteringKey(Key.ofInt(getColumnName4(), 1))
.intValue(getColumnName3(), 2)
.build());
storage.put(
Put.newBuilder()
.namespace(namespace)
.table(getTableName())
.partitionKey(Key.ofInt(getColumnName1(), pKey))
.clusteringKey(Key.ofInt(getColumnName4(), 2))
.intValue(getColumnName3(), 3)
.build());

// Act
Scanner scanner =
storage.scan(
Scan.newBuilder()
.namespace(namespace)
.table(getTableName())
.partitionKey(Key.ofInt(getColumnName1(), pKey))
.build());
List<Result> results = scanner.all();
scanner.close();

// Assert
assertThat(results).hasSize(3);
assertThat(results.get(0).getInt(getColumnName1())).isEqualTo(pKey);
assertThat(results.get(0).getInt(getColumnName4())).isEqualTo(0);
assertThat(results.get(0).getInt(getColumnName3())).isEqualTo(1);

assertThat(results.get(1).getInt(getColumnName1())).isEqualTo(pKey);
assertThat(results.get(1).getInt(getColumnName4())).isEqualTo(1);
assertThat(results.get(1).getInt(getColumnName3())).isEqualTo(2);

assertThat(results.get(2).getInt(getColumnName1())).isEqualTo(pKey);
assertThat(results.get(2).getInt(getColumnName4())).isEqualTo(2);
assertThat(results.get(2).getInt(getColumnName3())).isEqualTo(3);
}
}

private DistributedStorage getStorageInStreamingMode() {
Properties properties = JdbcEnv.getProperties(getTestName());
properties.setProperty(DatabaseConfig.SCAN_FETCH_SIZE, Integer.toString(Integer.MIN_VALUE));
return StorageFactory.create(properties).getStorage();
}
}
Loading