Split configs for RevisionDiffIT to different subclasses

RevisionDiffIT runs with three configs: default, intraline and new diff
cache. This causes the test class to run all methods three times, one
per each config. Splitting configs to different subclasses to allow
faster execution. RevisionDiffIT will run the class with the default
config, the two other subclasses will run with the other two configs.

Bug: Issue 14080
Change-Id: I108446cde5671953f2d843e4c968fe267f1c26bd
This commit is contained in:
Youssef Elghareeb
2021-02-15 17:18:38 +01:00
parent a95fb148b8
commit 0baf236546
4 changed files with 69 additions and 17 deletions

View File

@@ -4,4 +4,12 @@ load("//javatests/com/google/gerrit/acceptance:tests.bzl", "acceptance_tests")
srcs = [f],
group = f[:f.index(".")],
labels = ["api"],
deps = [":revision-diff-it"],
) for f in glob(["*IT.java"])]
# This is needed because RevisionDiffIT has subclasses that depend on it
java_library(
name = "revision-diff-it",
srcs = ["RevisionDiffIT.java"],
deps = ["//java/com/google/gerrit/acceptance:lib"],
)

View File

@@ -42,7 +42,6 @@ import com.google.gerrit.extensions.common.DiffInfo;
import com.google.gerrit.extensions.common.FileInfo;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.BinaryResult;
import com.google.gerrit.testing.ConfigSuite;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -55,7 +54,6 @@ import java.util.Map;
import java.util.function.Function;
import java.util.stream.IntStream;
import javax.imageio.ImageIO;
import org.eclipse.jgit.lib.Config;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.PersonIdent;
import org.eclipse.jgit.revwalk.RevCommit;
@@ -66,7 +64,8 @@ import org.junit.Test;
public class RevisionDiffIT extends AbstractDaemonTest {
// @RunWith(Parameterized.class) can't be used as AbstractDaemonTest is annotated with another
// runner. Using different configs is a workaround to achieve the same.
private static final String TEST_PARAMETER_MARKER = "test_only_parameter";
protected static final String TEST_PARAMETER_MARKER = "test_only_parameter";
private static final String CURRENT = "current";
private static final String FILE_NAME = "some_file.txt";
private static final String FILE_NAME2 = "another_file.txt";
@@ -83,20 +82,6 @@ public class RevisionDiffIT extends AbstractDaemonTest {
private String changeId;
private String initialPatchSetId;
@ConfigSuite.Config
public static Config intralineConfig() {
Config config = new Config();
config.setBoolean(TEST_PARAMETER_MARKER, null, "intraline", true);
return config;
}
@ConfigSuite.Config
public static Config newDiffCacheConfig() {
Config config = new Config();
config.setBoolean("cache", "diff_cache", "useNewDiffCache", true);
return config;
}
@Before
public void setUp() throws Exception {
// Reduce flakiness of tests. (If tests aren't fast enough, we would use a fall-back

View File

@@ -0,0 +1,28 @@
// Copyright (C) 2021 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.acceptance.api.revision;
import com.google.gerrit.testing.ConfigSuite;
import org.eclipse.jgit.lib.Config;
/** Runs the {@link RevisionDiffIT} tests with the intraline config enabled. */
public class RevisionDiffIntralineIT extends RevisionDiffIT {
@ConfigSuite.Default
public static Config intralineConfig() {
Config config = new Config();
config.setBoolean(TEST_PARAMETER_MARKER, null, "intraline", true);
return config;
}
}

View File

@@ -0,0 +1,31 @@
// Copyright (C) 2021 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.acceptance.api.revision;
import com.google.gerrit.testing.ConfigSuite;
import org.eclipse.jgit.lib.Config;
/**
* Runs the {@link RevisionDiffIT} tests with the new diff cache. This is temporary until the new
* diff cache is fully deployed. The new diff cache will become the default in the future.
*/
public class RevisionNewDiffCacheIT extends RevisionDiffIT {
@ConfigSuite.Default
public static Config newDiffCacheConfig() {
Config config = new Config();
config.setBoolean("cache", "diff_cache", "useNewDiffCache", true);
return config;
}
}