dlmarion commented on code in PR #30: URL: https://github.com/apache/accumulo-classloaders/pull/30#discussion_r2582138450
########## modules/local-caching-classloader/src/test/java/org/apache/accumulo/classloader/lcc/MiniAccumuloClusterClassLoaderFactoryTest.java: ########## @@ -0,0 +1,284 @@ +/* + * 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.classloader.lcc; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static java.nio.file.attribute.PosixFilePermission.OWNER_EXECUTE; +import static java.nio.file.attribute.PosixFilePermission.OWNER_READ; +import static java.nio.file.attribute.PosixFilePermission.OWNER_WRITE; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertIterableEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.File; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; +import java.nio.file.StandardOpenOption; +import java.nio.file.attribute.FileAttribute; +import java.nio.file.attribute.PosixFilePermission; +import java.nio.file.attribute.PosixFilePermissions; +import java.util.Collections; +import java.util.EnumSet; +import java.util.List; +import java.util.Map.Entry; +import java.util.Set; +import java.util.TreeSet; +import java.util.stream.Collectors; + +import org.apache.accumulo.classloader.lcc.definition.ContextDefinition; +import org.apache.accumulo.core.client.Accumulo; +import org.apache.accumulo.core.client.AccumuloClient; +import org.apache.accumulo.core.client.IteratorSetting; +import org.apache.accumulo.core.client.Scanner; +import org.apache.accumulo.core.clientImpl.AccumuloServerException; +import org.apache.accumulo.core.clientImpl.ClientContext; +import org.apache.accumulo.core.conf.Property; +import org.apache.accumulo.core.data.Key; +import org.apache.accumulo.core.data.TableId; +import org.apache.accumulo.core.data.Value; +import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope; +import org.apache.accumulo.core.metadata.schema.Ample; +import org.apache.accumulo.core.metadata.schema.TabletMetadata; +import org.apache.accumulo.core.metadata.schema.TabletsMetadata; +import org.apache.accumulo.harness.MiniClusterConfigurationCallback; +import org.apache.accumulo.harness.SharedMiniClusterBase; +import org.apache.accumulo.miniclusterImpl.MiniAccumuloConfigImpl; +import org.apache.accumulo.test.TestIngest; +import org.apache.accumulo.test.TestIngest.IngestParams; +import org.apache.accumulo.test.VerifyIngest; +import org.apache.accumulo.test.VerifyIngest.VerifyParams; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +public class MiniAccumuloClusterClassLoaderFactoryTest extends SharedMiniClusterBase { + + private static class TestMACConfiguration implements MiniClusterConfigurationCallback { + + @Override + public void configureMiniCluster(MiniAccumuloConfigImpl cfg, + org.apache.hadoop.conf.Configuration coreSite) { + cfg.setNumTservers(3); + cfg.setProperty(Property.TSERV_NATIVEMAP_ENABLED.getKey(), "false"); + cfg.setProperty(Property.GENERAL_CONTEXT_CLASSLOADER_FACTORY.getKey(), + LocalCachingContextClassLoaderFactory.class.getName()); + cfg.setProperty(Constants.CACHE_DIR_PROPERTY, tempDir.resolve("base").toUri().toString()); + cfg.setProperty(Constants.UPDATE_FAILURE_GRACE_PERIOD_MINS, "1"); + } + } + + @TempDir + private static java.nio.file.Path tempDir; + + private static final Set<PosixFilePermission> CACHE_DIR_PERMS = + EnumSet.of(OWNER_READ, OWNER_WRITE, OWNER_EXECUTE); + private static final FileAttribute<Set<PosixFilePermission>> PERMISSIONS = + PosixFilePermissions.asFileAttribute(CACHE_DIR_PERMS); + private static final String ITER_CLASS_NAME = + "org.apache.accumulo.classloader.vfs.examples.ExampleIterator"; + private static final int MONITOR_INTERVAL_SECS = + LocalCachingContextClassLoaderFactoryTest.MONITOR_INTERVAL_SECS; + + private static URL jarAOrigLocation; + private static URL jarBOrigLocation; + + @BeforeAll + public static void beforeAll() throws Exception { + + // Find the Test jar files + jarAOrigLocation = MiniAccumuloClusterClassLoaderFactoryTest.class + .getResource("/ExampleIteratorsA/example-iterators-a.jar"); + assertNotNull(jarAOrigLocation); + jarBOrigLocation = MiniAccumuloClusterClassLoaderFactoryTest.class + .getResource("/ExampleIteratorsB/example-iterators-b.jar"); + assertNotNull(jarBOrigLocation); + + startMiniClusterWithConfig(new TestMACConfiguration()); + } + + @AfterAll + public static void afterAll() throws Exception { + stopMiniCluster(); + } + + @Test + public void testClassLoader() throws Exception { Review Comment: I think I have that covered pretty well in the other tests. -- 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]
