From 80e71de72337f5977d6e3d72fdb543dbf7e3545b Mon Sep 17 00:00:00 2001 From: weiminyu Date: Fri, 18 Jan 2019 13:26:44 -0800 Subject: [PATCH] Add debug logging to AppEngineRule ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=229983437 --- javatests/google/registry/testing/AppEngineRule.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/javatests/google/registry/testing/AppEngineRule.java b/javatests/google/registry/testing/AppEngineRule.java index 2a40fc0c6..11a499c37 100644 --- a/javatests/google/registry/testing/AppEngineRule.java +++ b/javatests/google/registry/testing/AppEngineRule.java @@ -32,6 +32,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; +import com.google.common.flogger.FluentLogger; import com.google.common.io.Files; import com.googlecode.objectify.ObjectifyFilter; import google.registry.model.ofy.ObjectifyService; @@ -70,6 +71,8 @@ import org.junit.runners.model.Statement; */ public final class AppEngineRule extends ExternalResource { + private static final FluentLogger logger = FluentLogger.forEnclosingClass(); + public static final String NEW_REGISTRAR_GAE_USER_ID = "666"; public static final String THE_REGISTRAR_GAE_USER_ID = "31337"; @@ -346,7 +349,14 @@ public final class AppEngineRule extends ExternalResource { try { // To normalize the indexes, we are going to pass them through JSON and then rewrite the xml. JSONObject datastoreIndexes = new JSONObject(); - Object indexes = toJSONObject(indexFile).get("datastore-indexes"); + JSONObject indexFileObject = toJSONObject(indexFile); + if (!indexFileObject.has("datastore-indexes")) { + // Log for flaky appearance. We suspect that this is not a problem but need to inspect + // the content of this file to make sure. + // TODO(weiminyu): inspect file content and decide if this should be ignored. + logger.atWarning().log("Unexpected datastore-indexes-auto.xml:\n%s", indexFileObject); + } + Object indexes = indexFileObject.get("datastore-indexes"); if (indexes instanceof JSONObject) { datastoreIndexes = (JSONObject) indexes; }