cshannon commented on code in PR #3112: URL: https://github.com/apache/accumulo/pull/3112#discussion_r1064011889
########## test/src/main/java/org/apache/accumulo/test/compaction/UserCompactionStrategyIT.java: ########## @@ -1,334 +0,0 @@ -/* - * 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 - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * 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.accumulo.test.compaction; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; -import static org.junit.jupiter.api.Assumptions.assumeTrue; - -import java.io.File; -import java.time.Duration; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - -import org.apache.accumulo.core.client.Accumulo; -import org.apache.accumulo.core.client.AccumuloClient; -import org.apache.accumulo.core.client.AccumuloException; -import org.apache.accumulo.core.client.BatchWriter; -import org.apache.accumulo.core.client.IteratorSetting; -import org.apache.accumulo.core.client.Scanner; -import org.apache.accumulo.core.client.TableNotFoundException; -import org.apache.accumulo.core.client.admin.CompactionConfig; -import org.apache.accumulo.core.client.admin.CompactionStrategyConfig; -import org.apache.accumulo.core.client.admin.NewTableConfiguration; -import org.apache.accumulo.core.conf.Property; -import org.apache.accumulo.core.data.Key; -import org.apache.accumulo.core.data.Mutation; -import org.apache.accumulo.core.data.Value; -import org.apache.accumulo.core.iterators.user.RegExFilter; -import org.apache.accumulo.core.security.Authorizations; -import org.apache.accumulo.harness.AccumuloClusterHarness; -import org.apache.accumulo.test.functional.FunctionalTestUtils; -import org.apache.accumulo.test.functional.SlowIterator; -import org.apache.hadoop.io.Text; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Test; - -@SuppressWarnings("removal") -public class UserCompactionStrategyIT extends AccumuloClusterHarness { - - @Override - protected Duration defaultTimeout() { - return Duration.ofMinutes(3); - } - - @AfterEach - public void checkForDanglingFateLocks() { - if (getClusterType() == ClusterType.MINI) { - FunctionalTestUtils.assertNoDanglingFateLocks(getCluster()); - } - } - - @Test - public void testDropA() throws Exception { - try (AccumuloClient c = Accumulo.newClient().from(getClientProps()).build()) { - - String tableName = getUniqueNames(1)[0]; - c.tableOperations().create(tableName); - - writeFlush(c, tableName, "a"); - writeFlush(c, tableName, "b"); - // create a file that starts with A containing rows 'a' and 'b' - c.tableOperations().compact(tableName, new CompactionConfig().setWait(true)); - - writeFlush(c, tableName, "c"); - writeFlush(c, tableName, "d"); - - // drop files that start with A - CompactionStrategyConfig csConfig = - new CompactionStrategyConfig(TestCompactionStrategy.class.getName()); - csConfig.setOptions(Map.of("dropPrefix", "A", "inputPrefix", "F")); - c.tableOperations().compact(tableName, - new CompactionConfig().setWait(true).setCompactionStrategy(csConfig)); - - assertEquals(Set.of("c", "d"), getRows(c, tableName)); - - // this compaction should not drop files starting with A - c.tableOperations().compact(tableName, new CompactionConfig().setWait(true)); - c.tableOperations().compact(tableName, new CompactionConfig().setWait(true)); - - assertEquals(Set.of("c", "d"), getRows(c, tableName)); - } - } - - private void testDropNone(Map<String,String> options) throws Exception { - - try (AccumuloClient c = Accumulo.newClient().from(getClientProps()).build()) { - - String tableName = getUniqueNames(1)[0]; - c.tableOperations().create(tableName); - - writeFlush(c, tableName, "a"); - writeFlush(c, tableName, "b"); - - CompactionStrategyConfig csConfig = - new CompactionStrategyConfig(TestCompactionStrategy.class.getName()); - csConfig.setOptions(options); - c.tableOperations().compact(tableName, - new CompactionConfig().setWait(true).setCompactionStrategy(csConfig)); - - assertEquals(Set.of("a", "b"), getRows(c, tableName)); - } - } - - @Test - public void testDropNone() throws Exception { - // test a compaction strategy that selects no files. In this case there is no work to do, want - // to ensure it does not hang. - - testDropNone(Map.of("inputPrefix", "Z")); Review Comment: I adapted the test from UserCompactionStrategyIT and I added it to CompactionIT called [testSelectNoFiles() ](https://github.com/apache/accumulo/pull/3112/files#diff-677d3e61e8878b63f21837e5ee5f9c0e4422cb12f8f682086a7a0dba305c1bb6R565) -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
