Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,47 @@

package org.apache.hadoop.hive.llap;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;

import com.google.protobuf.Message;
import org.apache.commons.lang3.mutable.MutableInt;
import org.apache.hadoop.hive.llap.LlapNodeId;
import org.apache.hadoop.hive.llap.tez.LlapProtocolClientProxy;
import org.junit.Assert;
import org.junit.Test;

public class TestAsyncPbRpcProxy {
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

class TestAsyncPbRpcProxy {

private static final Logger LOG = LoggerFactory.getLogger(TestAsyncPbRpcProxy.class);

/**
* Front-loads one-time initialization (Mockito mock generation, classloading, log4j2
* setup) so the per-test timeouts guard only the code under test. A timeout here
* indicates a starved executor, not a test bug (HIVE-26089).
*/
@BeforeAll
@Timeout(value = 60000, unit = TimeUnit.MILLISECONDS, threadMode = Timeout.ThreadMode.SEPARATE_THREAD)
static void warmUp() {
mock(Message.class);
mock(LlapProtocolClientProxy.ExecuteRequestCallback.class);
LOG.info("warm-up");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

could you add a pre/post warmup message if it could be interesting? I feel that this message alone is not necessarily useful
if it's just for log4j warmup, it can also be noted by a code comment, but still, a pre/post message makes sense to me, like beginning and end of this whole method

new RequestManagerForTest(1);
LlapNodeId.getInstance("warmup-host", 1025);
Comment on lines +56 to +57

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please elaborate in a short code comment for later convenience what kind of warm-up mechanism kicks in by calling these? if classloading, which set classes approximately are about to load by this call

}

@Test (timeout = 5000)
public void testMultipleNodes() throws Exception {
@Test
@Timeout(value = 5000, unit = TimeUnit.MILLISECONDS, threadMode = Timeout.ThreadMode.SEPARATE_THREAD)
void testMultipleNodes() throws Exception {
RequestManagerForTest requestManager = new RequestManagerForTest(1);

LlapNodeId nodeId1 = LlapNodeId.getInstance("host1", 1025);
Expand All @@ -59,16 +80,16 @@ public void testMultipleNodes() throws Exception {
assertEquals(2, requestManager.numSubmissionsCounters);
assertNotNull(requestManager.numInvocationsPerNode.get(nodeId1));
assertNotNull(requestManager.numInvocationsPerNode.get(nodeId2));
Assert.assertEquals(1, requestManager.numInvocationsPerNode.get(nodeId1).getValue().intValue());
Assert.assertEquals(1, requestManager.numInvocationsPerNode.get(nodeId2).getValue().intValue());
assertEquals(1, requestManager.numInvocationsPerNode.get(nodeId1).getValue().intValue());
assertEquals(1, requestManager.numInvocationsPerNode.get(nodeId2).getValue().intValue());
assertEquals(0, requestManager.currentLoopSkippedRequests.size());
assertEquals(0, requestManager.currentLoopSkippedRequests.size());
assertEquals(0, requestManager.currentLoopDisabledNodes.size());
}

@org.junit.Ignore("HIVE-26089")
@Test(timeout = 5000)
public void testSingleInvocationPerNode() throws Exception {
@Test
@Timeout(value = 5000, unit = TimeUnit.MILLISECONDS, threadMode = Timeout.ThreadMode.SEPARATE_THREAD)
void testSingleInvocationPerNode() throws Exception {
RequestManagerForTest requestManager = new RequestManagerForTest(1);

LlapNodeId nodeId1 = LlapNodeId.getInstance("host1", 1025);
Expand All @@ -83,7 +104,7 @@ public void testSingleInvocationPerNode() throws Exception {
requestManager.process();
assertEquals(1, requestManager.numSubmissionsCounters);
assertNotNull(requestManager.numInvocationsPerNode.get(nodeId1));
Assert.assertEquals(1, requestManager.numInvocationsPerNode.get(nodeId1).getValue().intValue());
assertEquals(1, requestManager.numInvocationsPerNode.get(nodeId1).getValue().intValue());
assertEquals(0, requestManager.currentLoopSkippedRequests.size());

// Second request for host. Single invocation since the last has not completed.
Expand All @@ -92,7 +113,7 @@ public void testSingleInvocationPerNode() throws Exception {
requestManager.process();
assertEquals(1, requestManager.numSubmissionsCounters);
assertNotNull(requestManager.numInvocationsPerNode.get(nodeId1));
Assert.assertEquals(1, requestManager.numInvocationsPerNode.get(nodeId1).getValue().intValue());
assertEquals(1, requestManager.numInvocationsPerNode.get(nodeId1).getValue().intValue());
assertEquals(1, requestManager.currentLoopSkippedRequests.size());
assertEquals(1, requestManager.currentLoopDisabledNodes.size());
assertTrue(requestManager.currentLoopDisabledNodes.contains(nodeId1));
Expand All @@ -102,7 +123,7 @@ public void testSingleInvocationPerNode() throws Exception {
requestManager.process();
assertEquals(2, requestManager.numSubmissionsCounters);
assertNotNull(requestManager.numInvocationsPerNode.get(nodeId1));
Assert.assertEquals(2, requestManager.numInvocationsPerNode.get(nodeId1).getValue().intValue());
assertEquals(2, requestManager.numInvocationsPerNode.get(nodeId1).getValue().intValue());
assertEquals(0, requestManager.currentLoopSkippedRequests.size());
assertEquals(0, requestManager.currentLoopDisabledNodes.size());
assertFalse(requestManager.currentLoopDisabledNodes.contains(nodeId1));
Expand Down
Loading