Skip to content

Commit

Permalink
Fixing required stylecheck
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashutosh Gupta committed Jul 21, 2022
1 parent 0b7f682 commit efa7813
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ void testHostedUIs() throws Exception {
} finally {
historyServer.stop();
}
assertEquals(diskFileStr, connFileStr, "Web file contents should be the same as on disk contents");
assertEquals(diskFileStr, connFileStr,
"Web file contents should be the same as on disk contents");
}
private String readInputStream(InputStream input) throws Exception {
ByteArrayOutputStream data = new ByteArrayOutputStream();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,6 @@ protected Properties getConfiguration(String configPrefix,
}
}

private int round;

public TestAHSWebServices() {
super(new WebAppDescriptor.Builder(
"org.apache.hadoop.yarn.server.applicationhistoryservice.webapp")
Expand Down Expand Up @@ -571,7 +569,6 @@ void testSingleContainer(int round) throws Exception {
@ParameterizedTest
@Timeout(10000)
void testContainerLogsForFinishedApps(int round) throws Exception {

String fileName = "syslog";
String user = "user1";
NodeId nodeId = NodeId.newInstance("test host", 100);
Expand All @@ -581,7 +578,6 @@ void testContainerLogsForFinishedApps(int round) throws Exception {
appId, 1);
ContainerId containerId1 = ContainerId.newContainerId(appAttemptId, 1);
ContainerId containerId100 = ContainerId.newContainerId(appAttemptId, 100);

TestContainerLogsUtils.createContainerLogFileInRemoteFS(conf, fs,
rootLogDir, appId, Collections.singletonMap(containerId1,
"Hello." + containerId1),
Expand All @@ -601,7 +597,6 @@ void testContainerLogsForFinishedApps(int round) throws Exception {
.get(ClientResponse.class);
String responseText = response.getEntity(String.class);
assertTrue(responseText.contains("Hello." + containerId1));

// Do the same test with new API
r = resource();
response = r.path("ws").path("v1")
Expand All @@ -612,7 +607,6 @@ void testContainerLogsForFinishedApps(int round) throws Exception {
.get(ClientResponse.class);
responseText = response.getEntity(String.class);
assertTrue(responseText.contains("Hello." + containerId1));

// test whether we can find container log from remote diretory if
// the containerInfo for this container could not be fetched from AHS.
r = resource();
Expand All @@ -624,7 +618,6 @@ void testContainerLogsForFinishedApps(int round) throws Exception {
.get(ClientResponse.class);
responseText = response.getEntity(String.class);
assertTrue(responseText.contains("Hello." + containerId100));

// Do the same test with new API
r = resource();
response = r.path("ws").path("v1")
Expand All @@ -635,14 +628,12 @@ void testContainerLogsForFinishedApps(int round) throws Exception {
.get(ClientResponse.class);
responseText = response.getEntity(String.class);
assertTrue(responseText.contains("Hello." + containerId100));

// create an application which can not be found from AHS
ApplicationId appId100 = ApplicationId.newInstance(0, 100);
ApplicationAttemptId appAttemptId100 = ApplicationAttemptId.newInstance(
appId100, 1);
ContainerId containerId1ForApp100 = ContainerId.newContainerId(
appAttemptId100, 1);

TestContainerLogsUtils.createContainerLogFileInRemoteFS(conf, fs,
rootLogDir, appId100,
Collections.singletonMap(containerId1ForApp100,
Expand All @@ -662,7 +653,6 @@ void testContainerLogsForFinishedApps(int round) throws Exception {
"End of LogType:syslog".length() + 50) + "\n\n";
int tailTextSize = "\nEnd of LogType:syslog\n".getBytes().length
+ tailEndSeparator.getBytes().length;

String logMessage = "Hello." + containerId1ForApp100;
int fileContentSize = logMessage.getBytes().length;
// specify how many bytes we should get from logs
Expand All @@ -683,7 +673,6 @@ void testContainerLogsForFinishedApps(int round) throws Exception {
assertEquals(new String(responseText.getBytes(),
(fullTextSize - fileContentSize - tailTextSize), 5),
new String(logMessage.getBytes(), 0, 5));

// specify how many bytes we should get from logs
// if we specify a negative number, it would get the last n bytes from
// container log
Expand All @@ -702,7 +691,6 @@ void testContainerLogsForFinishedApps(int round) throws Exception {
assertEquals(new String(responseText.getBytes(),
(fullTextSize - fileContentSize - tailTextSize), 5),
new String(logMessage.getBytes(), fileContentSize - 5, 5));

// specify the bytes which is larger than the actual file size,
// we would get the full logs
r = resource();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.io.WritableComparator;
import org.apache.hadoop.yarn.server.timeline.GenericObjectMapper;
import org.junit.jupiter.api.Test;

import java.io.IOException;
Expand All @@ -39,11 +38,11 @@ public class TestGenericObjectMapper {
void testEncoding() {
testEncoding(Long.MAX_VALUE);
testEncoding(Long.MIN_VALUE);
testEncoding(0l);
testEncoding(128l);
testEncoding(256l);
testEncoding(512l);
testEncoding(-256l);
testEncoding(0L);
testEncoding(128L);
testEncoding(256L);
testEncoding(512L);
testEncoding(-256L);
}

private static void testEncoding(long l) {
Expand Down Expand Up @@ -82,13 +81,13 @@ void testValueTypes() throws IOException {
GenericObjectMapper.write((long) Integer.MAX_VALUE)));
assertEquals(Integer.MIN_VALUE, GenericObjectMapper.read(
GenericObjectMapper.write((long) Integer.MIN_VALUE)));
verify((long) Integer.MAX_VALUE + 1l);
verify((long) Integer.MIN_VALUE - 1l);
verify((long) Integer.MAX_VALUE + 1L);
verify((long) Integer.MIN_VALUE - 1L);

verify(Long.MAX_VALUE);
verify(Long.MIN_VALUE);

assertEquals(42, GenericObjectMapper.read(GenericObjectMapper.write(42l)));
assertEquals(42, GenericObjectMapper.read(GenericObjectMapper.write(42L)));
verify(42);
verify(1.23);
verify("abc");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ public static Collection<Object[]> withSsl() {
private static Configuration conf;
private static boolean withSsl;

public void initTestTimelineAuthenticationFilterForV1(boolean withSsl) {
TestTimelineAuthenticationFilterForV1.withSsl = withSsl;
public void initTestTimelineAuthenticationFilterForV1(boolean isSslEnabled) {
TestTimelineAuthenticationFilterForV1.withSsl = isSslEnabled;
}

@BeforeAll
Expand Down Expand Up @@ -186,8 +186,8 @@ public static void tearDown() throws Exception {

@MethodSource("withSsl")
@ParameterizedTest
void testPutTimelineEntities(boolean withSsl) throws Exception {
initTestTimelineAuthenticationFilterForV1(withSsl);
void testPutTimelineEntities(boolean isSslEnabled) throws Exception {
initTestTimelineAuthenticationFilterForV1(isSslEnabled);
KerberosTestUtils.doAs(PRINCIPAL, new Callable<Void>() {
@Override
public Void call() throws Exception {
Expand Down Expand Up @@ -215,8 +215,8 @@ public Void call() throws Exception {

@MethodSource("withSsl")
@ParameterizedTest
void testPutDomains(boolean withSsl) throws Exception {
initTestTimelineAuthenticationFilterForV1(withSsl);
void testPutDomains(boolean isSslEnabled) throws Exception {
initTestTimelineAuthenticationFilterForV1(isSslEnabled);
KerberosTestUtils.doAs(PRINCIPAL, new Callable<Void>() {
@Override
public Void call() throws Exception {
Expand All @@ -239,8 +239,8 @@ public Void call() throws Exception {

@MethodSource("withSsl")
@ParameterizedTest
void testDelegationTokenOperations(boolean withSsl) throws Exception {
initTestTimelineAuthenticationFilterForV1(withSsl);
void testDelegationTokenOperations(boolean isSslEnabled) throws Exception {
initTestTimelineAuthenticationFilterForV1(isSslEnabled);
TimelineClient httpUserClient =
KerberosTestUtils.doAs(PRINCIPAL,
new Callable<TimelineClient>() {
Expand All @@ -265,7 +265,8 @@ public UserGroupInformation call() throws Exception {
TimelineDelegationTokenIdentifier tDT = token.decodeIdentifier();
assertNotNull(tDT,
"Delegation token identifier should not be null");
assertEquals(new Text(HTTP_USER), tDT.getOwner(), "Owner of delegation token identifier does not match");
assertEquals(new Text(HTTP_USER), tDT.getOwner(),
"Owner of delegation token identifier does not match");

// Renew token
assertFalse(token.getService().toString().isEmpty(),
Expand Down Expand Up @@ -313,8 +314,10 @@ public TimelineClient run() {
tDT = token.decodeIdentifier();
assertNotNull(tDT,
"Delegation token identifier should not be null");
assertEquals(new Text(FOO_USER), tDT.getOwner(), "Owner of delegation token is not the expected");
assertEquals(new Text(HTTP_USER), tDT.getRealUser(), "Real user of delegation token is not the expected");
assertEquals(new Text(FOO_USER), tDT.getOwner(),
"Owner of delegation token is not the expected");
assertEquals(new Text(HTTP_USER), tDT.getRealUser(),
"Real user of delegation token is not the expected");

// Renew token as the renewer
final Token<TimelineDelegationTokenIdentifier> tokenToRenew = token;
Expand Down

0 comments on commit efa7813

Please sign in to comment.