|
@@ -41,12 +41,15 @@ import org.apache.hadoop.ozone.container.common.volume.VolumeSet;
|
|
import org.apache.hadoop.ozone.container.keyvalue.KeyValueContainer;
|
|
import org.apache.hadoop.ozone.container.keyvalue.KeyValueContainer;
|
|
import org.apache.hadoop.ozone.container.keyvalue.KeyValueContainerData;
|
|
import org.apache.hadoop.ozone.container.keyvalue.KeyValueContainerData;
|
|
import org.apache.hadoop.ozone.container.keyvalue.helpers.BlockUtils;
|
|
import org.apache.hadoop.ozone.container.keyvalue.helpers.BlockUtils;
|
|
|
|
+import org.apache.hadoop.test.LambdaTestUtils;
|
|
import org.junit.After;
|
|
import org.junit.After;
|
|
import org.junit.Before;
|
|
import org.junit.Before;
|
|
import org.junit.Rule;
|
|
import org.junit.Rule;
|
|
import org.junit.Test;
|
|
import org.junit.Test;
|
|
import org.junit.rules.TemporaryFolder;
|
|
import org.junit.rules.TemporaryFolder;
|
|
import org.mockito.Mockito;
|
|
import org.mockito.Mockito;
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
|
|
import java.util.Random;
|
|
import java.util.Random;
|
|
import java.util.UUID;
|
|
import java.util.UUID;
|
|
@@ -62,6 +65,9 @@ import static org.junit.Assert.assertEquals;
|
|
*/
|
|
*/
|
|
public class TestOzoneContainer {
|
|
public class TestOzoneContainer {
|
|
|
|
|
|
|
|
+ private static final Logger LOG =
|
|
|
|
+ LoggerFactory.getLogger(TestOzoneContainer.class);
|
|
|
|
+
|
|
@Rule
|
|
@Rule
|
|
public TemporaryFolder folder = new TemporaryFolder();
|
|
public TemporaryFolder folder = new TemporaryFolder();
|
|
|
|
|
|
@@ -148,7 +154,6 @@ public class TestOzoneContainer {
|
|
@Test
|
|
@Test
|
|
public void testContainerCreateDiskFull() throws Exception {
|
|
public void testContainerCreateDiskFull() throws Exception {
|
|
long containerSize = (long) StorageUnit.MB.toBytes(100);
|
|
long containerSize = (long) StorageUnit.MB.toBytes(100);
|
|
- boolean diskSpaceException = false;
|
|
|
|
|
|
|
|
// Format the volumes
|
|
// Format the volumes
|
|
for (HddsVolume volume : volumeSet.getVolumesList()) {
|
|
for (HddsVolume volume : volumeSet.getVolumesList()) {
|
|
@@ -164,16 +169,14 @@ public class TestOzoneContainer {
|
|
keyValueContainer = new KeyValueContainer(keyValueContainerData, conf);
|
|
keyValueContainer = new KeyValueContainer(keyValueContainerData, conf);
|
|
|
|
|
|
// we expect an out of space Exception
|
|
// we expect an out of space Exception
|
|
- try {
|
|
|
|
- keyValueContainer.create(volumeSet, volumeChoosingPolicy, scmId);
|
|
|
|
- } catch (StorageContainerException e) {
|
|
|
|
- if (e.getResult() == DISK_OUT_OF_SPACE) {
|
|
|
|
- diskSpaceException = true;
|
|
|
|
- }
|
|
|
|
|
|
+ StorageContainerException e = LambdaTestUtils.intercept(
|
|
|
|
+ StorageContainerException.class,
|
|
|
|
+ () -> keyValueContainer.create(volumeSet, volumeChoosingPolicy, scmId)
|
|
|
|
+ );
|
|
|
|
+ if (!DISK_OUT_OF_SPACE.equals(e.getResult())) {
|
|
|
|
+ LOG.info("Unexpected error during container creation", e);
|
|
}
|
|
}
|
|
-
|
|
|
|
- // Test failed if there was no exception
|
|
|
|
- assertEquals(true, diskSpaceException);
|
|
|
|
|
|
+ assertEquals(DISK_OUT_OF_SPACE, e.getResult());
|
|
}
|
|
}
|
|
|
|
|
|
//verify committed space on each volume
|
|
//verify committed space on each volume
|