From cdcf7dfae8f5b422dbc51f83189e9d1609c3d7e8 Mon Sep 17 00:00:00 2001 From: Michael Muller Date: Wed, 25 May 2022 09:47:05 -0400 Subject: [PATCH] Disable Ofy tests. (#1644) * Disable Ofy tests. This change just turns off the Ofy tests at the root, by removing processing for dual tests and disassociating the TestOfyOnly annotation from test annotations. This is far less comprehensive than #1631, but it's probably worth entering as a stopgap solution just because it should speed up our test runs and unblock a lot of other cleanup work. * Fix DualDatabaseTestInvocationContextProviderTest --- .../testing/DualDatabaseTestInvocationContextProvider.java | 7 +++---- .../DualDatabaseTestInvocationContextProviderTest.java | 4 ++-- .../src/test/java/google/registry/testing/TestOfyOnly.java | 2 -- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/core/src/test/java/google/registry/testing/DualDatabaseTestInvocationContextProvider.java b/core/src/test/java/google/registry/testing/DualDatabaseTestInvocationContextProvider.java index 3f31d4498..4649cf4b3 100644 --- a/core/src/test/java/google/registry/testing/DualDatabaseTestInvocationContextProvider.java +++ b/core/src/test/java/google/registry/testing/DualDatabaseTestInvocationContextProvider.java @@ -1,3 +1,4 @@ + // Copyright 2020 The Nomulus Authors. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -64,15 +65,13 @@ class DualDatabaseTestInvocationContextProvider implements TestTemplateInvocatio @Override public Stream provideTestTemplateInvocationContexts( ExtensionContext context) { - TestTemplateInvocationContext ofyContext = - createInvocationContext(context.getDisplayName() + " with Datastore", DatabaseType.OFY); TestTemplateInvocationContext sqlContext = createInvocationContext(context.getDisplayName() + " with PostgreSQL", DatabaseType.JPA); Method testMethod = context.getTestMethod().orElseThrow(IllegalStateException::new); if (testMethod.isAnnotationPresent(TestOfyAndSql.class)) { - return Stream.of(ofyContext, sqlContext); + return Stream.of(sqlContext); } else if (testMethod.isAnnotationPresent(TestOfyOnly.class)) { - return Stream.of(ofyContext); + throw new RuntimeException("Ofy-only test invoked."); } else if (testMethod.isAnnotationPresent(TestSqlOnly.class)) { return Stream.of(sqlContext); } else { diff --git a/core/src/test/java/google/registry/testing/DualDatabaseTestInvocationContextProviderTest.java b/core/src/test/java/google/registry/testing/DualDatabaseTestInvocationContextProviderTest.java index 3e037a507..f42cb516a 100644 --- a/core/src/test/java/google/registry/testing/DualDatabaseTestInvocationContextProviderTest.java +++ b/core/src/test/java/google/registry/testing/DualDatabaseTestInvocationContextProviderTest.java @@ -73,10 +73,10 @@ public class DualDatabaseTestInvocationContextProviderTest { @AfterAll static void assertEachTransactionManagerIsUsed() { - assertThat(testBothDbsOfyCounter).isEqualTo(1); + assertThat(testBothDbsOfyCounter).isEqualTo(0); assertThat(testBothDbsSqlCounter).isEqualTo(1); - assertThat(testOfyOnlyOfyCounter).isEqualTo(1); + assertThat(testOfyOnlyOfyCounter).isEqualTo(0); assertThat(testOfyOnlySqlCounter).isEqualTo(0); assertThat(testSqlOnlyOfyCounter).isEqualTo(0); diff --git a/core/src/test/java/google/registry/testing/TestOfyOnly.java b/core/src/test/java/google/registry/testing/TestOfyOnly.java index 7a74cc5d3..c90f5b699 100644 --- a/core/src/test/java/google/registry/testing/TestOfyOnly.java +++ b/core/src/test/java/google/registry/testing/TestOfyOnly.java @@ -19,10 +19,8 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; import java.lang.annotation.Retention; import java.lang.annotation.Target; -import org.junit.jupiter.api.TestTemplate; /** Annotation to indicate a test method will be executed only with Datastore. */ @Target({METHOD}) @Retention(RUNTIME) -@TestTemplate public @interface TestOfyOnly {}