Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#2282][FOLLOWUP] test: Add UT for DelegationRssShuffleManager#getReader #2287

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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 @@ -21,6 +21,7 @@
import java.util.Map;
import java.util.Set;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Maps;
import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.security.UserGroupInformation;
Expand Down Expand Up @@ -175,7 +176,8 @@ private boolean tryAccessCluster() {
return false;
}

private ShuffleManager createShuffleManagerInExecutor() throws RssException {
@VisibleForTesting
protected ShuffleManager createShuffleManagerInExecutor() throws RssException {
ShuffleManager shuffleManager;
// get useRSS from spark conf
boolean useRSS = sparkConf.get(RssSparkConfig.RSS_ENABLED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,18 @@
import org.apache.spark.shuffle.sort.SortShuffleManager;
import org.junit.jupiter.api.Test;

import org.apache.uniffle.common.exception.RssException;
import org.apache.uniffle.storage.util.StorageType;

import static org.apache.uniffle.common.rpc.StatusCode.ACCESS_DENIED;
import static org.apache.uniffle.common.rpc.StatusCode.SUCCESS;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;

public class DelegationRssShuffleManagerTest extends RssShuffleManagerTestBase {

Expand Down Expand Up @@ -131,6 +136,31 @@ public void testTryAccessCluster() throws Exception {
assertCreateSortShuffleManager(secondConf);
}

@Test
public void testGetReader() throws Exception {
ShuffleReader mockReader = mock(ShuffleReader.class);
ShuffleManager mockShuffleManager = mock(ShuffleManager.class);
doReturn(mockReader)
.when(mockShuffleManager)
.getReader(any(), anyInt(), anyInt(), anyInt(), anyInt(), any(), any());
DelegationRssShuffleManager delegationRssShuffleManager;
SparkConf conf = new SparkConf();
conf.set(RssSparkConfig.RSS_COORDINATOR_QUORUM.key(), "m1:8001,m2:8002");
delegationRssShuffleManager =
new DelegationRssShuffleManager(conf, false) {
@Override
protected ShuffleManager createShuffleManagerInExecutor() throws RssException {
return mockShuffleManager;
}
};
assertEquals(mockShuffleManager, delegationRssShuffleManager.getDelegate());
ShuffleReader<Object, Object> reader =
delegationRssShuffleManager.getReader(
new BaseShuffleHandle(0, null), 1, 1, 1, 1, null, null);

assertEquals(mockReader, reader);
}

private void assertCreateSortShuffleManager(SparkConf conf) throws Exception {
DelegationRssShuffleManager delegationRssShuffleManager =
new DelegationRssShuffleManager(conf, true);
Expand Down
Loading