Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -124,26 +124,6 @@
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
import org.apache.hadoop.yarn.logaggregation.filecontroller.LogAggregationFileControllerContext;
import org.apache.hadoop.yarn.logaggregation.filecontroller.LogAggregationFileControllerFactory;

import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* This class contains several utility functions for log aggregation tests.
*/
Expand Down Expand Up @@ -75,13 +73,12 @@ public static void createContainerLogFileInRemoteFS(Configuration conf,
if (fs.exists(rootLogDirPath)) {
fs.delete(rootLogDirPath, true);
}
assertTrue(fs.mkdirs(rootLogDirPath));
fs.mkdirs(rootLogDirPath);
Path appLogsDir = new Path(rootLogDirPath, appId.toString());
if (fs.exists(appLogsDir)) {
fs.delete(appLogsDir, true);
}
assertTrue(fs.mkdirs(appLogsDir));

fs.mkdirs(appLogsDir);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does cut the check of the outcome...are we all happy with this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we are happy because the directory has been removed in the previous line, but rethinking this, it's possible to fail removing the directory and then mkdir fails. Adding back the check in the next commit.

Copy link
Contributor

@slfan1989 slfan1989 Dec 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for your question, I think we should keep this assertTrue.

We are currently experiencing some difficulties.

TestContainerLogsUtils.java uses assertTrue of org.junit.jupiter, hadoop-mapreduce-client-hs and hadoop-mapreduce-client-app use TestContainerLogsUtils.java, hadoop-mapreduce-client-hs and hadoop-mapreduce-client-app These two modules have not upgraded the junit test, so when running the test, the classes cannot be found.

hadoop-mapreduce-client-hs and hadoop-mapreduce-client-app may take some time to upgrade junit test.

aajisaka's idea can quickly fix this problem without affecting the compilation of other modules.

I will continue to follow up the mapreduce junit upgrade. If the mapreduce module junit upgrade is completed, I will change this back.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aajisaka I see your latest changes, your changes are reasonable. LGTM.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we are happy because the directory has been removed in the previous line, but rethinking this, it's possible to fail removing the directory and then mkdir fails. Adding back the check in the next commit.

Thanks for adding it back. It makes sense. LGTM

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @slfan1989

hadoop-mapreduce-client-hs and hadoop-mapreduce-client-app may take some time to upgrade junit test.

I have already raised PR for both the modules. Can see some failures in hadoop-mapreduce-client-app - will fix it as well in that PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about removing the asserts and just calling getFileStatus(dir) after.

remember also that delete() returning false means "dir wasn't there"...not a reason to fail

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added getFileStatus(dir) to check the dir exists in the latest commit. Thank you @steveloughran

createContainerLogInLocalDir(appLogsDir, containerToContent, fs, fileName);
// upload container logs to remote log dir

Expand All @@ -95,7 +92,7 @@ public static void createContainerLogFileInRemoteFS(Configuration conf,
if (fs.exists(path) && deleteRemoteLogDir) {
fs.delete(path, true);
}
assertTrue(fs.mkdirs(path));
fs.mkdirs(path);
uploadContainerLogIntoRemoteDir(ugi, conf, rootLogDirList, nodeId, appId,
containerToContent.keySet(), path);
}
Expand All @@ -111,7 +108,7 @@ private static void createContainerLogInLocalDir(Path appLogsDir,
if (fs.exists(containerLogsDir)) {
fs.delete(containerLogsDir, true);
}
assertTrue(fs.mkdirs(containerLogsDir));
fs.mkdirs(containerLogsDir);
Writer writer =
new FileWriter(new File(containerLogsDir.toString(), fileName));
writer.write(content);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.assertj.core.api.Assertions.assertThat;

public class WebServicesTestUtils {
public static long getXmlLong(Element element, String name) {
Expand Down Expand Up @@ -121,28 +120,24 @@ public static String getXmlAttrString(Element element, String name) {
}

public static void checkStringMatch(String print, String expected, String got) {
assertTrue(
got.matches(expected),
print + " doesn't match, got: " + got + " expected: " + expected);
assertThat(got).as(print).matches(expected);
}

public static void checkStringContains(String print, String expected, String got) {
assertTrue(
got.contains(expected),
print + " doesn't contain expected string, got: " + got + " expected: " + expected);
assertThat(got).as(print).contains(expected);
}

public static void checkStringEqual(String print, String expected, String got) {
assertEquals(got, expected);
assertThat(got).as(print).isEqualTo(expected);
}

public static void assertResponseStatusCode(StatusType expected,
StatusType actual) {
assertResponseStatusCode(null, expected, actual);
assertThat(expected.getStatusCode()).isEqualTo(actual.getStatusCode());
}

public static void assertResponseStatusCode(String errmsg,
StatusType expected, StatusType actual) {
assertEquals(expected.getStatusCode(), actual.getStatusCode(), errmsg);
assertThat(expected.getStatusCode()).withFailMessage(errmsg).isEqualTo(actual.getStatusCode());
}
}