-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test all plugins in isolation (#161)
* E2E test all plugins * use `compileOnly` in schema's dependencies * fix DynamoDBPositionsStorageTest * Fix rerun task * Introduce `ApplicationRunner` * Add ClassLoader isolation to `ApplicationRunner` * fix Lombok's scope (from `testCompile` to `testCompileOnly`) * add logging
- Loading branch information
Showing
18 changed files
with
231 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 18 additions & 44 deletions
62
...orage/src/test/java/com/github/bsideup/liiklus/dynamodb/DynamoDBPositionsStorageTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,37 @@ | ||
package com.github.bsideup.liiklus.dynamodb; | ||
|
||
import com.github.bsideup.liiklus.ApplicationRunner; | ||
import com.github.bsideup.liiklus.positions.PositionsStorage; | ||
import com.github.bsideup.liiklus.positions.PositionsStorageTests; | ||
import lombok.Getter; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.springframework.context.ApplicationContext; | ||
import org.testcontainers.containers.localstack.LocalStackContainer; | ||
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; | ||
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; | ||
import software.amazon.awssdk.regions.Region; | ||
import software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient; | ||
import software.amazon.awssdk.services.dynamodb.model.AttributeDefinition; | ||
import software.amazon.awssdk.services.dynamodb.model.CreateTableRequest; | ||
import software.amazon.awssdk.services.dynamodb.model.KeySchemaElement; | ||
import software.amazon.awssdk.services.dynamodb.model.KeyType; | ||
import software.amazon.awssdk.services.dynamodb.model.ProvisionedThroughput; | ||
import software.amazon.awssdk.services.dynamodb.model.ScalarAttributeType; | ||
|
||
import java.net.URI; | ||
import org.testcontainers.containers.localstack.LocalStackContainer.Service; | ||
|
||
import java.util.UUID; | ||
|
||
class DynamoDBPositionsStorageTest implements PositionsStorageTests { | ||
|
||
private static final LocalStackContainer localstack = new LocalStackContainer("0.8.6") | ||
.withServices(LocalStackContainer.Service.DYNAMODB); | ||
.withServices(Service.DYNAMODB); | ||
|
||
static final ApplicationContext applicationContext; | ||
|
||
static { | ||
localstack.start(); | ||
} | ||
|
||
private final DynamoDbAsyncClient dynamoDB = DynamoDbAsyncClient.builder() | ||
.region(Region.of(localstack.getEndpointConfiguration(LocalStackContainer.Service.DYNAMODB).getSigningRegion())) | ||
.endpointOverride(URI.create(localstack.getEndpointConfiguration(LocalStackContainer.Service.DYNAMODB).getServiceEndpoint())) | ||
.credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("key", "secret"))) | ||
.build(); | ||
System.setProperty("dynamodb.autoCreateTable", "true"); | ||
System.setProperty("dynamodb.positionsTable", "positions-" + UUID.randomUUID()); | ||
var endpointConfiguration = localstack.getEndpointConfiguration(Service.DYNAMODB); | ||
System.setProperty("dynamodb.endpoint", endpointConfiguration.getServiceEndpoint()); | ||
System.setProperty("aws.region", endpointConfiguration.getSigningRegion()); | ||
var credentials = localstack.getDefaultCredentialsProvider().getCredentials(); | ||
System.setProperty("aws.accessKeyId", credentials.getAWSAccessKeyId()); | ||
System.setProperty("aws.secretAccessKey", credentials.getAWSSecretKey()); | ||
|
||
private final String tableName = UUID.randomUUID().toString(); | ||
applicationContext = new ApplicationRunner("MEMORY", "DYNAMODB").run(); | ||
} | ||
|
||
@Getter | ||
PositionsStorage storage = new DynamoDBPositionsStorage(dynamoDB, tableName); | ||
|
||
@BeforeEach | ||
void setUp() { | ||
var request = CreateTableRequest.builder() | ||
.keySchema( | ||
KeySchemaElement.builder().attributeName(DynamoDBPositionsStorage.HASH_KEY_FIELD).keyType(KeyType.HASH).build(), | ||
KeySchemaElement.builder().attributeName(DynamoDBPositionsStorage.RANGE_KEY_FIELD).keyType(KeyType.RANGE).build() | ||
) | ||
.attributeDefinitions( | ||
AttributeDefinition.builder().attributeName(DynamoDBPositionsStorage.HASH_KEY_FIELD).attributeType(ScalarAttributeType.S).build(), | ||
AttributeDefinition.builder().attributeName(DynamoDBPositionsStorage.RANGE_KEY_FIELD).attributeType(ScalarAttributeType.S).build() | ||
) | ||
.tableName(tableName) | ||
.provisionedThroughput(ProvisionedThroughput.builder().readCapacityUnits(10L).writeCapacityUnits(10L).build()) | ||
.build(); | ||
|
||
try { | ||
dynamoDB.createTable(request).get(); | ||
} catch (Exception e) { | ||
throw new IllegalStateException("Can't create positions dynamodb table", e); | ||
} | ||
} | ||
PositionsStorage storage = applicationContext.getBean(PositionsStorage.class); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 5 additions & 1 deletion
6
...test/java/com/github/bsideup/liiklus/positions/inmemory/InMemoryPositionsStorageTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
package com.github.bsideup.liiklus.positions.inmemory; | ||
|
||
import com.github.bsideup.liiklus.ApplicationRunner; | ||
import com.github.bsideup.liiklus.positions.PositionsStorage; | ||
import com.github.bsideup.liiklus.positions.PositionsStorageTests; | ||
import lombok.Getter; | ||
import org.springframework.context.ApplicationContext; | ||
|
||
class InMemoryPositionsStorageTest implements PositionsStorageTests { | ||
|
||
static final ApplicationContext applicationContext = new ApplicationRunner("MEMORY", "MEMORY").run(); | ||
|
||
@Getter | ||
PositionsStorage storage = new InMemoryPositionsStorage(); | ||
PositionsStorage storage = applicationContext.getBean(PositionsStorage.class); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.