diff --git a/buildSrc/gradle/dependency-locks/buildscript-classpath.lockfile b/buildSrc/gradle/dependency-locks/buildscript-classpath.lockfile index f03c6a7b4..06943c1ac 100644 --- a/buildSrc/gradle/dependency-locks/buildscript-classpath.lockfile +++ b/buildSrc/gradle/dependency-locks/buildscript-classpath.lockfile @@ -16,7 +16,7 @@ com.jcraft:jsch:0.1.54 com.jcraft:jzlib:1.1.1 com.netflix.nebula:gradle-lint-plugin:10.4.2 com.netflix.nebula:nebula-gradle-interop:1.0.11 -com.netflix.nebula:nebula-test:7.3.0 +com.netflix.nebula:nebula-test:7.4.0 commons-codec:commons-codec:1.9 commons-io:commons-io:2.5 commons-lang:commons-lang:2.6 @@ -41,7 +41,7 @@ org.apache.maven:maven-builder-support:3.6.2 org.apache.maven:maven-model-builder:3.6.2 org.apache.maven:maven-model:3.6.2 org.codehaus.gpars:gpars:1.2.1 -org.codehaus.groovy:groovy-all:2.4.9 +org.codehaus.groovy:groovy-all:2.4.15 org.codehaus.groovy:groovy-ant:2.1.8 org.codehaus.groovy:groovy-groovydoc:2.1.8 org.codehaus.groovy:groovy-templates:2.1.8 @@ -65,4 +65,4 @@ org.multiverse:multiverse-core:0.7.0 org.objenesis:objenesis:2.4 org.ow2.asm:asm:7.0 org.slf4j:slf4j-api:1.7.2 -org.spockframework:spock-core:1.1-groovy-2.4-rc-4 +org.spockframework:spock-core:1.3-groovy-2.4 diff --git a/config/dependency-license/allowed_licenses.json b/config/dependency-license/allowed_licenses.json index 15c5b2efb..0f1114e4e 100644 --- a/config/dependency-license/allowed_licenses.json +++ b/config/dependency-license/allowed_licenses.json @@ -90,6 +90,9 @@ { "moduleLicense": "The BSD License" }, + { + "moduleLicense": "The New BSD License" + }, { "moduleLicense": "The PostgreSQL License" }, @@ -198,6 +201,9 @@ { "moduleLicense": "The MIT license" }, + { + "moduleLicense": "The MIT License (MIT)" + }, { "moduleLicense": "The PostgreSQL License" }, diff --git a/core/build.gradle b/core/build.gradle index 3722e1e8c..160907558 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -192,7 +192,7 @@ dependencies { compile deps['com.jcraft:jsch'] testCompile deps['com.thoughtworks.qdox:qdox'] compile deps['dnsjava:dnsjava'] - runtime deps['org.glassfish.jaxb:jaxb-runtime'] + testCompile deps['io.github.classgraph:classgraph'] testCompile deps['javax.annotation:jsr250-api'] compile deps['javax.inject:javax.inject'] compile deps['javax.mail:mail'] @@ -218,6 +218,7 @@ dependencies { compile deps['org.bouncycastle:bcpg-jdk15on'] testCompile deps['org.bouncycastle:bcpkix-jdk15on'] compile deps['org.bouncycastle:bcprov-jdk15on'] + runtime deps['org.glassfish.jaxb:jaxb-runtime'] compile deps['org.joda:joda-money'] compile deps['org.json:json'] testCompile deps['org.mortbay.jetty:jetty'] @@ -606,6 +607,15 @@ task outcastTest(type: FilteringTest) { maxParallelForks 5 } +// Dedicated test suite for schema-dependent tests. +task sqlIntegrationTest(type: Test) { + include 'google/registry/schema/integration/SqlIntegrationTestSuite.*' + // Copied from FilteringTest. Not inheriting b/c it excludes TestSuites. + if (project.testFilter) { + testNameIncludePatterns = project.testFilter.split(',') + } +} + task findGoldenImages(type: JavaExec) { classpath = sourceSets.test.runtimeClasspath main = 'google.registry.webdriver.GoldenImageFinder' diff --git a/core/gradle/dependency-locks/testCompile.lockfile b/core/gradle/dependency-locks/testCompile.lockfile index a7d8484a1..8148dd55a 100644 --- a/core/gradle/dependency-locks/testCompile.lockfile +++ b/core/gradle/dependency-locks/testCompile.lockfile @@ -130,6 +130,7 @@ commons-codec:commons-codec:1.11 commons-logging:commons-logging:1.2 dnsjava:dnsjava:2.1.7 io.dropwizard.metrics:metrics-core:3.1.2 +io.github.classgraph:classgraph:4.8.52 io.grpc:grpc-all:1.17.1 io.grpc:grpc-alts:1.17.1 io.grpc:grpc-auth:1.17.1 diff --git a/core/gradle/dependency-locks/testCompileClasspath.lockfile b/core/gradle/dependency-locks/testCompileClasspath.lockfile index 88ce3055c..80976118c 100644 --- a/core/gradle/dependency-locks/testCompileClasspath.lockfile +++ b/core/gradle/dependency-locks/testCompileClasspath.lockfile @@ -129,6 +129,7 @@ commons-codec:commons-codec:1.11 commons-logging:commons-logging:1.2 dnsjava:dnsjava:2.1.7 io.dropwizard.metrics:metrics-core:3.1.2 +io.github.classgraph:classgraph:4.8.52 io.grpc:grpc-all:1.17.1 io.grpc:grpc-alts:1.17.1 io.grpc:grpc-auth:1.17.1 diff --git a/core/gradle/dependency-locks/testRuntime.lockfile b/core/gradle/dependency-locks/testRuntime.lockfile index 9217c15c2..ac015816f 100644 --- a/core/gradle/dependency-locks/testRuntime.lockfile +++ b/core/gradle/dependency-locks/testRuntime.lockfile @@ -141,6 +141,7 @@ commons-codec:commons-codec:1.11 commons-logging:commons-logging:1.2 dnsjava:dnsjava:2.1.7 io.dropwizard.metrics:metrics-core:3.1.2 +io.github.classgraph:classgraph:4.8.52 io.grpc:grpc-all:1.17.1 io.grpc:grpc-alts:1.17.1 io.grpc:grpc-auth:1.17.1 diff --git a/core/gradle/dependency-locks/testRuntimeClasspath.lockfile b/core/gradle/dependency-locks/testRuntimeClasspath.lockfile index 9217c15c2..ac015816f 100644 --- a/core/gradle/dependency-locks/testRuntimeClasspath.lockfile +++ b/core/gradle/dependency-locks/testRuntimeClasspath.lockfile @@ -141,6 +141,7 @@ commons-codec:commons-codec:1.11 commons-logging:commons-logging:1.2 dnsjava:dnsjava:2.1.7 io.dropwizard.metrics:metrics-core:3.1.2 +io.github.classgraph:classgraph:4.8.52 io.grpc:grpc-all:1.17.1 io.grpc:grpc-alts:1.17.1 io.grpc:grpc-auth:1.17.1 diff --git a/core/src/test/java/google/registry/schema/integration/SqlIntegrationMembershipTest.java b/core/src/test/java/google/registry/schema/integration/SqlIntegrationMembershipTest.java new file mode 100644 index 000000000..6a76e851d --- /dev/null +++ b/core/src/test/java/google/registry/schema/integration/SqlIntegrationMembershipTest.java @@ -0,0 +1,81 @@ +// Copyright 2018 The Nomulus Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package google.registry.schema.integration; + +import static com.google.common.truth.Truth.assertWithMessage; + +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; +import com.google.common.collect.Sets.SetView; +import google.registry.model.transaction.JpaTransactionManagerRule; +import io.github.classgraph.ClassGraph; +import io.github.classgraph.ScanResult; +import java.lang.reflect.Field; +import java.util.stream.Stream; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.junit.runners.Suite.SuiteClasses; + +/** + * Verifies that all tests that depends on the Cloud SQL schema are included in the project's + * sqlIntegrationTest suite. Names of the test classes is set to the 'test.sqlIntergrationTests' + * system property as a comma-separated string. + * + *

A test is deemed dependent on the SQL schema iff it has a field with type {@link + * JpaTransactionManagerRule}. + */ +// TODO(weiminyu): consider generating a TestSuite class instead. +@RunWith(JUnit4.class) +public class SqlIntegrationMembershipTest { + + @Test + public void sqlIntegrationMembershipComplete() { + ImmutableSet sqlDependentTests; + try (ScanResult scanResult = + new ClassGraph() + .enableAnnotationInfo() + .whitelistPackages("google.registry") + .scan()) { + sqlDependentTests = + scanResult.getClassesWithAnnotation(RunWith.class.getName()).stream() + .filter(clazz -> clazz.getSimpleName().endsWith("Test")) + .map(clazz -> clazz.loadClass()) + .filter(SqlIntegrationMembershipTest::isSqlDependent) + .map(Class::getName) + .collect(ImmutableSet.toImmutableSet()); + } + ImmutableSet declaredTests = + Stream.of(SqlIntegrationTestSuite.class.getAnnotation(SuiteClasses.class).value()) + .map(Class::getName) + .collect(ImmutableSet.toImmutableSet()); + SetView undeclaredTests = Sets.difference(sqlDependentTests, declaredTests); + assertWithMessage( + "Undeclared sql-dependent tests found. " + + "Please add them to SqlIntegrationTestSuite.java.") + .that(undeclaredTests) + .isEmpty(); + SetView unnecessaryDeclarations = Sets.difference(declaredTests, sqlDependentTests); + assertWithMessage("Found tests that should not be included in SqlIntegrationTestSuite.java.") + .that(unnecessaryDeclarations) + .isEmpty(); + } + + private static boolean isSqlDependent(Class testClass) { + return Stream.of(testClass.getDeclaredFields()) + .map(Field::getType) + .anyMatch(JpaTransactionManagerRule.class::equals); + } +} diff --git a/core/src/test/java/google/registry/schema/integration/SqlIntegrationTestSuite.java b/core/src/test/java/google/registry/schema/integration/SqlIntegrationTestSuite.java new file mode 100644 index 000000000..8c543208d --- /dev/null +++ b/core/src/test/java/google/registry/schema/integration/SqlIntegrationTestSuite.java @@ -0,0 +1,52 @@ +// Copyright 2018 The Nomulus Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package google.registry.schema.integration; + +import google.registry.model.registry.RegistryLockDaoTest; +import google.registry.model.tmch.ClaimsListDaoTest; +import google.registry.model.transaction.JpaTransactionManagerImplTest; +import google.registry.model.transaction.JpaTransactionManagerRuleTest; +import google.registry.persistence.BloomFilterConverterTest; +import google.registry.persistence.CreateAutoTimestampConverterTest; +import google.registry.persistence.UpdateAutoTimestampConverterTest; +import google.registry.persistence.ZonedDateTimeConverterTest; +import google.registry.schema.tld.PremiumListDaoTest; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +/** + * Groups all tests that may depends on Cloud SQL schema. They will be run for server-schema + * compatibility check. + * + *

Schema dependency is approximated by the use of {@link + * google.registry.model.transaction.JpaTransactionManagerRule}. + * + * @see SqlIntegrationMembershipTest + */ +// TODO(weiminyu): refactor JpaTransactionManagerRule to eliminate false positives. +@RunWith(Suite.class) +@SuiteClasses({ + BloomFilterConverterTest.class, + ClaimsListDaoTest.class, + CreateAutoTimestampConverterTest.class, + JpaTransactionManagerImplTest.class, + JpaTransactionManagerRuleTest.class, + PremiumListDaoTest.class, + RegistryLockDaoTest.class, + UpdateAutoTimestampConverterTest.class, + ZonedDateTimeConverterTest.class +}) +public class SqlIntegrationTestSuite {} diff --git a/dependencies.gradle b/dependencies.gradle index 6f893cf07..7100f014c 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -79,6 +79,7 @@ ext { 'com.sun.xml.bind:jaxb-xjc:2.2.11', 'com.thoughtworks.qdox:qdox:1.12.1', 'dnsjava:dnsjava:2.1.7', + 'io.github.classgraph:classgraph:4.8.52', 'io.github.java-diff-utils:java-diff-utils:4.0', 'io.netty:netty-buffer:4.1.31.Final', 'io.netty:netty-codec:4.1.31.Final', diff --git a/prober/gradle/dependency-locks/testCompile.lockfile b/prober/gradle/dependency-locks/testCompile.lockfile index c6357bed9..138f69558 100644 --- a/prober/gradle/dependency-locks/testCompile.lockfile +++ b/prober/gradle/dependency-locks/testCompile.lockfile @@ -141,6 +141,7 @@ commons-codec:commons-codec:1.11 commons-logging:commons-logging:1.2 dnsjava:dnsjava:2.1.7 io.dropwizard.metrics:metrics-core:3.1.2 +io.github.classgraph:classgraph:4.8.52 io.grpc:grpc-all:1.17.1 io.grpc:grpc-alts:1.17.1 io.grpc:grpc-auth:1.17.1 diff --git a/prober/gradle/dependency-locks/testCompileClasspath.lockfile b/prober/gradle/dependency-locks/testCompileClasspath.lockfile index 7fa66cf48..e37db3e05 100644 --- a/prober/gradle/dependency-locks/testCompileClasspath.lockfile +++ b/prober/gradle/dependency-locks/testCompileClasspath.lockfile @@ -130,6 +130,7 @@ commons-codec:commons-codec:1.11 commons-logging:commons-logging:1.2 dnsjava:dnsjava:2.1.7 io.dropwizard.metrics:metrics-core:3.1.2 +io.github.classgraph:classgraph:4.8.52 io.grpc:grpc-all:1.17.1 io.grpc:grpc-alts:1.17.1 io.grpc:grpc-auth:1.17.1 diff --git a/prober/gradle/dependency-locks/testRuntime.lockfile b/prober/gradle/dependency-locks/testRuntime.lockfile index df87aa16f..0167ab6c8 100644 --- a/prober/gradle/dependency-locks/testRuntime.lockfile +++ b/prober/gradle/dependency-locks/testRuntime.lockfile @@ -141,6 +141,7 @@ commons-codec:commons-codec:1.11 commons-logging:commons-logging:1.2 dnsjava:dnsjava:2.1.7 io.dropwizard.metrics:metrics-core:3.1.2 +io.github.classgraph:classgraph:4.8.52 io.grpc:grpc-all:1.17.1 io.grpc:grpc-alts:1.17.1 io.grpc:grpc-auth:1.17.1 diff --git a/prober/gradle/dependency-locks/testRuntimeClasspath.lockfile b/prober/gradle/dependency-locks/testRuntimeClasspath.lockfile index df87aa16f..0167ab6c8 100644 --- a/prober/gradle/dependency-locks/testRuntimeClasspath.lockfile +++ b/prober/gradle/dependency-locks/testRuntimeClasspath.lockfile @@ -141,6 +141,7 @@ commons-codec:commons-codec:1.11 commons-logging:commons-logging:1.2 dnsjava:dnsjava:2.1.7 io.dropwizard.metrics:metrics-core:3.1.2 +io.github.classgraph:classgraph:4.8.52 io.grpc:grpc-all:1.17.1 io.grpc:grpc-alts:1.17.1 io.grpc:grpc-auth:1.17.1 diff --git a/proxy/gradle/dependency-locks/testCompile.lockfile b/proxy/gradle/dependency-locks/testCompile.lockfile index c6357bed9..138f69558 100644 --- a/proxy/gradle/dependency-locks/testCompile.lockfile +++ b/proxy/gradle/dependency-locks/testCompile.lockfile @@ -141,6 +141,7 @@ commons-codec:commons-codec:1.11 commons-logging:commons-logging:1.2 dnsjava:dnsjava:2.1.7 io.dropwizard.metrics:metrics-core:3.1.2 +io.github.classgraph:classgraph:4.8.52 io.grpc:grpc-all:1.17.1 io.grpc:grpc-alts:1.17.1 io.grpc:grpc-auth:1.17.1 diff --git a/proxy/gradle/dependency-locks/testCompileClasspath.lockfile b/proxy/gradle/dependency-locks/testCompileClasspath.lockfile index 7fa66cf48..e37db3e05 100644 --- a/proxy/gradle/dependency-locks/testCompileClasspath.lockfile +++ b/proxy/gradle/dependency-locks/testCompileClasspath.lockfile @@ -130,6 +130,7 @@ commons-codec:commons-codec:1.11 commons-logging:commons-logging:1.2 dnsjava:dnsjava:2.1.7 io.dropwizard.metrics:metrics-core:3.1.2 +io.github.classgraph:classgraph:4.8.52 io.grpc:grpc-all:1.17.1 io.grpc:grpc-alts:1.17.1 io.grpc:grpc-auth:1.17.1 diff --git a/proxy/gradle/dependency-locks/testRuntime.lockfile b/proxy/gradle/dependency-locks/testRuntime.lockfile index df87aa16f..0167ab6c8 100644 --- a/proxy/gradle/dependency-locks/testRuntime.lockfile +++ b/proxy/gradle/dependency-locks/testRuntime.lockfile @@ -141,6 +141,7 @@ commons-codec:commons-codec:1.11 commons-logging:commons-logging:1.2 dnsjava:dnsjava:2.1.7 io.dropwizard.metrics:metrics-core:3.1.2 +io.github.classgraph:classgraph:4.8.52 io.grpc:grpc-all:1.17.1 io.grpc:grpc-alts:1.17.1 io.grpc:grpc-auth:1.17.1 diff --git a/proxy/gradle/dependency-locks/testRuntimeClasspath.lockfile b/proxy/gradle/dependency-locks/testRuntimeClasspath.lockfile index df87aa16f..0167ab6c8 100644 --- a/proxy/gradle/dependency-locks/testRuntimeClasspath.lockfile +++ b/proxy/gradle/dependency-locks/testRuntimeClasspath.lockfile @@ -141,6 +141,7 @@ commons-codec:commons-codec:1.11 commons-logging:commons-logging:1.2 dnsjava:dnsjava:2.1.7 io.dropwizard.metrics:metrics-core:3.1.2 +io.github.classgraph:classgraph:4.8.52 io.grpc:grpc-all:1.17.1 io.grpc:grpc-alts:1.17.1 io.grpc:grpc-auth:1.17.1 diff --git a/util/gradle/dependency-locks/testCompile.lockfile b/util/gradle/dependency-locks/testCompile.lockfile index 9217c15c2..ac015816f 100644 --- a/util/gradle/dependency-locks/testCompile.lockfile +++ b/util/gradle/dependency-locks/testCompile.lockfile @@ -141,6 +141,7 @@ commons-codec:commons-codec:1.11 commons-logging:commons-logging:1.2 dnsjava:dnsjava:2.1.7 io.dropwizard.metrics:metrics-core:3.1.2 +io.github.classgraph:classgraph:4.8.52 io.grpc:grpc-all:1.17.1 io.grpc:grpc-alts:1.17.1 io.grpc:grpc-auth:1.17.1 diff --git a/util/gradle/dependency-locks/testCompileClasspath.lockfile b/util/gradle/dependency-locks/testCompileClasspath.lockfile index d61ec8a91..6e85ba58a 100644 --- a/util/gradle/dependency-locks/testCompileClasspath.lockfile +++ b/util/gradle/dependency-locks/testCompileClasspath.lockfile @@ -130,6 +130,7 @@ commons-codec:commons-codec:1.11 commons-logging:commons-logging:1.2 dnsjava:dnsjava:2.1.7 io.dropwizard.metrics:metrics-core:3.1.2 +io.github.classgraph:classgraph:4.8.52 io.grpc:grpc-all:1.17.1 io.grpc:grpc-alts:1.17.1 io.grpc:grpc-auth:1.17.1 diff --git a/util/gradle/dependency-locks/testRuntime.lockfile b/util/gradle/dependency-locks/testRuntime.lockfile index 9217c15c2..ac015816f 100644 --- a/util/gradle/dependency-locks/testRuntime.lockfile +++ b/util/gradle/dependency-locks/testRuntime.lockfile @@ -141,6 +141,7 @@ commons-codec:commons-codec:1.11 commons-logging:commons-logging:1.2 dnsjava:dnsjava:2.1.7 io.dropwizard.metrics:metrics-core:3.1.2 +io.github.classgraph:classgraph:4.8.52 io.grpc:grpc-all:1.17.1 io.grpc:grpc-alts:1.17.1 io.grpc:grpc-auth:1.17.1 diff --git a/util/gradle/dependency-locks/testRuntimeClasspath.lockfile b/util/gradle/dependency-locks/testRuntimeClasspath.lockfile index 9217c15c2..ac015816f 100644 --- a/util/gradle/dependency-locks/testRuntimeClasspath.lockfile +++ b/util/gradle/dependency-locks/testRuntimeClasspath.lockfile @@ -141,6 +141,7 @@ commons-codec:commons-codec:1.11 commons-logging:commons-logging:1.2 dnsjava:dnsjava:2.1.7 io.dropwizard.metrics:metrics-core:3.1.2 +io.github.classgraph:classgraph:4.8.52 io.grpc:grpc-all:1.17.1 io.grpc:grpc-alts:1.17.1 io.grpc:grpc-auth:1.17.1