mirror of
https://github.com/google/nomulus.git
synced 2025-07-25 03:58:34 +02:00
Re-enable flyway deadlock check (#2092)
Use a system property to specify whether this check should be executed. We will update the presubmit test script to run this check only during foss-pr.
This commit is contained in:
parent
7a9668860b
commit
4db3968f85
2 changed files with 20 additions and 2 deletions
|
@ -179,6 +179,14 @@ dependencies {
|
|||
testImplementation project(path: ':common', configuration: 'testing')
|
||||
}
|
||||
|
||||
test {
|
||||
// When set, run FlywayDeadlockTest#validNewScript.
|
||||
def deadlock_check = 'do_flyway_deadlock_check'
|
||||
if (findProperty(deadlock_check)) {
|
||||
systemProperty deadlock_check, findProperty(deadlock_check)
|
||||
}
|
||||
}
|
||||
|
||||
task generateFlywayIndex {
|
||||
def flywayBase = "$projectDir/src/main/resources/sql/flyway"
|
||||
def filenamePattern = /V(\d+)__.*\.sql/
|
||||
|
|
|
@ -36,8 +36,8 @@ import java.util.Map;
|
|||
import java.util.Optional;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
|
||||
|
||||
/**
|
||||
* Checks if new Flyway scripts may cause Database deadlock.
|
||||
|
@ -53,7 +53,6 @@ import org.junit.jupiter.api.Test;
|
|||
* Therefore, we focus on 'alter' statements. However, 'create index' is a special case: if the
|
||||
* 'concurrently' modifier is not present, the indexed table is locked.
|
||||
*/
|
||||
@Disabled() // TODO(b/223669973): breaks cloudbuild.
|
||||
public class FlywayDeadlockTest {
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
|
@ -104,7 +103,18 @@ public class FlywayDeadlockTest {
|
|||
CASE_INSENSITIVE),
|
||||
3);
|
||||
|
||||
/**
|
||||
* Validates that new flyway scripts (if exist) do not have deadlock-inducing patterns.
|
||||
*
|
||||
* <p>This test may break if not invoked in a cloned Nomulus repository, therefore it is disabled
|
||||
* by default. User can enable it by setting the {@code do_flyway_deadlock_check} system property
|
||||
* with arbitrary non-empty value.
|
||||
*/
|
||||
@Test
|
||||
@EnabledIfSystemProperty(
|
||||
named = "do_flyway_deadlock_check",
|
||||
matches = ".+",
|
||||
disabledReason = "Not compatible with the release process on Cloud Build.")
|
||||
public void validateNewFlywayScripts() {
|
||||
ImmutableList<Path> newScriptPaths = findChangedFlywayScripts();
|
||||
ImmutableList<String> scriptAndLockedElements =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue