Skip to content

HDDS-1650. Fix Ozone tests leaking volume checker thread. Contributed… #915

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

Merged
merged 1 commit into from
Jun 6, 2019
Merged
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 @@ -73,13 +73,15 @@ public class TestHddsDispatcher {
public void testContainerCloseActionWhenFull() throws IOException {
String testDir = GenericTestUtils.getTempPath(
TestHddsDispatcher.class.getSimpleName());
OzoneConfiguration conf = new OzoneConfiguration();
DatanodeDetails dd = randomDatanodeDetails();
VolumeSet volumeSet = new VolumeSet(dd.getUuidString(), conf);

try {
UUID scmId = UUID.randomUUID();
OzoneConfiguration conf = new OzoneConfiguration();
conf.set(HDDS_DATANODE_DIR_KEY, testDir);
DatanodeDetails dd = randomDatanodeDetails();
ContainerSet containerSet = new ContainerSet();
VolumeSet volumeSet = new VolumeSet(dd.getUuidString(), conf);

DatanodeStateMachine stateMachine = Mockito.mock(
DatanodeStateMachine.class);
StateContext context = Mockito.mock(StateContext.class);
Expand Down Expand Up @@ -118,6 +120,7 @@ public void testContainerCloseActionWhenFull() throws IOException {
.addContainerActionIfAbsent(Mockito.any(ContainerAction.class));

} finally {
volumeSet.shutdown();
FileUtils.deleteDirectory(new File(testDir));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.hadoop.util.DiskChecker.DiskOutOfSpaceException;
import org.apache.hadoop.util.ReflectionUtils;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -40,10 +41,12 @@ public class TestRoundRobinVolumeChoosingPolicy {

private RoundRobinVolumeChoosingPolicy policy;
private List<HddsVolume> volumes;
private VolumeSet volumeSet;

private final String baseDir = MiniDFSCluster.getBaseDirectory();
private final String volume1 = baseDir + "disk1";
private final String volume2 = baseDir + "disk2";

private static final String DUMMY_IP_ADDR = "0.0.0.0";

@Before
Expand All @@ -53,10 +56,18 @@ public void setup() throws Exception {
conf.set(DFSConfigKeys.DFS_DATANODE_DATA_DIR_KEY, dataDirKey);
policy = ReflectionUtils.newInstance(
RoundRobinVolumeChoosingPolicy.class, null);
VolumeSet volumeSet = new VolumeSet(UUID.randomUUID().toString(), conf);
volumeSet = new VolumeSet(UUID.randomUUID().toString(), conf);
volumes = volumeSet.getVolumesList();
}

@After
public void cleanUp() {
if (volumeSet != null) {
volumeSet.shutdown();
volumeSet = null;
}
}

@Test
public void testRRVolumeChoosingPolicy() throws Exception {
HddsVolume hddsVolume1 = volumes.get(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ public void testFailVolumes() throws Exception{
//Set back to writable
try {
readOnlyVolumePath.setWritable(true);
volSet.shutdown();
} finally {
FileUtil.fullyDelete(volumePath);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public void testOzoneDirsAreCreated() throws IOException {
for (String d : dirs) {
assertTrue(new File(d).isDirectory());
}
volumeSet.shutdown();
}

/**
Expand All @@ -124,6 +125,7 @@ HddsVolumeChecker getVolumeChecker(Configuration configuration)
assertThat(volumeSet.getFailedVolumesList().size(), is(numBadVolumes));
assertThat(volumeSet.getVolumesList().size(),
is(numVolumes - numBadVolumes));
volumeSet.shutdown();
}

/**
Expand All @@ -146,6 +148,7 @@ HddsVolumeChecker getVolumeChecker(Configuration configuration)

assertEquals(volumeSet.getFailedVolumesList().size(), numVolumes);
assertEquals(volumeSet.getVolumesList().size(), 0);
volumeSet.shutdown();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,14 @@ public void testHandlerCommandHandling() throws Exception {
@Test
public void testVolumeSetInKeyValueHandler() throws Exception{
File path = GenericTestUtils.getRandomizedTestDir();
Configuration conf = new OzoneConfiguration();
conf.set(HDDS_DATANODE_DIR_KEY, path.getAbsolutePath());
VolumeSet volumeSet = new VolumeSet(UUID.randomUUID().toString(), conf);
try {
Configuration conf = new OzoneConfiguration();
conf.set(HDDS_DATANODE_DIR_KEY, path.getAbsolutePath());
ContainerSet cset = new ContainerSet();
int[] interval = new int[1];
interval[0] = 2;
ContainerMetrics metrics = new ContainerMetrics(interval);
VolumeSet volumeSet = new VolumeSet(UUID.randomUUID().toString(), conf);
DatanodeDetails datanodeDetails = Mockito.mock(DatanodeDetails.class);
DatanodeStateMachine stateMachine = Mockito.mock(
DatanodeStateMachine.class);
Expand All @@ -263,6 +263,7 @@ public void testVolumeSetInKeyValueHandler() throws Exception{
ex);
}
} finally {
volumeSet.shutdown();
FileUtil.fullyDelete(path);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.apache.hadoop.ozone.container.keyvalue.KeyValueContainer;
import org.apache.hadoop.ozone.container.keyvalue.KeyValueContainerData;
import org.apache.hadoop.ozone.container.keyvalue.helpers.BlockUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -82,13 +83,20 @@ public void setUp() throws Exception {
conf.set(HddsConfigKeys.OZONE_METADATA_DIRS,
folder.newFolder().getAbsolutePath());
commitSpaceMap = new HashMap<String, Long>();
volumeSet = new VolumeSet(datanodeDetails.getUuidString(), conf);
volumeChoosingPolicy = new RoundRobinVolumeChoosingPolicy();
}

@After
public void cleanUp() throws Exception {
if (volumeSet != null) {
volumeSet.shutdown();
volumeSet = null;
}
}

@Test
public void testBuildContainerMap() throws Exception {
volumeSet = new VolumeSet(datanodeDetails.getUuidString(), conf);
volumeChoosingPolicy = new RoundRobinVolumeChoosingPolicy();

// Format the volumes
for (HddsVolume volume : volumeSet.getVolumesList()) {
volume.format(UUID.randomUUID().toString());
Expand Down Expand Up @@ -139,8 +147,6 @@ public void testBuildContainerMap() throws Exception {

@Test
public void testContainerCreateDiskFull() throws Exception {
volumeSet = new VolumeSet(datanodeDetails.getUuidString(), conf);
volumeChoosingPolicy = new RoundRobinVolumeChoosingPolicy();
long containerSize = (long) StorageUnit.MB.toBytes(100);
boolean diskSpaceException = false;

Expand Down