This is an automated email from the ASF dual-hosted git repository. ctubbsii pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/accumulo.git
commit 7967fdac5296fece43072db9f505b1a6fe7f3ed0 Merge: 658346ce1a d3b910c4a0 Author: Christopher Tubbs <ctubb...@apache.org> AuthorDate: Mon Jun 12 17:20:30 2023 -0400 Merge branch '2.1' .../accumulo/server/conf/util/ZooInfoViewer.java | 62 +++---------------- .../server/conf/util/ZooInfoViewerTest.java | 61 ++----------------- .../accumulo/start/spi/KeywordExecutable.java | 5 +- .../apache/accumulo/test/start/KeywordStartIT.java | 69 ++++++++++++++++------ 4 files changed, 66 insertions(+), 131 deletions(-) diff --cc start/src/main/java/org/apache/accumulo/start/spi/KeywordExecutable.java index 42108f0bff,83015a77ab..4f67f5f3b4 --- a/start/src/main/java/org/apache/accumulo/start/spi/KeywordExecutable.java +++ b/start/src/main/java/org/apache/accumulo/start/spi/KeywordExecutable.java @@@ -34,11 -34,12 +34,12 @@@ import java.util.ServiceLoader * * <p> * One way to easily create META-INF/services files is to use the - * <a href="https://github.com/google/auto/tree/master/service">AutoService</a> annotation. + * <a href="https://github.com/google/auto/tree/main/service">AutoService</a> annotation. * * <p> - * If the implementing class also wishes to have a redundant main method, it may be useful to simply - * implement main as:<br> + * It generally should be avoided, but if the implementing class also must have a redundant main + * method, it may be useful to simply implement main as the following to ensure consistency of + * behavior when executing the main method and when executing using the keyword:<br> * {@code new MyImplementingClass().execute(args);} */ public interface KeywordExecutable { diff --cc test/src/main/java/org/apache/accumulo/test/start/KeywordStartIT.java index 4b74115a25,2887d9e846..448912999f --- a/test/src/main/java/org/apache/accumulo/test/start/KeywordStartIT.java +++ b/test/src/main/java/org/apache/accumulo/test/start/KeywordStartIT.java @@@ -120,6 -132,9 +130,7 @@@ public class KeywordStartIT expectSet.put("check-server-config", CheckServerConfig.class); expectSet.put("compaction-coordinator", CoordinatorExecutable.class); expectSet.put("compactor", CompactorExecutable.class); - expectSet.put("config-upgrade", ConfigPropertyUpgrader.class); - expectSet.put("convert-config", ConvertConfig.class); + expectSet.put("create-empty", CreateEmpty.class); expectSet.put("create-token", CreateToken.class); expectSet.put("dump-zoo", DumpZookeeper.class); expectSet.put("ec-admin", ECAdmin.class); @@@ -133,21 -148,23 +144,19 @@@ expectSet.put("minicluster", MiniClusterExecutable.class); expectSet.put("monitor", MonitorExecutable.class); expectSet.put("rfile-info", PrintInfo.class); - expectSet.put("wal-info", LogReader.class); expectSet.put("shell", Shell.class); - expectSet.put("tserver", TServerExecutable.class); - expectSet.put("version", Version.class); - expectSet.put("zookeeper", ZooKeeperMain.class); - expectSet.put("create-empty", CreateEmpty.class); expectSet.put("split-large", SplitLarge.class); expectSet.put("sserver", ScanServerExecutable.class); + expectSet.put("tserver", TServerExecutable.class); + expectSet.put("version", Version.class); + expectSet.put("wal-info", LogReader.class); expectSet.put("zoo-info-viewer", ZooInfoViewer.class); expectSet.put("zoo-zap", ZooZap.class); + expectSet.put("zookeeper", ZooKeeperMain.class); - @SuppressWarnings("deprecation") - var masterExecutableClass = org.apache.accumulo.manager.MasterExecutable.class; - expectSet.put("master", masterExecutableClass); - Iterator<Entry<String,Class<? extends KeywordExecutable>>> expectIter = expectSet.entrySet().iterator(); - TreeMap<String,KeywordExecutable> actualSet = - new TreeMap<>(Main.getExecutables(getClass().getClassLoader())); + TreeMap<String,KeywordExecutable> actualSet = new TreeMap<>(getKeywordExecutables()); Iterator<Entry<String,KeywordExecutable>> actualIter = actualSet.entrySet().iterator(); Entry<String,Class<? extends KeywordExecutable>> expected; Entry<String,KeywordExecutable> actual; @@@ -181,24 -203,50 +195,43 @@@ HashSet<Class<?>> expectSet = new HashSet<>(); expectSet.add(Admin.class); expectSet.add(CheckCompactionConfig.class); + expectSet.add(CheckServerConfig.class); - expectSet.add(ConfigPropertyUpgrader.class); - expectSet.add(ConvertConfig.class); + expectSet.add(CreateEmpty.class); expectSet.add(CreateToken.class); expectSet.add(DumpZookeeper.class); + expectSet.add(ECAdmin.class); + expectSet.add(GenerateSplits.class); expectSet.add(Info.class); expectSet.add(Initialize.class); + expectSet.add(LogReader.class); expectSet.add(LoginProperties.class); expectSet.add(MiniAccumuloRunner.class); expectSet.add(Monitor.class); expectSet.add(PrintInfo.class); - expectSet.add(LogReader.class); expectSet.add(Shell.class); expectSet.add(SimpleGarbageCollector.class); + expectSet.add(SplitLarge.class); expectSet.add(TabletServer.class); expectSet.add(ZooKeeperMain.class); + expectSet.add(ZooZap.class); - for (Class<?> c : expectSet) { - assertTrue(hasMain(c), "Class " + c.getName() + " is missing a main method!"); - } - // not a KeywordExecutable, but this is known to have a main method - @SuppressWarnings("deprecation") - var masterClass = org.apache.accumulo.master.Master.class; - expectSet.add(masterClass); - + // check that classes in the expected set contain a main + // not all have them; these do because they always have, and we don't want to break things + expectSet.forEach( + c -> assertTrue(hasMain(c), "Class " + c.getName() + " is missing a main method!")); + + // build a list of all classed that implement KeywordExecutable + var all = getKeywordExecutables().values().stream().map(Object::getClass).collect(toSet()); + + // remove the ones we already verified have a main method + assertTrue(all.removeAll(expectSet)); + + // ensure there's still some left (there should be some that don't have a main method) + assertNotEquals(0, all.size()); + // for those remaining, make sure they *don't* have an unexpected main method + all.forEach( + c -> assertFalse(hasMain(c), "Class " + c.getName() + " has an unexpected main method!")); } private static boolean hasMain(Class<?> classToCheck) {