From e51e220a984b6ed56df20d2b23975dd72276ef21 Mon Sep 17 00:00:00 2001 From: ctingue Date: Wed, 30 Nov 2016 05:38:54 -0800 Subject: [PATCH] Log the start and finish of tests within ShardableTestCase Kokoro's logs do not identify which test is allocated to which shard, so explicitly log the test names at start and finish. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=140594581 --- ...xpandRecurringBillingEventsActionTest.java | 9 -------- .../registry/testing/ShardableTestCase.java | 22 ++++++++++++++++++- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/javatests/google/registry/batch/ExpandRecurringBillingEventsActionTest.java b/javatests/google/registry/batch/ExpandRecurringBillingEventsActionTest.java index ceb434c67..25a056903 100644 --- a/javatests/google/registry/batch/ExpandRecurringBillingEventsActionTest.java +++ b/javatests/google/registry/batch/ExpandRecurringBillingEventsActionTest.java @@ -44,7 +44,6 @@ import google.registry.testing.ExceptionRule; import google.registry.testing.FakeClock; import google.registry.testing.FakeResponse; import google.registry.testing.mapreduce.MapreduceTestCase; -import google.registry.util.FormattingLogger; import java.util.ArrayList; import java.util.List; import org.joda.money.Money; @@ -52,12 +51,10 @@ import org.joda.time.DateTime; import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import org.junit.rules.TestName; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; /** Unit tests for {@link ExpandRecurringBillingEventsAction}. */ -// The logger in this class is temporary, necessary for diagnosing some odd test failure behavior. @RunWith(JUnit4.class) public class ExpandRecurringBillingEventsActionTest extends MapreduceTestCase { @@ -65,11 +62,6 @@ public class ExpandRecurringBillingEventsActionTest @Rule public final ExceptionRule thrown = new ExceptionRule(); - @Rule - public TestName testName = new TestName(); - - private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); - final FakeClock clock = new FakeClock(DateTime.parse("2000-10-02T00:00:00Z")); DomainResource domain; @@ -78,7 +70,6 @@ public class ExpandRecurringBillingEventsActionTest @Before public void init() { - logger.infofmt("Running test %s", testName.getMethodName()); action = new ExpandRecurringBillingEventsAction(); action.mrRunner = makeDefaultRunner(); action.clock = clock; diff --git a/javatests/google/registry/testing/ShardableTestCase.java b/javatests/google/registry/testing/ShardableTestCase.java index 2d1ce7400..90c1332d1 100644 --- a/javatests/google/registry/testing/ShardableTestCase.java +++ b/javatests/google/registry/testing/ShardableTestCase.java @@ -14,16 +14,36 @@ package google.registry.testing; +import google.registry.util.FormattingLogger; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TestName; /** * Test case with 3 empty methods. * - * The sharding test runner fails if it produces an empty shard, and we shard 4 ways. This makes + *

The sharding test runner fails if it produces an empty shard, and we shard 4 ways. This makes * sure that we never produces empty shards. */ public abstract class ShardableTestCase { + private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); + + @Rule + public final TestName testName = new TestName(); + + @Before + public void beforeShardable() { + logger.infofmt("Starting test %s", testName.getMethodName()); + } + + @After + public void afterShardable() { + logger.infofmt("Finishing test %s", testName.getMethodName()); + } + @Test public void testNothing1() {}