YARN-9470. Fix order of actual and expected expression in assert statements
Signed-off-by: Akira Ajisaka <aajisaka@apache.org>
This commit is contained in:
parent
6e4399ea61
commit
aa4c744aef
@ -250,6 +250,12 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
@ -61,6 +61,7 @@
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.apache.hadoop.yarn.api.records.YarnApplicationState.FINISHED;
|
||||
import static org.apache.hadoop.yarn.service.conf.YarnServiceConf.*;
|
||||
import static org.apache.hadoop.yarn.service.exceptions.LauncherExitCodes.EXIT_COMMAND_ARGUMENT_ERROR;
|
||||
@ -904,7 +905,7 @@ private void checkEachCompInstancesInOrder(Component component, String
|
||||
|
||||
int i = 0;
|
||||
for (String s : instances) {
|
||||
Assert.assertEquals(component.getName() + "-" + i, s);
|
||||
assertThat(s).isEqualTo(component.getName() + "-" + i);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,7 @@
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.apache.hadoop.yarn.client.api.AppAdminClient.YARN_APP_ADMIN_CLIENT_PREFIX;
|
||||
import static org.apache.hadoop.yarn.service.conf.YarnServiceConf.DEPENDENCY_TARBALL_PATH;
|
||||
import static org.apache.hadoop.yarn.service.conf.YarnServiceConf.YARN_SERVICE_BASE_PATH;
|
||||
@ -172,7 +173,7 @@ public void testInitiateServiceUpgrade() throws Exception {
|
||||
"-initiate", ExampleAppJson.resourceName(ExampleAppJson.APP_JSON),
|
||||
"-appTypes", DUMMY_APP_TYPE};
|
||||
int result = cli.run(ApplicationCLI.preProcessArgs(args));
|
||||
Assert.assertEquals(result, 0);
|
||||
assertThat(result).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test (timeout = 180000)
|
||||
@ -182,7 +183,7 @@ public void testInitiateAutoFinalizeServiceUpgrade() throws Exception {
|
||||
"-autoFinalize",
|
||||
"-appTypes", DUMMY_APP_TYPE};
|
||||
int result = cli.run(ApplicationCLI.preProcessArgs(args));
|
||||
Assert.assertEquals(result, 0);
|
||||
assertThat(result).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -194,7 +195,7 @@ public void testUpgradeInstances() throws Exception {
|
||||
"-instances", "comp1-0,comp1-1",
|
||||
"-appTypes", DUMMY_APP_TYPE};
|
||||
int result = cli.run(ApplicationCLI.preProcessArgs(args));
|
||||
Assert.assertEquals(result, 0);
|
||||
assertThat(result).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -206,7 +207,7 @@ public void testUpgradeComponents() throws Exception {
|
||||
"-components", "comp1,comp2",
|
||||
"-appTypes", DUMMY_APP_TYPE};
|
||||
int result = cli.run(ApplicationCLI.preProcessArgs(args));
|
||||
Assert.assertEquals(result, 0);
|
||||
assertThat(result).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -218,7 +219,7 @@ public void testGetInstances() throws Exception {
|
||||
"-components", "comp1,comp2",
|
||||
"-appTypes", DUMMY_APP_TYPE};
|
||||
int result = cli.run(ApplicationCLI.preProcessArgs(args));
|
||||
Assert.assertEquals(result, 0);
|
||||
assertThat(result).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -229,7 +230,7 @@ public void testCancelUpgrade() throws Exception {
|
||||
String[] args = {"app", "-upgrade", "app-1",
|
||||
"-cancel", "-appTypes", DUMMY_APP_TYPE};
|
||||
int result = cli.run(ApplicationCLI.preProcessArgs(args));
|
||||
Assert.assertEquals(result, 0);
|
||||
assertThat(result).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test (timeout = 180000)
|
||||
|
@ -45,6 +45,7 @@
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.apache.hadoop.yarn.service.conf.RestApiConstants.DEFAULT_UNLIMITED_LIFETIME;
|
||||
import static org.apache.hadoop.yarn.service.exceptions.RestApiErrorMessages.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@ -268,7 +269,7 @@ public void testArtifacts() throws IOException {
|
||||
Assert.fail(NO_EXCEPTION_PREFIX + e.getMessage());
|
||||
}
|
||||
|
||||
assertEquals(app.getLifetime(), DEFAULT_UNLIMITED_LIFETIME);
|
||||
assertThat(app.getLifetime()).isEqualTo(DEFAULT_UNLIMITED_LIFETIME);
|
||||
}
|
||||
|
||||
private static Resource createValidResource() {
|
||||
|
@ -84,6 +84,11 @@
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- 'mvn dependency:analyze' fails to detect use of this dependency -->
|
||||
<dependency>
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package org.apache.hadoop.yarn.client.api.async.impl;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyFloat;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
@ -596,7 +597,7 @@ public float getProgress() {
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Assert.assertEquals(e.getMessage(), "Exception from callback handler");
|
||||
assertThat(e).hasMessage("Exception from callback handler");
|
||||
callStopAndNotify();
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package org.apache.hadoop.yarn.client.api.impl;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
@ -84,7 +85,7 @@ public void testGetApplications() throws YarnException, IOException {
|
||||
Assert.assertEquals(reports, expectedReports);
|
||||
|
||||
reports = client.getApplications();
|
||||
Assert.assertEquals(reports.size(), 4);
|
||||
assertThat(reports).hasSize(4);
|
||||
client.stop();
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package org.apache.hadoop.yarn.client.api.impl;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ -80,14 +81,14 @@ public void testGetContainerReport() throws IOException, YarnException {
|
||||
when(spyTimelineReaderClient.getApplicationEntity(appId, "ALL", null))
|
||||
.thenReturn(createApplicationTimelineEntity(appId, true, false));
|
||||
ContainerReport report = client.getContainerReport(containerId);
|
||||
Assert.assertEquals(report.getContainerId(), containerId);
|
||||
Assert.assertEquals(report.getAssignedNode().getHost(), "test host");
|
||||
Assert.assertEquals(report.getAssignedNode().getPort(), 100);
|
||||
Assert.assertEquals(report.getAllocatedResource().getVirtualCores(), 8);
|
||||
Assert.assertEquals(report.getCreationTime(), 123456);
|
||||
Assert.assertEquals(report.getLogUrl(),
|
||||
"https://localhost:8188/ahs/logs/test host:100/"
|
||||
+ "container_0_0001_01_000001/container_0_0001_01_000001/user1");
|
||||
assertThat(report.getContainerId()).isEqualTo(containerId);
|
||||
assertThat(report.getAssignedNode().getHost()).isEqualTo("test host");
|
||||
assertThat(report.getAssignedNode().getPort()).isEqualTo(100);
|
||||
assertThat(report.getAllocatedResource().getVirtualCores()).isEqualTo(8);
|
||||
assertThat(report.getCreationTime()).isEqualTo(123456);
|
||||
assertThat(report.getLogUrl()).isEqualTo("https://localhost:8188/ahs/logs/"
|
||||
+ "test host:100/container_0_0001_01_000001/"
|
||||
+ "container_0_0001_01_000001/user1");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -100,10 +101,10 @@ public void testGetAppAttemptReport() throws IOException, YarnException {
|
||||
.thenReturn(createAppAttemptTimelineEntity(appAttemptId));
|
||||
ApplicationAttemptReport report =
|
||||
client.getApplicationAttemptReport(appAttemptId);
|
||||
Assert.assertEquals(report.getApplicationAttemptId(), appAttemptId);
|
||||
Assert.assertEquals(report.getFinishTime(), Integer.MAX_VALUE + 2L);
|
||||
Assert.assertEquals(report.getOriginalTrackingUrl(),
|
||||
"test original tracking url");
|
||||
assertThat(report.getApplicationAttemptId()).isEqualTo(appAttemptId);
|
||||
assertThat(report.getFinishTime()).isEqualTo(Integer.MAX_VALUE + 2L);
|
||||
assertThat(report.getOriginalTrackingUrl()).
|
||||
isEqualTo("test original tracking url");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -112,11 +113,12 @@ public void testGetAppReport() throws IOException, YarnException {
|
||||
when(spyTimelineReaderClient.getApplicationEntity(appId, "ALL", null))
|
||||
.thenReturn(createApplicationTimelineEntity(appId, false, false));
|
||||
ApplicationReport report = client.getApplicationReport(appId);
|
||||
Assert.assertEquals(report.getApplicationId(), appId);
|
||||
Assert.assertEquals(report.getAppNodeLabelExpression(), "test_node_label");
|
||||
assertThat(report.getApplicationId()).isEqualTo(appId);
|
||||
assertThat(report.getAppNodeLabelExpression()).
|
||||
isEqualTo("test_node_label");
|
||||
Assert.assertTrue(report.getApplicationTags().contains("Test_APP_TAGS_1"));
|
||||
Assert.assertEquals(report.getYarnApplicationState(),
|
||||
YarnApplicationState.FINISHED);
|
||||
assertThat(report.getYarnApplicationState()).
|
||||
isEqualTo(YarnApplicationState.FINISHED);
|
||||
}
|
||||
|
||||
private static TimelineEntity createApplicationTimelineEntity(
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package org.apache.hadoop.yarn.client.api.impl;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
@ -1616,7 +1617,7 @@ private void waitForContainerCompletion(int numIterations,
|
||||
for(ContainerStatus cStatus :allocResponse
|
||||
.getCompletedContainersStatuses()) {
|
||||
if(releases.contains(cStatus.getContainerId())) {
|
||||
assertEquals(cStatus.getState(), ContainerState.COMPLETE);
|
||||
assertThat(cStatus.getState()).isEqualTo(ContainerState.COMPLETE);
|
||||
assertEquals(-100, cStatus.getExitStatus());
|
||||
releases.remove(cStatus.getContainerId());
|
||||
}
|
||||
|
@ -81,6 +81,7 @@
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
@ -657,7 +658,7 @@ public void testMixedAllocationAndRelease() throws YarnException,
|
||||
for (ContainerStatus cStatus : allocResponse
|
||||
.getCompletedContainersStatuses()) {
|
||||
if (releases.contains(cStatus.getContainerId())) {
|
||||
assertEquals(cStatus.getState(), ContainerState.COMPLETE);
|
||||
assertThat(cStatus.getState()).isEqualTo(ContainerState.COMPLETE);
|
||||
assertEquals(-100, cStatus.getExitStatus());
|
||||
releases.remove(cStatus.getContainerId());
|
||||
}
|
||||
|
@ -93,6 +93,7 @@
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
@ -416,7 +417,7 @@ public void testGetApplications() throws YarnException, IOException {
|
||||
List<ApplicationReport> expectedReports = ((MockYarnClient)client).getReports();
|
||||
|
||||
List<ApplicationReport> reports = client.getApplications();
|
||||
Assert.assertEquals(reports, expectedReports);
|
||||
assertThat(reports).isEqualTo(expectedReports);
|
||||
|
||||
Set<String> appTypes = new HashSet<>();
|
||||
appTypes.add("YARN");
|
||||
@ -424,7 +425,7 @@ public void testGetApplications() throws YarnException, IOException {
|
||||
|
||||
reports =
|
||||
client.getApplications(appTypes, null);
|
||||
Assert.assertEquals(reports.size(), 2);
|
||||
assertThat(reports).hasSize(2);
|
||||
Assert
|
||||
.assertTrue((reports.get(0).getApplicationType().equals("YARN") && reports
|
||||
.get(1).getApplicationType().equals("NON-YARN"))
|
||||
@ -439,7 +440,7 @@ public void testGetApplications() throws YarnException, IOException {
|
||||
appStates.add(YarnApplicationState.FINISHED);
|
||||
appStates.add(YarnApplicationState.FAILED);
|
||||
reports = client.getApplications(null, appStates);
|
||||
Assert.assertEquals(reports.size(), 2);
|
||||
assertThat(reports).hasSize(2);
|
||||
Assert
|
||||
.assertTrue((reports.get(0).getApplicationType().equals("NON-YARN") && reports
|
||||
.get(1).getApplicationType().equals("NON-MAPREDUCE"))
|
||||
@ -469,9 +470,9 @@ public void testGetApplicationAttempts() throws YarnException, IOException {
|
||||
List<ApplicationAttemptReport> reports = client
|
||||
.getApplicationAttempts(applicationId);
|
||||
Assert.assertNotNull(reports);
|
||||
Assert.assertEquals(reports.get(0).getApplicationAttemptId(),
|
||||
assertThat(reports.get(0).getApplicationAttemptId()).isEqualTo(
|
||||
ApplicationAttemptId.newInstance(applicationId, 1));
|
||||
Assert.assertEquals(reports.get(1).getApplicationAttemptId(),
|
||||
assertThat(reports.get(1).getApplicationAttemptId()).isEqualTo(
|
||||
ApplicationAttemptId.newInstance(applicationId, 2));
|
||||
client.stop();
|
||||
}
|
||||
@ -492,7 +493,7 @@ public void testGetApplicationAttempt() throws YarnException, IOException {
|
||||
ApplicationAttemptReport report = client
|
||||
.getApplicationAttemptReport(appAttemptId);
|
||||
Assert.assertNotNull(report);
|
||||
Assert.assertEquals(report.getApplicationAttemptId().toString(),
|
||||
assertThat(report.getApplicationAttemptId().toString()).isEqualTo(
|
||||
expectedReports.get(0).getCurrentApplicationAttemptId().toString());
|
||||
client.stop();
|
||||
}
|
||||
@ -512,11 +513,11 @@ public void testGetContainers() throws YarnException, IOException {
|
||||
applicationId, 1);
|
||||
List<ContainerReport> reports = client.getContainers(appAttemptId);
|
||||
Assert.assertNotNull(reports);
|
||||
Assert.assertEquals(reports.get(0).getContainerId(),
|
||||
assertThat(reports.get(0).getContainerId()).isEqualTo(
|
||||
(ContainerId.newContainerId(appAttemptId, 1)));
|
||||
Assert.assertEquals(reports.get(1).getContainerId(),
|
||||
assertThat(reports.get(1).getContainerId()).isEqualTo(
|
||||
(ContainerId.newContainerId(appAttemptId, 2)));
|
||||
Assert.assertEquals(reports.get(2).getContainerId(),
|
||||
assertThat(reports.get(2).getContainerId()).isEqualTo(
|
||||
(ContainerId.newContainerId(appAttemptId, 3)));
|
||||
|
||||
//First2 containers should come from RM with updated state information and
|
||||
@ -554,9 +555,9 @@ public List<ContainerReport> getContainers(
|
||||
List<ContainerReport> reports = client.getContainers(appAttemptId);
|
||||
Assert.assertNotNull(reports);
|
||||
Assert.assertTrue(reports.size() == 2);
|
||||
Assert.assertEquals(reports.get(0).getContainerId(),
|
||||
assertThat(reports.get(0).getContainerId()).isEqualTo(
|
||||
(ContainerId.newContainerId(appAttemptId, 1)));
|
||||
Assert.assertEquals(reports.get(1).getContainerId(),
|
||||
assertThat(reports.get(1).getContainerId()).isEqualTo(
|
||||
(ContainerId.newContainerId(appAttemptId, 2)));
|
||||
|
||||
//Only 2 running containers from RM are present when AHS throws exception
|
||||
@ -586,13 +587,13 @@ public void testGetContainerReport() throws YarnException, IOException {
|
||||
ContainerId containerId = ContainerId.newContainerId(appAttemptId, 1);
|
||||
ContainerReport report = client.getContainerReport(containerId);
|
||||
Assert.assertNotNull(report);
|
||||
Assert.assertEquals(report.getContainerId().toString(),
|
||||
assertThat(report.getContainerId().toString()).isEqualTo(
|
||||
(ContainerId.newContainerId(expectedReports.get(0)
|
||||
.getCurrentApplicationAttemptId(), 1)).toString());
|
||||
containerId = ContainerId.newContainerId(appAttemptId, 3);
|
||||
report = client.getContainerReport(containerId);
|
||||
Assert.assertNotNull(report);
|
||||
Assert.assertEquals(report.getContainerId().toString(),
|
||||
assertThat(report.getContainerId().toString()).isEqualTo(
|
||||
(ContainerId.newContainerId(expectedReports.get(0)
|
||||
.getCurrentApplicationAttemptId(), 3)).toString());
|
||||
Assert.assertNotNull(report.getExecutionType());
|
||||
@ -609,16 +610,16 @@ public void testGetLabelsToNodes() throws YarnException, IOException {
|
||||
Map<String, Set<NodeId>> expectedLabelsToNodes =
|
||||
((MockYarnClient)client).getLabelsToNodesMap();
|
||||
Map<String, Set<NodeId>> labelsToNodes = client.getLabelsToNodes();
|
||||
Assert.assertEquals(labelsToNodes, expectedLabelsToNodes);
|
||||
Assert.assertEquals(labelsToNodes.size(), 3);
|
||||
assertThat(labelsToNodes).isEqualTo(expectedLabelsToNodes);
|
||||
assertThat(labelsToNodes).hasSize(3);
|
||||
|
||||
// Get labels to nodes for selected labels
|
||||
Set<String> setLabels = new HashSet<>(Arrays.asList("x", "z"));
|
||||
expectedLabelsToNodes =
|
||||
((MockYarnClient)client).getLabelsToNodesMap(setLabels);
|
||||
labelsToNodes = client.getLabelsToNodes(setLabels);
|
||||
Assert.assertEquals(labelsToNodes, expectedLabelsToNodes);
|
||||
Assert.assertEquals(labelsToNodes.size(), 2);
|
||||
assertThat(labelsToNodes).isEqualTo(expectedLabelsToNodes);
|
||||
assertThat(labelsToNodes).hasSize(2);
|
||||
|
||||
client.stop();
|
||||
client.close();
|
||||
@ -634,8 +635,8 @@ public void testGetNodesToLabels() throws YarnException, IOException {
|
||||
Map<NodeId, Set<String>> expectedNodesToLabels = ((MockYarnClient) client)
|
||||
.getNodeToLabelsMap();
|
||||
Map<NodeId, Set<String>> nodesToLabels = client.getNodeToLabels();
|
||||
Assert.assertEquals(nodesToLabels, expectedNodesToLabels);
|
||||
Assert.assertEquals(nodesToLabels.size(), 1);
|
||||
assertThat(nodesToLabels).isEqualTo(expectedNodesToLabels);
|
||||
assertThat(nodesToLabels).hasSize(1);
|
||||
|
||||
client.stop();
|
||||
client.close();
|
||||
|
@ -62,6 +62,8 @@
|
||||
import java.util.Collections;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
/**
|
||||
* This class is to test class {@link YarnClient) and {@link YarnClientImpl}
|
||||
@ -432,7 +434,7 @@ public void testListReservationsByTimeIntervalContainingNoReservations()
|
||||
|
||||
// Ensure all reservations are filtered out.
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getReservationAllocationState().size(), 0);
|
||||
assertThat(response.getReservationAllocationState()).isEmpty();
|
||||
|
||||
duration = 30000;
|
||||
deadline = sRequest.getReservationDefinition().getDeadline();
|
||||
@ -447,7 +449,7 @@ public void testListReservationsByTimeIntervalContainingNoReservations()
|
||||
|
||||
// Ensure all reservations are filtered out.
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getReservationAllocationState().size(), 0);
|
||||
assertThat(response.getReservationAllocationState()).isEmpty();
|
||||
|
||||
arrival = clock.getTime();
|
||||
// List reservations, search by end time before the reservation start
|
||||
@ -460,7 +462,7 @@ public void testListReservationsByTimeIntervalContainingNoReservations()
|
||||
|
||||
// Ensure all reservations are filtered out.
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getReservationAllocationState().size(), 0);
|
||||
assertThat(response.getReservationAllocationState()).isEmpty();
|
||||
|
||||
// List reservations, search by very small end time.
|
||||
request = ReservationListRequest
|
||||
@ -470,7 +472,7 @@ public void testListReservationsByTimeIntervalContainingNoReservations()
|
||||
|
||||
// Ensure all reservations are filtered out.
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getReservationAllocationState().size(), 0);
|
||||
assertThat(response.getReservationAllocationState()).isEmpty();
|
||||
|
||||
} finally {
|
||||
// clean-up
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
import org.apache.hadoop.yarn.api.records.NodeAttribute;
|
||||
import org.apache.hadoop.yarn.api.records.NodeAttributeType;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
@ -1685,26 +1686,26 @@ public void testNodeCLIUsageInfo() throws Exception {
|
||||
public void testMissingArguments() throws Exception {
|
||||
ApplicationCLI cli = createAndGetAppCLI();
|
||||
int result = cli.run(new String[] { "application", "-status" });
|
||||
Assert.assertEquals(result, -1);
|
||||
assertThat(result).isEqualTo(-1);
|
||||
Assert.assertEquals(String.format("Missing argument for options%n%1s",
|
||||
createApplicationCLIHelpMessage()), sysOutStream.toString());
|
||||
|
||||
sysOutStream.reset();
|
||||
result = cli.run(new String[] { "applicationattempt", "-status" });
|
||||
Assert.assertEquals(result, -1);
|
||||
assertThat(result).isEqualTo(-1);
|
||||
Assert.assertEquals(String.format("Missing argument for options%n%1s",
|
||||
createApplicationAttemptCLIHelpMessage()), sysOutStream.toString());
|
||||
|
||||
sysOutStream.reset();
|
||||
result = cli.run(new String[] { "container", "-status" });
|
||||
Assert.assertEquals(result, -1);
|
||||
assertThat(result).isEqualTo(-1);
|
||||
Assert.assertEquals(String.format("Missing argument for options %1s",
|
||||
createContainerCLIHelpMessage()), normalize(sysOutStream.toString()));
|
||||
|
||||
sysOutStream.reset();
|
||||
NodeCLI nodeCLI = createAndGetNodeCLI();
|
||||
result = nodeCLI.run(new String[] { "-status" });
|
||||
Assert.assertEquals(result, -1);
|
||||
assertThat(result).isEqualTo(-1);
|
||||
Assert.assertEquals(String.format("Missing argument for options%n%1s",
|
||||
createNodeCLIHelpMessage()), sysOutStream.toString());
|
||||
}
|
||||
@ -2017,7 +2018,7 @@ public void testUpdateApplicationPriority() throws Exception {
|
||||
cli.run(new String[] { "application", "-appId",
|
||||
applicationId.toString(),
|
||||
"-updatePriority", "1" });
|
||||
Assert.assertEquals(result, 0);
|
||||
assertThat(result).isEqualTo(0);
|
||||
verify(client).updateApplicationPriority(any(ApplicationId.class),
|
||||
any(Priority.class));
|
||||
|
||||
@ -2413,7 +2414,7 @@ public void testUpdateApplicationTimeout() throws Exception {
|
||||
|
||||
int result = cli.run(new String[] { "application", "-appId",
|
||||
applicationId.toString(), "-updateLifetime", "10" });
|
||||
Assert.assertEquals(result, 0);
|
||||
assertThat(result).isEqualTo(0);
|
||||
verify(client)
|
||||
.updateApplicationTimeouts(any(UpdateApplicationTimeoutsRequest.class));
|
||||
}
|
||||
|
@ -114,6 +114,11 @@
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- 'mvn dependency:analyze' fails to detect use of this dependency -->
|
||||
<dependency>
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
|
@ -34,6 +34,7 @@
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
@ -294,7 +295,7 @@ public void testParsingResourceTags() {
|
||||
ResourceUtils.getResourceTypes().get("resource3");
|
||||
Assert.assertTrue(info.getAttributes().isEmpty());
|
||||
Assert.assertFalse(info.getTags().isEmpty());
|
||||
Assert.assertEquals(info.getTags().size(), 2);
|
||||
assertThat(info.getTags()).hasSize(2);
|
||||
info.getTags().remove("resource3_tag_1");
|
||||
info.getTags().remove("resource3_tag_2");
|
||||
Assert.assertTrue(info.getTags().isEmpty());
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package org.apache.hadoop.yarn.logaggregation.filecontroller.ifile;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@ -288,7 +289,7 @@ public boolean isRollover(final FileContext fc,
|
||||
// We can only get the logs/logmeta from the first write.
|
||||
meta = fileFormat.readAggregatedLogsMeta(
|
||||
logRequest);
|
||||
Assert.assertEquals(meta.size(), 1);
|
||||
assertThat(meta.size()).isEqualTo(1);
|
||||
for (ContainerLogMeta log : meta) {
|
||||
Assert.assertTrue(log.getContainerId().equals(containerId.toString()));
|
||||
Assert.assertTrue(log.getNodeId().equals(nodeId.toString()));
|
||||
@ -319,7 +320,7 @@ public boolean isRollover(final FileContext fc,
|
||||
fileFormat.closeWriter();
|
||||
meta = fileFormat.readAggregatedLogsMeta(
|
||||
logRequest);
|
||||
Assert.assertEquals(meta.size(), 2);
|
||||
assertThat(meta.size()).isEqualTo(2);
|
||||
for (ContainerLogMeta log : meta) {
|
||||
Assert.assertTrue(log.getContainerId().equals(containerId.toString()));
|
||||
Assert.assertTrue(log.getNodeId().equals(nodeId.toString()));
|
||||
@ -347,7 +348,7 @@ public boolean isRollover(final FileContext fc,
|
||||
Assert.assertTrue(status.length == 2);
|
||||
meta = fileFormat.readAggregatedLogsMeta(
|
||||
logRequest);
|
||||
Assert.assertEquals(meta.size(), 3);
|
||||
assertThat(meta.size()).isEqualTo(3);
|
||||
for (ContainerLogMeta log : meta) {
|
||||
Assert.assertTrue(log.getContainerId().equals(containerId.toString()));
|
||||
Assert.assertTrue(log.getNodeId().equals(nodeId.toString()));
|
||||
|
@ -25,6 +25,7 @@
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@ -52,7 +53,7 @@ public void testSetEnvFromInputString() {
|
||||
String badEnv = "1,,2=a=b,3=a=,4==,5==a,==,c-3=3,=";
|
||||
environment.clear();
|
||||
Apps.setEnvFromInputString(environment, badEnv, File.pathSeparator);
|
||||
assertEquals(environment.size(), 0);
|
||||
assertThat(environment).isEmpty();
|
||||
|
||||
// Test "=" in the value part
|
||||
environment.clear();
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
package org.apache.hadoop.yarn.util;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@ -93,12 +94,12 @@ public void testNodeIdWithDefaultPort() throws URISyntaxException {
|
||||
NodeId nid;
|
||||
|
||||
nid = ConverterUtils.toNodeIdWithDefaultPort("node:10");
|
||||
assertEquals(nid.getPort(), 10);
|
||||
assertEquals(nid.getHost(), "node");
|
||||
assertThat(nid.getPort()).isEqualTo(10);
|
||||
assertThat(nid.getHost()).isEqualTo("node");
|
||||
|
||||
nid = ConverterUtils.toNodeIdWithDefaultPort("node");
|
||||
assertEquals(nid.getPort(), 0);
|
||||
assertEquals(nid.getHost(), "node");
|
||||
assertThat(nid.getPort()).isEqualTo(0);
|
||||
assertThat(nid.getHost()).isEqualTo("node");
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
|
@ -17,6 +17,8 @@
|
||||
*/
|
||||
package org.apache.hadoop.yarn.util;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
@ -59,7 +61,7 @@ public void testMapCastToHashMap() {
|
||||
HashMap<String, String> alternateHashMap =
|
||||
TimelineServiceHelper.mapCastToHashMap(firstTreeMap);
|
||||
Assert.assertEquals(firstTreeMap.size(), alternateHashMap.size());
|
||||
Assert.assertEquals(alternateHashMap.get(key), value);
|
||||
assertThat(alternateHashMap.get(key)).isEqualTo(value);
|
||||
|
||||
// Test complicated hashmap be casted correctly
|
||||
Map<String, Set<String>> complicatedHashMap =
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
package org.apache.hadoop.yarn.util.resource;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.yarn.api.protocolrecords.ResourceTypes;
|
||||
@ -501,27 +503,25 @@ public void testMultipleOpsForResourcesWithTags() throws Exception {
|
||||
ResourceInformation.newInstance("yarn.io/test-volume", "", 3));
|
||||
|
||||
Resource addedResource = Resources.add(resourceA, resourceB);
|
||||
Assert.assertEquals(addedResource.getMemorySize(), 5);
|
||||
Assert.assertEquals(addedResource.getVirtualCores(), 10);
|
||||
Assert.assertEquals(
|
||||
addedResource.getResourceInformation("resource1").getValue(), 8);
|
||||
assertThat(addedResource.getMemorySize()).isEqualTo(5);
|
||||
assertThat(addedResource.getVirtualCores()).isEqualTo(10);
|
||||
assertThat(addedResource.getResourceInformation("resource1").getValue()).
|
||||
isEqualTo(8);
|
||||
|
||||
// Verify that value of resourceA and resourceB is not added up for
|
||||
// "yarn.io/test-volume".
|
||||
Assert.assertEquals(
|
||||
addedResource.getResourceInformation("yarn.io/test-volume").getValue(),
|
||||
2);
|
||||
assertThat(addedResource.getResourceInformation("yarn.io/test-volume").
|
||||
getValue()).isEqualTo(2);
|
||||
|
||||
Resource mulResource = Resources.multiplyAndRoundDown(resourceA, 3);
|
||||
Assert.assertEquals(mulResource.getMemorySize(), 6);
|
||||
Assert.assertEquals(mulResource.getVirtualCores(), 12);
|
||||
Assert.assertEquals(
|
||||
mulResource.getResourceInformation("resource1").getValue(), 15);
|
||||
assertThat(mulResource.getMemorySize()).isEqualTo(6);
|
||||
assertThat(mulResource.getVirtualCores()).isEqualTo(12);
|
||||
assertThat(mulResource.getResourceInformation("resource1").getValue()).
|
||||
isEqualTo(15);
|
||||
|
||||
// Verify that value of resourceA is not multiplied up for
|
||||
// "yarn.io/test-volume".
|
||||
Assert.assertEquals(
|
||||
mulResource.getResourceInformation("yarn.io/test-volume").getValue(),
|
||||
2);
|
||||
assertThat(mulResource.getResourceInformation("yarn.io/test-volume").
|
||||
getValue()).isEqualTo(2);
|
||||
}
|
||||
}
|
||||
|
@ -73,6 +73,11 @@
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
<artifactId>hadoop-common</artifactId>
|
||||
|
@ -52,6 +52,7 @@
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.ServerSocket;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.apache.hadoop.yarn.api.protocolrecords.ValidateVolumeCapabilitiesRequest.AccessMode.MULTI_NODE_MULTI_WRITER;
|
||||
import static org.apache.hadoop.yarn.api.protocolrecords.ValidateVolumeCapabilitiesRequest.VolumeType.FILE_SYSTEM;
|
||||
|
||||
@ -333,8 +334,8 @@ public void testCustomizedAdaptor() throws IOException, YarnException {
|
||||
// Test getPluginInfo
|
||||
GetPluginInfoResponse pluginInfo =
|
||||
adaptorClient.getPluginInfo(GetPluginInfoRequest.newInstance());
|
||||
Assert.assertEquals(pluginInfo.getDriverName(), "customized-driver");
|
||||
Assert.assertEquals(pluginInfo.getVersion(), "1.0");
|
||||
assertThat(pluginInfo.getDriverName()).isEqualTo("customized-driver");
|
||||
assertThat(pluginInfo.getVersion()).isEqualTo("1.0");
|
||||
|
||||
// Test validateVolumeCapacity
|
||||
ValidateVolumeCapabilitiesRequest request =
|
||||
@ -412,8 +413,8 @@ public void testMultipleCsiAdaptors() throws IOException, YarnException {
|
||||
// Test getPluginInfo
|
||||
GetPluginInfoResponse pluginInfo =
|
||||
client1.getPluginInfo(GetPluginInfoRequest.newInstance());
|
||||
Assert.assertEquals(pluginInfo.getDriverName(), "customized-driver-1");
|
||||
Assert.assertEquals(pluginInfo.getVersion(), "1.0");
|
||||
assertThat(pluginInfo.getDriverName()).isEqualTo("customized-driver-1");
|
||||
assertThat(pluginInfo.getVersion()).isEqualTo("1.0");
|
||||
|
||||
// Test validateVolumeCapacity
|
||||
ValidateVolumeCapabilitiesRequest request =
|
||||
@ -440,8 +441,8 @@ public void testMultipleCsiAdaptors() throws IOException, YarnException {
|
||||
driver2Addr.getLocalPort()));
|
||||
GetPluginInfoResponse pluginInfo2 =
|
||||
client2.getPluginInfo(GetPluginInfoRequest.newInstance());
|
||||
Assert.assertEquals(pluginInfo2.getDriverName(), "customized-driver-2");
|
||||
Assert.assertEquals(pluginInfo2.getVersion(), "1.0");
|
||||
assertThat(pluginInfo2.getDriverName()).isEqualTo("customized-driver-2");
|
||||
assertThat(pluginInfo2.getVersion()).isEqualTo("1.0");
|
||||
|
||||
services.stop();
|
||||
}
|
||||
|
@ -76,6 +76,11 @@
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- 'mvn dependency:analyze' fails to detect use of this dependency -->
|
||||
<dependency>
|
||||
<groupId>com.google.inject</groupId>
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package org.apache.hadoop.yarn.server.applicationhistoryservice.webapp;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.apache.hadoop.yarn.webapp.WebServicesTestUtils.assertResponseStatusCode;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@ -678,7 +679,7 @@ public void testContainerLogsForFinishedApps() throws Exception {
|
||||
.accept(MediaType.TEXT_PLAIN)
|
||||
.get(ClientResponse.class);
|
||||
responseText = response.getEntity(String.class);
|
||||
assertEquals(responseText.getBytes().length, fullTextSize);
|
||||
assertThat(responseText.getBytes()).hasSize(fullTextSize);
|
||||
|
||||
r = resource();
|
||||
response = r.path("ws").path("v1")
|
||||
@ -689,7 +690,7 @@ public void testContainerLogsForFinishedApps() throws Exception {
|
||||
.accept(MediaType.TEXT_PLAIN)
|
||||
.get(ClientResponse.class);
|
||||
responseText = response.getEntity(String.class);
|
||||
assertEquals(responseText.getBytes().length, fullTextSize);
|
||||
assertThat(responseText.getBytes()).hasSize(fullTextSize);
|
||||
}
|
||||
|
||||
@Test(timeout = 10000)
|
||||
@ -880,8 +881,8 @@ public void testContainerLogsMetaForRunningApps() throws Exception {
|
||||
List<ContainerLogFileInfo> logMeta = logInfo
|
||||
.getContainerLogsInfo();
|
||||
assertTrue(logMeta.size() == 1);
|
||||
assertEquals(logMeta.get(0).getFileName(), fileName);
|
||||
assertEquals(logMeta.get(0).getFileSize(), String.valueOf(
|
||||
assertThat(logMeta.get(0).getFileName()).isEqualTo(fileName);
|
||||
assertThat(logMeta.get(0).getFileSize()).isEqualTo(String.valueOf(
|
||||
content.length()));
|
||||
} else {
|
||||
assertEquals(logInfo.getLogType(),
|
||||
@ -908,11 +909,11 @@ public void testContainerLogsMetaForRunningApps() throws Exception {
|
||||
List<ContainerLogFileInfo> logMeta = logInfo
|
||||
.getContainerLogsInfo();
|
||||
assertTrue(logMeta.size() == 1);
|
||||
assertEquals(logMeta.get(0).getFileName(), fileName);
|
||||
assertEquals(logMeta.get(0).getFileSize(), String.valueOf(
|
||||
assertThat(logMeta.get(0).getFileName()).isEqualTo(fileName);
|
||||
assertThat(logMeta.get(0).getFileSize()).isEqualTo(String.valueOf(
|
||||
content.length()));
|
||||
} else {
|
||||
assertEquals(logInfo.getLogType(),
|
||||
assertThat(logInfo.getLogType()).isEqualTo(
|
||||
ContainerLogAggregationType.LOCAL.toString());
|
||||
}
|
||||
}
|
||||
@ -946,8 +947,8 @@ public void testContainerLogsMetaForFinishedApps() throws Exception {
|
||||
List<ContainerLogFileInfo> logMeta = responseText.get(0)
|
||||
.getContainerLogsInfo();
|
||||
assertTrue(logMeta.size() == 1);
|
||||
assertEquals(logMeta.get(0).getFileName(), fileName);
|
||||
assertEquals(logMeta.get(0).getFileSize(),
|
||||
assertThat(logMeta.get(0).getFileName()).isEqualTo(fileName);
|
||||
assertThat(logMeta.get(0).getFileSize()).isEqualTo(
|
||||
String.valueOf(content.length()));
|
||||
}
|
||||
|
||||
|
@ -95,6 +95,11 @@
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.zookeeper</groupId>
|
||||
<artifactId>zookeeper</artifactId>
|
||||
|
@ -17,6 +17,8 @@
|
||||
|
||||
package org.apache.hadoop.yarn.server.federation.policies.manager;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.apache.hadoop.yarn.server.federation.policies.FederationPolicyInitializationContext;
|
||||
import org.apache.hadoop.yarn.server.federation.policies.amrmproxy.FederationAMRMProxyPolicy;
|
||||
import org.apache.hadoop.yarn.server.federation.policies.exceptions.FederationPolicyInitializationException;
|
||||
@ -24,7 +26,6 @@
|
||||
import org.apache.hadoop.yarn.server.federation.store.records.SubClusterId;
|
||||
import org.apache.hadoop.yarn.server.federation.store.records.SubClusterPolicyConfiguration;
|
||||
import org.apache.hadoop.yarn.server.federation.utils.FederationPoliciesTestUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
@ -92,10 +93,10 @@ protected static void serializeAndDeserializePolicyManager(
|
||||
FederationRouterPolicy federationRouterPolicy =
|
||||
wfp2.getRouterPolicy(context, null);
|
||||
|
||||
Assert.assertEquals(federationAMRMProxyPolicy.getClass(),
|
||||
expAMRMProxyPolicy);
|
||||
assertThat(federationAMRMProxyPolicy).
|
||||
isExactlyInstanceOf(expAMRMProxyPolicy);
|
||||
|
||||
Assert.assertEquals(federationRouterPolicy.getClass(), expRouterPolicy);
|
||||
assertThat(federationRouterPolicy).isExactlyInstanceOf(expRouterPolicy);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -131,6 +131,11 @@
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.inject</groupId>
|
||||
<artifactId>guice</artifactId>
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package org.apache.hadoop.yarn.server.nodemanager;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.apache.hadoop.test.PlatformAssumptions.assumeNotWindows;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
@ -306,33 +307,34 @@ public void testStartLocalizer() throws IOException {
|
||||
.build());
|
||||
|
||||
List<String> result=readMockParams();
|
||||
Assert.assertEquals(result.size(), 26);
|
||||
Assert.assertEquals(result.get(0), YarnConfiguration.DEFAULT_NM_NONSECURE_MODE_LOCAL_USER);
|
||||
Assert.assertEquals(result.get(1), "test");
|
||||
Assert.assertEquals(result.get(2), "0" );
|
||||
Assert.assertEquals(result.get(3), "application_0");
|
||||
Assert.assertEquals(result.get(4), "12345");
|
||||
Assert.assertEquals(result.get(5), "/bin/nmPrivateCTokensPath");
|
||||
Assert.assertEquals(result.get(9), "-classpath" );
|
||||
Assert.assertEquals(result.get(12), "-Xmx256m" );
|
||||
Assert.assertEquals(result.get(13),
|
||||
assertThat(result).hasSize(26);
|
||||
assertThat(result.get(0)).isEqualTo(YarnConfiguration.
|
||||
DEFAULT_NM_NONSECURE_MODE_LOCAL_USER);
|
||||
assertThat(result.get(1)).isEqualTo("test");
|
||||
assertThat(result.get(2)).isEqualTo("0");
|
||||
assertThat(result.get(3)).isEqualTo("application_0");
|
||||
assertThat(result.get(4)).isEqualTo("12345");
|
||||
assertThat(result.get(5)).isEqualTo("/bin/nmPrivateCTokensPath");
|
||||
assertThat(result.get(9)).isEqualTo("-classpath");
|
||||
assertThat(result.get(12)).isEqualTo("-Xmx256m");
|
||||
assertThat(result.get(13)).isEqualTo(
|
||||
"-Dlog4j.configuration=container-log4j.properties" );
|
||||
Assert.assertEquals(result.get(14),
|
||||
assertThat(result.get(14)).isEqualTo(
|
||||
String.format("-Dyarn.app.container.log.dir=%s/application_0/12345",
|
||||
mockExec.getConf().get(YarnConfiguration.NM_LOG_DIRS)));
|
||||
Assert.assertEquals(result.get(15),
|
||||
assertThat(result.get(15)).isEqualTo(
|
||||
"-Dyarn.app.container.log.filesize=0");
|
||||
Assert.assertEquals(result.get(16), "-Dhadoop.root.logger=INFO,CLA");
|
||||
Assert.assertEquals(result.get(17),
|
||||
assertThat(result.get(16)).isEqualTo("-Dhadoop.root.logger=INFO,CLA");
|
||||
assertThat(result.get(17)).isEqualTo(
|
||||
"-Dhadoop.root.logfile=container-localizer-syslog");
|
||||
Assert.assertEquals(result.get(18),
|
||||
"org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.ContainerLocalizer");
|
||||
Assert.assertEquals(result.get(19), "test");
|
||||
Assert.assertEquals(result.get(20), "application_0");
|
||||
Assert.assertEquals(result.get(21), "12345");
|
||||
Assert.assertEquals(result.get(22), "localhost");
|
||||
Assert.assertEquals(result.get(23), "8040");
|
||||
Assert.assertEquals(result.get(24), "nmPrivateCTokensPath");
|
||||
assertThat(result.get(18)).isEqualTo("org.apache.hadoop.yarn.server." +
|
||||
"nodemanager.containermanager.localizer.ContainerLocalizer");
|
||||
assertThat(result.get(19)).isEqualTo("test");
|
||||
assertThat(result.get(20)).isEqualTo("application_0");
|
||||
assertThat(result.get(21)).isEqualTo("12345");
|
||||
assertThat(result.get(22)).isEqualTo("localhost");
|
||||
assertThat(result.get(23)).isEqualTo("8040");
|
||||
assertThat(result.get(24)).isEqualTo("nmPrivateCTokensPath");
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
LOG.error("Error:"+e.getMessage(),e);
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package org.apache.hadoop.yarn.server.nodemanager.containermanager;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
@ -302,7 +303,7 @@ public void testApplicationRecovery() throws Exception {
|
||||
// simulate log aggregation completion
|
||||
app.handle(new ApplicationEvent(app.getAppId(),
|
||||
ApplicationEventType.APPLICATION_RESOURCES_CLEANEDUP));
|
||||
assertEquals(app.getApplicationState(), ApplicationState.FINISHED);
|
||||
assertThat(app.getApplicationState()).isEqualTo(ApplicationState.FINISHED);
|
||||
app.handle(new ApplicationEvent(app.getAppId(),
|
||||
ApplicationEventType.APPLICATION_LOG_HANDLING_FINISHED));
|
||||
|
||||
@ -362,7 +363,7 @@ public void testNMRecoveryForAppFinishedWithLogAggregationFailure()
|
||||
|
||||
app.handle(new ApplicationEvent(app.getAppId(),
|
||||
ApplicationEventType.APPLICATION_RESOURCES_CLEANEDUP));
|
||||
assertEquals(app.getApplicationState(), ApplicationState.FINISHED);
|
||||
assertThat(app.getApplicationState()).isEqualTo(ApplicationState.FINISHED);
|
||||
// application is still in NM context.
|
||||
assertEquals(1, context.getApplications().size());
|
||||
|
||||
@ -386,7 +387,7 @@ public void testNMRecoveryForAppFinishedWithLogAggregationFailure()
|
||||
// is needed.
|
||||
app.handle(new ApplicationEvent(app.getAppId(),
|
||||
ApplicationEventType.APPLICATION_RESOURCES_CLEANEDUP));
|
||||
assertEquals(app.getApplicationState(), ApplicationState.FINISHED);
|
||||
assertThat(app.getApplicationState()).isEqualTo(ApplicationState.FINISHED);
|
||||
|
||||
// simulate log aggregation failed.
|
||||
app.handle(new ApplicationEvent(app.getAppId(),
|
||||
@ -528,7 +529,8 @@ public void testContainerSchedulerRecovery() throws Exception {
|
||||
|
||||
ResourceUtilization utilization =
|
||||
ResourceUtilization.newInstance(1024, 2048, 1.0F);
|
||||
assertEquals(cm.getContainerScheduler().getNumRunningContainers(), 1);
|
||||
assertThat(cm.getContainerScheduler().getNumRunningContainers()).
|
||||
isEqualTo(1);
|
||||
assertEquals(utilization,
|
||||
cm.getContainerScheduler().getCurrentUtilization());
|
||||
|
||||
@ -544,7 +546,8 @@ public void testContainerSchedulerRecovery() throws Exception {
|
||||
assertNotNull(app);
|
||||
waitForNMContainerState(cm, cid, ContainerState.RUNNING);
|
||||
|
||||
assertEquals(cm.getContainerScheduler().getNumRunningContainers(), 1);
|
||||
assertThat(cm.getContainerScheduler().getNumRunningContainers()).
|
||||
isEqualTo(1);
|
||||
assertEquals(utilization,
|
||||
cm.getContainerScheduler().getCurrentUtilization());
|
||||
cm.stop();
|
||||
|
@ -18,9 +18,11 @@
|
||||
|
||||
package org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.apache.hadoop.test.PlatformAssumptions.assumeWindows;
|
||||
import static org.apache.hadoop.test.PlatformAssumptions.assumeNotWindows;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
@ -124,7 +126,6 @@
|
||||
import org.apache.hadoop.yarn.util.AuxiliaryServiceHelper;
|
||||
import org.apache.hadoop.yarn.util.LinuxResourceCalculatorPlugin;
|
||||
import org.apache.hadoop.yarn.util.ResourceCalculatorPlugin;
|
||||
import org.hamcrest.CoreMatchers;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Before;
|
||||
@ -212,7 +213,7 @@ public void testSpecialCharSymlinks() throws IOException {
|
||||
= new Shell.ShellCommandExecutor(new String[]{tempFile.getAbsolutePath()}, tmpDir);
|
||||
|
||||
shexc.execute();
|
||||
assertEquals(shexc.getExitCode(), 0);
|
||||
assertThat(shexc.getExitCode()).isEqualTo(0);
|
||||
//Capture output from prelaunch.out
|
||||
|
||||
List<String> output = Files.readAllLines(Paths.get(localLogDir.getAbsolutePath(), ContainerLaunch.CONTAINER_PRE_LAUNCH_STDOUT),
|
||||
@ -1485,7 +1486,7 @@ public void testWindowsShellScriptBuilderCommand() throws IOException {
|
||||
"X", Shell.WINDOWS_MAX_SHELL_LENGTH -callCmd.length() + 1)));
|
||||
fail("longCommand was expected to throw");
|
||||
} catch(IOException e) {
|
||||
assertThat(e.getMessage(), CoreMatchers.containsString(expectedMessage));
|
||||
assertThat(e).hasMessageContaining(expectedMessage);
|
||||
}
|
||||
|
||||
// Composite tests, from parts: less, exact and +
|
||||
@ -1507,7 +1508,7 @@ public void testWindowsShellScriptBuilderCommand() throws IOException {
|
||||
org.apache.commons.lang3.StringUtils.repeat("X", 2048 - callCmd.length())));
|
||||
fail("long commands was expected to throw");
|
||||
} catch(IOException e) {
|
||||
assertThat(e.getMessage(), CoreMatchers.containsString(expectedMessage));
|
||||
assertThat(e).hasMessageContaining(expectedMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1530,7 +1531,7 @@ public void testWindowsShellScriptBuilderEnv() throws IOException {
|
||||
"A", Shell.WINDOWS_MAX_SHELL_LENGTH - ("@set somekey=").length()) + 1);
|
||||
fail("long env was expected to throw");
|
||||
} catch(IOException e) {
|
||||
assertThat(e.getMessage(), CoreMatchers.containsString(expectedMessage));
|
||||
assertThat(e).hasMessageContaining(expectedMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1555,8 +1556,8 @@ public void testWindowsShellScriptBuilderMkdir() throws IOException {
|
||||
"X", (Shell.WINDOWS_MAX_SHELL_LENGTH - mkDirCmd.length())/2 +1)));
|
||||
fail("long mkdir was expected to throw");
|
||||
} catch(IOException e) {
|
||||
assertThat(e.getMessage(), CoreMatchers.containsString(expectedMessage));
|
||||
}
|
||||
assertThat(e).hasMessageContaining(expectedMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@Test (timeout = 10000)
|
||||
@ -1586,7 +1587,7 @@ public void testWindowsShellScriptBuilderLink() throws IOException {
|
||||
"Y", (Shell.WINDOWS_MAX_SHELL_LENGTH - linkCmd.length())/2) + 1));
|
||||
fail("long link was expected to throw");
|
||||
} catch(IOException e) {
|
||||
assertThat(e.getMessage(), CoreMatchers.containsString(expectedMessage));
|
||||
assertThat(e).hasMessageContaining(expectedMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1747,7 +1748,7 @@ public void testDebuggingInformation() throws IOException {
|
||||
new String[] { tempFile.getAbsolutePath() }, tmpDir);
|
||||
|
||||
shexc.execute();
|
||||
assertEquals(shexc.getExitCode(), 0);
|
||||
assertThat(shexc.getExitCode()).isEqualTo(0);
|
||||
File directorInfo =
|
||||
new File(localLogDir, ContainerExecutor.DIRECTORY_CONTENTS);
|
||||
File scriptCopy = new File(localLogDir, tempFile.getName());
|
||||
|
@ -20,6 +20,8 @@
|
||||
|
||||
package org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
||||
import org.apache.hadoop.yarn.server.nodemanager.Context;
|
||||
@ -71,7 +73,7 @@ public void testOutboundBandwidthHandler() {
|
||||
List<ResourceHandler> resourceHandlers = resourceHandlerChain
|
||||
.getResourceHandlerList();
|
||||
//Exactly one resource handler in chain
|
||||
Assert.assertEquals(resourceHandlers.size(), 1);
|
||||
assertThat(resourceHandlers).hasSize(1);
|
||||
//Same instance is expected to be in the chain.
|
||||
Assert.assertTrue(resourceHandlers.get(0) == resourceHandler);
|
||||
} else {
|
||||
@ -102,7 +104,7 @@ public void testDiskResourceHandler() throws Exception {
|
||||
List<ResourceHandler> resourceHandlers =
|
||||
resourceHandlerChain.getResourceHandlerList();
|
||||
// Exactly one resource handler in chain
|
||||
Assert.assertEquals(resourceHandlers.size(), 1);
|
||||
assertThat(resourceHandlers).hasSize(1);
|
||||
// Same instance is expected to be in the chain.
|
||||
Assert.assertTrue(resourceHandlers.get(0) == handler);
|
||||
} else {
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
@ -1325,15 +1326,15 @@ private void doLocalization(ResourceLocalizationService spyService,
|
||||
// hence its not removed despite ref cnt being 0.
|
||||
LocalizedResource rsrc1 = tracker.getLocalizedResource(req1);
|
||||
assertNotNull(rsrc1);
|
||||
assertEquals(rsrc1.getState(), ResourceState.LOCALIZED);
|
||||
assertEquals(rsrc1.getRefCount(), 0);
|
||||
assertThat(rsrc1.getState()).isEqualTo(ResourceState.LOCALIZED);
|
||||
assertThat(rsrc1.getRefCount()).isEqualTo(0);
|
||||
|
||||
// Container c1 was killed but this resource is referenced by container c2
|
||||
// as well hence its ref cnt is 1.
|
||||
LocalizedResource rsrc2 = tracker.getLocalizedResource(req2);
|
||||
assertNotNull(rsrc2);
|
||||
assertEquals(rsrc2.getState(), ResourceState.DOWNLOADING);
|
||||
assertEquals(rsrc2.getRefCount(), 1);
|
||||
assertThat(rsrc2.getState()).isEqualTo(ResourceState.DOWNLOADING);
|
||||
assertThat(rsrc2.getRefCount()).isEqualTo(1);
|
||||
|
||||
// As container c1 was killed and this resource was not referenced by any
|
||||
// other container, hence its removed.
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package org.apache.hadoop.yarn.server.nodemanager.containermanager.logaggregation;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
@ -870,7 +871,7 @@ public LogAggregationFileController getLogAggregationFileController(
|
||||
};
|
||||
checkEvents(appEventHandler, expectedEvents, false,
|
||||
"getType", "getApplicationID", "getDiagnostic");
|
||||
Assert.assertEquals(logAggregationService.getInvalidTokenApps().size(), 1);
|
||||
assertThat(logAggregationService.getInvalidTokenApps()).hasSize(1);
|
||||
// verify trying to collect logs for containers/apps we don't know about
|
||||
// doesn't blow up and tear down the NM
|
||||
logAggregationService.handle(new LogHandlerContainerFinishedEvent(
|
||||
|
@ -39,6 +39,7 @@
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyMap;
|
||||
import static org.mockito.ArgumentMatchers.anySet;
|
||||
@ -265,7 +266,7 @@ public void testTopologySchedulingWithPackPolicy() throws Exception {
|
||||
reset(spyPlugin);
|
||||
Set<Device> allocation = spyPlugin.allocateDevices(copyAvailableDevices,
|
||||
1, env);
|
||||
Assert.assertEquals(allocation.size(), 1);
|
||||
assertThat(allocation).hasSize(1);
|
||||
verify(spyPlugin).basicSchedule(anySet(), anyInt(), anySet());
|
||||
Assert.assertFalse(spyPlugin.isTopoInitialized());
|
||||
|
||||
@ -273,7 +274,7 @@ public void testTopologySchedulingWithPackPolicy() throws Exception {
|
||||
reset(spyPlugin);
|
||||
allocation = spyPlugin.allocateDevices(allDevices, 1, env);
|
||||
// ensure no topology scheduling needed
|
||||
Assert.assertEquals(allocation.size(), 1);
|
||||
assertThat(allocation).hasSize(1);
|
||||
verify(spyPlugin).basicSchedule(anySet(), anyInt(), anySet());
|
||||
reset(spyPlugin);
|
||||
// Case 2. allocate all available
|
||||
@ -285,13 +286,13 @@ public void testTopologySchedulingWithPackPolicy() throws Exception {
|
||||
int count = 2;
|
||||
Map<String, Integer> pairToWeight = spyPlugin.getDevicePairToWeight();
|
||||
allocation = spyPlugin.allocateDevices(allDevices, count, env);
|
||||
Assert.assertEquals(allocation.size(), count);
|
||||
assertThat(allocation).hasSize(count);
|
||||
// the costTable should be init and used topology scheduling
|
||||
verify(spyPlugin).initCostTable();
|
||||
Assert.assertTrue(spyPlugin.isTopoInitialized());
|
||||
verify(spyPlugin).topologyAwareSchedule(anySet(), anyInt(), anyMap(),
|
||||
anySet(), anyMap());
|
||||
Assert.assertEquals(allocation.size(), count);
|
||||
assertThat(allocation).hasSize(count);
|
||||
Device[] allocatedDevices =
|
||||
allocation.toArray(new Device[count]);
|
||||
// Check weights
|
||||
@ -302,13 +303,13 @@ public void testTopologySchedulingWithPackPolicy() throws Exception {
|
||||
reset(spyPlugin);
|
||||
count = 3;
|
||||
allocation = spyPlugin.allocateDevices(allDevices, count, env);
|
||||
Assert.assertEquals(allocation.size(), count);
|
||||
assertThat(allocation).hasSize(count);
|
||||
// the costTable should be init and used topology scheduling
|
||||
verify(spyPlugin, times(0)).initCostTable();
|
||||
Assert.assertTrue(spyPlugin.isTopoInitialized());
|
||||
verify(spyPlugin).topologyAwareSchedule(anySet(), anyInt(), anyMap(),
|
||||
anySet(), anyMap());
|
||||
Assert.assertEquals(allocation.size(), count);
|
||||
assertThat(allocation).hasSize(count);
|
||||
allocatedDevices =
|
||||
allocation.toArray(new Device[count]);
|
||||
// check weights
|
||||
@ -327,13 +328,13 @@ public void testTopologySchedulingWithPackPolicy() throws Exception {
|
||||
iterator.remove();
|
||||
count = 2;
|
||||
allocation = spyPlugin.allocateDevices(allDevices, count, env);
|
||||
Assert.assertEquals(allocation.size(), count);
|
||||
assertThat(allocation).hasSize(count);
|
||||
// the costTable should be init and used topology scheduling
|
||||
verify(spyPlugin, times(0)).initCostTable();
|
||||
Assert.assertTrue(spyPlugin.isTopoInitialized());
|
||||
verify(spyPlugin).topologyAwareSchedule(anySet(), anyInt(), anyMap(),
|
||||
anySet(), anyMap());
|
||||
Assert.assertEquals(allocation.size(), count);
|
||||
assertThat(allocation).hasSize(count);
|
||||
allocatedDevices =
|
||||
allocation.toArray(new Device[count]);
|
||||
// check weights
|
||||
@ -377,13 +378,13 @@ public void testTopologySchedulingWithSpreadPolicy() throws Exception {
|
||||
int count = 2;
|
||||
Map<String, Integer> pairToWeight = spyPlugin.getDevicePairToWeight();
|
||||
allocation = spyPlugin.allocateDevices(allDevices, count, env);
|
||||
Assert.assertEquals(allocation.size(), count);
|
||||
assertThat(allocation).hasSize(count);
|
||||
// the costTable should be init and used topology scheduling
|
||||
verify(spyPlugin).initCostTable();
|
||||
Assert.assertTrue(spyPlugin.isTopoInitialized());
|
||||
verify(spyPlugin).topologyAwareSchedule(anySet(), anyInt(), anyMap(),
|
||||
anySet(), anyMap());
|
||||
Assert.assertEquals(allocation.size(), count);
|
||||
assertThat(allocation).hasSize(count);
|
||||
Device[] allocatedDevices =
|
||||
allocation.toArray(new Device[count]);
|
||||
// Check weights
|
||||
@ -394,13 +395,13 @@ public void testTopologySchedulingWithSpreadPolicy() throws Exception {
|
||||
reset(spyPlugin);
|
||||
count = 3;
|
||||
allocation = spyPlugin.allocateDevices(allDevices, count, env);
|
||||
Assert.assertEquals(allocation.size(), count);
|
||||
assertThat(allocation).hasSize(count);
|
||||
// the costTable should be init and used topology scheduling
|
||||
verify(spyPlugin, times(0)).initCostTable();
|
||||
Assert.assertTrue(spyPlugin.isTopoInitialized());
|
||||
verify(spyPlugin).topologyAwareSchedule(anySet(), anyInt(), anyMap(),
|
||||
anySet(), anyMap());
|
||||
Assert.assertEquals(allocation.size(), count);
|
||||
assertThat(allocation).hasSize(count);
|
||||
allocatedDevices =
|
||||
allocation.toArray(new Device[count]);
|
||||
// check weights
|
||||
@ -419,13 +420,13 @@ public void testTopologySchedulingWithSpreadPolicy() throws Exception {
|
||||
iterator.remove();
|
||||
count = 2;
|
||||
allocation = spyPlugin.allocateDevices(allDevices, count, env);
|
||||
Assert.assertEquals(allocation.size(), count);
|
||||
assertThat(allocation).hasSize(count);
|
||||
// the costTable should be init and used topology scheduling
|
||||
verify(spyPlugin, times(0)).initCostTable();
|
||||
Assert.assertTrue(spyPlugin.isTopoInitialized());
|
||||
verify(spyPlugin).topologyAwareSchedule(anySet(), anyInt(), anyMap(),
|
||||
anySet(), anyMap());
|
||||
Assert.assertEquals(allocation.size(), count);
|
||||
assertThat(allocation).hasSize(count);
|
||||
allocatedDevices =
|
||||
allocation.toArray(new Device[count]);
|
||||
// check weights
|
||||
@ -574,7 +575,7 @@ public void testTopologySchedulingPerformanceWithPackPolicyWithNVLink()
|
||||
report.readFromFile();
|
||||
ArrayList<ActualPerformanceReport.DataRecord> dataSet =
|
||||
report.getDataSet();
|
||||
Assert.assertEquals(dataSet.size(), 2952);
|
||||
assertThat(dataSet).hasSize(2952);
|
||||
String[] allModels = {"alexnet", "resnet50", "vgg16", "inception3"};
|
||||
int[] batchSizes = {32, 64, 128};
|
||||
int[] gpuCounts = {2, 3, 4, 5, 6, 7};
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package org.apache.hadoop.yarn.server.nodemanager.recovery;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.fusesource.leveldbjni.JniDBFactory.bytes;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
@ -36,6 +37,7 @@
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
@ -1350,9 +1352,9 @@ public void testUnexpectedKeyDoesntThrowException() throws IOException {
|
||||
@Test
|
||||
public void testAMRMProxyStorage() throws IOException {
|
||||
RecoveredAMRMProxyState state = stateStore.loadAMRMProxyState();
|
||||
assertEquals(state.getCurrentMasterKey(), null);
|
||||
assertEquals(state.getNextMasterKey(), null);
|
||||
assertEquals(state.getAppContexts().size(), 0);
|
||||
assertThat(state.getCurrentMasterKey()).isNull();
|
||||
assertThat(state.getNextMasterKey()).isNull();
|
||||
assertThat(state.getAppContexts()).isEmpty();
|
||||
|
||||
ApplicationId appId1 = ApplicationId.newInstance(1, 1);
|
||||
ApplicationId appId2 = ApplicationId.newInstance(1, 2);
|
||||
@ -1384,18 +1386,18 @@ public void testAMRMProxyStorage() throws IOException {
|
||||
state = stateStore.loadAMRMProxyState();
|
||||
assertEquals(state.getCurrentMasterKey(),
|
||||
secretManager.getCurrentMasterKeyData().getMasterKey());
|
||||
assertEquals(state.getNextMasterKey(), null);
|
||||
assertEquals(state.getAppContexts().size(), 2);
|
||||
assertThat(state.getNextMasterKey()).isNull();
|
||||
assertThat(state.getAppContexts()).hasSize(2);
|
||||
// app1
|
||||
Map<String, byte[]> map = state.getAppContexts().get(attemptId1);
|
||||
assertNotEquals(map, null);
|
||||
assertEquals(map.size(), 2);
|
||||
assertThat(map).hasSize(2);
|
||||
assertTrue(Arrays.equals(map.get(key1), data1));
|
||||
assertTrue(Arrays.equals(map.get(key2), data2));
|
||||
// app2
|
||||
map = state.getAppContexts().get(attemptId2);
|
||||
assertNotEquals(map, null);
|
||||
assertEquals(map.size(), 2);
|
||||
assertThat(map).hasSize(2);
|
||||
assertTrue(Arrays.equals(map.get(key1), data1));
|
||||
assertTrue(Arrays.equals(map.get(key2), data2));
|
||||
|
||||
@ -1414,14 +1416,14 @@ public void testAMRMProxyStorage() throws IOException {
|
||||
assertEquals(state.getAppContexts().size(), 2);
|
||||
// app1
|
||||
map = state.getAppContexts().get(attemptId1);
|
||||
assertNotEquals(map, null);
|
||||
assertEquals(map.size(), 2);
|
||||
assertThat(map).isNotNull();
|
||||
assertThat(map).hasSize(2);
|
||||
assertTrue(Arrays.equals(map.get(key1), data1));
|
||||
assertTrue(Arrays.equals(map.get(key2), data2));
|
||||
// app2
|
||||
map = state.getAppContexts().get(attemptId2);
|
||||
assertNotEquals(map, null);
|
||||
assertEquals(map.size(), 1);
|
||||
assertThat(map).isNotNull();
|
||||
assertThat(map).hasSize(1);
|
||||
assertTrue(Arrays.equals(map.get(key2), data2));
|
||||
|
||||
// Activate next master key and remove all entries of app1
|
||||
@ -1434,12 +1436,12 @@ public void testAMRMProxyStorage() throws IOException {
|
||||
state = stateStore.loadAMRMProxyState();
|
||||
assertEquals(state.getCurrentMasterKey(),
|
||||
secretManager.getCurrentMasterKeyData().getMasterKey());
|
||||
assertEquals(state.getNextMasterKey(), null);
|
||||
assertEquals(state.getAppContexts().size(), 1);
|
||||
assertThat(state.getNextMasterKey()).isNull();
|
||||
assertThat(state.getAppContexts()).hasSize(1);
|
||||
// app2 only
|
||||
map = state.getAppContexts().get(attemptId2);
|
||||
assertNotEquals(map, null);
|
||||
assertEquals(map.size(), 1);
|
||||
assertThat(map).isNotNull();
|
||||
assertThat(map).hasSize(1);
|
||||
assertTrue(Arrays.equals(map.get(key2), data2));
|
||||
} finally {
|
||||
secretManager.stop();
|
||||
|
@ -96,6 +96,7 @@
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.apache.hadoop.yarn.webapp.WebServicesTestUtils.assertResponseStatusCode;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
@ -704,7 +705,7 @@ private void testContainerLogs(WebResource r, ContainerId containerId)
|
||||
List<ContainerLogFileInfo> logMeta = responseList.get(0)
|
||||
.getContainerLogsInfo();
|
||||
assertTrue(logMeta.size() == 1);
|
||||
assertEquals(logMeta.get(0).getFileName(), filename);
|
||||
assertThat(logMeta.get(0).getFileName()).isEqualTo(filename);
|
||||
|
||||
// now create an aggregated log in Remote File system
|
||||
File tempLogDir = new File("target",
|
||||
@ -724,19 +725,19 @@ private void testContainerLogs(WebResource r, ContainerId containerId)
|
||||
assertEquals(200, response.getStatus());
|
||||
responseList = response.getEntity(new GenericType<
|
||||
List<ContainerLogsInfo>>(){});
|
||||
assertEquals(responseList.size(), 2);
|
||||
assertThat(responseList).hasSize(2);
|
||||
for (ContainerLogsInfo logInfo : responseList) {
|
||||
if(logInfo.getLogType().equals(
|
||||
ContainerLogAggregationType.AGGREGATED.toString())) {
|
||||
List<ContainerLogFileInfo> meta = logInfo.getContainerLogsInfo();
|
||||
assertTrue(meta.size() == 1);
|
||||
assertEquals(meta.get(0).getFileName(), aggregatedLogFile);
|
||||
assertThat(meta.get(0).getFileName()).isEqualTo(aggregatedLogFile);
|
||||
} else {
|
||||
assertEquals(logInfo.getLogType(),
|
||||
ContainerLogAggregationType.LOCAL.toString());
|
||||
List<ContainerLogFileInfo> meta = logInfo.getContainerLogsInfo();
|
||||
assertTrue(meta.size() == 1);
|
||||
assertEquals(meta.get(0).getFileName(), filename);
|
||||
assertThat(meta.get(0).getFileName()).isEqualTo(filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,6 +57,11 @@
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package org.apache.hadoop.yarn.server.resourcemanager;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
@ -1788,7 +1789,7 @@ public void testListReservationsByTimeIntervalContainingNoReservations() {
|
||||
|
||||
// Ensure all reservations are filtered out.
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getReservationAllocationState().size(), 0);
|
||||
assertThat(response.getReservationAllocationState()).isEmpty();
|
||||
|
||||
duration = 30000;
|
||||
deadline = sRequest.getReservationDefinition().getDeadline();
|
||||
@ -1808,7 +1809,7 @@ public void testListReservationsByTimeIntervalContainingNoReservations() {
|
||||
|
||||
// Ensure all reservations are filtered out.
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getReservationAllocationState().size(), 0);
|
||||
assertThat(response.getReservationAllocationState()).isEmpty();
|
||||
|
||||
arrival = clock.getTime();
|
||||
// List reservations, search by end time before the reservation start
|
||||
@ -1826,7 +1827,7 @@ public void testListReservationsByTimeIntervalContainingNoReservations() {
|
||||
|
||||
// Ensure all reservations are filtered out.
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getReservationAllocationState().size(), 0);
|
||||
assertThat(response.getReservationAllocationState()).isEmpty();
|
||||
|
||||
// List reservations, search by very small end time.
|
||||
request = ReservationListRequest
|
||||
@ -1841,7 +1842,7 @@ public void testListReservationsByTimeIntervalContainingNoReservations() {
|
||||
|
||||
// Ensure all reservations are filtered out.
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.getReservationAllocationState().size(), 0);
|
||||
assertThat(response.getReservationAllocationState()).isEmpty();
|
||||
|
||||
rm.stop();
|
||||
}
|
||||
@ -2012,7 +2013,7 @@ protected ClientRMService createClientRMService() {
|
||||
Arrays.asList(node1A)));
|
||||
Assert.assertTrue(labelsToNodes.get(labelZ.getName()).containsAll(
|
||||
Arrays.asList(node1B, node3B)));
|
||||
Assert.assertEquals(labelsToNodes.get(labelY.getName()), null);
|
||||
assertThat(labelsToNodes.get(labelY.getName())).isNull();
|
||||
|
||||
rpc.stopProxy(client, conf);
|
||||
rm.close();
|
||||
@ -2113,10 +2114,10 @@ protected ClientRMService createClientRMService() {
|
||||
client.getAttributesToNodes(request);
|
||||
Map<NodeAttributeKey, List<NodeToAttributeValue>> attrs =
|
||||
response.getAttributesToNodes();
|
||||
Assert.assertEquals(response.getAttributesToNodes().size(), 4);
|
||||
Assert.assertEquals(attrs.get(dist.getAttributeKey()).size(), 2);
|
||||
Assert.assertEquals(attrs.get(os.getAttributeKey()).size(), 1);
|
||||
Assert.assertEquals(attrs.get(gpu.getAttributeKey()).size(), 1);
|
||||
assertThat(response.getAttributesToNodes()).hasSize(4);
|
||||
assertThat(attrs.get(dist.getAttributeKey())).hasSize(2);
|
||||
assertThat(attrs.get(os.getAttributeKey())).hasSize(1);
|
||||
assertThat(attrs.get(gpu.getAttributeKey())).hasSize(1);
|
||||
Assert.assertTrue(findHostnameAndValInMapping(node1, "3_0_2",
|
||||
attrs.get(dist.getAttributeKey())));
|
||||
Assert.assertTrue(findHostnameAndValInMapping(node2, "3_0_2",
|
||||
@ -2130,7 +2131,7 @@ protected ClientRMService createClientRMService() {
|
||||
client.getAttributesToNodes(request2);
|
||||
Map<NodeAttributeKey, List<NodeToAttributeValue>> attrs2 =
|
||||
response2.getAttributesToNodes();
|
||||
Assert.assertEquals(attrs2.size(), 1);
|
||||
assertThat(attrs2).hasSize(1);
|
||||
Assert.assertTrue(findHostnameAndValInMapping(node2, "docker0",
|
||||
attrs2.get(docker.getAttributeKey())));
|
||||
|
||||
@ -2141,7 +2142,7 @@ protected ClientRMService createClientRMService() {
|
||||
client.getAttributesToNodes(request3);
|
||||
Map<NodeAttributeKey, List<NodeToAttributeValue>> attrs3 =
|
||||
response3.getAttributesToNodes();
|
||||
Assert.assertEquals(attrs3.size(), 2);
|
||||
assertThat(attrs3).hasSize(2);
|
||||
Assert.assertTrue(findHostnameAndValInMapping(node1, "windows64",
|
||||
attrs3.get(os.getAttributeKey())));
|
||||
Assert.assertTrue(findHostnameAndValInMapping(node2, "docker0",
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package org.apache.hadoop.yarn.server.resourcemanager;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -150,7 +151,7 @@ public void testKillAppWhenFailOverHappensDuringApplicationKill()
|
||||
MockAM am0 = launchAM(app0, rm1, nm1);
|
||||
|
||||
// ensure that the app is in running state
|
||||
Assert.assertEquals(app0.getState(), RMAppState.RUNNING);
|
||||
assertThat(app0.getState()).isEqualTo(RMAppState.RUNNING);
|
||||
|
||||
// kill the app.
|
||||
rm1.killApp(app0.getApplicationId());
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package org.apache.hadoop.yarn.server.resourcemanager;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
@ -608,7 +609,7 @@ private void verifyServiceACLsRefresh(ServiceAuthorizationManager manager,
|
||||
Assert.assertEquals(accessList.getAclString(),
|
||||
aclString);
|
||||
} else {
|
||||
Assert.assertEquals(accessList.getAclString(), "*");
|
||||
assertThat(accessList.getAclString()).isEqualTo("*");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
import org.apache.hadoop.test.GenericTestUtils;
|
||||
import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode;
|
||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeUpdateSchedulerEvent;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@ -381,14 +382,14 @@ public void testHAIDLookup() {
|
||||
rm = new MockRM(conf);
|
||||
rm.init(conf);
|
||||
|
||||
assertEquals(conf.get(YarnConfiguration.RM_HA_ID), RM2_NODE_ID);
|
||||
assertThat(conf.get(YarnConfiguration.RM_HA_ID)).isEqualTo(RM2_NODE_ID);
|
||||
|
||||
//test explicitly lookup HA-ID
|
||||
configuration.set(YarnConfiguration.RM_HA_ID, RM1_NODE_ID);
|
||||
conf = new YarnConfiguration(configuration);
|
||||
rm = new MockRM(conf);
|
||||
rm.init(conf);
|
||||
assertEquals(conf.get(YarnConfiguration.RM_HA_ID), RM1_NODE_ID);
|
||||
assertThat(conf.get(YarnConfiguration.RM_HA_ID)).isEqualTo(RM1_NODE_ID);
|
||||
|
||||
//test if RM_HA_ID can not be found
|
||||
configuration
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package org.apache.hadoop.yarn.server.resourcemanager;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.ArgumentMatchers.isA;
|
||||
@ -609,7 +610,7 @@ public void testRMRestartWaitForPreviousAMToFinish() throws Exception {
|
||||
MockAM am2 = launchAM(app1, rm1, nm1);
|
||||
|
||||
Assert.assertEquals(1, rmAppState.size());
|
||||
Assert.assertEquals(app1.getState(), RMAppState.RUNNING);
|
||||
assertThat(app1.getState()).isEqualTo(RMAppState.RUNNING);
|
||||
Assert.assertEquals(app1.getAppAttempts()
|
||||
.get(app1.getCurrentAppAttempt().getAppAttemptId())
|
||||
.getAppAttemptState(), RMAppAttemptState.RUNNING);
|
||||
@ -665,7 +666,7 @@ public void testRMRestartWaitForPreviousAMToFinish() throws Exception {
|
||||
rmApp = rm3.getRMContext().getRMApps().get(app1.getApplicationId());
|
||||
// application should be in ACCEPTED state
|
||||
rm3.waitForState(app1.getApplicationId(), RMAppState.ACCEPTED);
|
||||
Assert.assertEquals(rmApp.getState(), RMAppState.ACCEPTED);
|
||||
assertThat(rmApp.getState()).isEqualTo(RMAppState.ACCEPTED);
|
||||
// new attempt should not be started
|
||||
Assert.assertEquals(3, rmApp.getAppAttempts().size());
|
||||
// am1 and am2 attempts should be in FAILED state where as am3 should be
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package org.apache.hadoop.yarn.server.resourcemanager;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.apache.hadoop.yarn.api.records.ContainerUpdateType.INCREASE_RESOURCE;
|
||||
import static org.apache.hadoop.yarn.server.resourcemanager.RMServerUtils.RESOURCE_OUTSIDE_ALLOWED_RANGE;
|
||||
|
||||
@ -140,22 +141,22 @@ public void testQueryRMNodes() throws Exception {
|
||||
List<RMNode> result = RMServerUtils.queryRMNodes(rmContext,
|
||||
EnumSet.of(NodeState.SHUTDOWN));
|
||||
Assert.assertTrue(result.size() != 0);
|
||||
Assert.assertEquals(result.get(0), rmNode1);
|
||||
assertThat(result.get(0)).isEqualTo(rmNode1);
|
||||
when(rmNode1.getState()).thenReturn(NodeState.DECOMMISSIONED);
|
||||
result = RMServerUtils.queryRMNodes(rmContext,
|
||||
EnumSet.of(NodeState.DECOMMISSIONED));
|
||||
Assert.assertTrue(result.size() != 0);
|
||||
Assert.assertEquals(result.get(0), rmNode1);
|
||||
assertThat(result.get(0)).isEqualTo(rmNode1);
|
||||
when(rmNode1.getState()).thenReturn(NodeState.LOST);
|
||||
result = RMServerUtils.queryRMNodes(rmContext,
|
||||
EnumSet.of(NodeState.LOST));
|
||||
Assert.assertTrue(result.size() != 0);
|
||||
Assert.assertEquals(result.get(0), rmNode1);
|
||||
assertThat(result.get(0)).isEqualTo(rmNode1);
|
||||
when(rmNode1.getState()).thenReturn(NodeState.REBOOTED);
|
||||
result = RMServerUtils.queryRMNodes(rmContext,
|
||||
EnumSet.of(NodeState.REBOOTED));
|
||||
Assert.assertTrue(result.size() != 0);
|
||||
Assert.assertEquals(result.get(0), rmNode1);
|
||||
assertThat(result.get(0)).isEqualTo(rmNode1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -100,6 +100,8 @@
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.PREFIX;
|
||||
|
||||
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler
|
||||
@ -263,7 +265,8 @@ public void testSchedulerRecovery() throws Exception {
|
||||
scheduler.getRMContainer(amContainer.getContainerId())));
|
||||
assertTrue(schedulerAttempt.getLiveContainers().contains(
|
||||
scheduler.getRMContainer(runningContainer.getContainerId())));
|
||||
assertEquals(schedulerAttempt.getCurrentConsumption(), usedResources);
|
||||
assertThat(schedulerAttempt.getCurrentConsumption()).
|
||||
isEqualTo(usedResources);
|
||||
|
||||
// *********** check appSchedulingInfo state ***********
|
||||
assertEquals((1L << 40) + 1L, schedulerAttempt.getNewContainerId());
|
||||
@ -421,7 +424,8 @@ public void testDynamicQueueRecovery() throws Exception {
|
||||
.contains(scheduler.getRMContainer(amContainer.getContainerId())));
|
||||
assertTrue(schedulerAttempt.getLiveContainers()
|
||||
.contains(scheduler.getRMContainer(runningContainer.getContainerId())));
|
||||
assertEquals(schedulerAttempt.getCurrentConsumption(), usedResources);
|
||||
assertThat(schedulerAttempt.getCurrentConsumption()).
|
||||
isEqualTo(usedResources);
|
||||
|
||||
// *********** check appSchedulingInfo state ***********
|
||||
assertEquals((1L << 40) + 1L, schedulerAttempt.getNewContainerId());
|
||||
@ -775,8 +779,9 @@ private void verifyAppRecoveryWithWrongQueueConfig(
|
||||
ApplicationReport report = rm2.getApplicationReport(app.getApplicationId());
|
||||
assertEquals(report.getFinalApplicationStatus(),
|
||||
FinalApplicationStatus.KILLED);
|
||||
assertEquals(report.getYarnApplicationState(), YarnApplicationState.KILLED);
|
||||
assertEquals(report.getDiagnostics(), diagnostics);
|
||||
assertThat(report.getYarnApplicationState()).
|
||||
isEqualTo(YarnApplicationState.KILLED);
|
||||
assertThat(report.getDiagnostics()).isEqualTo(diagnostics);
|
||||
|
||||
//Reload previous state with cloned app sub context object
|
||||
RMState newState = memStore2.reloadStateWithClonedAppSubCtxt(state);
|
||||
@ -1730,7 +1735,8 @@ public void testDynamicAutoCreatedQueueRecovery(String user, String queueName)
|
||||
.contains(scheduler.getRMContainer(amContainer.getContainerId())));
|
||||
assertTrue(schedulerAttempt.getLiveContainers()
|
||||
.contains(scheduler.getRMContainer(runningContainer.getContainerId())));
|
||||
assertEquals(schedulerAttempt.getCurrentConsumption(), usedResources);
|
||||
assertThat(schedulerAttempt.getCurrentConsumption()).
|
||||
isEqualTo(usedResources);
|
||||
|
||||
// *********** check appSchedulingInfo state ***********
|
||||
assertEquals((1L << 40) + 1L, schedulerAttempt.getNewContainerId());
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package org.apache.hadoop.yarn.server.resourcemanager.metrics;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ -290,7 +291,7 @@ public void testPublishApplicationMetrics() throws Exception {
|
||||
} else if (event.getEventType().equals(
|
||||
ApplicationMetricsConstants.STATE_UPDATED_EVENT_TYPE)) {
|
||||
hasStateUpdateEvent = true;
|
||||
Assert.assertEquals(event.getTimestamp(), stateUpdateTimeStamp);
|
||||
assertThat(event.getTimestamp()).isEqualTo(stateUpdateTimeStamp);
|
||||
Assert.assertEquals(YarnApplicationState.RUNNING.toString(), event
|
||||
.getEventInfo().get(
|
||||
ApplicationMetricsConstants.STATE_EVENT_INFO));
|
||||
|
@ -27,6 +27,7 @@
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.argThat;
|
||||
import static org.mockito.Mockito.times;
|
||||
@ -230,7 +231,8 @@ public void testPreemptionToBalanceWithConfiguredTimeout() throws IOException {
|
||||
FifoCandidatesSelector pcs = (FifoCandidatesSelector) pc.getKey();
|
||||
if (pcs.getAllowQueuesBalanceAfterAllQueuesSatisfied() == true) {
|
||||
hasFifoSelector = true;
|
||||
assertEquals(pcs.getMaximumKillWaitTimeMs(), FB_MAX_BEFORE_KILL);
|
||||
assertThat(pcs.getMaximumKillWaitTimeMs()).
|
||||
isEqualTo(FB_MAX_BEFORE_KILL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
package org.apache.hadoop.yarn.server.resourcemanager.nodelabels;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
@ -139,8 +140,8 @@ public void testRecoverWithMirror() throws Exception {
|
||||
toAddAttributes);
|
||||
Map<NodeAttribute, AttributeValue> attrs =
|
||||
mgr.getAttributesForNode("host0");
|
||||
Assert.assertEquals(attrs.size(), 1);
|
||||
Assert.assertEquals(attrs.keySet().toArray()[0], docker);
|
||||
assertThat(attrs).hasSize(1);
|
||||
assertThat(attrs.keySet().toArray()[0]).isEqualTo(docker);
|
||||
mgr.stop();
|
||||
|
||||
// Start new attribute manager with same path
|
||||
@ -154,8 +155,8 @@ public void testRecoverWithMirror() throws Exception {
|
||||
Assert.assertEquals("host1 size", 1,
|
||||
mgr.getAttributesForNode("host1").size());
|
||||
attrs = mgr.getAttributesForNode("host0");
|
||||
Assert.assertEquals(attrs.size(), 1);
|
||||
Assert.assertEquals(attrs.keySet().toArray()[0], docker);
|
||||
assertThat(attrs).hasSize(1);
|
||||
assertThat(attrs.keySet().toArray()[0]).isEqualTo(docker);
|
||||
//------host0----
|
||||
// current - docker
|
||||
// replace - gpu
|
||||
@ -181,8 +182,8 @@ public void testRecoverWithMirror() throws Exception {
|
||||
Assert.assertEquals("host1 size", 2,
|
||||
mgr.getAttributesForNode("host1").size());
|
||||
attrs = mgr.getAttributesForNode("host0");
|
||||
Assert.assertEquals(attrs.size(), 1);
|
||||
Assert.assertEquals(attrs.keySet().toArray()[0], gpu);
|
||||
assertThat(attrs).hasSize(1);
|
||||
assertThat(attrs.keySet().toArray()[0]).isEqualTo(gpu);
|
||||
attrs = mgr.getAttributesForNode("host1");
|
||||
Assert.assertTrue(attrs.keySet().contains(docker));
|
||||
Assert.assertTrue(attrs.keySet().contains(gpu));
|
||||
|
@ -17,6 +17,8 @@
|
||||
*/
|
||||
|
||||
package org.apache.hadoop.yarn.server.resourcemanager.nodelabels;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@ -88,37 +90,37 @@ public void testGetLabelResourceWhenNodeActiveDeactive() throws Exception {
|
||||
mgr.replaceLabelsOnNode(ImmutableMap.of(toNodeId("n1"), toSet("p1"),
|
||||
toNodeId("n2"), toSet("p2"), toNodeId("n3"), toSet("p3")));
|
||||
|
||||
Assert.assertEquals(mgr.getResourceByLabel("p1", null), EMPTY_RESOURCE);
|
||||
Assert.assertEquals(mgr.getResourceByLabel("p2", null), EMPTY_RESOURCE);
|
||||
Assert.assertEquals(mgr.getResourceByLabel("p3", null), EMPTY_RESOURCE);
|
||||
Assert.assertEquals(mgr.getResourceByLabel(RMNodeLabelsManager.NO_LABEL, null),
|
||||
EMPTY_RESOURCE);
|
||||
assertThat(mgr.getResourceByLabel("p1", null)).isEqualTo(EMPTY_RESOURCE);
|
||||
assertThat(mgr.getResourceByLabel("p2", null)).isEqualTo(EMPTY_RESOURCE);
|
||||
assertThat(mgr.getResourceByLabel("p3", null)).isEqualTo(EMPTY_RESOURCE);
|
||||
assertThat(mgr.getResourceByLabel(RMNodeLabelsManager.NO_LABEL, null)).
|
||||
isEqualTo(EMPTY_RESOURCE);
|
||||
|
||||
// active two NM to n1, one large and one small
|
||||
mgr.activateNode(NodeId.newInstance("n1", 1), SMALL_RESOURCE);
|
||||
mgr.activateNode(NodeId.newInstance("n1", 2), LARGE_NODE);
|
||||
Assert.assertEquals(mgr.getResourceByLabel("p1", null),
|
||||
assertThat(mgr.getResourceByLabel("p1", null)).isEqualTo(
|
||||
Resources.add(SMALL_RESOURCE, LARGE_NODE));
|
||||
|
||||
// check add labels multiple times shouldn't overwrite
|
||||
// original attributes on labels like resource
|
||||
mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p1", "p4"));
|
||||
Assert.assertEquals(mgr.getResourceByLabel("p1", null),
|
||||
assertThat(mgr.getResourceByLabel("p1", null)).isEqualTo(
|
||||
Resources.add(SMALL_RESOURCE, LARGE_NODE));
|
||||
Assert.assertEquals(mgr.getResourceByLabel("p4", null), EMPTY_RESOURCE);
|
||||
|
||||
// change the large NM to small, check if resource updated
|
||||
mgr.updateNodeResource(NodeId.newInstance("n1", 2), SMALL_RESOURCE);
|
||||
Assert.assertEquals(mgr.getResourceByLabel("p1", null),
|
||||
assertThat(mgr.getResourceByLabel("p1", null)).isEqualTo(
|
||||
Resources.multiply(SMALL_RESOURCE, 2));
|
||||
|
||||
// deactive one NM, and check if resource updated
|
||||
mgr.deactivateNode(NodeId.newInstance("n1", 1));
|
||||
Assert.assertEquals(mgr.getResourceByLabel("p1", null), SMALL_RESOURCE);
|
||||
assertThat(mgr.getResourceByLabel("p1", null)).isEqualTo(SMALL_RESOURCE);
|
||||
|
||||
// continus deactive, check if resource updated
|
||||
mgr.deactivateNode(NodeId.newInstance("n1", 2));
|
||||
Assert.assertEquals(mgr.getResourceByLabel("p1", null), EMPTY_RESOURCE);
|
||||
assertThat(mgr.getResourceByLabel("p1", null)).isEqualTo(EMPTY_RESOURCE);
|
||||
|
||||
// Add two NM to n1 back
|
||||
mgr.activateNode(NodeId.newInstance("n1", 1), SMALL_RESOURCE);
|
||||
@ -126,8 +128,8 @@ public void testGetLabelResourceWhenNodeActiveDeactive() throws Exception {
|
||||
|
||||
// And remove p1, now the two NM should come to default label,
|
||||
mgr.removeFromClusterNodeLabels(ImmutableSet.of("p1"));
|
||||
Assert.assertEquals(mgr.getResourceByLabel(RMNodeLabelsManager.NO_LABEL, null),
|
||||
Resources.add(SMALL_RESOURCE, LARGE_NODE));
|
||||
assertThat(mgr.getResourceByLabel(RMNodeLabelsManager.NO_LABEL, null)).
|
||||
isEqualTo(Resources.add(SMALL_RESOURCE, LARGE_NODE));
|
||||
}
|
||||
|
||||
@Test(timeout = 5000)
|
||||
@ -152,10 +154,10 @@ public void testGetLabelResource() throws Exception {
|
||||
|
||||
// change label of n1 to p2
|
||||
mgr.replaceLabelsOnNode(ImmutableMap.of(toNodeId("n1"), toSet("p2")));
|
||||
Assert.assertEquals(mgr.getResourceByLabel("p1", null), EMPTY_RESOURCE);
|
||||
Assert.assertEquals(mgr.getResourceByLabel("p2", null),
|
||||
assertThat(mgr.getResourceByLabel("p1", null)).isEqualTo(EMPTY_RESOURCE);
|
||||
assertThat(mgr.getResourceByLabel("p2", null)).isEqualTo(
|
||||
Resources.multiply(SMALL_RESOURCE, 2));
|
||||
Assert.assertEquals(mgr.getResourceByLabel("p3", null), SMALL_RESOURCE);
|
||||
assertThat(mgr.getResourceByLabel("p3", null)).isEqualTo(SMALL_RESOURCE);
|
||||
|
||||
// add more labels
|
||||
mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p4", "p5", "p6"));
|
||||
@ -180,17 +182,17 @@ public void testGetLabelResource() throws Exception {
|
||||
mgr.activateNode(NodeId.newInstance("n9", 1), SMALL_RESOURCE);
|
||||
|
||||
// check varibles
|
||||
Assert.assertEquals(mgr.getResourceByLabel("p1", null), SMALL_RESOURCE);
|
||||
Assert.assertEquals(mgr.getResourceByLabel("p2", null),
|
||||
assertThat(mgr.getResourceByLabel("p1", null)).isEqualTo(SMALL_RESOURCE);
|
||||
assertThat(mgr.getResourceByLabel("p2", null)).isEqualTo(
|
||||
Resources.multiply(SMALL_RESOURCE, 3));
|
||||
Assert.assertEquals(mgr.getResourceByLabel("p3", null),
|
||||
assertThat(mgr.getResourceByLabel("p3", null)).isEqualTo(
|
||||
Resources.multiply(SMALL_RESOURCE, 2));
|
||||
Assert.assertEquals(mgr.getResourceByLabel("p4", null),
|
||||
assertThat(mgr.getResourceByLabel("p4", null)).isEqualTo(
|
||||
Resources.multiply(SMALL_RESOURCE, 1));
|
||||
Assert.assertEquals(mgr.getResourceByLabel("p5", null),
|
||||
Resources.multiply(SMALL_RESOURCE, 1));
|
||||
Assert.assertEquals(mgr.getResourceByLabel(RMNodeLabelsManager.NO_LABEL, null),
|
||||
assertThat(mgr.getResourceByLabel("p5", null)).isEqualTo(
|
||||
Resources.multiply(SMALL_RESOURCE, 1));
|
||||
assertThat(mgr.getResourceByLabel(RMNodeLabelsManager.NO_LABEL, null)).
|
||||
isEqualTo(Resources.multiply(SMALL_RESOURCE, 1));
|
||||
|
||||
// change a bunch of nodes -> labels
|
||||
// n4 -> p2
|
||||
@ -212,17 +214,17 @@ public void testGetLabelResource() throws Exception {
|
||||
toNodeId("n9"), toSet("p1")));
|
||||
|
||||
// check varibles
|
||||
Assert.assertEquals(mgr.getResourceByLabel("p1", null),
|
||||
assertThat(mgr.getResourceByLabel("p1", null)).isEqualTo(
|
||||
Resources.multiply(SMALL_RESOURCE, 2));
|
||||
Assert.assertEquals(mgr.getResourceByLabel("p2", null),
|
||||
assertThat(mgr.getResourceByLabel("p2", null)).isEqualTo(
|
||||
Resources.multiply(SMALL_RESOURCE, 3));
|
||||
Assert.assertEquals(mgr.getResourceByLabel("p3", null),
|
||||
assertThat(mgr.getResourceByLabel("p3", null)).isEqualTo(
|
||||
Resources.multiply(SMALL_RESOURCE, 2));
|
||||
Assert.assertEquals(mgr.getResourceByLabel("p4", null),
|
||||
assertThat(mgr.getResourceByLabel("p4", null)).isEqualTo(
|
||||
Resources.multiply(SMALL_RESOURCE, 0));
|
||||
Assert.assertEquals(mgr.getResourceByLabel("p5", null),
|
||||
assertThat(mgr.getResourceByLabel("p5", null)).isEqualTo(
|
||||
Resources.multiply(SMALL_RESOURCE, 0));
|
||||
Assert.assertEquals(mgr.getResourceByLabel("", null),
|
||||
assertThat(mgr.getResourceByLabel("", null)).isEqualTo(
|
||||
Resources.multiply(SMALL_RESOURCE, 2));
|
||||
}
|
||||
|
||||
@ -413,9 +415,9 @@ public void testGetLabelResourceWhenMultipleNMsExistingInSameHost() throws IOExc
|
||||
mgr.activateNode(NodeId.newInstance("n1", 4), SMALL_RESOURCE);
|
||||
|
||||
// check resource of no label, it should be small * 4
|
||||
Assert.assertEquals(
|
||||
mgr.getResourceByLabel(CommonNodeLabelsManager.NO_LABEL, null),
|
||||
Resources.multiply(SMALL_RESOURCE, 4));
|
||||
assertThat(
|
||||
mgr.getResourceByLabel(CommonNodeLabelsManager.NO_LABEL, null)).
|
||||
isEqualTo(Resources.multiply(SMALL_RESOURCE, 4));
|
||||
|
||||
// change two of these nodes to p1, check resource of no_label and P1
|
||||
mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p1"));
|
||||
@ -423,12 +425,12 @@ public void testGetLabelResourceWhenMultipleNMsExistingInSameHost() throws IOExc
|
||||
toNodeId("n1:2"), toSet("p1")));
|
||||
|
||||
// check resource
|
||||
Assert.assertEquals(
|
||||
mgr.getResourceByLabel(CommonNodeLabelsManager.NO_LABEL, null),
|
||||
Resources.multiply(SMALL_RESOURCE, 2));
|
||||
Assert.assertEquals(
|
||||
mgr.getResourceByLabel("p1", null),
|
||||
Resources.multiply(SMALL_RESOURCE, 2));
|
||||
assertThat(
|
||||
mgr.getResourceByLabel(CommonNodeLabelsManager.NO_LABEL, null)).
|
||||
isEqualTo(Resources.multiply(SMALL_RESOURCE, 2));
|
||||
assertThat(
|
||||
mgr.getResourceByLabel("p1", null)).isEqualTo(
|
||||
Resources.multiply(SMALL_RESOURCE, 2));
|
||||
}
|
||||
|
||||
@Test(timeout = 5000)
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package org.apache.hadoop.yarn.server.resourcemanager.recovery;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -125,8 +126,8 @@ public RMStateStore getRMStateStore() throws Exception {
|
||||
YarnConfiguration.YARN_INTERMEDIATE_DATA_ENCRYPTION, true);
|
||||
}
|
||||
this.store = new TestFileSystemRMStore(conf);
|
||||
Assert.assertEquals(store.getNumRetries(), 8);
|
||||
Assert.assertEquals(store.getRetryInterval(), 900L);
|
||||
assertThat(store.getNumRetries()).isEqualTo(8);
|
||||
assertThat(store.getRetryInterval()).isEqualTo(900L);
|
||||
Assert.assertTrue(store.fs.getConf() == store.fsConf);
|
||||
FileSystem previousFs = store.fs;
|
||||
store.startInternal();
|
||||
|
@ -76,6 +76,7 @@
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
@ -435,14 +436,14 @@ public void testZKRootPathAcls() throws Exception {
|
||||
rm.getRMContext().getRMAdminService().transitionToActive(req);
|
||||
ZKRMStateStore stateStore = (ZKRMStateStore) rm.getRMContext().getStateStore();
|
||||
List<ACL> acls = stateStore.getACL(rootPath);
|
||||
assertEquals(acls.size(), 2);
|
||||
assertThat(acls).hasSize(2);
|
||||
// CREATE and DELETE permissions for root node based on RM ID
|
||||
verifyZKACL("digest", "localhost", Perms.CREATE | Perms.DELETE, acls);
|
||||
verifyZKACL(
|
||||
"world", "anyone", Perms.ALL ^ (Perms.CREATE | Perms.DELETE), acls);
|
||||
|
||||
acls = stateStore.getACL(parentPath);
|
||||
assertEquals(1, acls.size());
|
||||
assertThat(acls).hasSize(1);
|
||||
assertEquals(perm, acls.get(0).getPerms());
|
||||
rm.close();
|
||||
|
||||
@ -463,7 +464,7 @@ public void testZKRootPathAcls() throws Exception {
|
||||
rm.start();
|
||||
rm.getRMContext().getRMAdminService().transitionToActive(req);
|
||||
acls = stateStore.getACL(rootPath);
|
||||
assertEquals(acls.size(), 2);
|
||||
assertThat(acls).hasSize(2);
|
||||
verifyZKACL("digest", "localhost", Perms.CREATE | Perms.DELETE, acls);
|
||||
verifyZKACL(
|
||||
"world", "anyone", Perms.ALL ^ (Perms.CREATE | Perms.DELETE), acls);
|
||||
|
@ -17,6 +17,7 @@
|
||||
*******************************************************************************/
|
||||
package org.apache.hadoop.yarn.server.resourcemanager.reservation;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import org.apache.hadoop.yarn.api.records.ReservationAllocationState;
|
||||
@ -49,9 +50,9 @@ public void testConvertAllocationsToReservationInfo() {
|
||||
.convertAllocationsToReservationInfo(
|
||||
Collections.singleton(allocation), true);
|
||||
|
||||
Assert.assertEquals(infoList.size(), 1);
|
||||
Assert.assertEquals(infoList.get(0).getReservationId().toString(),
|
||||
id.toString());
|
||||
assertThat(infoList).hasSize(1);
|
||||
assertThat(infoList.get(0).getReservationId().toString()).isEqualTo(
|
||||
id.toString());
|
||||
Assert.assertFalse(infoList.get(0).getResourceAllocationRequests()
|
||||
.isEmpty());
|
||||
}
|
||||
@ -104,7 +105,7 @@ public void testConvertAllocationsToReservationInfoEmptySet() {
|
||||
.convertAllocationsToReservationInfo(
|
||||
Collections.<ReservationAllocation>emptySet(), false);
|
||||
|
||||
Assert.assertEquals(infoList.size(), 0);
|
||||
assertThat(infoList).isEmpty();
|
||||
}
|
||||
|
||||
private ReservationAllocation createReservationAllocation(long startTime,
|
||||
|
@ -18,7 +18,8 @@
|
||||
|
||||
package org.apache.hadoop.yarn.server.resourcemanager.reservation.planning;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.within;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
@ -990,8 +991,9 @@ public void testGetDurationInterval() throws PlanningException {
|
||||
StageAllocatorLowCostAligned.getDurationInterval(10*step, 30*step,
|
||||
planLoads, planModifications, clusterCapacity, netRLERes, res, step,
|
||||
requestedResources);
|
||||
assertEquals(durationInterval.numCanFit(), 4);
|
||||
assertEquals(durationInterval.getTotalCost(), 0.55, 0.00001);
|
||||
assertThat(durationInterval.numCanFit()).isEqualTo(4);
|
||||
assertThat(durationInterval.getTotalCost()).
|
||||
isCloseTo(0.55, within(0.00001));
|
||||
|
||||
// 2.
|
||||
// currLoad: should start at 20*step, end at 31*step with a null value
|
||||
@ -1003,8 +1005,9 @@ public void testGetDurationInterval() throws PlanningException {
|
||||
planLoads, planModifications, clusterCapacity, netRLERes, res, step,
|
||||
requestedResources);
|
||||
System.out.println(durationInterval);
|
||||
assertEquals(durationInterval.numCanFit(), 3);
|
||||
assertEquals(durationInterval.getTotalCost(), 0.56, 0.00001);
|
||||
assertThat(durationInterval.numCanFit()).isEqualTo(3);
|
||||
assertThat(durationInterval.getTotalCost()).
|
||||
isCloseTo(0.56, within(0.00001));
|
||||
|
||||
// 3.
|
||||
// currLoad: should start at 20*step, end at 30*step with a null value
|
||||
@ -1015,8 +1018,9 @@ public void testGetDurationInterval() throws PlanningException {
|
||||
StageAllocatorLowCostAligned.getDurationInterval(15*step, 30*step,
|
||||
planLoads, planModifications, clusterCapacity, netRLERes, res, step,
|
||||
requestedResources);
|
||||
assertEquals(durationInterval.numCanFit(), 4);
|
||||
assertEquals(durationInterval.getTotalCost(), 0.55, 0.00001);
|
||||
assertThat(durationInterval.numCanFit()).isEqualTo(4);
|
||||
assertThat(durationInterval.getTotalCost()).
|
||||
isCloseTo(0.55, within(0.00001));
|
||||
|
||||
// 4.
|
||||
// currLoad: should start at 20*step, end at 31*step with a null value
|
||||
@ -1028,8 +1032,9 @@ public void testGetDurationInterval() throws PlanningException {
|
||||
planLoads, planModifications, clusterCapacity, netRLERes, res, step,
|
||||
requestedResources);
|
||||
System.out.println(durationInterval);
|
||||
assertEquals(durationInterval.numCanFit(), 3);
|
||||
assertEquals(durationInterval.getTotalCost(), 0.56, 0.00001);
|
||||
assertThat(durationInterval.numCanFit()).isEqualTo(3);
|
||||
assertThat(durationInterval.getTotalCost()).
|
||||
isCloseTo(0.56, within(0.00001));
|
||||
|
||||
// 5.
|
||||
// currLoad: should only contain one entry at startTime
|
||||
@ -1042,8 +1047,9 @@ public void testGetDurationInterval() throws PlanningException {
|
||||
planLoads, planModifications, clusterCapacity, netRLERes, res, step,
|
||||
requestedResources);
|
||||
System.out.println(durationInterval);
|
||||
assertEquals(durationInterval.numCanFit(), 8);
|
||||
assertEquals(durationInterval.getTotalCost(), 0.05, 0.00001);
|
||||
assertThat(durationInterval.numCanFit()).isEqualTo(8);
|
||||
assertThat(durationInterval.getTotalCost()).
|
||||
isCloseTo(0.05, within(0.00001));
|
||||
|
||||
// 6.
|
||||
// currLoad: should start at 39*step, end at 41*step with a null value
|
||||
@ -1055,8 +1061,9 @@ public void testGetDurationInterval() throws PlanningException {
|
||||
planLoads, planModifications, clusterCapacity, netRLERes, res, step,
|
||||
requestedResources);
|
||||
System.out.println(durationInterval);
|
||||
assertEquals(durationInterval.numCanFit(), 0);
|
||||
assertEquals(durationInterval.getTotalCost(), 0, 0.00001);
|
||||
assertThat(durationInterval.numCanFit()).isEqualTo(0);
|
||||
assertThat(durationInterval.getTotalCost()).
|
||||
isCloseTo(0, within(0.00001));
|
||||
|
||||
}
|
||||
|
||||
|
@ -105,6 +105,7 @@
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
@ -1278,7 +1279,8 @@ public void testGetAppReport() throws IOException {
|
||||
assertAppState(RMAppState.NEW, app);
|
||||
ApplicationReport report = app.createAndGetApplicationReport(null, true);
|
||||
Assert.assertNotNull(report.getApplicationResourceUsageReport());
|
||||
Assert.assertEquals(report.getApplicationResourceUsageReport(),RMServerUtils.DUMMY_APPLICATION_RESOURCE_USAGE_REPORT);
|
||||
assertThat(report.getApplicationResourceUsageReport()).
|
||||
isEqualTo(RMServerUtils.DUMMY_APPLICATION_RESOURCE_USAGE_REPORT);
|
||||
report = app.createAndGetApplicationReport("clientuser", true);
|
||||
Assert.assertNotNull(report.getApplicationResourceUsageReport());
|
||||
Assert.assertTrue("bad proxy url for app",
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@ -308,14 +309,15 @@ public void testLimitsComputation() throws Exception {
|
||||
queue.getUserAMResourceLimit());
|
||||
|
||||
Resource amResourceLimit = Resource.newInstance(160 * GB, 1);
|
||||
assertEquals(queue.calculateAndGetAMResourceLimit(), amResourceLimit);
|
||||
assertEquals(queue.getUserAMResourceLimit(),
|
||||
assertThat(queue.calculateAndGetAMResourceLimit()).
|
||||
isEqualTo(amResourceLimit);
|
||||
assertThat(queue.getUserAMResourceLimit()).isEqualTo(
|
||||
Resource.newInstance(80*GB, 1));
|
||||
|
||||
// Assert in metrics
|
||||
assertEquals(queue.getMetrics().getAMResourceLimitMB(),
|
||||
assertThat(queue.getMetrics().getAMResourceLimitMB()).isEqualTo(
|
||||
amResourceLimit.getMemorySize());
|
||||
assertEquals(queue.getMetrics().getAMResourceLimitVCores(),
|
||||
assertThat(queue.getMetrics().getAMResourceLimitVCores()).isEqualTo(
|
||||
amResourceLimit.getVirtualCores());
|
||||
|
||||
assertEquals(
|
||||
@ -327,11 +329,11 @@ public void testLimitsComputation() throws Exception {
|
||||
clusterResource = Resources.createResource(120 * 16 * GB);
|
||||
root.updateClusterResource(clusterResource, new ResourceLimits(
|
||||
clusterResource));
|
||||
|
||||
assertEquals(queue.calculateAndGetAMResourceLimit(),
|
||||
|
||||
assertThat(queue.calculateAndGetAMResourceLimit()).isEqualTo(
|
||||
Resource.newInstance(192 * GB, 1));
|
||||
assertEquals(queue.getUserAMResourceLimit(),
|
||||
Resource.newInstance(96*GB, 1));
|
||||
assertThat(queue.getUserAMResourceLimit()).isEqualTo(
|
||||
Resource.newInstance(96*GB, 1));
|
||||
|
||||
assertEquals(
|
||||
(int)(clusterResource.getMemorySize() * queue.getAbsoluteCapacity()),
|
||||
@ -378,11 +380,11 @@ public void testLimitsComputation() throws Exception {
|
||||
(long) csConf.getMaximumApplicationMasterResourcePerQueuePercent(
|
||||
queue.getQueuePath())
|
||||
);
|
||||
|
||||
assertEquals(queue.calculateAndGetAMResourceLimit(),
|
||||
|
||||
assertThat(queue.calculateAndGetAMResourceLimit()).isEqualTo(
|
||||
Resource.newInstance(800 * GB, 1));
|
||||
assertEquals(queue.getUserAMResourceLimit(),
|
||||
Resource.newInstance(400*GB, 1));
|
||||
assertThat(queue.getUserAMResourceLimit()).isEqualTo(
|
||||
Resource.newInstance(400*GB, 1));
|
||||
|
||||
// Change the per-queue max applications.
|
||||
csConf.setInt(PREFIX + queue.getQueuePath() + ".maximum-applications",
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ -140,9 +140,9 @@ public void testApplicationOrderingWithPriority() throws Exception {
|
||||
|
||||
// Now, the first assignment will be for app2 since app2 is of highest
|
||||
// priority
|
||||
assertEquals(q.getApplications().size(), 2);
|
||||
assertEquals(q.getApplications().iterator().next()
|
||||
.getApplicationAttemptId(), appAttemptId2);
|
||||
assertThat(q.getApplications()).hasSize(2);
|
||||
assertThat(q.getApplications().iterator().next().getApplicationAttemptId())
|
||||
.isEqualTo(appAttemptId2);
|
||||
|
||||
rm.stop();
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.MAXIMUM_ALLOCATION;
|
||||
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.MAXIMUM_ALLOCATION_MB;
|
||||
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.MAXIMUM_ALLOCATION_VCORES;
|
||||
@ -5251,7 +5252,8 @@ public void testContainerAllocationLocalitySkipped() throws Exception {
|
||||
RMNode node1 = rm.getRMContext().getRMNodes().get(nm1.getNodeId());
|
||||
cs.handle(new NodeUpdateSchedulerEvent(node1));
|
||||
ContainerId cid = ContainerId.newContainerId(am.getApplicationAttemptId(), 1l);
|
||||
Assert.assertEquals(cs.getRMContainer(cid).getState(), RMContainerState.ACQUIRED);
|
||||
assertThat(cs.getRMContainer(cid).getState()).
|
||||
isEqualTo(RMContainerState.ACQUIRED);
|
||||
cid = ContainerId.newContainerId(am.getApplicationAttemptId(), 2l);
|
||||
Assert.assertNull(cs.getRMContainer(cid));
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
import org.apache.hadoop.yarn.util.resource.Resources;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@ -52,8 +53,10 @@ public void testGetResourceWithPercentage() {
|
||||
public void testGetResourceWithAbsolute() {
|
||||
ConfigurableResource configurableResource =
|
||||
new ConfigurableResource(Resources.createResource(3072, 3));
|
||||
assertEquals(configurableResource.getResource().getMemorySize(), 3072);
|
||||
assertEquals(configurableResource.getResource().getVirtualCores(), 3);
|
||||
assertThat(configurableResource.getResource().getMemorySize()).
|
||||
isEqualTo(3072);
|
||||
assertThat(configurableResource.getResource().getVirtualCores()).
|
||||
isEqualTo(3);
|
||||
|
||||
assertEquals(
|
||||
configurableResource.getResource(clusterResource).getMemorySize(),
|
||||
@ -62,7 +65,9 @@ public void testGetResourceWithAbsolute() {
|
||||
configurableResource.getResource(clusterResource).getVirtualCores(),
|
||||
3);
|
||||
|
||||
assertEquals(configurableResource.getResource(null).getMemorySize(), 3072);
|
||||
assertEquals(configurableResource.getResource(null).getVirtualCores(), 3);
|
||||
assertThat(configurableResource.getResource(null).getMemorySize()).
|
||||
isEqualTo(3072);
|
||||
assertThat(configurableResource.getResource(null).getVirtualCores()).
|
||||
isEqualTo(3);
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,7 @@
|
||||
import org.apache.hadoop.yarn.util.resource.Resources;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@ -153,9 +154,10 @@ public void testSortedNodes() throws Exception {
|
||||
scheduler.handle(nodeEvent2);
|
||||
|
||||
// available resource
|
||||
Assert.assertEquals(scheduler.getClusterResource().getMemorySize(),
|
||||
16 * 1024);
|
||||
Assert.assertEquals(scheduler.getClusterResource().getVirtualCores(), 16);
|
||||
assertThat(scheduler.getClusterResource().getMemorySize()).
|
||||
isEqualTo(16 * 1024);
|
||||
assertThat(scheduler.getClusterResource().getVirtualCores()).
|
||||
isEqualTo(16);
|
||||
|
||||
// send application request
|
||||
ApplicationAttemptId appAttemptId =
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@ -90,8 +91,9 @@ public void testUpdateDemand() {
|
||||
String queueName = "root.queue1";
|
||||
FSLeafQueue schedulable = new FSLeafQueue(queueName, scheduler, null);
|
||||
schedulable.setMaxShare(new ConfigurableResource(maxResource));
|
||||
assertEquals(schedulable.getMetrics().getMaxApps(), Integer.MAX_VALUE);
|
||||
assertEquals(schedulable.getMetrics().getSchedulingPolicy(),
|
||||
assertThat(schedulable.getMetrics().getMaxApps()).
|
||||
isEqualTo(Integer.MAX_VALUE);
|
||||
assertThat(schedulable.getMetrics().getSchedulingPolicy()).isEqualTo(
|
||||
SchedulingPolicy.DEFAULT_POLICY.getName());
|
||||
|
||||
FSAppAttempt app = mock(FSAppAttempt.class);
|
||||
@ -124,8 +126,8 @@ public void test() throws Exception {
|
||||
resourceManager.start();
|
||||
scheduler = (FairScheduler) resourceManager.getResourceScheduler();
|
||||
for(FSQueue queue: scheduler.getQueueManager().getQueues()) {
|
||||
assertEquals(queue.getMetrics().getMaxApps(), Integer.MAX_VALUE);
|
||||
assertEquals(queue.getMetrics().getSchedulingPolicy(),
|
||||
assertThat(queue.getMetrics().getMaxApps()).isEqualTo(Integer.MAX_VALUE);
|
||||
assertThat(queue.getMetrics().getSchedulingPolicy()).isEqualTo(
|
||||
SchedulingPolicy.DEFAULT_POLICY.getName());
|
||||
}
|
||||
|
||||
|
@ -114,6 +114,7 @@
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.apache.hadoop.yarn.conf.YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
@ -4623,17 +4624,17 @@ public void testResourceUsageByMoveApp() throws Exception {
|
||||
FSQueue queue2 = queueMgr.getLeafQueue("parent2.queue2", true);
|
||||
FSQueue queue1 = queueMgr.getLeafQueue("parent1.queue1", true);
|
||||
|
||||
Assert.assertEquals(parent2.getResourceUsage().getMemorySize(), 0);
|
||||
Assert.assertEquals(queue2.getResourceUsage().getMemorySize(), 0);
|
||||
Assert.assertEquals(parent1.getResourceUsage().getMemorySize(), 1 * GB);
|
||||
Assert.assertEquals(queue1.getResourceUsage().getMemorySize(), 1 * GB);
|
||||
assertThat(parent2.getResourceUsage().getMemorySize()).isEqualTo(0);
|
||||
assertThat(queue2.getResourceUsage().getMemorySize()).isEqualTo(0);
|
||||
assertThat(parent1.getResourceUsage().getMemorySize()).isEqualTo(1 * GB);
|
||||
assertThat(queue1.getResourceUsage().getMemorySize()).isEqualTo(1 * GB);
|
||||
|
||||
scheduler.moveApplication(appAttId.getApplicationId(), "parent2.queue2");
|
||||
|
||||
Assert.assertEquals(parent2.getResourceUsage().getMemorySize(), 1 * GB);
|
||||
Assert.assertEquals(queue2.getResourceUsage().getMemorySize(), 1 * GB);
|
||||
Assert.assertEquals(parent1.getResourceUsage().getMemorySize(), 0);
|
||||
Assert.assertEquals(queue1.getResourceUsage().getMemorySize(), 0);
|
||||
assertThat(parent2.getResourceUsage().getMemorySize()).isEqualTo(1 * GB);
|
||||
assertThat(queue2.getResourceUsage().getMemorySize()).isEqualTo(1 * GB);
|
||||
assertThat(parent1.getResourceUsage().getMemorySize()).isEqualTo(0);
|
||||
assertThat(queue1.getResourceUsage().getMemorySize()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test (expected = YarnException.class)
|
||||
@ -5070,20 +5071,20 @@ public void handle(Event event) {
|
||||
Resource usedResource =
|
||||
resourceManager.getResourceScheduler()
|
||||
.getSchedulerNode(nm_0.getNodeId()).getAllocatedResource();
|
||||
Assert.assertEquals(usedResource.getMemorySize(), 0);
|
||||
Assert.assertEquals(usedResource.getVirtualCores(), 0);
|
||||
assertThat(usedResource.getMemorySize()).isEqualTo(0);
|
||||
assertThat(usedResource.getVirtualCores()).isEqualTo(0);
|
||||
// Check total resource of scheduler node is also changed to 0 GB 0 core
|
||||
Resource totalResource =
|
||||
resourceManager.getResourceScheduler()
|
||||
.getSchedulerNode(nm_0.getNodeId()).getTotalResource();
|
||||
Assert.assertEquals(totalResource.getMemorySize(), 0 * GB);
|
||||
Assert.assertEquals(totalResource.getVirtualCores(), 0);
|
||||
assertThat(totalResource.getMemorySize()).isEqualTo(0 * GB);
|
||||
assertThat(totalResource.getVirtualCores()).isEqualTo(0);
|
||||
// Check the available resource is 0/0
|
||||
Resource availableResource =
|
||||
resourceManager.getResourceScheduler()
|
||||
.getSchedulerNode(nm_0.getNodeId()).getUnallocatedResource();
|
||||
Assert.assertEquals(availableResource.getMemorySize(), 0);
|
||||
Assert.assertEquals(availableResource.getVirtualCores(), 0);
|
||||
assertThat(availableResource.getMemorySize()).isEqualTo(0);
|
||||
assertThat(availableResource.getVirtualCores()).isEqualTo(0);
|
||||
}
|
||||
|
||||
private NodeManager registerNode(String hostName, int containerManagerPort,
|
||||
@ -5159,8 +5160,7 @@ public void testContainerAllocationWithContainerIdLeap() throws Exception {
|
||||
|
||||
// container will be allocated at node2
|
||||
scheduler.handle(new NodeUpdateSchedulerEvent(node2));
|
||||
assertEquals(scheduler.getSchedulerApp(app2).
|
||||
getLiveContainers().size(), 1);
|
||||
assertThat(scheduler.getSchedulerApp(app2).getLiveContainers()).hasSize(1);
|
||||
|
||||
long maxId = 0;
|
||||
for (RMContainer container :
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package org.apache.hadoop.yarn.server.resourcemanager.scheduler.fifo;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
@ -333,7 +334,7 @@ public void testUpdateResourceOnNode() throws Exception {
|
||||
NodeAddedSchedulerEvent nodeEvent1 = new NodeAddedSchedulerEvent(node0);
|
||||
scheduler.handle(nodeEvent1);
|
||||
|
||||
assertEquals(scheduler.getNumClusterNodes(), 1);
|
||||
assertThat(scheduler.getNumClusterNodes()).isEqualTo(1);
|
||||
|
||||
Resource newResource = Resources.createResource(1024, 4);
|
||||
|
||||
@ -1286,20 +1287,20 @@ public void handle(Event event) {
|
||||
Resource usedResource =
|
||||
resourceManager.getResourceScheduler()
|
||||
.getSchedulerNode(nm_0.getNodeId()).getAllocatedResource();
|
||||
Assert.assertEquals(usedResource.getMemorySize(), 1 * GB);
|
||||
Assert.assertEquals(usedResource.getVirtualCores(), 1);
|
||||
assertThat(usedResource.getMemorySize()).isEqualTo(1 * GB);
|
||||
assertThat(usedResource.getVirtualCores()).isEqualTo(1);
|
||||
// Check total resource of scheduler node is also changed to 1 GB 1 core
|
||||
Resource totalResource =
|
||||
resourceManager.getResourceScheduler()
|
||||
.getSchedulerNode(nm_0.getNodeId()).getTotalResource();
|
||||
Assert.assertEquals(totalResource.getMemorySize(), 1 * GB);
|
||||
Assert.assertEquals(totalResource.getVirtualCores(), 1);
|
||||
assertThat(totalResource.getMemorySize()).isEqualTo(1 * GB);
|
||||
assertThat(totalResource.getVirtualCores()).isEqualTo(1);
|
||||
// Check the available resource is 0/0
|
||||
Resource availableResource =
|
||||
resourceManager.getResourceScheduler()
|
||||
.getSchedulerNode(nm_0.getNodeId()).getUnallocatedResource();
|
||||
Assert.assertEquals(availableResource.getMemorySize(), 0);
|
||||
Assert.assertEquals(availableResource.getVirtualCores(), 0);
|
||||
assertThat(availableResource.getMemorySize()).isEqualTo(0);
|
||||
assertThat(availableResource.getVirtualCores()).isEqualTo(0);
|
||||
}
|
||||
|
||||
private void checkApplicationResourceUsage(int expected,
|
||||
|
@ -25,6 +25,8 @@
|
||||
|
||||
import org.apache.hadoop.yarn.api.records.Priority;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TestFifoOrderingPolicy {
|
||||
|
||||
@Test
|
||||
@ -33,14 +35,14 @@ public void testFifoOrderingPolicy() {
|
||||
new FifoOrderingPolicy<MockSchedulableEntity>();
|
||||
MockSchedulableEntity r1 = new MockSchedulableEntity();
|
||||
MockSchedulableEntity r2 = new MockSchedulableEntity();
|
||||
|
||||
Assert.assertEquals(policy.getComparator().compare(r1, r2), 0);
|
||||
|
||||
assertThat(policy.getComparator().compare(r1, r2)).isEqualTo(0);
|
||||
|
||||
r1.setSerial(1);
|
||||
Assert.assertEquals(policy.getComparator().compare(r1, r2), 1);
|
||||
assertThat(policy.getComparator().compare(r1, r2)).isEqualTo(1);
|
||||
|
||||
r2.setSerial(2);
|
||||
Assert.assertEquals(policy.getComparator().compare(r1, r2), -1);
|
||||
assertThat(policy.getComparator().compare(r1, r2)).isEqualTo(-1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -23,6 +23,8 @@
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TestFifoOrderingPolicyForPendingApps {
|
||||
|
||||
@Test
|
||||
@ -33,16 +35,16 @@ public void testFifoOrderingPolicyForPendingApps() {
|
||||
MockSchedulableEntity r1 = new MockSchedulableEntity();
|
||||
MockSchedulableEntity r2 = new MockSchedulableEntity();
|
||||
|
||||
Assert.assertEquals(policy.getComparator().compare(r1, r2), 0);
|
||||
assertThat(policy.getComparator().compare(r1, r2)).isEqualTo(0);
|
||||
|
||||
r1.setSerial(1);
|
||||
r1.setRecovering(true);
|
||||
Assert.assertEquals(policy.getComparator().compare(r1, r2), -1);
|
||||
assertThat(policy.getComparator().compare(r1, r2)).isEqualTo(-1);
|
||||
|
||||
r1.setRecovering(false);
|
||||
r2.setSerial(2);
|
||||
r2.setRecovering(true);
|
||||
Assert.assertEquals(policy.getComparator().compare(r1, r2), 1);
|
||||
assertThat(policy.getComparator().compare(r1, r2)).isEqualTo(1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -64,6 +64,7 @@
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
@ -316,13 +317,13 @@ public void testVolumeResourceAllocate() throws Exception {
|
||||
|
||||
Assert.assertEquals(1, allocated.size());
|
||||
Container alloc = allocated.get(0);
|
||||
Assert.assertEquals(alloc.getResource().getMemorySize(), 1024);
|
||||
Assert.assertEquals(alloc.getResource().getVirtualCores(), 1);
|
||||
assertThat(alloc.getResource().getMemorySize()).isEqualTo(1024);
|
||||
assertThat(alloc.getResource().getVirtualCores()).isEqualTo(1);
|
||||
ResourceInformation allocatedVolume =
|
||||
alloc.getResource().getResourceInformation(VOLUME_RESOURCE_NAME);
|
||||
Assert.assertNotNull(allocatedVolume);
|
||||
Assert.assertEquals(allocatedVolume.getValue(), 1024);
|
||||
Assert.assertEquals(allocatedVolume.getUnits(), "Mi");
|
||||
assertThat(allocatedVolume.getValue()).isEqualTo(1024);
|
||||
assertThat(allocatedVolume.getUnits()).isEqualTo("Mi");
|
||||
rm.stop();
|
||||
}
|
||||
}
|
@ -18,6 +18,7 @@
|
||||
|
||||
package org.apache.hadoop.yarn.server.resourcemanager.webapp;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.apache.hadoop.yarn.webapp.WebServicesTestUtils.assertResponseStatusCode;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@ -1088,8 +1089,8 @@ private void verifyNodeAllocationTag(JSONObject json,
|
||||
for (int j=0; j<tagsInfo.length(); j++) {
|
||||
JSONObject tagInfo = tagsInfo.getJSONObject(j);
|
||||
String expectedTag = it.next();
|
||||
assertEquals(tagInfo.getString("allocationTag"), expectedTag);
|
||||
assertEquals(tagInfo.getLong("allocationsCount"),
|
||||
assertThat(tagInfo.getString("allocationTag")).isEqualTo(expectedTag);
|
||||
assertThat(tagInfo.getLong("allocationsCount")).isEqualTo(
|
||||
expectedTags.get(expectedTag).longValue());
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package org.apache.hadoop.yarn.server.resourcemanager.webapp;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.apache.hadoop.yarn.webapp.WebServicesTestUtils.assertResponseStatusCode;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@ -770,7 +771,7 @@ public void testQueueOnlyRequestListReservation() throws Exception {
|
||||
return;
|
||||
}
|
||||
|
||||
assertEquals(json.getJSONArray("reservations").length(), 2);
|
||||
assertThat(json.getJSONArray("reservations").length()).isEqualTo(2);
|
||||
|
||||
testRDLHelper(json.getJSONArray("reservations").getJSONObject(0));
|
||||
testRDLHelper(json.getJSONArray("reservations").getJSONObject(1));
|
||||
|
@ -124,6 +124,11 @@
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
|
@ -60,6 +60,7 @@
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
@ -414,7 +415,7 @@ store.new AppLogs(mainTestAppId, mainTestAppDirPath,
|
||||
TimelineEntities entities = tdm.getEntities("type_1", null, null, null,
|
||||
null, null, null, null, EnumSet.allOf(TimelineReader.Field.class),
|
||||
UserGroupInformation.getLoginUser());
|
||||
assertEquals(entities.getEntities().size(), 1);
|
||||
assertThat(entities.getEntities()).hasSize(1);
|
||||
for (TimelineEntity entity : entities.getEntities()) {
|
||||
assertEquals((Long) 123L, entity.getStartTime());
|
||||
}
|
||||
|
@ -324,6 +324,12 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.hbase</groupId>
|
||||
<artifactId>hbase-testing-util</artifactId>
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package org.apache.hadoop.yarn.server.timelineservice.storage.flow;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
@ -119,7 +120,8 @@ public void testWriteNonNumericData() throws Exception {
|
||||
Cell actualValue = r.getColumnLatestCell(
|
||||
FlowRunColumnFamily.INFO.getBytes(), columnNameBytes);
|
||||
assertNotNull(CellUtil.cloneValue(actualValue));
|
||||
assertEquals(Bytes.toString(CellUtil.cloneValue(actualValue)), value);
|
||||
assertThat(Bytes.toString(CellUtil.cloneValue(actualValue))).
|
||||
isEqualTo(value);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -131,6 +131,12 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
|
@ -42,6 +42,7 @@
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
@ -109,7 +110,7 @@ public void testAggregation() throws Exception {
|
||||
TimelineEntities testEntities = generateTestEntities(groups, n);
|
||||
TimelineEntity resultEntity = TimelineCollector.aggregateEntities(
|
||||
testEntities, "test_result", "TEST_AGGR", true);
|
||||
assertEquals(resultEntity.getMetrics().size(), groups * 3);
|
||||
assertThat(resultEntity.getMetrics()).hasSize(groups * 3);
|
||||
|
||||
for (int i = 0; i < groups; i++) {
|
||||
Set<TimelineMetric> metrics = resultEntity.getMetrics();
|
||||
@ -130,7 +131,7 @@ public void testAggregation() throws Exception {
|
||||
TimelineEntities testEntities1 = generateTestEntities(1, n);
|
||||
TimelineEntity resultEntity1 = TimelineCollector.aggregateEntities(
|
||||
testEntities1, "test_result", "TEST_AGGR", false);
|
||||
assertEquals(resultEntity1.getMetrics().size(), 3);
|
||||
assertThat(resultEntity1.getMetrics()).hasSize(3);
|
||||
|
||||
Set<TimelineMetric> metrics = resultEntity1.getMetrics();
|
||||
for (TimelineMetric m : metrics) {
|
||||
|
@ -74,6 +74,11 @@
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- 'mvn dependency:analyze' fails to detect use of this dependency -->
|
||||
<dependency>
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package org.apache.hadoop.yarn.server.webproxy;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
@ -334,7 +335,7 @@ public void testWebAppProxyPassThroughHeaders() throws Exception {
|
||||
"Access-Control-Request-Headers", "Authorization");
|
||||
proxyConn.addRequestProperty(UNKNOWN_HEADER, "unknown");
|
||||
// Verify if four headers mentioned above have been added
|
||||
assertEquals(proxyConn.getRequestProperties().size(), 4);
|
||||
assertThat(proxyConn.getRequestProperties()).hasSize(4);
|
||||
proxyConn.connect();
|
||||
assertEquals(HttpURLConnection.HTTP_OK, proxyConn.getResponseCode());
|
||||
// Verify if number of headers received by end server is 9.
|
||||
|
@ -44,6 +44,7 @@
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@ -163,7 +164,7 @@ public void testFindRedirectUrl() throws Exception {
|
||||
spy.proxyUriBases.put(rm2, rm2Url);
|
||||
spy.rmUrls = new String[] { rm1, rm2 };
|
||||
|
||||
assertEquals(spy.findRedirectUrl(), rm1Url);
|
||||
assertThat(spy.findRedirectUrl()).isEqualTo(rm1Url);
|
||||
}
|
||||
|
||||
private String startHttpServer() throws Exception {
|
||||
|
@ -25,7 +25,7 @@
|
||||
import java.util.HashSet;
|
||||
import java.util.HashMap;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@ -137,7 +137,7 @@ public void testFindRedirectUrl() throws Exception {
|
||||
|
||||
assertTrue(spy.isValidUrl(rm1Url));
|
||||
assertFalse(spy.isValidUrl(rm2Url));
|
||||
assertEquals(spy.findRedirectUrl(), rm1Url);
|
||||
assertThat(spy.findRedirectUrl()).isEqualTo(rm1Url);
|
||||
}
|
||||
|
||||
private String startSecureHttpServer() throws Exception {
|
||||
|
Loading…
Reference in New Issue
Block a user