Repository: incubator-rya Updated Branches: refs/heads/master 2e02f22ef -> b71e892ac
RYA-489 Moved common Accumulo integration test code to the rya.test.accumulo project. Closes #292 Project: http://git-wip-us.apache.org/repos/asf/incubator-rya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-rya/commit/b71e892a Tree: http://git-wip-us.apache.org/repos/asf/incubator-rya/tree/b71e892a Diff: http://git-wip-us.apache.org/repos/asf/incubator-rya/diff/b71e892a Branch: refs/heads/master Commit: b71e892ac3d02dff37a3adc8caf0c5677289a1d3 Parents: 2e02f22 Author: kchilton2 <kevin.e.chil...@gmail.com> Authored: Thu Apr 19 15:18:38 2018 -0400 Committer: Valiyil <puja.vali...@parsons.com> Committed: Tue May 1 11:49:46 2018 -0400 ---------------------------------------------------------------------- dao/accumulo.rya/pom.xml | 26 +--- .../org/apache/rya/accumulo/AccumuloITBase.java | 98 --------------- .../apache/rya/accumulo/AccumuloRyaITBase.java | 46 ------- .../accumulo/MiniAccumuloClusterInstance.java | 119 ------------------- .../rya/accumulo/MiniAccumuloSingleton.java | 84 ------------- .../rya/accumulo/RyaTestInstanceRule.java | 93 --------------- .../AccumuloRyaDetailsRepositoryIT.java | 4 +- extras/indexing/pom.xml | 11 +- .../api/client/accumulo/AccumuloAddUserIT.java | 2 +- .../accumulo/AccumuloBatchUpdatePCJIT.java | 2 +- .../accumulo/AccumuloGetInstanceDetailsIT.java | 2 +- .../api/client/accumulo/AccumuloInstallIT.java | 2 +- .../accumulo/AccumuloInstanceExistsIT.java | 3 +- .../accumulo/AccumuloListInstancesIT.java | 2 +- .../accumulo/AccumuloLoadStatementsFileIT.java | 2 +- .../client/accumulo/AccumuloRemoveUserIT.java | 2 +- .../AccumuloSetRyaStreamsConfigurationIT.java | 2 +- .../client/accumulo/AccumuloUninstallIT.java | 2 +- .../rya/api/client/accumulo/FluoITBase.java | 8 +- extras/rya.indexing.pcj/pom.xml | 12 +- .../pcj/storage/accumulo/PcjTablesIT.java | 10 +- .../integration/AccumuloPcjStorageIT.java | 70 ++++++++--- .../AccumuloPeriodicQueryResultStorageIT.java | 2 +- extras/rya.pcj.fluo/pcj.fluo.test.base/pom.xml | 12 +- .../rya/pcj/fluo/test/base/FluoITBase.java | 8 +- extras/shell/pom.xml | 10 +- .../rya/shell/RyaShellAccumuloITBase.java | 8 +- .../rya/shell/util/ConnectorFactoryIT.java | 3 +- pom.xml | 5 + test/accumulo/pom.xml | 55 +++++++++ .../rya/test/accumulo/AccumuloITBase.java | 97 +++++++++++++++ .../accumulo/MiniAccumuloClusterInstance.java | 119 +++++++++++++++++++ .../test/accumulo/MiniAccumuloSingleton.java | 83 +++++++++++++ .../rya/test/accumulo/RyaTestInstanceRule.java | 92 ++++++++++++++ test/pom.xml | 1 + 35 files changed, 554 insertions(+), 543 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/dao/accumulo.rya/pom.xml ---------------------------------------------------------------------- diff --git a/dao/accumulo.rya/pom.xml b/dao/accumulo.rya/pom.xml index 03f4dc7..19e01d5 100644 --- a/dao/accumulo.rya/pom.xml +++ b/dao/accumulo.rya/pom.xml @@ -61,7 +61,8 @@ under the License. <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> - </dependency> + </dependency> + <!-- testing dependencies --> <dependency> <groupId>org.eclipse.rdf4j</groupId> @@ -80,29 +81,13 @@ under the License. <scope>test</scope> </dependency> <dependency> - <groupId>org.apache.accumulo</groupId> - <artifactId>accumulo-minicluster</artifactId> + <groupId>org.apache.rya</groupId> + <artifactId>rya.test.accumulo</artifactId> <scope>test</scope> </dependency> </dependencies> <build> - <plugins> - <plugin> - <!-- generate the test jar as well so it can be reused by dependent tools. - TODO this is messy. in the future, classes that provide this functionality - should be decoupled into reusable frameworks. --> - <artifactId>maven-jar-plugin</artifactId> - <executions> - <execution> - <goals> - <goal>test-jar</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - <pluginManagement> <plugins> <plugin> @@ -133,10 +118,9 @@ under the License. </configuration> </execution> </executions> - </plugin> </plugins> </build> </profile> </profiles> -</project> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/AccumuloITBase.java ---------------------------------------------------------------------- diff --git a/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/AccumuloITBase.java b/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/AccumuloITBase.java deleted file mode 100644 index 6d66090..0000000 --- a/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/AccumuloITBase.java +++ /dev/null @@ -1,98 +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 - * - * http://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.rya.accumulo; - -import org.apache.accumulo.core.client.AccumuloException; -import org.apache.accumulo.core.client.AccumuloSecurityException; -import org.apache.accumulo.core.client.Connector; -import org.apache.accumulo.minicluster.MiniAccumuloCluster; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.apache.zookeeper.ClientCnxn; -import org.junit.BeforeClass; -import org.junit.Rule; - -/** - * Boilerplate code for a unit test that uses a {@link MiniAccumuloCluster}. - * <p> - * It uses the same instance of {@link MiniAccumuloCluster} and just clears out - * any tables that were added between tests. - */ -public class AccumuloITBase { - - private static MiniAccumuloClusterInstance cluster = MiniAccumuloSingleton.getInstance(); - - @Rule - public RyaTestInstanceRule testInstance = new RyaTestInstanceRule(false); - - - @BeforeClass - public static void killLoudLogs() { - Logger.getLogger(ClientCnxn.class).setLevel(Level.ERROR); - } - - /** - * @return The {@link MiniAccumuloClusterInstance} used by the tests. - */ - public MiniAccumuloClusterInstance getClusterInstance() { - return cluster; - } - - /** - * @return The root username. - */ - public String getUsername() { - return cluster.getUsername(); - } - - /** - * @return The root password. - */ - public String getPassword() { - return cluster.getPassword(); - } - - /** - * @return The MiniAccumulo's zookeeper instance name. - */ - public String getInstanceName() { - return cluster.getInstanceName(); - } - - /** - * @return The MiniAccumulo's zookeepers. - */ - public String getZookeepers() { - return cluster.getZookeepers(); - } - - /** - * @return A {@link Connector} that creates connections to the mini accumulo cluster. - * @throws AccumuloException Could not connect to the cluster. - * @throws AccumuloSecurityException Could not connect to the cluster because of a security violation. - */ - public Connector getConnector() throws AccumuloException, AccumuloSecurityException { - return cluster.getConnector(); - } - - public String getRyaInstanceName() { - return testInstance.getRyaInstanceName(); - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/AccumuloRyaITBase.java ---------------------------------------------------------------------- diff --git a/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/AccumuloRyaITBase.java b/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/AccumuloRyaITBase.java deleted file mode 100644 index 41d5cea..0000000 --- a/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/AccumuloRyaITBase.java +++ /dev/null @@ -1,46 +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 - * - * http://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.rya.accumulo; - -import org.junit.Rule; - -/** - * Contains boilerplate code for spinning up a Mini Accumulo Cluster and initializing - * some of the Rya stuff. We can not actually initialize an instance of Rya here - * because Sail is not available to us. - */ -public class AccumuloRyaITBase { - - @Rule - public RyaTestInstanceRule testInstance = new RyaTestInstanceRule(true); - - /** - * @return The {@link MiniAccumuloClusterInstance} used by the tests. - */ - public MiniAccumuloClusterInstance getClusterInstance() { - return MiniAccumuloSingleton.getInstance(); - } - - /** - * @return The name of the Rya instance that is being used for the current test. - */ - public String getRyaInstanceName() { - return testInstance.getRyaInstanceName(); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/MiniAccumuloClusterInstance.java ---------------------------------------------------------------------- diff --git a/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/MiniAccumuloClusterInstance.java b/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/MiniAccumuloClusterInstance.java deleted file mode 100644 index 75ab792..0000000 --- a/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/MiniAccumuloClusterInstance.java +++ /dev/null @@ -1,119 +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 - * - * http://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.rya.accumulo; - -import java.io.File; -import java.io.IOException; - -import org.apache.accumulo.core.client.AccumuloException; -import org.apache.accumulo.core.client.AccumuloSecurityException; -import org.apache.accumulo.core.client.Connector; -import org.apache.accumulo.minicluster.MiniAccumuloCluster; -import org.apache.accumulo.minicluster.MiniAccumuloConfig; -import org.apache.log4j.Logger; - -import com.google.common.io.Files; - -/** - * Contains boilerplate code that can be used by an integration test that - * uses a {@link MiniAccumuloCluster}. - * <p> - * You can just extend {@link AccumuloITBase} if your test only requires Accumulo. - */ -public class MiniAccumuloClusterInstance { - - private static final Logger log = Logger.getLogger(MiniAccumuloClusterInstance.class); - - private static final String USERNAME = "root"; - private static final String PASSWORD = "password"; - - /** - * A mini Accumulo cluster that can be used by the tests. - */ - private static MiniAccumuloCluster cluster = null; - - /** - * Start the {@link MiniAccumuloCluster}. - */ - public void startMiniAccumulo() throws IOException, InterruptedException, AccumuloException, AccumuloSecurityException { - final File miniDataDir = Files.createTempDir(); - - // Setup and start the Mini Accumulo. - final MiniAccumuloConfig cfg = new MiniAccumuloConfig(miniDataDir, PASSWORD); - cluster = new MiniAccumuloCluster(cfg); - cluster.start(); - } - - /** - * Stop the {@link MiniAccumuloCluster}. - */ - public void stopMiniAccumulo() throws IOException, InterruptedException { - if(cluster != null) { - try { - log.info("Shutting down the Mini Accumulo being used as a Rya store."); - cluster.stop(); - log.info("Mini Accumulo being used as a Rya store shut down."); - } catch(final Exception e) { - log.error("Could not shut down the Mini Accumulo.", e); - } - } - } - - /** - * @return The {@link MiniAccumuloCluster} managed by this class. - */ - public MiniAccumuloCluster getCluster() { - return cluster; - } - - /** - * @return An Accumulo connector that is connected to the mini cluster's root account. - */ - public Connector getConnector() throws AccumuloException, AccumuloSecurityException { - return cluster.getConnector(USERNAME, PASSWORD); - } - - /** - * @return The root username. - */ - public String getUsername() { - return USERNAME; - } - - /** - * @return The root password. - */ - public String getPassword() { - return PASSWORD; - } - - /** - * @return The MiniAccumulo's zookeeper instance name. - */ - public String getInstanceName() { - return cluster.getInstanceName(); - } - - /** - * @return The MiniAccumulo's zookeepers. - */ - public String getZookeepers() { - return cluster.getZooKeepers(); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/MiniAccumuloSingleton.java ---------------------------------------------------------------------- diff --git a/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/MiniAccumuloSingleton.java b/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/MiniAccumuloSingleton.java deleted file mode 100644 index 8d731d3..0000000 --- a/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/MiniAccumuloSingleton.java +++ /dev/null @@ -1,84 +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 - * - * http://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.rya.accumulo; - -import org.apache.accumulo.core.client.AccumuloException; -import org.apache.accumulo.core.client.AccumuloSecurityException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; - -public final class MiniAccumuloSingleton { - - public static MiniAccumuloClusterInstance getInstance() { - return InstanceHolder.SINGLETON.instance; - } - - private MiniAccumuloSingleton() { - // hiding implicit default constructor - } - - private enum InstanceHolder { - - SINGLETON; - - private final Logger log; - private final MiniAccumuloClusterInstance instance; - - InstanceHolder() { - this.log = LoggerFactory.getLogger(MiniAccumuloSingleton.class); - this.instance = new MiniAccumuloClusterInstance(); - try { - this.instance.startMiniAccumulo(); - - // JUnit does not have an overall lifecycle event for tearing down - // this kind of resource, but shutdown hooks work alright in practice - // since this should only be used during testing - - // The only other alternative for lifecycle management is to use a - // suite lifecycle to enclose the tests that need this resource. - // In practice this becomes unwieldy. - - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - try { - InstanceHolder.this.instance.stopMiniAccumulo(); - } catch (Throwable t) { - // logging frameworks will likely be shut down - t.printStackTrace(System.err); - } - } - }); - - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - log.error("Interrupted while starting mini accumulo", e); - } catch (IOException | AccumuloException | AccumuloSecurityException e) { - log.error("Unexpected error while starting mini accumulo", e); - } catch (Throwable e) { - // catching throwable because failure to construct an enum - // instance will lead to another error being thrown downstream - log.error("Unexpected throwable while starting mini accumulo", e); - } - } - } - -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/RyaTestInstanceRule.java ---------------------------------------------------------------------- diff --git a/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/RyaTestInstanceRule.java b/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/RyaTestInstanceRule.java deleted file mode 100644 index 3bbceb9..0000000 --- a/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/RyaTestInstanceRule.java +++ /dev/null @@ -1,93 +0,0 @@ -package org.apache.rya.accumulo; - -import java.util.concurrent.atomic.AtomicInteger; - -import org.apache.rya.accumulo.instance.AccumuloRyaInstanceDetailsRepository; -import org.apache.rya.api.instance.RyaDetails; -import org.apache.rya.api.instance.RyaDetails.EntityCentricIndexDetails; -import org.apache.rya.api.instance.RyaDetails.FreeTextIndexDetails; -import org.apache.rya.api.instance.RyaDetails.JoinSelectivityDetails; -import org.apache.rya.api.instance.RyaDetails.PCJIndexDetails; -import org.apache.rya.api.instance.RyaDetails.ProspectorDetails; -import org.apache.rya.api.instance.RyaDetails.TemporalIndexDetails; -import org.apache.rya.api.instance.RyaDetailsRepository; -import org.junit.rules.ExternalResource; - -import com.google.common.base.Optional; - -/** - * 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 - * - * http://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. - */ -public class RyaTestInstanceRule extends ExternalResource { - - private static final MiniAccumuloClusterInstance cluster = MiniAccumuloSingleton.getInstance(); - private static final AtomicInteger ryaInstanceNameCounter = new AtomicInteger(1); - private static final AtomicInteger userId = new AtomicInteger(1); - - private final boolean install; - private String ryaInstanceName; - - public RyaTestInstanceRule(boolean install) { - this.install = install; - } - - public String getRyaInstanceName() { - if (ryaInstanceName == null) { - throw new IllegalStateException("Cannot get rya instance name outside of a test execution."); - } - return ryaInstanceName; - } - - public String createUniqueUser() { - int id = userId.getAndIncrement(); - return "user_" + id; - } - - @Override - protected void before() throws Throwable { - - // Get the next Rya instance name. - ryaInstanceName = "testInstance_" + ryaInstanceNameCounter.getAndIncrement(); - - if (install) { - // Create Rya Details for the instance name. - final RyaDetailsRepository detailsRepo = new AccumuloRyaInstanceDetailsRepository(cluster.getConnector(), ryaInstanceName); - - final RyaDetails details = RyaDetails.builder() - .setRyaInstanceName(ryaInstanceName) - .setRyaVersion("0.0.0.0") - .setFreeTextDetails(new FreeTextIndexDetails(true)) - .setEntityCentricIndexDetails(new EntityCentricIndexDetails(true)) - //RYA-215 .setGeoIndexDetails( new GeoIndexDetails(true) ) - .setTemporalIndexDetails(new TemporalIndexDetails(true)) - .setPCJIndexDetails(PCJIndexDetails.builder().setEnabled(true)) - .setJoinSelectivityDetails(new JoinSelectivityDetails(Optional.absent())) - .setProspectorDetails(new ProspectorDetails(Optional.absent())) - .build(); - - detailsRepo.initialize(details); - } - } - - @Override - protected void after() { - ryaInstanceName = null; - // TODO consider teardown of instance (probably requires additional features) - } - -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/instance/AccumuloRyaDetailsRepositoryIT.java ---------------------------------------------------------------------- diff --git a/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/instance/AccumuloRyaDetailsRepositoryIT.java b/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/instance/AccumuloRyaDetailsRepositoryIT.java index 93ae174..ff0df6b 100644 --- a/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/instance/AccumuloRyaDetailsRepositoryIT.java +++ b/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/instance/AccumuloRyaDetailsRepositoryIT.java @@ -28,8 +28,6 @@ import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.client.Connector; import org.apache.accumulo.minicluster.MiniAccumuloCluster; -import org.apache.rya.accumulo.AccumuloITBase; -import org.apache.rya.accumulo.MiniAccumuloClusterInstance; import org.apache.rya.api.instance.RyaDetails; import org.apache.rya.api.instance.RyaDetails.EntityCentricIndexDetails; import org.apache.rya.api.instance.RyaDetails.FreeTextIndexDetails; @@ -45,6 +43,8 @@ import org.apache.rya.api.instance.RyaDetailsRepository.AlreadyInitializedExcept import org.apache.rya.api.instance.RyaDetailsRepository.ConcurrentUpdateException; import org.apache.rya.api.instance.RyaDetailsRepository.NotInitializedException; import org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException; +import org.apache.rya.test.accumulo.AccumuloITBase; +import org.apache.rya.test.accumulo.MiniAccumuloClusterInstance; import org.junit.Test; import com.google.common.base.Optional; http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/extras/indexing/pom.xml ---------------------------------------------------------------------- diff --git a/extras/indexing/pom.xml b/extras/indexing/pom.xml index 357c552..3adc823 100644 --- a/extras/indexing/pom.xml +++ b/extras/indexing/pom.xml @@ -102,28 +102,21 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.apache.accumulo</groupId> - <artifactId>accumulo-minicluster</artifactId> - <scope>test</scope> - </dependency> - <dependency> <groupId>org.apache.fluo</groupId> <artifactId>fluo-mini</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.rya</groupId> - <artifactId>accumulo.rya</artifactId> + <artifactId>mongodb.rya</artifactId> <type>test-jar</type> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.rya</groupId> - <artifactId>mongodb.rya</artifactId> - <type>test-jar</type> + <artifactId>rya.test.accumulo</artifactId> <scope>test</scope> </dependency> - </dependencies> <build> <pluginManagement> http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloAddUserIT.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloAddUserIT.java b/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloAddUserIT.java index ed359f4..f7da7b8 100644 --- a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloAddUserIT.java +++ b/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloAddUserIT.java @@ -25,13 +25,13 @@ import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.client.admin.SecurityOperations; import org.apache.accumulo.core.client.security.tokens.PasswordToken; import org.apache.accumulo.core.security.SystemPermission; -import org.apache.rya.accumulo.AccumuloITBase; import org.apache.rya.accumulo.AccumuloRdfConfiguration; import org.apache.rya.api.client.Install.InstallConfiguration; import org.apache.rya.api.client.RyaClient; import org.apache.rya.api.instance.RyaDetails; import org.apache.rya.indexing.accumulo.ConfigUtils; import org.apache.rya.sail.config.RyaSailFactory; +import org.apache.rya.test.accumulo.AccumuloITBase; import org.eclipse.rdf4j.model.ValueFactory; import org.eclipse.rdf4j.sail.Sail; import org.eclipse.rdf4j.sail.SailConnection; http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloBatchUpdatePCJIT.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloBatchUpdatePCJIT.java b/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloBatchUpdatePCJIT.java index 2a6fbd5..3ee3ad8 100644 --- a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloBatchUpdatePCJIT.java +++ b/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloBatchUpdatePCJIT.java @@ -23,7 +23,6 @@ import static org.junit.Assert.assertEquals; import java.util.HashSet; import java.util.Set; -import org.apache.rya.accumulo.AccumuloITBase; import org.apache.rya.accumulo.AccumuloRdfConfiguration; import org.apache.rya.api.client.Install.InstallConfiguration; import org.apache.rya.api.client.RyaClient; @@ -34,6 +33,7 @@ import org.apache.rya.indexing.external.PrecomputedJoinIndexerConfig.Precomputed import org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage; import org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPcjStorage; import org.apache.rya.sail.config.RyaSailFactory; +import org.apache.rya.test.accumulo.AccumuloITBase; import org.eclipse.rdf4j.model.ValueFactory; import org.eclipse.rdf4j.query.BindingSet; import org.eclipse.rdf4j.query.impl.MapBindingSet; http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloGetInstanceDetailsIT.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloGetInstanceDetailsIT.java b/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloGetInstanceDetailsIT.java index e7ae332..b919569 100644 --- a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloGetInstanceDetailsIT.java +++ b/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloGetInstanceDetailsIT.java @@ -27,7 +27,6 @@ import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.client.TableExistsException; import org.apache.accumulo.core.client.admin.TableOperations; -import org.apache.rya.accumulo.AccumuloITBase; import org.apache.rya.api.RdfCloudTripleStoreConstants; import org.apache.rya.api.client.GetInstanceDetails; import org.apache.rya.api.client.Install; @@ -42,6 +41,7 @@ import org.apache.rya.api.instance.RyaDetails.JoinSelectivityDetails; import org.apache.rya.api.instance.RyaDetails.PCJIndexDetails; import org.apache.rya.api.instance.RyaDetails.ProspectorDetails; import org.apache.rya.api.instance.RyaDetails.TemporalIndexDetails; +import org.apache.rya.test.accumulo.AccumuloITBase; import org.junit.Test; import com.google.common.base.Optional; http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloInstallIT.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloInstallIT.java b/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloInstallIT.java index a8c7455..e1fa40c 100644 --- a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloInstallIT.java +++ b/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloInstallIT.java @@ -22,13 +22,13 @@ import static org.junit.Assert.assertTrue; import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; -import org.apache.rya.accumulo.AccumuloITBase; import org.apache.rya.api.client.Install.DuplicateInstanceNameException; import org.apache.rya.api.client.Install.InstallConfiguration; import org.apache.rya.api.client.RyaClient; import org.apache.rya.api.client.RyaClientException; import org.apache.rya.api.instance.RyaDetailsRepository.NotInitializedException; import org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException; +import org.apache.rya.test.accumulo.AccumuloITBase; import org.junit.Test; /** http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloInstanceExistsIT.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloInstanceExistsIT.java b/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloInstanceExistsIT.java index 7157ad6..fd47735 100644 --- a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloInstanceExistsIT.java +++ b/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloInstanceExistsIT.java @@ -27,11 +27,10 @@ import org.apache.accumulo.core.client.Connector; import org.apache.accumulo.core.client.TableExistsException; import org.apache.accumulo.core.client.admin.TableOperations; import org.junit.Test; - -import org.apache.rya.accumulo.AccumuloITBase; import org.apache.rya.accumulo.instance.AccumuloRyaInstanceDetailsRepository; import org.apache.rya.api.RdfCloudTripleStoreConstants; import org.apache.rya.api.client.RyaClientException; +import org.apache.rya.test.accumulo.AccumuloITBase; /** * Integration tests the methods of {@link AccumuloInstanceExists}. http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloListInstancesIT.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloListInstancesIT.java b/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloListInstancesIT.java index b153a8c..e74f3d1 100644 --- a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloListInstancesIT.java +++ b/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloListInstancesIT.java @@ -28,9 +28,9 @@ import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.client.admin.SecurityOperations; import org.apache.accumulo.core.client.admin.TableOperations; import org.apache.accumulo.core.security.SystemPermission; -import org.apache.rya.accumulo.AccumuloITBase; import org.apache.rya.api.client.Install; import org.apache.rya.api.client.Install.InstallConfiguration; +import org.apache.rya.test.accumulo.AccumuloITBase; import org.apache.rya.api.client.ListInstances; import org.apache.rya.api.client.RyaClientException; import org.junit.Before; http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloLoadStatementsFileIT.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloLoadStatementsFileIT.java b/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloLoadStatementsFileIT.java index 9b2926e..9ad0b49 100644 --- a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloLoadStatementsFileIT.java +++ b/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloLoadStatementsFileIT.java @@ -30,7 +30,6 @@ import org.apache.accumulo.core.client.Scanner; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.security.Authorizations; -import org.apache.rya.accumulo.AccumuloITBase; import org.apache.rya.api.RdfCloudTripleStoreConstants.TABLE_LAYOUT; import org.apache.rya.api.client.Install; import org.apache.rya.api.client.Install.InstallConfiguration; @@ -40,6 +39,7 @@ import org.apache.rya.api.domain.RyaStatement; import org.apache.rya.api.resolver.RyaToRdfConversions; import org.apache.rya.api.resolver.triple.TripleRow; import org.apache.rya.api.resolver.triple.impl.WholeRowTripleResolver; +import org.apache.rya.test.accumulo.AccumuloITBase; import org.eclipse.rdf4j.model.Statement; import org.eclipse.rdf4j.model.ValueFactory; import org.eclipse.rdf4j.model.impl.SimpleValueFactory; http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloRemoveUserIT.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloRemoveUserIT.java b/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloRemoveUserIT.java index 35e1210..580d863 100644 --- a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloRemoveUserIT.java +++ b/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloRemoveUserIT.java @@ -25,13 +25,13 @@ import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.client.admin.SecurityOperations; import org.apache.accumulo.core.client.security.tokens.PasswordToken; import org.apache.accumulo.core.security.SystemPermission; -import org.apache.rya.accumulo.AccumuloITBase; import org.apache.rya.accumulo.AccumuloRdfConfiguration; import org.apache.rya.api.client.Install.InstallConfiguration; import org.apache.rya.api.client.RyaClient; import org.apache.rya.api.instance.RyaDetails; import org.apache.rya.indexing.accumulo.ConfigUtils; import org.apache.rya.sail.config.RyaSailFactory; +import org.apache.rya.test.accumulo.AccumuloITBase; import org.eclipse.rdf4j.model.ValueFactory; import org.eclipse.rdf4j.sail.Sail; import org.eclipse.rdf4j.sail.SailConnection; http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloSetRyaStreamsConfigurationIT.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloSetRyaStreamsConfigurationIT.java b/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloSetRyaStreamsConfigurationIT.java index 928a29e..026a2a6 100644 --- a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloSetRyaStreamsConfigurationIT.java +++ b/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloSetRyaStreamsConfigurationIT.java @@ -21,12 +21,12 @@ package org.apache.rya.api.client.accumulo; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; -import org.apache.rya.accumulo.AccumuloITBase; import org.apache.rya.api.client.Install; import org.apache.rya.api.client.Install.InstallConfiguration; import org.apache.rya.api.client.InstanceDoesNotExistException; import org.apache.rya.api.client.RyaClient; import org.apache.rya.api.instance.RyaDetails.RyaStreamsDetails; +import org.apache.rya.test.accumulo.AccumuloITBase; import org.junit.Test; /** http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloUninstallIT.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloUninstallIT.java b/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloUninstallIT.java index e88e35c..939e267 100644 --- a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloUninstallIT.java +++ b/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/AccumuloUninstallIT.java @@ -21,8 +21,8 @@ package org.apache.rya.api.client.accumulo; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import org.apache.rya.accumulo.AccumuloITBase; import org.apache.rya.api.client.Install.InstallConfiguration; +import org.apache.rya.test.accumulo.AccumuloITBase; import org.apache.rya.api.client.InstanceDoesNotExistException; import org.apache.rya.api.client.RyaClient; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/FluoITBase.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/FluoITBase.java b/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/FluoITBase.java index 1ef38aa..fd33e1d 100644 --- a/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/FluoITBase.java +++ b/extras/indexing/src/test/java/org/apache/rya/api/client/accumulo/FluoITBase.java @@ -44,9 +44,6 @@ import org.apache.fluo.api.mini.MiniFluo; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.rya.accumulo.AccumuloRdfConfiguration; -import org.apache.rya.accumulo.MiniAccumuloClusterInstance; -import org.apache.rya.accumulo.MiniAccumuloSingleton; -import org.apache.rya.accumulo.RyaTestInstanceRule; import org.apache.rya.api.client.Install; import org.apache.rya.api.client.Install.DuplicateInstanceNameException; import org.apache.rya.api.client.Install.InstallConfiguration; @@ -66,6 +63,9 @@ import org.apache.rya.indexing.pcj.fluo.app.observers.TripleObserver; import org.apache.rya.rdftriplestore.RyaSailRepository; import org.apache.rya.rdftriplestore.inference.InferenceEngineException; import org.apache.rya.sail.config.RyaSailFactory; +import org.apache.rya.test.accumulo.MiniAccumuloClusterInstance; +import org.apache.rya.test.accumulo.MiniAccumuloSingleton; +import org.apache.rya.test.accumulo.RyaTestInstanceRule; import org.apache.zookeeper.ClientCnxn; import org.eclipse.rdf4j.repository.RepositoryConnection; import org.eclipse.rdf4j.repository.RepositoryException; @@ -103,7 +103,7 @@ public abstract class FluoITBase { protected RepositoryConnection ryaConn = null; @Rule - public RyaTestInstanceRule testInstance = new RyaTestInstanceRule(false); + public RyaTestInstanceRule testInstance = new RyaTestInstanceRule(); @BeforeClass public static void beforeClass() throws Exception { http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/extras/rya.indexing.pcj/pom.xml ---------------------------------------------------------------------- diff --git a/extras/rya.indexing.pcj/pom.xml b/extras/rya.indexing.pcj/pom.xml index d36e94b..f40fb38 100644 --- a/extras/rya.indexing.pcj/pom.xml +++ b/extras/rya.indexing.pcj/pom.xml @@ -79,26 +79,20 @@ under the License. <scope>test</scope> </dependency> <dependency> - <groupId>org.apache.accumulo</groupId> - <artifactId>accumulo-minicluster</artifactId> - <scope>test</scope> - </dependency> - <dependency> <groupId>org.apache.rya</groupId> <artifactId>rya.sail</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.rya</groupId> - <artifactId>accumulo.rya</artifactId> + <artifactId>mongodb.rya</artifactId> <type>test-jar</type> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.rya</groupId> - <artifactId>mongodb.rya</artifactId> - <type>test-jar</type> + <artifactId>rya.test.accumulo</artifactId> <scope>test</scope> </dependency> </dependencies> -</project> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/extras/rya.indexing.pcj/src/test/java/org/apache/rya/indexing/pcj/storage/accumulo/PcjTablesIT.java ---------------------------------------------------------------------- diff --git a/extras/rya.indexing.pcj/src/test/java/org/apache/rya/indexing/pcj/storage/accumulo/PcjTablesIT.java b/extras/rya.indexing.pcj/src/test/java/org/apache/rya/indexing/pcj/storage/accumulo/PcjTablesIT.java index be1a64d..26d7596 100644 --- a/extras/rya.indexing.pcj/src/test/java/org/apache/rya/indexing/pcj/storage/accumulo/PcjTablesIT.java +++ b/extras/rya.indexing.pcj/src/test/java/org/apache/rya/indexing/pcj/storage/accumulo/PcjTablesIT.java @@ -41,9 +41,6 @@ import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.rya.accumulo.AccumuloRdfConfiguration; import org.apache.rya.accumulo.AccumuloRyaDAO; -import org.apache.rya.accumulo.MiniAccumuloClusterInstance; -import org.apache.rya.accumulo.MiniAccumuloSingleton; -import org.apache.rya.accumulo.RyaTestInstanceRule; import org.apache.rya.api.RdfCloudTripleStoreConfiguration; import org.apache.rya.api.model.VisibilityBindingSet; import org.apache.rya.api.utils.CloseableIterator; @@ -53,6 +50,9 @@ import org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage.PCJStorageExce import org.apache.rya.indexing.pcj.storage.accumulo.BindingSetConverter.BindingSetConversionException; import org.apache.rya.rdftriplestore.RdfCloudTripleStore; import org.apache.rya.rdftriplestore.RyaSailRepository; +import org.apache.rya.test.accumulo.MiniAccumuloClusterInstance; +import org.apache.rya.test.accumulo.MiniAccumuloSingleton; +import org.apache.rya.test.accumulo.RyaTestInstanceRule; import org.apache.zookeeper.ClientCnxn; import org.eclipse.rdf4j.model.Statement; import org.eclipse.rdf4j.model.ValueFactory; @@ -87,14 +87,14 @@ public class PcjTablesIT { private static final AccumuloPcjSerializer converter = new AccumuloPcjSerializer(); // The MiniAccumuloCluster is re-used between tests. - private MiniAccumuloClusterInstance cluster = MiniAccumuloSingleton.getInstance(); + private final MiniAccumuloClusterInstance cluster = MiniAccumuloSingleton.getInstance(); // Rya data store and connections. protected RyaSailRepository ryaRepo = null; protected RepositoryConnection ryaConn = null; @Rule - public RyaTestInstanceRule testInstance = new RyaTestInstanceRule(false); + public RyaTestInstanceRule testInstance = new RyaTestInstanceRule(); @BeforeClass public static void killLoudLogs() { http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/extras/rya.indexing.pcj/src/test/java/org/apache/rya/indexing/pcj/storage/accumulo/integration/AccumuloPcjStorageIT.java ---------------------------------------------------------------------- diff --git a/extras/rya.indexing.pcj/src/test/java/org/apache/rya/indexing/pcj/storage/accumulo/integration/AccumuloPcjStorageIT.java b/extras/rya.indexing.pcj/src/test/java/org/apache/rya/indexing/pcj/storage/accumulo/integration/AccumuloPcjStorageIT.java index 8968898..d04712e 100644 --- a/extras/rya.indexing.pcj/src/test/java/org/apache/rya/indexing/pcj/storage/accumulo/integration/AccumuloPcjStorageIT.java +++ b/extras/rya.indexing.pcj/src/test/java/org/apache/rya/indexing/pcj/storage/accumulo/integration/AccumuloPcjStorageIT.java @@ -32,9 +32,15 @@ import java.util.stream.Collectors; import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.client.Connector; -import org.apache.rya.accumulo.AccumuloRyaITBase; import org.apache.rya.accumulo.instance.AccumuloRyaInstanceDetailsRepository; +import org.apache.rya.api.instance.RyaDetails; +import org.apache.rya.api.instance.RyaDetails.EntityCentricIndexDetails; +import org.apache.rya.api.instance.RyaDetails.FreeTextIndexDetails; +import org.apache.rya.api.instance.RyaDetails.JoinSelectivityDetails; +import org.apache.rya.api.instance.RyaDetails.PCJIndexDetails; import org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails; +import org.apache.rya.api.instance.RyaDetails.ProspectorDetails; +import org.apache.rya.api.instance.RyaDetails.TemporalIndexDetails; import org.apache.rya.api.instance.RyaDetailsRepository; import org.apache.rya.api.instance.RyaDetailsRepository.NotInitializedException; import org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException; @@ -46,13 +52,18 @@ import org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage.PCJStorageExce import org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPcjStorage; import org.apache.rya.indexing.pcj.storage.accumulo.ShiftVarOrderFactory; import org.apache.rya.indexing.pcj.storage.accumulo.VariableOrder; +import org.apache.rya.test.accumulo.MiniAccumuloClusterInstance; +import org.apache.rya.test.accumulo.MiniAccumuloSingleton; +import org.apache.rya.test.accumulo.RyaTestInstanceRule; import org.eclipse.rdf4j.model.ValueFactory; import org.eclipse.rdf4j.model.impl.SimpleValueFactory; import org.eclipse.rdf4j.query.BindingSet; import org.eclipse.rdf4j.query.MalformedQueryException; import org.eclipse.rdf4j.query.impl.MapBindingSet; +import org.junit.Rule; import org.junit.Test; +import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; /** @@ -61,14 +72,41 @@ import com.google.common.collect.ImmutableMap; * These tests ensures that the PCJ tables are maintained and that these operations * also update the Rya instance's details. */ -public class AccumuloPcjStorageIT extends AccumuloRyaITBase { +public class AccumuloPcjStorageIT { private static final ValueFactory VF = SimpleValueFactory.getInstance(); + @Rule + public RyaTestInstanceRule testInstance = new RyaTestInstanceRule(ryaInstanceName -> { + // Create Rya Details for the instance name. + final MiniAccumuloClusterInstance cluster = MiniAccumuloSingleton.getInstance(); + final RyaDetailsRepository detailsRepo = new AccumuloRyaInstanceDetailsRepository(cluster.getConnector(), ryaInstanceName); + final RyaDetails details = RyaDetails.builder() + .setRyaInstanceName(ryaInstanceName) + .setRyaVersion("0.0.0.0") + .setFreeTextDetails(new FreeTextIndexDetails(true)) + .setEntityCentricIndexDetails(new EntityCentricIndexDetails(true)) + //RYA-215 .setGeoIndexDetails( new GeoIndexDetails(true) ) + .setTemporalIndexDetails(new TemporalIndexDetails(true)) + .setPCJIndexDetails(PCJIndexDetails.builder().setEnabled(true)) + .setJoinSelectivityDetails(new JoinSelectivityDetails(Optional.absent())) + .setProspectorDetails(new ProspectorDetails(Optional.absent())) + .build(); + + detailsRepo.initialize(details); + }); + + /** + * @return The {@link MiniAccumuloClusterInstance} used by the tests. + */ + private MiniAccumuloClusterInstance getClusterInstance() { + return MiniAccumuloSingleton.getInstance(); + } + @Test public void createPCJ() throws AccumuloException, AccumuloSecurityException, PCJStorageException, NotInitializedException, RyaDetailsRepositoryException { // Setup the PCJ storage that will be tested against. - final Connector connector = super.getClusterInstance().getConnector(); - final String ryaInstanceName = super.getRyaInstanceName(); + final Connector connector = getClusterInstance().getConnector(); + final String ryaInstanceName = testInstance.getRyaInstanceName(); try(final PrecomputedJoinStorage pcjStorage = new AccumuloPcjStorage(connector, ryaInstanceName)) { // Create a PCJ. final String pcjId = pcjStorage.createPcj("SELECT * WHERE { ?a <http://isA> ?b } "); @@ -91,8 +129,8 @@ public class AccumuloPcjStorageIT extends AccumuloRyaITBase { @Test public void dropPCJ() throws AccumuloException, AccumuloSecurityException, PCJStorageException, NotInitializedException, RyaDetailsRepositoryException { // Setup the PCJ storage that will be tested against. - final Connector connector = super.getClusterInstance().getConnector(); - final String ryaInstanceName = super.getRyaInstanceName(); + final Connector connector = getClusterInstance().getConnector(); + final String ryaInstanceName = testInstance.getRyaInstanceName(); try(final PrecomputedJoinStorage pcjStorage = new AccumuloPcjStorage(connector, ryaInstanceName)) { // Create a PCJ. final String pcjId = pcjStorage.createPcj("SELECT * WHERE { ?a <http://isA> ?b } "); @@ -114,8 +152,8 @@ public class AccumuloPcjStorageIT extends AccumuloRyaITBase { @Test public void listPcjs() throws AccumuloException, AccumuloSecurityException, PCJStorageException { // Setup the PCJ storage that will be tested against. - final Connector connector = super.getClusterInstance().getConnector(); - final String ryaInstanceName = super.getRyaInstanceName(); + final Connector connector = getClusterInstance().getConnector(); + final String ryaInstanceName = testInstance.getRyaInstanceName(); try(final PrecomputedJoinStorage pcjStorage = new AccumuloPcjStorage(connector, ryaInstanceName)) { // Create a few PCJs and hold onto their IDs. final List<String> expectedIds = new ArrayList<>(); @@ -142,8 +180,8 @@ public class AccumuloPcjStorageIT extends AccumuloRyaITBase { @Test public void getPcjMetadata() throws AccumuloException, AccumuloSecurityException, PCJStorageException, MalformedQueryException { // Setup the PCJ storage that will be tested against. - final Connector connector = super.getClusterInstance().getConnector(); - final String ryaInstanceName = super.getRyaInstanceName(); + final Connector connector = getClusterInstance().getConnector(); + final String ryaInstanceName = testInstance.getRyaInstanceName(); try(final PrecomputedJoinStorage pcjStorage = new AccumuloPcjStorage(connector, ryaInstanceName)) { // Create a PCJ. final String sparql = "SELECT * WHERE { ?a <http://isA> ?b }"; @@ -162,8 +200,8 @@ public class AccumuloPcjStorageIT extends AccumuloRyaITBase { @Test public void addResults() throws AccumuloException, AccumuloSecurityException, PCJStorageException, MalformedQueryException { // Setup the PCJ storage that will be tested against. - final Connector connector = super.getClusterInstance().getConnector(); - final String ryaInstanceName = super.getRyaInstanceName(); + final Connector connector = getClusterInstance().getConnector(); + final String ryaInstanceName = testInstance.getRyaInstanceName(); try(final PrecomputedJoinStorage pcjStorage = new AccumuloPcjStorage(connector, ryaInstanceName)) { // Create a PCJ. final String sparql = "SELECT * WHERE { ?a <http://isA> ?b }"; @@ -196,8 +234,8 @@ public class AccumuloPcjStorageIT extends AccumuloRyaITBase { @Test public void listResults() throws Exception { // Setup the PCJ storage that will be tested against. - final Connector connector = super.getClusterInstance().getConnector(); - final String ryaInstanceName = super.getRyaInstanceName(); + final Connector connector = getClusterInstance().getConnector(); + final String ryaInstanceName = testInstance.getRyaInstanceName(); try(final PrecomputedJoinStorage pcjStorage = new AccumuloPcjStorage(connector, ryaInstanceName)) { // Create a PCJ. final String sparql = "SELECT * WHERE { ?a <http://isA> ?b }"; @@ -238,8 +276,8 @@ public class AccumuloPcjStorageIT extends AccumuloRyaITBase { @Test public void purge() throws Exception { // Setup the PCJ storage that will be tested against. - final Connector connector = super.getClusterInstance().getConnector(); - final String ryaInstanceName = super.getRyaInstanceName(); + final Connector connector = getClusterInstance().getConnector(); + final String ryaInstanceName = testInstance.getRyaInstanceName(); try(final PrecomputedJoinStorage pcjStorage = new AccumuloPcjStorage(connector, ryaInstanceName)) { // Create a PCJ. final String sparql = "SELECT * WHERE { ?a <http://isA> ?b }"; http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/extras/rya.indexing.pcj/src/test/java/org/apache/rya/indexing/pcj/storage/accumulo/integration/AccumuloPeriodicQueryResultStorageIT.java ---------------------------------------------------------------------- diff --git a/extras/rya.indexing.pcj/src/test/java/org/apache/rya/indexing/pcj/storage/accumulo/integration/AccumuloPeriodicQueryResultStorageIT.java b/extras/rya.indexing.pcj/src/test/java/org/apache/rya/indexing/pcj/storage/accumulo/integration/AccumuloPeriodicQueryResultStorageIT.java index 723c700..9eb48a3 100644 --- a/extras/rya.indexing.pcj/src/test/java/org/apache/rya/indexing/pcj/storage/accumulo/integration/AccumuloPeriodicQueryResultStorageIT.java +++ b/extras/rya.indexing.pcj/src/test/java/org/apache/rya/indexing/pcj/storage/accumulo/integration/AccumuloPeriodicQueryResultStorageIT.java @@ -28,7 +28,6 @@ import java.util.UUID; import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.security.Authorizations; -import org.apache.rya.accumulo.AccumuloITBase; import org.apache.rya.api.model.VisibilityBindingSet; import org.apache.rya.api.utils.CloseableIterator; import org.apache.rya.indexing.pcj.storage.PeriodicQueryResultStorage; @@ -37,6 +36,7 @@ import org.apache.rya.indexing.pcj.storage.PeriodicQueryStorageMetadata; import org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPeriodicQueryResultStorage; import org.apache.rya.indexing.pcj.storage.accumulo.PeriodicQueryTableNameFactory; import org.apache.rya.indexing.pcj.storage.accumulo.VariableOrder; +import org.apache.rya.test.accumulo.AccumuloITBase; import org.eclipse.rdf4j.model.ValueFactory; import org.eclipse.rdf4j.model.impl.SimpleValueFactory; import org.eclipse.rdf4j.model.vocabulary.XMLSchema; http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/extras/rya.pcj.fluo/pcj.fluo.test.base/pom.xml ---------------------------------------------------------------------- diff --git a/extras/rya.pcj.fluo/pcj.fluo.test.base/pom.xml b/extras/rya.pcj.fluo/pcj.fluo.test.base/pom.xml index 512666c..f53ce92 100644 --- a/extras/rya.pcj.fluo/pcj.fluo.test.base/pom.xml +++ b/extras/rya.pcj.fluo/pcj.fluo.test.base/pom.xml @@ -52,14 +52,9 @@ under the License. <groupId>org.apache.fluo</groupId> <artifactId>fluo-api</artifactId> </dependency> - + <!-- Testing dependencies. (should be compile scope for this project) --> <dependency> - <groupId>org.apache.rya</groupId> - <artifactId>accumulo.rya</artifactId> - <type>test-jar</type> - </dependency> - <dependency> <groupId>org.apache.fluo</groupId> <artifactId>fluo-mini</artifactId> <scope>compile</scope> @@ -105,5 +100,10 @@ under the License. <artifactId>fluo-recipes-test</artifactId> <scope>compile</scope> </dependency> + <dependency> + <groupId>org.apache.rya</groupId> + <artifactId>rya.test.accumulo</artifactId> + <scope>compile</scope> + </dependency> </dependencies> </project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/extras/rya.pcj.fluo/pcj.fluo.test.base/src/main/java/org/apache/rya/pcj/fluo/test/base/FluoITBase.java ---------------------------------------------------------------------- diff --git a/extras/rya.pcj.fluo/pcj.fluo.test.base/src/main/java/org/apache/rya/pcj/fluo/test/base/FluoITBase.java b/extras/rya.pcj.fluo/pcj.fluo.test.base/src/main/java/org/apache/rya/pcj/fluo/test/base/FluoITBase.java index 18fc1c6..1c8c78b 100644 --- a/extras/rya.pcj.fluo/pcj.fluo.test.base/src/main/java/org/apache/rya/pcj/fluo/test/base/FluoITBase.java +++ b/extras/rya.pcj.fluo/pcj.fluo.test.base/src/main/java/org/apache/rya/pcj/fluo/test/base/FluoITBase.java @@ -38,9 +38,6 @@ import org.apache.fluo.api.mini.MiniFluo; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.rya.accumulo.AccumuloRdfConfiguration; -import org.apache.rya.accumulo.MiniAccumuloClusterInstance; -import org.apache.rya.accumulo.MiniAccumuloSingleton; -import org.apache.rya.accumulo.RyaTestInstanceRule; import org.apache.rya.api.client.Install; import org.apache.rya.api.client.Install.DuplicateInstanceNameException; import org.apache.rya.api.client.Install.InstallConfiguration; @@ -56,6 +53,9 @@ import org.apache.rya.indexing.pcj.fluo.app.query.StatementPatternIdCacheSupplie import org.apache.rya.rdftriplestore.RyaSailRepository; import org.apache.rya.rdftriplestore.inference.InferenceEngineException; import org.apache.rya.sail.config.RyaSailFactory; +import org.apache.rya.test.accumulo.MiniAccumuloClusterInstance; +import org.apache.rya.test.accumulo.MiniAccumuloSingleton; +import org.apache.rya.test.accumulo.RyaTestInstanceRule; import org.apache.zookeeper.ClientCnxn; import org.eclipse.rdf4j.repository.RepositoryConnection; import org.eclipse.rdf4j.repository.RepositoryException; @@ -94,7 +94,7 @@ public abstract class FluoITBase { protected RepositoryConnection ryaConn = null; @Rule - public RyaTestInstanceRule testInstance = new RyaTestInstanceRule(false); + public RyaTestInstanceRule testInstance = new RyaTestInstanceRule(); @BeforeClass public static void beforeClass() throws Exception { http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/extras/shell/pom.xml ---------------------------------------------------------------------- diff --git a/extras/shell/pom.xml b/extras/shell/pom.xml index 5e671b3..d650ab3 100644 --- a/extras/shell/pom.xml +++ b/extras/shell/pom.xml @@ -88,25 +88,19 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.apache.accumulo</groupId> - <artifactId>accumulo-minicluster</artifactId> - <scope>test</scope> - </dependency> - <dependency> <groupId>org.apache.fluo</groupId> <artifactId>fluo-mini</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.rya</groupId> - <artifactId>accumulo.rya</artifactId> + <artifactId>mongodb.rya</artifactId> <type>test-jar</type> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.rya</groupId> - <artifactId>mongodb.rya</artifactId> - <type>test-jar</type> + <artifactId>rya.test.accumulo</artifactId> <scope>test</scope> </dependency> </dependencies> http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/extras/shell/src/test/java/org/apache/rya/shell/RyaShellAccumuloITBase.java ---------------------------------------------------------------------- diff --git a/extras/shell/src/test/java/org/apache/rya/shell/RyaShellAccumuloITBase.java b/extras/shell/src/test/java/org/apache/rya/shell/RyaShellAccumuloITBase.java index a115639..b761937 100644 --- a/extras/shell/src/test/java/org/apache/rya/shell/RyaShellAccumuloITBase.java +++ b/extras/shell/src/test/java/org/apache/rya/shell/RyaShellAccumuloITBase.java @@ -25,8 +25,8 @@ import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.minicluster.MiniAccumuloCluster; import org.apache.log4j.Level; import org.apache.log4j.Logger; -import org.apache.rya.accumulo.MiniAccumuloSingleton; -import org.apache.rya.accumulo.RyaTestInstanceRule; +import org.apache.rya.test.accumulo.MiniAccumuloSingleton; +import org.apache.rya.test.accumulo.RyaTestInstanceRule; import org.apache.zookeeper.ClientCnxn; import org.junit.After; import org.junit.Before; @@ -35,8 +35,6 @@ import org.junit.Rule; import org.springframework.shell.Bootstrap; import org.springframework.shell.core.JLineShellComponent; -import org.apache.rya.accumulo.MiniAccumuloClusterInstance; - /** * All Rya Shell integration tests should extend this one. It provides startup * and shutdown hooks for a Mini Accumulo Cluster when you start and stop testing. @@ -55,7 +53,7 @@ public class RyaShellAccumuloITBase { private JLineShellComponent shell; @Rule - public RyaTestInstanceRule testInstance = new RyaTestInstanceRule(false); + public RyaTestInstanceRule testInstance = new RyaTestInstanceRule(); @BeforeClass public static void killLoudLogs() { http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/extras/shell/src/test/java/org/apache/rya/shell/util/ConnectorFactoryIT.java ---------------------------------------------------------------------- diff --git a/extras/shell/src/test/java/org/apache/rya/shell/util/ConnectorFactoryIT.java b/extras/shell/src/test/java/org/apache/rya/shell/util/ConnectorFactoryIT.java index c3a5e74..c86b526 100644 --- a/extras/shell/src/test/java/org/apache/rya/shell/util/ConnectorFactoryIT.java +++ b/extras/shell/src/test/java/org/apache/rya/shell/util/ConnectorFactoryIT.java @@ -22,10 +22,9 @@ import java.nio.CharBuffer; import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; +import org.apache.rya.test.accumulo.AccumuloITBase; import org.junit.Test; -import org.apache.rya.accumulo.AccumuloITBase; - /** * Tests the methods of {@link ConnectorFactory}. */ http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 052f294..932d443 100644 --- a/pom.xml +++ b/pom.xml @@ -536,6 +536,11 @@ under the License. </dependency> <dependency> <groupId>org.apache.rya</groupId> + <artifactId>rya.test.accumulo</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.rya</groupId> <artifactId>rya.test.rdf</artifactId> <version>${project.version}</version> </dependency> http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/test/accumulo/pom.xml ---------------------------------------------------------------------- diff --git a/test/accumulo/pom.xml b/test/accumulo/pom.xml new file mode 100644 index 0000000..4596171 --- /dev/null +++ b/test/accumulo/pom.xml @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +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 + + http://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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <parent> + <groupId>org.apache.rya</groupId> + <artifactId>rya.test.parent</artifactId> + <version>4.0.0-incubating-SNAPSHOT</version> + </parent> + + <modelVersion>4.0.0</modelVersion> + <artifactId>rya.test.accumulo</artifactId> + + <name>Apache Rya Test Accumulo</name> + <description> + This module contains the Rya Test Accumulo components that help write + Accumulo based integration tests. + </description> + + <dependencies> + <!-- 3rd party dependencies. --> + <dependency> + <groupId>com.github.stephenc.findbugs</groupId> + <artifactId>findbugs-annotations</artifactId> + </dependency> + <dependency> + <groupId>org.apache.accumulo</groupId> + <artifactId>accumulo-minicluster</artifactId> + </dependency> + + <!-- Testing dependencies. --> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>compile</scope> + </dependency> + </dependencies> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/test/accumulo/src/main/java/org/apache/rya/test/accumulo/AccumuloITBase.java ---------------------------------------------------------------------- diff --git a/test/accumulo/src/main/java/org/apache/rya/test/accumulo/AccumuloITBase.java b/test/accumulo/src/main/java/org/apache/rya/test/accumulo/AccumuloITBase.java new file mode 100644 index 0000000..ba55001 --- /dev/null +++ b/test/accumulo/src/main/java/org/apache/rya/test/accumulo/AccumuloITBase.java @@ -0,0 +1,97 @@ +/** + * 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 + * + * http://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.rya.test.accumulo; + +import org.apache.accumulo.core.client.AccumuloException; +import org.apache.accumulo.core.client.AccumuloSecurityException; +import org.apache.accumulo.core.client.Connector; +import org.apache.accumulo.minicluster.MiniAccumuloCluster; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.apache.zookeeper.ClientCnxn; +import org.junit.BeforeClass; +import org.junit.Rule; + +/** + * Boilerplate code for a unit test that uses a {@link MiniAccumuloCluster}. + * <p> + * It uses the same instance of {@link MiniAccumuloCluster} and just clears out + * any tables that were added between tests. + */ +public class AccumuloITBase { + + private static MiniAccumuloClusterInstance cluster = MiniAccumuloSingleton.getInstance(); + + @Rule + public RyaTestInstanceRule testInstance = new RyaTestInstanceRule(); + + + @BeforeClass + public static void killLoudLogs() { + Logger.getLogger(ClientCnxn.class).setLevel(Level.ERROR); + } + + /** + * @return The {@link MiniAccumuloClusterInstance} used by the tests. + */ + public MiniAccumuloClusterInstance getClusterInstance() { + return cluster; + } + + /** + * @return The root username. + */ + public String getUsername() { + return cluster.getUsername(); + } + + /** + * @return The root password. + */ + public String getPassword() { + return cluster.getPassword(); + } + + /** + * @return The MiniAccumulo's zookeeper instance name. + */ + public String getInstanceName() { + return cluster.getInstanceName(); + } + + /** + * @return The MiniAccumulo's zookeepers. + */ + public String getZookeepers() { + return cluster.getZookeepers(); + } + + /** + * @return A {@link Connector} that creates connections to the mini accumulo cluster. + * @throws AccumuloException Could not connect to the cluster. + * @throws AccumuloSecurityException Could not connect to the cluster because of a security violation. + */ + public Connector getConnector() throws AccumuloException, AccumuloSecurityException { + return cluster.getConnector(); + } + + public String getRyaInstanceName() { + return testInstance.getRyaInstanceName(); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/test/accumulo/src/main/java/org/apache/rya/test/accumulo/MiniAccumuloClusterInstance.java ---------------------------------------------------------------------- diff --git a/test/accumulo/src/main/java/org/apache/rya/test/accumulo/MiniAccumuloClusterInstance.java b/test/accumulo/src/main/java/org/apache/rya/test/accumulo/MiniAccumuloClusterInstance.java new file mode 100644 index 0000000..8b641c3 --- /dev/null +++ b/test/accumulo/src/main/java/org/apache/rya/test/accumulo/MiniAccumuloClusterInstance.java @@ -0,0 +1,119 @@ +/** + * 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 + * + * http://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.rya.test.accumulo; + +import java.io.File; +import java.io.IOException; + +import org.apache.accumulo.core.client.AccumuloException; +import org.apache.accumulo.core.client.AccumuloSecurityException; +import org.apache.accumulo.core.client.Connector; +import org.apache.accumulo.minicluster.MiniAccumuloCluster; +import org.apache.accumulo.minicluster.MiniAccumuloConfig; +import org.apache.log4j.Logger; + +import com.google.common.io.Files; + +/** + * Contains boilerplate code that can be used by an integration test that + * uses a {@link MiniAccumuloCluster}. + * <p> + * You can just extend {@link AccumuloITBase} if your test only requires Accumulo. + */ +public class MiniAccumuloClusterInstance { + + private static final Logger log = Logger.getLogger(MiniAccumuloClusterInstance.class); + + private static final String USERNAME = "root"; + private static final String PASSWORD = "password"; + + /** + * A mini Accumulo cluster that can be used by the tests. + */ + private static MiniAccumuloCluster cluster = null; + + /** + * Start the {@link MiniAccumuloCluster}. + */ + public void startMiniAccumulo() throws IOException, InterruptedException, AccumuloException, AccumuloSecurityException { + final File miniDataDir = Files.createTempDir(); + + // Setup and start the Mini Accumulo. + final MiniAccumuloConfig cfg = new MiniAccumuloConfig(miniDataDir, PASSWORD); + cluster = new MiniAccumuloCluster(cfg); + cluster.start(); + } + + /** + * Stop the {@link MiniAccumuloCluster}. + */ + public void stopMiniAccumulo() throws IOException, InterruptedException { + if(cluster != null) { + try { + log.info("Shutting down the Mini Accumulo being used as a Rya store."); + cluster.stop(); + log.info("Mini Accumulo being used as a Rya store shut down."); + } catch(final Exception e) { + log.error("Could not shut down the Mini Accumulo.", e); + } + } + } + + /** + * @return The {@link MiniAccumuloCluster} managed by this class. + */ + public MiniAccumuloCluster getCluster() { + return cluster; + } + + /** + * @return An Accumulo connector that is connected to the mini cluster's root account. + */ + public Connector getConnector() throws AccumuloException, AccumuloSecurityException { + return cluster.getConnector(USERNAME, PASSWORD); + } + + /** + * @return The root username. + */ + public String getUsername() { + return USERNAME; + } + + /** + * @return The root password. + */ + public String getPassword() { + return PASSWORD; + } + + /** + * @return The MiniAccumulo's zookeeper instance name. + */ + public String getInstanceName() { + return cluster.getInstanceName(); + } + + /** + * @return The MiniAccumulo's zookeepers. + */ + public String getZookeepers() { + return cluster.getZooKeepers(); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/test/accumulo/src/main/java/org/apache/rya/test/accumulo/MiniAccumuloSingleton.java ---------------------------------------------------------------------- diff --git a/test/accumulo/src/main/java/org/apache/rya/test/accumulo/MiniAccumuloSingleton.java b/test/accumulo/src/main/java/org/apache/rya/test/accumulo/MiniAccumuloSingleton.java new file mode 100644 index 0000000..832844f --- /dev/null +++ b/test/accumulo/src/main/java/org/apache/rya/test/accumulo/MiniAccumuloSingleton.java @@ -0,0 +1,83 @@ +/** + * 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 + * + * http://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.rya.test.accumulo; + +import java.io.IOException; + +import org.apache.accumulo.core.client.AccumuloException; +import org.apache.accumulo.core.client.AccumuloSecurityException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public final class MiniAccumuloSingleton { + + public static MiniAccumuloClusterInstance getInstance() { + return InstanceHolder.SINGLETON.instance; + } + + private MiniAccumuloSingleton() { + // hiding implicit default constructor + } + + private enum InstanceHolder { + + SINGLETON; + + private final Logger log; + private final MiniAccumuloClusterInstance instance; + + InstanceHolder() { + this.log = LoggerFactory.getLogger(MiniAccumuloSingleton.class); + this.instance = new MiniAccumuloClusterInstance(); + try { + this.instance.startMiniAccumulo(); + + // JUnit does not have an overall lifecycle event for tearing down + // this kind of resource, but shutdown hooks work alright in practice + // since this should only be used during testing + + // The only other alternative for lifecycle management is to use a + // suite lifecycle to enclose the tests that need this resource. + // In practice this becomes unwieldy. + + Runtime.getRuntime().addShutdownHook(new Thread() { + @Override + public void run() { + try { + InstanceHolder.this.instance.stopMiniAccumulo(); + } catch (final Throwable t) { + // logging frameworks will likely be shut down + t.printStackTrace(System.err); + } + } + }); + + } catch (final InterruptedException e) { + Thread.currentThread().interrupt(); + log.error("Interrupted while starting mini accumulo", e); + } catch (IOException | AccumuloException | AccumuloSecurityException e) { + log.error("Unexpected error while starting mini accumulo", e); + } catch (final Throwable e) { + // catching throwable because failure to construct an enum + // instance will lead to another error being thrown downstream + log.error("Unexpected throwable while starting mini accumulo", e); + } + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/test/accumulo/src/main/java/org/apache/rya/test/accumulo/RyaTestInstanceRule.java ---------------------------------------------------------------------- diff --git a/test/accumulo/src/main/java/org/apache/rya/test/accumulo/RyaTestInstanceRule.java b/test/accumulo/src/main/java/org/apache/rya/test/accumulo/RyaTestInstanceRule.java new file mode 100644 index 0000000..dd13a28 --- /dev/null +++ b/test/accumulo/src/main/java/org/apache/rya/test/accumulo/RyaTestInstanceRule.java @@ -0,0 +1,92 @@ +/** + * 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 + * + * http://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.rya.test.accumulo; + +import java.util.Optional; +import java.util.concurrent.atomic.AtomicInteger; + +import org.junit.rules.ExternalResource; + +public class RyaTestInstanceRule extends ExternalResource { + + private static final AtomicInteger ryaInstanceNameCounter = new AtomicInteger(1); + private static final AtomicInteger userId = new AtomicInteger(1); + + private final Optional<DoInstall> doInstall; + private String ryaInstanceName; + + /** + * Invoked within {@link RyaTestInstanceRule#before()} when provided. + */ + public static interface DoInstall { + + /** + * Invoked within {@link RyaTestInstanceRule#before()}. + * + * @param ryaInstanceName - The Rya Instance name for the test. (not null) + * @throws Throwable Anything caused the install to fail. + */ + public void doInstall(String ryaInstanceName) throws Throwable; + } + + /** + * Constructs an instance of {@link RyaTestInstnaceRule} where no extra steps need + * to be performed within {@link #before()}. + */ + public RyaTestInstanceRule() { + this.doInstall = Optional.empty(); + } + + /** + * Constructs an instance of {@link RyaTestInstnaceRule}. + * + * @param doInstall - Invoked within {@link #before()}. (not null) + */ + public RyaTestInstanceRule(final DoInstall doInstall) { + this.doInstall = Optional.of(doInstall); + } + + public String getRyaInstanceName() { + if (ryaInstanceName == null) { + throw new IllegalStateException("Cannot get rya instance name outside of a test execution."); + } + return ryaInstanceName; + } + + public String createUniqueUser() { + final int id = userId.getAndIncrement(); + return "user_" + id; + } + + @Override + protected void before() throws Throwable { + // Get the next Rya instance name. + ryaInstanceName = "testInstance_" + ryaInstanceNameCounter.getAndIncrement(); + + if (doInstall.isPresent()) { + doInstall.get().doInstall(ryaInstanceName); + } + } + + @Override + protected void after() { + ryaInstanceName = null; + // TODO consider teardown of instance (probably requires additional features) + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/b71e892a/test/pom.xml ---------------------------------------------------------------------- diff --git a/test/pom.xml b/test/pom.xml index f19743e..2517f6a 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -34,6 +34,7 @@ <packaging>pom</packaging> <modules> + <module>accumulo</module> <module>kafka</module> <module>rdf</module> </modules>