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
This commit is contained in:
Michael Muller 2022-05-25 09:47:05 -04:00 committed by GitHub
parent 5f1643cca3
commit cdcf7dfae8
3 changed files with 5 additions and 8 deletions

View file

@ -1,3 +1,4 @@
// Copyright 2020 The Nomulus Authors. All Rights Reserved. // Copyright 2020 The Nomulus Authors. All Rights Reserved.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
@ -64,15 +65,13 @@ class DualDatabaseTestInvocationContextProvider implements TestTemplateInvocatio
@Override @Override
public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts( public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(
ExtensionContext context) { ExtensionContext context) {
TestTemplateInvocationContext ofyContext =
createInvocationContext(context.getDisplayName() + " with Datastore", DatabaseType.OFY);
TestTemplateInvocationContext sqlContext = TestTemplateInvocationContext sqlContext =
createInvocationContext(context.getDisplayName() + " with PostgreSQL", DatabaseType.JPA); createInvocationContext(context.getDisplayName() + " with PostgreSQL", DatabaseType.JPA);
Method testMethod = context.getTestMethod().orElseThrow(IllegalStateException::new); Method testMethod = context.getTestMethod().orElseThrow(IllegalStateException::new);
if (testMethod.isAnnotationPresent(TestOfyAndSql.class)) { if (testMethod.isAnnotationPresent(TestOfyAndSql.class)) {
return Stream.of(ofyContext, sqlContext); return Stream.of(sqlContext);
} else if (testMethod.isAnnotationPresent(TestOfyOnly.class)) { } else if (testMethod.isAnnotationPresent(TestOfyOnly.class)) {
return Stream.of(ofyContext); throw new RuntimeException("Ofy-only test invoked.");
} else if (testMethod.isAnnotationPresent(TestSqlOnly.class)) { } else if (testMethod.isAnnotationPresent(TestSqlOnly.class)) {
return Stream.of(sqlContext); return Stream.of(sqlContext);
} else { } else {

View file

@ -73,10 +73,10 @@ public class DualDatabaseTestInvocationContextProviderTest {
@AfterAll @AfterAll
static void assertEachTransactionManagerIsUsed() { static void assertEachTransactionManagerIsUsed() {
assertThat(testBothDbsOfyCounter).isEqualTo(1); assertThat(testBothDbsOfyCounter).isEqualTo(0);
assertThat(testBothDbsSqlCounter).isEqualTo(1); assertThat(testBothDbsSqlCounter).isEqualTo(1);
assertThat(testOfyOnlyOfyCounter).isEqualTo(1); assertThat(testOfyOnlyOfyCounter).isEqualTo(0);
assertThat(testOfyOnlySqlCounter).isEqualTo(0); assertThat(testOfyOnlySqlCounter).isEqualTo(0);
assertThat(testSqlOnlyOfyCounter).isEqualTo(0); assertThat(testSqlOnlyOfyCounter).isEqualTo(0);

View file

@ -19,10 +19,8 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import org.junit.jupiter.api.TestTemplate;
/** Annotation to indicate a test method will be executed only with Datastore. */ /** Annotation to indicate a test method will be executed only with Datastore. */
@Target({METHOD}) @Target({METHOD})
@Retention(RUNTIME) @Retention(RUNTIME)
@TestTemplate
public @interface TestOfyOnly {} public @interface TestOfyOnly {}