Skip to content

Commit

Permalink
fixes 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Sadanand Shenoy committed Oct 7, 2024
1 parent 3464e06 commit a39d08e
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1831,12 +1831,14 @@ public void testLoopInLinkBuckets() throws Exception {
String rootPath = String.format("%s://%s.%s/",
OzoneConsts.OZONE_URI_SCHEME, linkBucket1Name, linksVolume);

try {
FileSystem.get(URI.create(rootPath), cluster.getConf());
fail("Should throw Exception due to loop in Link Buckets");
try (FileSystem fileSystem = FileSystem.get(URI.create(rootPath),
cluster.getConf())) {
fail("Should throw Exception due to loop in Link Buckets" +
" while initialising fs with URI " + fileSystem.getUri());
} catch (OMException oe) {
// Expected exception
assertEquals(OMException.ResultCodes.DETECTED_LOOP_IN_BUCKET_LINKS, oe.getResult());
assertEquals(OMException.ResultCodes.DETECTED_LOOP_IN_BUCKET_LINKS,
oe.getResult());
} finally {
volume.deleteBucket(linkBucket1Name);
volume.deleteBucket(linkBucket2Name);
Expand Down Expand Up @@ -2230,7 +2232,17 @@ void testFileSystemWithObjectStoreLayout() throws IOException {
OzoneConfiguration config = new OzoneConfiguration(fs.getConf());
config.set(FS_DEFAULT_NAME_KEY, obsRootPath);

IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> FileSystem.get(config));
IllegalArgumentException e =
assertThrows(IllegalArgumentException.class, () -> {
FileSystem fileSystem = null;
try {
fileSystem = FileSystem.get(config);
} finally {
if (fileSystem != null) {
fileSystem.close();
}
}
});
assertThat(e.getMessage()).contains("OBJECT_STORE, which does not support file system semantics");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,17 @@ public static void listStatusIteratorOnPageSize(OzoneConfiguration conf,
URI uri = FileSystem.getDefaultUri(config);
config.setBoolean(
String.format("fs.%s.impl.disable.cache", uri.getScheme()), true);
FileSystem subject = FileSystem.get(uri, config);
Path dir = new Path(Objects.requireNonNull(rootPath), "listStatusIterator");
try {
Set<String> paths = new TreeSet<>();
for (int dirCount : dirCounts) {
listStatusIterator(subject, dir, paths, dirCount);
try (FileSystem subject = FileSystem.get(uri, config)) {
Path dir = new Path(Objects.requireNonNull(rootPath),
"listStatusIterator");
try {
Set<String> paths = new TreeSet<>();
for (int dirCount : dirCounts) {
listStatusIterator(subject, dir, paths, dirCount);
}
} finally {
subject.delete(dir, true);
}
} finally {
subject.delete(dir, true);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.TreeMap;
import java.util.UUID;
import java.util.concurrent.CountDownLatch;
Expand Down Expand Up @@ -221,6 +223,7 @@ abstract class OzoneRpcClientTests extends OzoneTestBase {
private static OzoneAcl inheritedGroupAcl = new OzoneAcl(GROUP,
remoteGroupName, ACCESS, READ);
private static MessageDigest eTagProvider;
private static Set<OzoneClient> ozoneClients = new HashSet<>();

@BeforeAll
public static void initialize() throws NoSuchAlgorithmException {
Expand Down Expand Up @@ -250,6 +253,7 @@ static void startCluster(OzoneConfiguration conf, MiniOzoneCluster.Builder build
.build();
cluster.waitForClusterToBeReady();
ozClient = OzoneClientFactory.getRpcClient(conf);
ozoneClients.add(ozClient);
store = ozClient.getObjectStore();
storageContainerLocationClient =
cluster.getStorageContainerLocationClient();
Expand All @@ -260,9 +264,12 @@ static void startCluster(OzoneConfiguration conf, MiniOzoneCluster.Builder build
* Close OzoneClient and shutdown MiniOzoneCluster.
*/
static void shutdownCluster() throws IOException {
if (ozClient != null) {
ozClient.close();
for (OzoneClient ozoneClient : ozoneClients) {
if (ozoneClient != null) {
ozoneClient.close();
}
}
ozoneClients.clear();

if (storageContainerLocationClient != null) {
storageContainerLocationClient.close();
Expand All @@ -274,6 +281,7 @@ static void shutdownCluster() throws IOException {
}

private static void setOzClient(OzoneClient ozClient) {
ozoneClients.add(ozClient);
OzoneRpcClientTests.ozClient = ozClient;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ public static void setUp() throws Exception {

@AfterAll
public static void cleanup() throws Exception {
writeClient.close();
scm.stop();
scm.join();
om.stop();
Expand All @@ -252,10 +253,11 @@ public void init() throws Exception {
public void cleanupTest() throws IOException {
mockContainerClient();
org.apache.hadoop.fs.Path volumePath = new org.apache.hadoop.fs.Path(OZONE_URI_DELIMITER, VOLUME_NAME);
FileSystem fs = FileSystem.get(conf);
fs.delete(new org.apache.hadoop.fs.Path(volumePath, BUCKET_NAME), true);
fs.delete(new org.apache.hadoop.fs.Path(volumePath, BUCKET2_NAME), true);
fs.delete(new org.apache.hadoop.fs.Path(volumePath, VERSIONED_BUCKET_NAME), true);
try (FileSystem fs = FileSystem.get(conf)) {
fs.delete(new org.apache.hadoop.fs.Path(volumePath, BUCKET_NAME), true);
fs.delete(new org.apache.hadoop.fs.Path(volumePath, BUCKET2_NAME), true);
fs.delete(new org.apache.hadoop.fs.Path(volumePath, VERSIONED_BUCKET_NAME), true);
}
}

private static void mockContainerClient() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
import org.apache.hadoop.ozone.om.helpers.OmBucketInfo;
import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs;
import org.apache.hadoop.ozone.om.helpers.ServiceInfoEx;
import org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol;
import org.apache.hadoop.ozone.om.request.OMRequestTestUtils;
import org.apache.ozone.test.GenericTestUtils;
import org.apache.ratis.thirdparty.com.google.protobuf.ByteString;
Expand Down Expand Up @@ -162,7 +163,7 @@ public class TestOmContainerLocationCache {
private static final DatanodeDetails DN5 =
MockDatanodeDetails.createDatanodeDetails(UUID.randomUUID());
private static final AtomicLong CONTAINER_ID = new AtomicLong(1);

private static OzoneManagerProtocol writeClient;

@BeforeAll
public static void setUp() throws Exception {
Expand All @@ -184,6 +185,7 @@ public static void setUp() throws Exception {
OmTestManagers omTestManagers = new OmTestManagers(conf,
mockScmBlockLocationProtocol, mockScmContainerClient);
om = omTestManagers.getOzoneManager();
writeClient = omTestManagers.getWriteClient();
metadataManager = omTestManagers.getMetadataManager();

rpcClient = new RpcClient(conf, null) {
Expand All @@ -204,6 +206,7 @@ protected XceiverClientFactory createXceiverClientFactory(

@AfterAll
public static void cleanup() throws Exception {
writeClient.close();
om.stop();
FileUtils.deleteDirectory(dir);
}
Expand Down

0 comments on commit a39d08e

Please sign in to comment.