bilaharith commented on a change in pull request #2549: URL: https://github.com/apache/hadoop/pull/2549#discussion_r554932129
########## File path: hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/services/TestGetContentSummary.java ########## @@ -0,0 +1,204 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.fs.azurebfs.services; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.SynchronousQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +import org.assertj.core.api.Assertions; +import org.junit.Test; + +import org.apache.hadoop.fs.ContentSummary; +import org.apache.hadoop.fs.FSDataOutputStream; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.fs.azurebfs.AbstractAbfsIntegrationTest; +import org.apache.hadoop.fs.azurebfs.AzureBlobFileSystem; + +import static org.apache.hadoop.fs.azurebfs.constants.FileSystemConfigurations.DEFAULT_AZURE_LIST_MAX_RESULTS; +import static org.apache.hadoop.test.LambdaTestUtils.intercept; + +public class TestGetContentSummary extends AbstractAbfsIntegrationTest { + + private final String[] directories = {"/testFolder", + "/testFolder/testFolder1", + "/testFolder/testFolder2", "/testFolder/testFolder3", "/testFolderII", + "/testFolder/testFolder2/testFolder4", + "/testFolder/testFolder2/testFolder5", + "/testFolder/testFolder3/testFolder6", + "/testFolder/testFolder3/testFolder7", + "/testFolder/testFolder3/testFolder6/leafDir", + "/testFolderII/listMaxDir", + "/testFolderII/listMaxDir/" + DEFAULT_AZURE_LIST_MAX_RESULTS/2 + "_mid_folder"}; + + private final Path pathToFile = new Path("/testFolder/test1"); + private final Path pathToListMaxDir = new Path("/testFolderII/listMaxDir"); + private final Path pathToLeafDir = + new Path("/testFolder/testFolder3/testFolder6/leafDir"); + private final Path pathToIntermediateDirWithFilesOnly = new Path( + "/testFolder/testFolder2/testFolder5"); + private final Path pathToIntermediateDirWithFilesAndSubdirs = new Path( + "/testFolder/testFolder3"); + private final String[] dirsWithNonEmptyFiles = {"/testFolder", "/testFolder/testFolder1", + "/testFolder/testFolder2/testFolder5", "/testFolder/testFolder3"}; + + private final AzureBlobFileSystem fs = createFileSystem(); + private final int testBufferSize = 20; + private final int filesPerDirectory = 2; + private final int numFilesForListMaxTest = DEFAULT_AZURE_LIST_MAX_RESULTS + 10; + private final byte[] b = new byte[testBufferSize]; + private final int maxThreads = 16; + + public TestGetContentSummary() throws Exception { + createDirectoryStructure(); + new Random().nextBytes(b); + } + + @Test + public void testFilesystemRoot() + throws IOException { + int fileCount = + (directories.length - 2) * filesPerDirectory + numFilesForListMaxTest; + ContentSummary contentSummary = fs.getContentSummary(new Path("/")); + checkContentSummary(contentSummary, directories.length, fileCount, Review comment: nit: verifyContentSummary() ? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
