github-code-scanning[bot] commented on code in PR #12197:
URL:
https://github.com/apache/dolphinscheduler/pull/12197#discussion_r1000872353
##########
dolphinscheduler-aop/src/test/java/org/apache/dolphinscheduler/poc/YarnClientMoc.java:
##########
@@ -0,0 +1,23 @@
+package org.apache.dolphinscheduler.poc;
+
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
+import org.apache.hadoop.yarn.exceptions.YarnException;
+
+import java.io.IOException;
+import java.util.Random;
+
+public class YarnClientMoc {
+
+ private Random random = new Random();
+
+ public ApplicationId createAppId() {
+ ApplicationId created =
ApplicationId.newInstance(System.currentTimeMillis(), random.nextInt());
+ System.out.println("created id " + created.getId());
+ return created;
+ }
+
+ public ApplicationId submitApplication(ApplicationSubmissionContext
appContext) throws YarnException, IOException {
Review Comment:
## Useless parameter
The parameter 'appContext' is never used.
[Show more
details](https://github.com/apache/dolphinscheduler/security/code-scanning/1996)
##########
dolphinscheduler-aop/src/test/java/org/apache/dolphinscheduler/YarnClientAspectMocTest.java:
##########
@@ -0,0 +1,54 @@
+package org.apache.dolphinscheduler;
+
+import org.apache.dolphinscheduler.poc.YarnClientMoc;
+
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
+import org.apache.hadoop.yarn.api.records.Priority;
+import org.apache.hadoop.yarn.exceptions.YarnException;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+public class YarnClientAspectMocTest {
+
+ private final PrintStream standardOut = System.out;
+ ByteArrayOutputStream stdoutStream = new ByteArrayOutputStream();
+ @BeforeEach
+ public void beforeEveryTest() {
+ System.setOut(new PrintStream(stdoutStream));
+ }
+ @AfterEach
+ public void afterEveryTest() throws IOException {
+ System.setOut(standardOut);
+ stdoutStream.close();
+ }
+ @Test
+ public void testMoc() {
+ YarnClientMoc moc = new YarnClientMoc();
+ try {
+ ApplicationSubmissionContext appContext =
ApplicationSubmissionContext.newInstance(
+ ApplicationId.newInstance(System.currentTimeMillis(),
1236), "appName",
+ "queue", Priority.UNDEFINED,
+ null, false,
+ false, 10, null,
+ "type");
+ moc.createAppId();
+ ApplicationId applicationId = moc.submitApplication(appContext);
Review Comment:
## Unread local variable
Variable 'ApplicationId applicationId' is never read.
[Show more
details](https://github.com/apache/dolphinscheduler/security/code-scanning/1997)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]