swagle commented on a change in pull request #1146: HDDS-1366. Add ability in Recon to track the number of small files in an Ozone Cluster URL: https://github.com/apache/hadoop/pull/1146#discussion_r306559214
########## File path: hadoop-ozone/ozone-recon/src/test/java/org/apache/hadoop/ozone/recon/tasks/TestFileSizeCountTask.java ########## @@ -0,0 +1,311 @@ +/** + * 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.ozone.recon.tasks; + +import com.google.inject.Injector; +import org.apache.hadoop.hdds.client.BlockID; +import org.apache.hadoop.hdds.conf.OzoneConfiguration; +import org.apache.hadoop.hdds.protocol.proto.HddsProtos; +import org.apache.hadoop.hdds.scm.pipeline.Pipeline; +import org.apache.hadoop.ozone.om.OMMetadataManager; +import org.apache.hadoop.ozone.om.helpers.OmKeyInfo; +import org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo; +import org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfoGroup; +import org.apache.hadoop.ozone.recon.AbstractOMMetadataManagerTest; +import org.apache.hadoop.ozone.recon.GuiceInjectorUtilsForTestsImpl; +import org.apache.hadoop.ozone.recon.ReconUtils; +import org.apache.hadoop.ozone.recon.recovery.ReconOMMetadataManager; +import org.apache.hadoop.ozone.recon.spi.impl.OzoneManagerServiceProviderImpl; +import org.apache.hadoop.utils.db.Table; +import org.hadoop.ozone.recon.schema.UtilizationSchemaDefinition; +import org.hadoop.ozone.recon.schema.tables.daos.FileCountBySizeDao; +import org.hadoop.ozone.recon.schema.tables.pojos.FileCountBySize; +import org.jooq.Configuration; +import org.jooq.impl.DSL; +import org.jooq.impl.DefaultConfiguration; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; +import org.junit.runner.RunWith; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import javax.sql.DataSource; +import java.io.IOException; +import java.util.*; + +import static org.junit.Assert.*; + +/** + * Unit test for Container Key mapper task. + */ +@RunWith(PowerMockRunner.class) +@PowerMockIgnore({"javax.management.*", "javax.net.ssl.*"}) +@PrepareForTest(ReconUtils.class) +public class TestFileSizeCountTask extends AbstractOMMetadataManagerTest { + private OMMetadataManager omMetadataManager; + private ReconOMMetadataManager reconOMMetadataManager; + private Injector injector; + private OzoneManagerServiceProviderImpl ozoneManagerServiceProvider; + private boolean setUpIsDone = false; + private GuiceInjectorUtilsForTestsImpl guiceInjectorTest = + new GuiceInjectorUtilsForTestsImpl(); + + private Injector getInjector() { + return injector; + } + private Configuration sqlConfiguration; + + @Rule + TemporaryFolder temporaryFolder = new TemporaryFolder(); + + private void initializeInjector() throws Exception { + omMetadataManager = initializeNewOmMetadataManager(); + OzoneConfiguration configuration = + guiceInjectorTest.getTestOzoneConfiguration(temporaryFolder); + + ozoneManagerServiceProvider = new OzoneManagerServiceProviderImpl( + configuration); + reconOMMetadataManager = getTestMetadataManager(omMetadataManager); + + injector = guiceInjectorTest.getInjector( + ozoneManagerServiceProvider, reconOMMetadataManager, temporaryFolder); + } + + @Before + public void setUp() throws Exception { + // The following setup is run only once + if (!setUpIsDone) { + initializeInjector(); + + DSL.using(new DefaultConfiguration().set( + injector.getInstance(DataSource.class))); + + UtilizationSchemaDefinition utilizationSchemaDefinition = getInjector().getInstance( + UtilizationSchemaDefinition.class); + utilizationSchemaDefinition.initializeSchema(); + + sqlConfiguration = getInjector().getInstance(Configuration.class); + setUpIsDone = true; + } + } + + @Test + public void testFileCountBySizeReprocess() throws IOException { Review comment: Looks like repeated code, we are doing all this in the service test above, one of these could be completely mock based. ---------------------------------------------------------------- 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] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
