HDDS-926. Use Timeout rule for the the test methods in TestOzoneManager. Contributed by Dinesh Chitlangia.

This commit is contained in:
Bharat Viswanadham 2019-01-07 22:04:06 -08:00
parent 7f78397036
commit 4297e20c8b
1 changed files with 15 additions and 12 deletions

View File

@ -70,7 +70,7 @@
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.ExpectedException; import org.junit.rules.ExpectedException;
import org.junit.rules.Timeout;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -110,6 +110,9 @@ public class TestOzoneManager {
@Rule @Rule
public ExpectedException exception = ExpectedException.none(); public ExpectedException exception = ExpectedException.none();
@Rule
public Timeout timeout = new Timeout(60000);
/** /**
* Create a MiniDFSCluster for testing. * Create a MiniDFSCluster for testing.
* <p> * <p>
@ -148,7 +151,7 @@ public void shutdown() {
} }
// Create a volume and test its attribute after creating them // Create a volume and test its attribute after creating them
@Test(timeout = 60000) @Test
public void testCreateVolume() throws IOException, OzoneException { public void testCreateVolume() throws IOException, OzoneException {
long volumeCreateFailCount = omMetrics.getNumVolumeCreateFails(); long volumeCreateFailCount = omMetrics.getNumVolumeCreateFails();
String userName = "user" + RandomStringUtils.randomNumeric(5); String userName = "user" + RandomStringUtils.randomNumeric(5);
@ -169,7 +172,7 @@ public void testCreateVolume() throws IOException, OzoneException {
} }
// Create a volume and modify the volume owner and then test its attributes // Create a volume and modify the volume owner and then test its attributes
@Test(timeout = 60000) @Test
public void testChangeVolumeOwner() throws IOException, OzoneException { public void testChangeVolumeOwner() throws IOException, OzoneException {
long volumeCreateFailCount = omMetrics.getNumVolumeCreateFails(); long volumeCreateFailCount = omMetrics.getNumVolumeCreateFails();
long volumeInfoFailCount = omMetrics.getNumVolumeInfoFails(); long volumeInfoFailCount = omMetrics.getNumVolumeInfoFails();
@ -199,7 +202,7 @@ public void testChangeVolumeOwner() throws IOException, OzoneException {
} }
// Create a volume and modify the volume owner and then test its attributes // Create a volume and modify the volume owner and then test its attributes
@Test(timeout = 60000) @Test
public void testChangeVolumeQuota() throws IOException, OzoneException { public void testChangeVolumeQuota() throws IOException, OzoneException {
long numVolumeCreateFail = omMetrics.getNumVolumeCreateFails(); long numVolumeCreateFail = omMetrics.getNumVolumeCreateFails();
long numVolumeInfoFail = omMetrics.getNumVolumeInfoFails(); long numVolumeInfoFail = omMetrics.getNumVolumeInfoFails();
@ -245,7 +248,7 @@ public void testChangeVolumeQuota() throws IOException, OzoneException {
} }
// Create a volume and then delete it and then check for deletion // Create a volume and then delete it and then check for deletion
@Test(timeout = 60000) @Test
public void testDeleteVolume() throws IOException, OzoneException { public void testDeleteVolume() throws IOException, OzoneException {
long volumeCreateFailCount = omMetrics.getNumVolumeCreateFails(); long volumeCreateFailCount = omMetrics.getNumVolumeCreateFails();
String userName = "user" + RandomStringUtils.randomNumeric(5); String userName = "user" + RandomStringUtils.randomNumeric(5);
@ -309,7 +312,7 @@ public void testDeleteVolume() throws IOException, OzoneException {
// Create a volume and a bucket inside the volume, // Create a volume and a bucket inside the volume,
// then delete it and then check for deletion failure // then delete it and then check for deletion failure
@Test(timeout = 60000) @Test
public void testFailedDeleteVolume() throws IOException, OzoneException { public void testFailedDeleteVolume() throws IOException, OzoneException {
long numVolumeCreateFails = omMetrics.getNumVolumeCreateFails(); long numVolumeCreateFails = omMetrics.getNumVolumeCreateFails();
String userName = "user" + RandomStringUtils.randomNumeric(5); String userName = "user" + RandomStringUtils.randomNumeric(5);
@ -346,7 +349,7 @@ public void testFailedDeleteVolume() throws IOException, OzoneException {
} }
// Create a volume and test Volume access for a different user // Create a volume and test Volume access for a different user
@Test(timeout = 60000) @Test
public void testAccessVolume() throws IOException, OzoneException { public void testAccessVolume() throws IOException, OzoneException {
String userName = "user" + RandomStringUtils.randomNumeric(5); String userName = "user" + RandomStringUtils.randomNumeric(5);
String adminName = "admin" + RandomStringUtils.randomNumeric(5); String adminName = "admin" + RandomStringUtils.randomNumeric(5);
@ -390,7 +393,7 @@ public void testAccessVolume() throws IOException, OzoneException {
Assert.assertEquals(0, omMetrics.getNumVolumeCreateFails()); Assert.assertEquals(0, omMetrics.getNumVolumeCreateFails());
} }
@Test(timeout = 60000) @Test
public void testCreateBucket() throws IOException, OzoneException { public void testCreateBucket() throws IOException, OzoneException {
long numVolumeCreateFail = omMetrics.getNumVolumeCreateFails(); long numVolumeCreateFail = omMetrics.getNumVolumeCreateFails();
long numBucketCreateFail = omMetrics.getNumBucketCreateFails(); long numBucketCreateFail = omMetrics.getNumBucketCreateFails();
@ -421,7 +424,7 @@ public void testCreateBucket() throws IOException, OzoneException {
omMetrics.getNumBucketInfoFails()); omMetrics.getNumBucketInfoFails());
} }
@Test(timeout = 60000) @Test
public void testDeleteBucket() throws IOException, OzoneException { public void testDeleteBucket() throws IOException, OzoneException {
String userName = "user" + RandomStringUtils.randomNumeric(5); String userName = "user" + RandomStringUtils.randomNumeric(5);
String adminName = "admin" + RandomStringUtils.randomNumeric(5); String adminName = "admin" + RandomStringUtils.randomNumeric(5);
@ -444,7 +447,7 @@ public void testDeleteBucket() throws IOException, OzoneException {
storageHandler.getBucketInfo(getBucketArgs); storageHandler.getBucketInfo(getBucketArgs);
} }
@Test(timeout = 60000) @Test
public void testDeleteNonExistingBucket() throws IOException, OzoneException { public void testDeleteNonExistingBucket() throws IOException, OzoneException {
String userName = "user" + RandomStringUtils.randomNumeric(5); String userName = "user" + RandomStringUtils.randomNumeric(5);
String adminName = "admin" + RandomStringUtils.randomNumeric(5); String adminName = "admin" + RandomStringUtils.randomNumeric(5);
@ -469,7 +472,7 @@ public void testDeleteNonExistingBucket() throws IOException, OzoneException {
} }
@Test(timeout = 60000) @Test
public void testDeleteNonEmptyBucket() throws IOException, OzoneException { public void testDeleteNonEmptyBucket() throws IOException, OzoneException {
String userName = "user" + RandomStringUtils.randomNumeric(5); String userName = "user" + RandomStringUtils.randomNumeric(5);
String adminName = "admin" + RandomStringUtils.randomNumeric(5); String adminName = "admin" + RandomStringUtils.randomNumeric(5);
@ -791,7 +794,7 @@ public void testRenameKey() throws IOException, OzoneException {
omMetrics.getNumKeyRenameFails()); omMetrics.getNumKeyRenameFails());
} }
@Test(timeout = 60000) @Test
public void testListBuckets() throws IOException, OzoneException { public void testListBuckets() throws IOException, OzoneException {
ListBuckets result = null; ListBuckets result = null;
ListArgs listBucketArgs = null; ListArgs listBucketArgs = null;