8000 HADOOP-19440. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-sls. by slfan1989 · Pull Request #7553 · apache/hadoop · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

HADOOP-19440. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-sls. #7553

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,11 @@
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.server.resourcemanager.monitor.invariants.MetricsInvariantChecker;
import org.junit.After;
import org.junit.Assert;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.Assume;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.BeforeAll;

import java.io.File;
import java.util.ArrayList;
Expand All @@ -42,37 +39,32 @@
/**
* This is a base class to ease the implementation of SLS-based tests.
*/
@RunWith(value = Parameterized.class)
@NotThreadSafe
@SuppressWarnings("VisibilityModifier")
public abstract class BaseSLSRunnerTest {

@Parameter(value = 0)
public String schedulerType;

@Parameter(value = 1)
public String traceType;

@Parameter(value = 2)
public String traceLocation;

@Parameter(value = 3)
public String nodeFile;

protected SLSRunner sls;
protected String ongoingInvariantFile;
protected String exitInvariantFile;

@BeforeClass
@BeforeAll
public static void checkForJavaScript() {
Assume.assumeNotNull("JavaScript engine not available (JEP 372)",
new ScriptEngineManager().getEngineByName("JavaScript"));
}

@Before
@BeforeEach
public abstract void setup();

@After
@AfterEach
public void tearDown() throws InterruptedException {
if (sls != null) {
sls.stop();
Expand Down Expand Up @@ -136,7 +128,7 @@ public void uncaughtException(Thread t, Throwable e) {

if (!exceptionList.isEmpty()) {
sls.stop();
Assert.fail("TestSLSRunner caught exception from child thread "
Assertions.fail("TestSLSRunner caught exception from child thread "
+ "(TaskRunner.TaskDefinition): " + exceptionList);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@

import org.apache.hadoop.yarn.sls.appmaster.DAGAMSimulator;
import org.apache.hadoop.yarn.sls.scheduler.ContainerSimulator;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.List;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,19 @@
import org.apache.hadoop.yarn.server.resourcemanager.monitor.invariants.ReservationInvariantsChecker;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

import net.jcip.annotations.NotThreadSafe;

/**
* This test performs an SLS run enabling a
* {@code ReservationInvariantsChecker}.
*/
@RunWith(value = Parameterized.class)
@NotThreadSafe
public class TestReservationSystemInvariants extends BaseSLSRunnerTest {

@Parameters(name = "Testing with: {1}, {0}, (nodeFile {3})")
public static Collection<Object[]> data() {
// Test with both schedulers, and all three trace types
return Arrays.asList(new Object[][] {
Expand All @@ -53,10 +50,22 @@ public static Collection<Object[]> data() {
});
}

@Test(timeout = 120000)
@SuppressWarnings("all")
public void testSimulatorRunning() throws Exception {
public void initTestReservationSystemInvariants(String pSchedulerType,
String pTraceType, String pTraceLocation, String pNodeFile) {
this.schedulerType = pSchedulerType;
this.traceType = pTraceType;
this.traceLocation = pTraceLocation;
this.nodeFile = pNodeFile;
setup();
}

@ParameterizedTest(name = "Testing with: {1}, {0}, (nodeFile {3})")
@MethodSource("data")
@Timeout(value = 120)
@SuppressWarnings("all")
public void testSimulatorRunning(String pSchedulerType,
String pTraceType, String pTraceLocation, String pNodeFile) throws Exception {
initTestReservationSystemInvariants(pSchedulerType, pTraceType, pTraceLocation, pNodeFile);
Configuration conf = new Configuration(false);
conf.set(YarnConfiguration.RM_SCHEDULER, schedulerType);
conf.setBoolean(YarnConfiguration.RM_SCHEDULER_ENABLE_MONITORS, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,20 @@
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

import java.util.Arrays;
import java.util.Collection;

/**
* This test performs simple runs of the SLS with the generic syn json format.
*/
@RunWith(value = Parameterized.class)
@NotThreadSafe
public class TestSLSDagAMSimulator extends BaseSLSRunnerTest {

@Parameters(name = "Testing with: {1}, {0}, (nodeFile {3})")
public static Collection<Object[]> data() {

String capScheduler = CapacityScheduler.class.getCanonicalName();
Expand All @@ -60,15 +57,28 @@ public static Collection<Object[]> data() {
});
}

@Before
public void initTestSLSDagAMSimulator(String pSchedulerType,
String pTraceType, String pTraceLocation, String pNodeFile) {
this.schedulerType = pSchedulerType;
this.traceType = pTraceType;
this.traceLocation = pTraceLocation;
this.nodeFile = pNodeFile;
setup();
}

@BeforeEach
public void setup() {
>
exitInvariantFile = "src/test/resources/exit-invariants.txt";
}

@Test(timeout = 90000)
@ParameterizedTest(name = "Testing with: {1}, {0}, (nodeFile {3})")
@Timeout(value = 90)
@MethodSource("data")
@SuppressWarnings("all")
public void testSimulatorRunning() throws Exception {
public void testSimulatorRunning(String pSchedulerType,
String pTraceType, String pTraceLocation, String pNodeFile) throws Exception {
initTestSLSDagAMSimulator(pSchedulerType, pTraceType, pTraceLocation, pNodeFile);
Configuration conf = new Configuration(false);
long timeTillShutdownInsec = 20L;
runSLS(conf, timeTillShutdownInsec);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,20 @@
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

import java.util.Arrays;
import java.util.Collection;

/**
* This test performs simple runs of the SLS with the generic syn json format.
*/
@RunWith(value = Parameterized.class)
@NotThreadSafe
public class TestSLSGenericSynth extends BaseSLSRunnerTest {

@Parameters(name = "Testing with: {1}, {0}, (nodeFile {3})")
public static Collection<Object[]> data() {

String capScheduler = CapacityScheduler.class.getCanonicalName();
Expand All @@ -60,15 +57,28 @@ public static Collection<Object[]> data() {
});
}

@Before
@BeforeEach
public void setup() {
>
exitInvariantFile = "src/test/resources/exit-invariants.txt";
}

@Test(timeout = 90000)
public void initTestSLSGenericSynth(String pSchedulerType,
String pTraceType, String pTraceLocation, String pNodeFile) {
this.schedulerType = pSchedulerType;
this.traceType = pTraceType;
this.traceLocation = pTraceLocation;
this.nodeFile = pNodeFile;
setup();
}

@ParameterizedTest(name = "Testing with: {1}, {0}, (nodeFile {3})")
@Timeout(value = 90)
@SuppressWarnings("all")
public void testSimulatorRunning() throws Exception {
@MethodSource("data")
public void testSimulatorRunning(String pSchedulerType,
String pTraceType, String pTraceLocation, String pNodeFile) throws Exception {
initTestSLSGenericSynth(pSchedulerType, pTraceType, pTraceLocation, pNodeFile);
Configuration conf = new Configuration(false);
long timeTillShutdownInsec = 20L;
runSLS(conf, timeTillShutdownInsec);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,22 @@
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler;
import org.apache.hadoop.yarn.sls.conf.SLSConfiguration;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.*;
import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

import java.security.Security;
import java.util.*;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

/**
* This test performs simple runs of the SLS with different trace types and
* schedulers.
*/
@RunWith(value = Parameterized.class)
@NotThreadSafe
public class TestSLSRunner extends BaseSLSRunnerTest {

@Parameters(name = "Testing with: {1}, {0}, (nodeFile {3})")
public static Collection<Object[]> data() {

String capScheduler = CapacityScheduler.class.getCanonicalName();
Expand Down Expand Up @@ -76,15 +72,27 @@ public static Collection<Object[]> data() {
});
}

@Before
public void setup() {
>
exitInvariantFile = "src/test/resources/exit-invariants.txt";
}

@Test(timeout = 90000)
public void initTestSLSRunner(String pSchedulerType,
String pTraceType, String pTraceLocation, String pNodeFile) {
this.schedulerType = pSchedulerType;
this.traceType = pTraceType;
this.traceLocation = pTraceLocation;
this.nodeFile = pNodeFile;
setup();
}

@ParameterizedTest(name = "Testing with: {1}, {0}, (nodeFile {3})")
@Timeout(value = 90)
@MethodSource("data")
@SuppressWarnings("all")
public void testSimulatorRunning() throws Exception {
public void testSimulatorRunning(String pSchedulerType,
String pTraceType, String pTraceLocation, String pNodeFile) throws Exception {
initTestSLSRunner(pSchedulerType, pTraceType, pTraceLocation, pNodeFile);
Configuration conf = new Configuration(false);
long timeTillShutdownInsec = 20L;
runSLS(conf, timeTillShutdownInsec);
Expand All @@ -93,8 +101,11 @@ public void testSimulatorRunning() throws Exception {
/**
* Test to check whether caching is enabled based on config.
*/
@Test
public void testEnableCaching() {
@ParameterizedTest(name = "Testing with: {1}, {0}, (nodeFile {3})")
@MethodSource("data")
public void testEnableCaching(String pSchedulerType,
String pTraceType, String pTraceLocation, String pNodeFile) {
initTestSLSRunner(pSchedulerType, pTraceType, pTraceLocation, pNodeFile);
String networkCacheDefault = Security.getProperty(
SLSRunner.NETWORK_CACHE_TTL);
String networkNegativeCacheDefault =
Expand Down
Loading
0