Skip to content

Commit

Permalink
fix(sql-test): Disable foreign key checks on test db cleanup (spinnak…
Browse files Browse the repository at this point in the history
…er#368)

* chore(core): Add resilience4j to core api
* fix(sql-test): Disable foreign key checks on test db cleanup
  • Loading branch information
robzienert authored Aug 26, 2019
1 parent 02b29d3 commit c827a7f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions kork-core/kork-core.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ dependencies {
api "com.netflix.spectator:spectator-api"
api "com.google.code.findbugs:jsr305"
api "javax.inject:javax.inject:1"
api "io.github.resilience4j:resilience4j-retry"

implementation "com.netflix.netflix-commons:netflix-eventbus"
implementation "com.netflix.archaius:archaius-core"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
import com.netflix.spinnaker.kork.version.ManifestVersionResolver;
import com.netflix.spinnaker.kork.version.ServiceVersion;
import com.netflix.spinnaker.kork.version.VersionResolver;
import io.github.resilience4j.retry.RetryRegistry;
import java.util.List;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
Expand All @@ -45,4 +47,10 @@ ServiceVersion serviceVersion(List<VersionResolver> versionResolvers) {
VersionResolver manifestVersionResolver() {
return new ManifestVersionResolver();
}

@Bean
@ConditionalOnMissingBean(RetryRegistry.class)
RetryRegistry retryRegistry() {
return RetryRegistry.ofDefaults();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,18 @@ public static void cleanupDb(DSLContext context) {
GlobalConfiguration configuration =
LiquibaseConfiguration.getInstance().getConfiguration(GlobalConfiguration.class);

context.execute("set foreign_key_checks=0");
context.meta().getTables().stream()
.filter(
table ->
table.getSchema().getName().equals(schema)
&& !table.getName().equals(configuration.getDatabaseChangeLogTableName())
&& !table.getName().equals(configuration.getDatabaseChangeLogLockTableName()))
.forEach(table -> context.truncate(table.getName()).execute());
.forEach(
table -> {
context.truncate(table.getName()).execute();
});
context.execute("set foreign_key_checks=1");
}

public static class TestDatabase implements Closeable {
Expand Down
5 changes: 4 additions & 1 deletion spinnaker-dependencies/spinnaker-dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ ext {
jsch : "0.0.9",
okhttp : "2.7.0",
okhttp3 : "3.14.2",
resilience4j : "0.17.0",
retrofit : "1.9.0",
retrofit2 : "2.6.1",
spectator : "0.75.0",
Expand Down Expand Up @@ -113,7 +114,9 @@ dependencies {
api("de.danielbechler:java-object-diff:0.95")
api("de.huxhorn.sulky:de.huxhorn.sulky.ulid:8.2.0")
api("dev.minutest:minutest:1.7.0")
api("io.github.resilience4j:resilience4j-retry:0.13.2")
api("io.github.resilience4j:resilience4j-kotlin:${versions.resilience4j}")
api("io.github.resilience4j:resilience4j-retry:${versions.resilience4j}")
api("io.github.resilience4j:resilience4j-spring-boot2:${versions.resilience4j}")
api("io.mockk:mockk:1.9.3")
api("io.springfox:springfox-swagger-ui:${versions.swagger}")
api("io.springfox:springfox-swagger2:${versions.swagger}")
Expand Down

0 comments on commit c827a7f

Please sign in to comment.