Enable optional DEBUG level logs for query tests
Allow optionally enabling DEBUG level logs for Lucene and Elasticsearch query tests. It occurs in the form of a command passed to the JVM before tests start. Tests will only emit INFO level logs if not enabled. Enable rootLogger default INFO log level after tests conclude. Add missing log4j-config rule which includes log4j.properties in BUILD files. Update online Gerrit documentation to explain how to optionally enable DEBUG log level for these specific tests. Bug: Issue 10498 Change-Id: I75492de1c5ef8721ae745266e36b8cbfb0b67682
This commit is contained in:
@@ -389,6 +389,21 @@ If Docker is not available, the Elasticsearch tests will be skipped.
|
|||||||
Note that Bazel currently does not show
|
Note that Bazel currently does not show
|
||||||
link:https://github.com/bazelbuild/bazel/issues/3476[the skipped tests].
|
link:https://github.com/bazelbuild/bazel/issues/3476[the skipped tests].
|
||||||
|
|
||||||
|
[[debug]]
|
||||||
|
=== Index Query Tests
|
||||||
|
|
||||||
|
The `DEBUG` log level can optionally be enabled for the index query tests. That log level applies to
|
||||||
|
both Elasticsearch and Lucene tests.
|
||||||
|
|
||||||
|
In Eclipse, set `-Ddebug=true` as a VM argument under the Run Configuration's `Arguments` tab.
|
||||||
|
|
||||||
|
With `bazel`, here is an example for the Lucene `account` test:
|
||||||
|
|
||||||
|
----
|
||||||
|
bazel test --jvmopt='-Ddebug=true' \
|
||||||
|
javatests/com/google/gerrit/server/query/account:lucene_query_test
|
||||||
|
----
|
||||||
|
|
||||||
== Dependencies
|
== Dependencies
|
||||||
|
|
||||||
Dependency JARs are normally downloaded as needed, but you can
|
Dependency JARs are normally downloaded as needed, but you can
|
||||||
|
|||||||
@@ -91,10 +91,14 @@ import java.util.HashMap;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import org.apache.log4j.Level;
|
||||||
|
import org.apache.log4j.LogManager;
|
||||||
import org.eclipse.jgit.lib.PersonIdent;
|
import org.eclipse.jgit.lib.PersonIdent;
|
||||||
import org.eclipse.jgit.lib.Repository;
|
import org.eclipse.jgit.lib.Repository;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
import org.junit.AfterClass;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@@ -146,6 +150,20 @@ public abstract class AbstractQueryAccountsTest extends GerritServerTests {
|
|||||||
|
|
||||||
protected abstract Injector createInjector();
|
protected abstract Injector createInjector();
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setLogLevel() {
|
||||||
|
if (Boolean.getBoolean("debug")) {
|
||||||
|
LogManager.getRootLogger().setLevel(Level.DEBUG);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void resetLogLevel() {
|
||||||
|
if (Boolean.getBoolean("debug")) {
|
||||||
|
LogManager.getRootLogger().setLevel(Level.INFO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUpInjector() throws Exception {
|
public void setUpInjector() throws Exception {
|
||||||
lifecycle = new LifecycleManager();
|
lifecycle = new LifecycleManager();
|
||||||
|
|||||||
@@ -19,9 +19,11 @@ java_library(
|
|||||||
"//lib:guava",
|
"//lib:guava",
|
||||||
"//lib/guice",
|
"//lib/guice",
|
||||||
"//lib/jgit/org.eclipse.jgit:jgit",
|
"//lib/jgit/org.eclipse.jgit:jgit",
|
||||||
|
"//lib/log:log4j",
|
||||||
"//lib/truth",
|
"//lib/truth",
|
||||||
"//lib/truth:truth-java8-extension",
|
"//lib/truth:truth-java8-extension",
|
||||||
"//prolog:gerrit-prolog-common",
|
"//prolog:gerrit-prolog-common",
|
||||||
|
"//resources:log4j-config",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -139,6 +139,8 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import org.apache.log4j.Level;
|
||||||
|
import org.apache.log4j.LogManager;
|
||||||
import org.eclipse.jgit.junit.TestRepository;
|
import org.eclipse.jgit.junit.TestRepository;
|
||||||
import org.eclipse.jgit.lib.ObjectId;
|
import org.eclipse.jgit.lib.ObjectId;
|
||||||
import org.eclipse.jgit.lib.ObjectInserter;
|
import org.eclipse.jgit.lib.ObjectInserter;
|
||||||
@@ -150,7 +152,9 @@ import org.eclipse.jgit.revwalk.RevCommit;
|
|||||||
import org.eclipse.jgit.revwalk.RevWalk;
|
import org.eclipse.jgit.revwalk.RevWalk;
|
||||||
import org.eclipse.jgit.util.SystemReader;
|
import org.eclipse.jgit.util.SystemReader;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
import org.junit.AfterClass;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@@ -214,6 +218,20 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
|
|
||||||
protected abstract Injector createInjector();
|
protected abstract Injector createInjector();
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setLogLevel() {
|
||||||
|
if (Boolean.getBoolean("debug")) {
|
||||||
|
LogManager.getRootLogger().setLevel(Level.DEBUG);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void resetLogLevel() {
|
||||||
|
if (Boolean.getBoolean("debug")) {
|
||||||
|
LogManager.getRootLogger().setLevel(Level.INFO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUpInjector() throws Exception {
|
public void setUpInjector() throws Exception {
|
||||||
lifecycle = new LifecycleManager();
|
lifecycle = new LifecycleManager();
|
||||||
|
|||||||
@@ -26,7 +26,9 @@ java_library(
|
|||||||
"//lib/guice",
|
"//lib/guice",
|
||||||
"//lib/jgit/org.eclipse.jgit:jgit",
|
"//lib/jgit/org.eclipse.jgit:jgit",
|
||||||
"//lib/jgit/org.eclipse.jgit.junit:junit",
|
"//lib/jgit/org.eclipse.jgit.junit:junit",
|
||||||
|
"//lib/log:log4j",
|
||||||
"//lib/truth",
|
"//lib/truth",
|
||||||
|
"//resources:log4j-config",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -68,8 +68,12 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import org.apache.log4j.Level;
|
||||||
|
import org.apache.log4j.LogManager;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
import org.junit.AfterClass;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@@ -115,6 +119,20 @@ public abstract class AbstractQueryGroupsTest extends GerritServerTests {
|
|||||||
|
|
||||||
protected abstract Injector createInjector();
|
protected abstract Injector createInjector();
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setLogLevel() {
|
||||||
|
if (Boolean.getBoolean("debug")) {
|
||||||
|
LogManager.getRootLogger().setLevel(Level.DEBUG);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void resetLogLevel() {
|
||||||
|
if (Boolean.getBoolean("debug")) {
|
||||||
|
LogManager.getRootLogger().setLevel(Level.INFO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUpInjector() throws Exception {
|
public void setUpInjector() throws Exception {
|
||||||
lifecycle = new LifecycleManager();
|
lifecycle = new LifecycleManager();
|
||||||
|
|||||||
@@ -19,8 +19,10 @@ java_library(
|
|||||||
"//lib:guava",
|
"//lib:guava",
|
||||||
"//lib/guice",
|
"//lib/guice",
|
||||||
"//lib/jgit/org.eclipse.jgit:jgit",
|
"//lib/jgit/org.eclipse.jgit:jgit",
|
||||||
|
"//lib/log:log4j",
|
||||||
"//lib/truth",
|
"//lib/truth",
|
||||||
"//lib/truth:truth-java8-extension",
|
"//lib/truth:truth-java8-extension",
|
||||||
|
"//resources:log4j-config",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -68,8 +68,12 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import org.apache.log4j.Level;
|
||||||
|
import org.apache.log4j.LogManager;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
import org.junit.AfterClass;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@@ -111,6 +115,20 @@ public abstract class AbstractQueryProjectsTest extends GerritServerTests {
|
|||||||
|
|
||||||
protected abstract Injector createInjector();
|
protected abstract Injector createInjector();
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setLogLevel() {
|
||||||
|
if (Boolean.getBoolean("debug")) {
|
||||||
|
LogManager.getRootLogger().setLevel(Level.DEBUG);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void resetLogLevel() {
|
||||||
|
if (Boolean.getBoolean("debug")) {
|
||||||
|
LogManager.getRootLogger().setLevel(Level.INFO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUpInjector() throws Exception {
|
public void setUpInjector() throws Exception {
|
||||||
lifecycle = new LifecycleManager();
|
lifecycle = new LifecycleManager();
|
||||||
|
|||||||
@@ -20,7 +20,9 @@ java_library(
|
|||||||
"//lib:guava",
|
"//lib:guava",
|
||||||
"//lib/guice",
|
"//lib/guice",
|
||||||
"//lib/jgit/org.eclipse.jgit:jgit",
|
"//lib/jgit/org.eclipse.jgit:jgit",
|
||||||
|
"//lib/log:log4j",
|
||||||
"//lib/truth",
|
"//lib/truth",
|
||||||
|
"//resources:log4j-config",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user