-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request eventuate-tram#42 from dartartem/wip-db-id-gen
Added db id migration testing
- Loading branch information
Showing
15 changed files
with
126 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,6 @@ | |
set -e | ||
|
||
export DATABASE=mysql | ||
export READER=MySqlReader | ||
|
||
./_build-and-test-all.sh |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
EVENTUATE_OUTBOX_ID=1 |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
dependencies { | ||
testCompile "org.springframework.boot:spring-boot-starter-jdbc:${springBootVersion}" | ||
testCompile "org.springframework.boot:spring-boot-starter-test:${springBootVersion}" | ||
|
||
testRuntime 'mysql:mysql-connector-java:5.1.36' | ||
testRuntime ('org.postgresql:postgresql:9.4-1200-jdbc41') { | ||
exclude group: "org.slf4j", module: "slf4j-simple" | ||
} | ||
testRuntime 'com.microsoft.sqlserver:mssql-jdbc:7.2.1.jre8' | ||
} | ||
|
||
test { | ||
if (!project.ext.has("verifyDbIdMigration")) { | ||
exclude '**/DbIdMigrationVerificationTest**' | ||
} | ||
|
||
forkEvery 1 | ||
} |
39 changes: 39 additions & 0 deletions
39
...tuate/examples/tram/sagas/ordersandcustomers/migration/DbIdMigrationVerificationTest.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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package io.eventuate.examples.tram.sagas.ordersandcustomers.migration; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.jdbc.core.JdbcTemplate; | ||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@RunWith(SpringJUnit4ClassRunner.class) | ||
@SpringBootTest(classes = DbIdMigrationVerificationTest.Config.class) | ||
public class DbIdMigrationVerificationTest { | ||
|
||
@Configuration | ||
@EnableAutoConfiguration | ||
public static class Config {} | ||
|
||
@Autowired | ||
private JdbcTemplate jdbcTemplate; | ||
|
||
@Test | ||
//after first call of e2e tests (before migration), messages should have ids, after second call (after migration) don't | ||
public void testThatMessagesAreMigrated() { | ||
List<Map<String, Object>> messagesWithEmptyId = | ||
jdbcTemplate.queryForList("select * from eventuate.message where destination <> 'CDC-IGNORED' and id = ''"); | ||
|
||
List<Map<String, Object>> messagesWithNotEmptyId = | ||
jdbcTemplate.queryForList("select * from eventuate.message where destination <> 'CDC-IGNORED' and id <> ''"); | ||
|
||
Assert.assertTrue(messagesWithEmptyId.size() > 0); | ||
Assert.assertEquals(messagesWithEmptyId.size(), messagesWithNotEmptyId.size()); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
migration-tests/src/test/resources/application-mssql.properties
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
spring.datasource.url=jdbc:sqlserver://${DOCKER_HOST_IP:localhost}:1433;databaseName=eventuate | ||
spring.datasource.username=sa | ||
spring.datasource.password=Eventuate123! | ||
spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver |
4 changes: 4 additions & 0 deletions
4
migration-tests/src/test/resources/application-postgres.properties
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
spring.datasource.url=jdbc:postgresql://${DOCKER_HOST_IP:localhost}/eventuate | ||
spring.datasource.username=eventuate | ||
spring.datasource.password=eventuate | ||
spring.datasource.driver-class-name=org.postgresql.Driver |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
spring.datasource.url=jdbc:mysql://${DOCKER_HOST_IP:localhost}/eventuate | ||
spring.datasource.username=mysqluser | ||
spring.datasource.password=mysqlpw | ||
spring.datasource.driver-class-name=com.mysql.jdbc.Driver |
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