Skip to content

Commit

Permalink
GEODE-4181: Migrate uses of JUnitParamsRunner (apache#6890)
Browse files Browse the repository at this point in the history
Migrate all uses of `JUnitParamsRunner` to use a new runner that can be
made compatible with JUnit 5.

PROBLEM

We want to upgrade Geode to use JUnit 5. JUnit 5 includes a test engine
called JUnit Vintage, which it uses to run JUnit 4 tests. JUnit Vintage
interacts with test runners differently than JUnit 4 did.

`JUnitParamsRunner` is incompatible with JUnit Vintage in several ways:
- When `JUnitParamsRunner` describes parameterized tests, it discards
  the `@Category` annotation that JUnit Vintage uses to filter tests by
  category.
- When JUnit Vintage asks `JUnitParamsRunner` to filter tests by name,
  the runner fails to apply the filter to parameterized tests.

The net result is that when JUnit Vintage tries to filter tests by
category, `JUnitParamsRunner` runs every parameterized test, including
tests that lack the category. This affects the Windows Gfsh distributed
test job in particular, causing it to run 900 tests instead of the
desired 200. Numerous of the extra 700 tests fail on Windows.

This problem prevents us from upgrading to JUnit 5.

`JUnitParamsRunner` is no longer maintained. It will not be made
compatible with JUnit Vintage.

Approximately 140 test classes use `JUnitParamsRunner`. To upgrade to
JUnit 5, we will have to migrate all of these tests to use a runner
compatible with JUnit Vintage.

SOLUTION

The solution involves two steps:
1. Migrate every existing use of `JUnitParamsRunner` to instead use a
   new `GeodeParamsRunner` that behaves identically to
   `JUnitParamsRunner`.
2. Upgrade Geode to use JUnit 5.

This PR implements step 1. This PR implements a "dummy" version of
`GeodeParamsRunner` that behaves identically to `JUnitParamsRunner`. Its
only purpose is to allow migrating approximately 140 test classes to use
the new runner name.

I will implement step 2 in a later PR. This will include re-implementing
`GeodeParamsRunner` to be compatible with JUnit 5. (I have verified the
viability of this via a spike.)

Separating the "migrate the tests" and "upgrade JUnit" steps into
separate PRs makes each PR much more focused and much easier to review.
  • Loading branch information
demery-pivotal authored Sep 24, 2021
1 parent 09c01c8 commit 1d6eef3
Show file tree
Hide file tree
Showing 142 changed files with 314 additions and 283 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

import javax.servlet.ServletException;

import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import org.apache.catalina.Context;
import org.apache.catalina.Manager;
Expand All @@ -38,8 +37,9 @@
import org.junit.runner.RunWith;

import org.apache.geode.cache.RegionShortcut;
import org.apache.geode.test.junit.runners.GeodeParamsRunner;

@RunWith(JUnitParamsRunner.class)
@RunWith(GeodeParamsRunner.class)
public abstract class AbstractCommitSessionValveIntegrationTest<CommitSessionValveT extends AbstractCommitSessionValve<CommitSessionValveT>>
extends AbstractSessionValveIntegrationTest {
protected Request request;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

import javax.servlet.ServletException;

import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import org.apache.catalina.Context;
import org.apache.catalina.Manager;
Expand All @@ -40,8 +39,9 @@
import org.junit.runner.RunWith;

import org.apache.geode.cache.RegionShortcut;
import org.apache.geode.test.junit.runners.GeodeParamsRunner;

@RunWith(JUnitParamsRunner.class)
@RunWith(GeodeParamsRunner.class)
public class JvmRouteBinderValveIntegrationTest extends AbstractSessionValveIntegrationTest {
private Request request;
private Response response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import javax.servlet.http.HttpSession;

import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import org.junit.Before;
import org.junit.Rule;
Expand All @@ -32,8 +31,9 @@
import org.apache.geode.cache.RegionShortcut;
import org.apache.geode.modules.session.catalina.DeltaSession;
import org.apache.geode.test.junit.rules.ServerStarterRule;
import org.apache.geode.test.junit.runners.GeodeParamsRunner;

@RunWith(JUnitParamsRunner.class)
@RunWith(GeodeParamsRunner.class)
public class LocalSessionCacheLoaderIntegrationTest {
private static final String SESSION_ID = "id";
private static final String REGION_NAME = "sessions";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import javax.servlet.http.HttpSession;

import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import org.junit.Before;
import org.junit.Rule;
Expand All @@ -37,8 +36,9 @@
import org.apache.geode.cache.util.CacheWriterAdapter;
import org.apache.geode.modules.session.catalina.DeltaSession;
import org.apache.geode.test.junit.rules.ServerStarterRule;
import org.apache.geode.test.junit.runners.GeodeParamsRunner;

@RunWith(JUnitParamsRunner.class)
@RunWith(GeodeParamsRunner.class)
public class LocalSessionCacheWriterIntegrationTest {
private static final String SESSION_ID = "id";
private static final String REGION_NAME = "sessions";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import javax.servlet.http.HttpSession;

import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import org.apache.juli.logging.Log;
import org.junit.Before;
Expand All @@ -42,8 +41,9 @@
import org.apache.geode.modules.session.catalina.DeltaSessionManager;
import org.apache.geode.modules.session.catalina.SessionCache;
import org.apache.geode.test.junit.rules.ServerStarterRule;
import org.apache.geode.test.junit.runners.GeodeParamsRunner;

@RunWith(JUnitParamsRunner.class)
@RunWith(GeodeParamsRunner.class)
public class SessionExpirationCacheListenerIntegrationTest {
private static final String KEY = "key1";
private static final String REGION_NAME = "sessions";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
import java.util.Collections;
import java.util.List;

import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import org.junit.Test;
import org.junit.runner.RunWith;

import org.apache.geode.cache.RegionShortcut;
import org.apache.geode.test.junit.runners.GeodeParamsRunner;

@RunWith(JUnitParamsRunner.class)
@RunWith(GeodeParamsRunner.class)
public class DeltaSessionAttributeEventBatchIntegrationTest
extends AbstractDeltaSessionIntegrationTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@

import java.io.IOException;

import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import org.junit.Test;
import org.junit.runner.RunWith;

import org.apache.geode.cache.RegionShortcut;
import org.apache.geode.modules.session.catalina.DeltaSession;
import org.apache.geode.test.junit.runners.GeodeParamsRunner;

@RunWith(JUnitParamsRunner.class)
@RunWith(GeodeParamsRunner.class)
public class DeltaSessionDestroyAttributeEventIntegrationTest
extends AbstractDeltaSessionIntegrationTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

import javax.servlet.http.HttpSession;

import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -39,8 +38,9 @@
import org.apache.geode.modules.session.catalina.DeltaSession;
import org.apache.geode.modules.session.catalina.SessionCache;
import org.apache.geode.modules.session.catalina.callback.SessionExpirationCacheListener;
import org.apache.geode.test.junit.runners.GeodeParamsRunner;

@RunWith(JUnitParamsRunner.class)
@RunWith(GeodeParamsRunner.class)
public class DeltaSessionStatisticsIntegrationTest extends AbstractDeltaSessionIntegrationTest {
private DeltaSessionStatistics statistics;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@

import java.io.IOException;

import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import org.junit.Test;
import org.junit.runner.RunWith;

import org.apache.geode.cache.RegionShortcut;
import org.apache.geode.modules.session.catalina.DeltaSession;
import org.apache.geode.test.junit.runners.GeodeParamsRunner;

@RunWith(JUnitParamsRunner.class)
@RunWith(GeodeParamsRunner.class)
public class DeltaSessionUpdateAttributeEventIntegrationTest
extends AbstractDeltaSessionIntegrationTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.ArrayList;
import java.util.List;

import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import org.apache.commons.lang3.StringUtils;
import org.junit.After;
Expand All @@ -36,8 +35,9 @@
import redis.clients.jedis.Protocol;

import org.apache.geode.redis.RedisIntegrationTest;
import org.apache.geode.test.junit.runners.GeodeParamsRunner;

@RunWith(JUnitParamsRunner.class)
@RunWith(GeodeParamsRunner.class)
public abstract class AbstractZLexCountIntegrationTest implements RedisIntegrationTest {
public static final String KEY = "key";
public static final int SCORE = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.util.List;
import java.util.stream.Collectors;

import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import org.apache.commons.lang3.StringUtils;
import org.junit.After;
Expand All @@ -41,8 +40,9 @@

import org.apache.geode.redis.RedisIntegrationTest;
import org.apache.geode.redis.internal.netty.Coder;
import org.apache.geode.test.junit.runners.GeodeParamsRunner;

@RunWith(JUnitParamsRunner.class)
@RunWith(GeodeParamsRunner.class)
public abstract class AbstractZRangeByLexIntegrationTest implements RedisIntegrationTest {
public static final String KEY = "key";
public static final int SCORE = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.ArrayList;
import java.util.List;

import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import org.apache.commons.lang3.StringUtils;
import org.junit.After;
Expand All @@ -36,8 +35,9 @@
import redis.clients.jedis.Protocol;

import org.apache.geode.redis.RedisIntegrationTest;
import org.apache.geode.test.junit.runners.GeodeParamsRunner;

@RunWith(JUnitParamsRunner.class)
@RunWith(GeodeParamsRunner.class)
public abstract class AbstractZRemRangeByLexIntegrationTest implements RedisIntegrationTest {
public static final String KEY = "key";
public static final int SCORE = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import org.junit.After;
import org.junit.Before;
Expand All @@ -32,8 +31,9 @@
import redis.clients.jedis.Protocol;

import org.apache.geode.redis.RedisIntegrationTest;
import org.apache.geode.test.junit.runners.GeodeParamsRunner;

@RunWith(JUnitParamsRunner.class)
@RunWith(GeodeParamsRunner.class)
public abstract class AbstractZRemRangeByRankIntegrationTest implements RedisIntegrationTest {
public static final String KEY = "key";
public static final int BASE_SCORE = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.util.List;
import java.util.stream.Collectors;

import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import org.apache.commons.lang3.StringUtils;
import org.junit.After;
Expand All @@ -41,8 +40,9 @@

import org.apache.geode.redis.RedisIntegrationTest;
import org.apache.geode.redis.internal.netty.Coder;
import org.apache.geode.test.junit.runners.GeodeParamsRunner;

@RunWith(JUnitParamsRunner.class)
@RunWith(GeodeParamsRunner.class)
public abstract class AbstractZRevRangeByLexIntegrationTest implements RedisIntegrationTest {
public static final String KEY = "key";
public static final int SCORE = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import java.util.Map;
import java.util.Set;

import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import junitparams.naming.TestCaseName;
import org.junit.After;
Expand All @@ -44,8 +43,9 @@
import redis.clients.jedis.Tuple;

import org.apache.geode.redis.RedisIntegrationTest;
import org.apache.geode.test.junit.runners.GeodeParamsRunner;

@RunWith(JUnitParamsRunner.class)
@RunWith(GeodeParamsRunner.class)
public abstract class AbstractZRevRangeByScoreIntegrationTest implements RedisIntegrationTest {
private static final String MEMBER_BASE_NAME = "member";
private static final String KEY = "key";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.util.List;
import java.util.Set;

import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import junitparams.naming.TestCaseName;
import org.junit.After;
Expand All @@ -40,8 +39,9 @@
import redis.clients.jedis.Tuple;

import org.apache.geode.redis.RedisIntegrationTest;
import org.apache.geode.test.junit.runners.GeodeParamsRunner;

@RunWith(JUnitParamsRunner.class)
@RunWith(GeodeParamsRunner.class)
public abstract class AbstractZRevRangeIntegrationTest implements RedisIntegrationTest {
private static final String MEMBER_BASE_NAME = "member";
private static final String KEY = "key";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import java.util.Random;
import java.util.stream.Collectors;

import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.junit.BeforeClass;
Expand All @@ -69,8 +68,9 @@
import org.apache.geode.redis.internal.executor.sortedset.SortedSetRankRangeOptions;
import org.apache.geode.redis.internal.executor.sortedset.ZAddOptions;
import org.apache.geode.redis.internal.netty.Coder;
import org.apache.geode.test.junit.runners.GeodeParamsRunner;

@RunWith(JUnitParamsRunner.class)
@RunWith(GeodeParamsRunner.class)
public class RedisSortedSetTest {
private final ReflectionObjectSizer sizer = ReflectionObjectSizer.getInstance();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@

import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(JUnitParamsRunner.class)
import org.apache.geode.test.junit.runners.GeodeParamsRunner;

@RunWith(GeodeParamsRunner.class)
public class CoderTest {
@Test
@Parameters(method = "stringPairs")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@

import javax.sql.DataSource;

import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import org.junit.After;
import org.junit.Before;
Expand Down Expand Up @@ -75,9 +74,10 @@
import org.apache.geode.test.junit.rules.GfshCommandRule;
import org.apache.geode.test.junit.rules.serializable.SerializableTemporaryFolder;
import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
import org.apache.geode.test.junit.runners.GeodeParamsRunner;

@Category({JDBCConnectorTest.class})
@RunWith(JUnitParamsRunner.class)
@RunWith(GeodeParamsRunner.class)
public class CreateMappingCommandForProxyRegionDUnitTest {

private static final String TEST_REGION = "testRegion";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

import javax.sql.DataSource;

import junitparams.JUnitParamsRunner;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -56,8 +55,9 @@
import org.apache.geode.pdx.PdxInstanceFactory;
import org.apache.geode.pdx.internal.PdxInstanceImpl;
import org.apache.geode.pdx.internal.PdxType;
import org.apache.geode.test.junit.runners.GeodeParamsRunner;

@RunWith(JUnitParamsRunner.class)
@RunWith(GeodeParamsRunner.class)
public class SqlHandlerTest {
private static final String DATA_SOURCE_NAME = "dataSourceName";
private static final String REGION_NAME = "testRegion";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.sql.SQLException;
import java.util.Arrays;

import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -34,8 +33,9 @@
import org.apache.geode.pdx.FieldType;
import org.apache.geode.pdx.PdxInstance;
import org.apache.geode.pdx.PdxInstanceFactory;
import org.apache.geode.test.junit.runners.GeodeParamsRunner;

@RunWith(JUnitParamsRunner.class)
@RunWith(GeodeParamsRunner.class)
public class SqlToPdxInstanceCreatorTest {

private static final String COLUMN_NAME_1 = "columnName1";
Expand Down
Loading

0 comments on commit 1d6eef3

Please sign in to comment.