From 709598a3b6fd067327c922979a22071ff50fd1a6 Mon Sep 17 00:00:00 2001 From: Madhan Neethiraj <madhan@apache.org> Date: Tue, 20 Oct 2020 21:42:46 -0700 Subject: [PATCH] ATLAS-4000: refactored UTs and ITs to remove compile dependency from product code on atlas-testtools - #1 --- graphdb/janus/pom.xml | 1 + graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusGraphDatabase.java | 56 +++++++++++++++++++++++++++++++++++++++----------------- graphdb/janus/src/main/java/org/janusgraph/diskstorage/solr/Solr6Index.java | 57 ++++++++++++++++++++++++--------------------------------- graphdb/janus/src/test/java/org/apache/atlas/repository/graphdb/janus/AbstractGraphDatabaseTest.java | 13 ++++++++++++- graphdb/janus/src/test/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusDatabaseTest.java | 36 +++++++++++++++++++++++------------- graphdb/janus/src/test/java/org/apache/atlas/repository/graphdb/janus/JanusGraphProviderTest.java | 11 +++++++++++ pom.xml | 44 ++++++++++++++++++++++++++++++++++++++++++++ repository/pom.xml | 8 ++++++++ repository/src/main/java/org/apache/atlas/discovery/FreeTextSearchProcessor.java | 3 +-- repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java | 2 +- repository/src/test/java/org/apache/atlas/BasicTestSetup.java | 3 ++- repository/src/test/java/org/apache/atlas/TestModules.java | 4 ++-- repository/src/test/java/org/apache/atlas/discovery/AtlasDiscoveryServiceTest.java | 9 ++++++--- repository/src/test/java/org/apache/atlas/discovery/ClassificationSearchProcessorTest.java | 8 ++++++-- repository/src/test/java/org/apache/atlas/discovery/EntitySearchProcessorTest.java | 8 ++++++-- repository/src/test/java/org/apache/atlas/discovery/FreeTextSearchProcessorTest.java | 8 ++++++-- repository/src/test/java/org/apache/atlas/query/DSLQueriesTest.java | 9 +++------ repository/src/test/java/org/apache/atlas/repository/AtlasTestBase.java | 13 +++++++++++++ repository/src/test/java/org/apache/atlas/repository/audit/AdminPurgeTest.java | 12 +++++++----- repository/src/test/java/org/apache/atlas/repository/impexp/ExportServiceTest.java | 10 ++++------ repository/src/test/java/org/apache/atlas/repository/impexp/ImportReactivateTableTest.java | 12 +++++++----- repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceTest.java | 12 +++++++----- repository/src/test/java/org/apache/atlas/repository/impexp/RelationshipAttributesExtractorTest.java | 10 ++++------ repository/src/test/java/org/apache/atlas/repository/impexp/TableReplicationRequestProcessorTest.java | 16 +++++++++------- repository/src/test/java/org/apache/atlas/repository/migration/MigrationBaseAsserts.java | 15 +++++++++------ repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java | 16 ++++++++++------ repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityDefStoreV2Test.java | 15 +++++++++------ repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityTestBase.java | 11 +++++------ repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasRelationshipDefStoreV2Test.java | 16 ++++++++++------ repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasRelationshipStoreV2Test.java | 11 +++++------ repository/src/test/java/org/apache/atlas/repository/store/graph/v2/InverseReferenceUpdateV2Test.java | 11 +++++------ repository/src/test/java/org/apache/atlas/repository/tagpropagation/ClassificationPropagationTest.java | 13 ++++++------- repository/src/test/java/org/apache/atlas/repository/userprofile/UserProfileServiceTest.java | 15 +++++++++------ repository/src/test/java/org/apache/atlas/services/MetricsServiceTest.java | 13 ++++++------- test-tools/pom.xml | 15 ++++++++++++++- test-tools/src/main/java/org/apache/atlas/runner/LocalSolrRunner.java | 16 +++++++++++++++- webapp/pom.xml | 5 +++++ webapp/src/test/java/org/apache/atlas/web/security/SSLAndKerberosTest.java | 4 ---- 38 files changed, 354 insertions(+), 187 deletions(-) diff --git a/graphdb/janus/pom.xml b/graphdb/janus/pom.xml index 6deef51..147e062 100644 --- a/graphdb/janus/pom.xml +++ b/graphdb/janus/pom.xml @@ -61,6 +61,7 @@ <groupId>org.apache.atlas</groupId> <artifactId>atlas-testtools</artifactId> <version>${project.version}</version> + <scope>test</scope> </dependency> <dependency> diff --git a/graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusGraphDatabase.java b/graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusGraphDatabase.java index e9b4b09..11267c4 100644 --- a/graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusGraphDatabase.java +++ b/graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusGraphDatabase.java @@ -27,7 +27,6 @@ import org.apache.atlas.repository.graphdb.GraphDatabase; import org.apache.atlas.repository.graphdb.janus.serializer.BigDecimalSerializer; import org.apache.atlas.repository.graphdb.janus.serializer.BigIntegerSerializer; import org.apache.atlas.repository.graphdb.janus.serializer.TypeCategorySerializer; -import org.apache.atlas.runner.LocalSolrRunner; import org.apache.atlas.typesystem.types.DataTypes.TypeCategory; import org.apache.atlas.utils.AtlasPerfTracer; import org.apache.commons.configuration.Configuration; @@ -45,6 +44,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.lang.reflect.Field; +import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.math.BigDecimal; import java.math.BigInteger; @@ -80,11 +80,11 @@ public class AtlasJanusGraphDatabase implements GraphDatabase<AtlasJanusVertex, } public static Configuration getConfiguration() throws AtlasException { - startLocalSolr(); - Configuration configProperties = ApplicationProperties.get(); if (isEmbeddedSolr()) { // AtlasJanusGraphIndexClient.performRequestHandlerAction() fails for embedded-solr; disable freetext until this issue is resolved + startEmbeddedSolr(); + configProperties.setProperty(ApplicationProperties.ENABLE_FREETEXT_SEARCH_CONF, false); } @@ -264,10 +264,12 @@ public class AtlasJanusGraphDatabase implements GraphDatabase<AtlasJanusVertex, t.printStackTrace(); } - try { - LocalSolrRunner.stop(); - } catch (Throwable t) { - LOG.warn("Could not stop local solr server", t); + if (isEmbeddedSolr()) { + try { + stopEmbeddedSolr(); + } catch (Throwable t) { + LOG.warn("Could not stop local solr server", t); + } } } @@ -282,18 +284,38 @@ public class AtlasJanusGraphDatabase implements GraphDatabase<AtlasJanusVertex, return new AtlasJanusGraph(getBulkLoadingGraphInstance()); } - private static void startLocalSolr() { - if (isEmbeddedSolr()) { - try { - LocalSolrRunner.start(); + private static void startEmbeddedSolr() throws AtlasException { + LOG.info("==> startEmbeddedSolr()"); - Configuration configuration = ApplicationProperties.get(); - configuration.clearProperty(SOLR_ZOOKEEPER_URL); - configuration.setProperty(SOLR_ZOOKEEPER_URL, LocalSolrRunner.getZookeeperUrls()); - } catch (Exception e) { - throw new RuntimeException("Failed to start embedded solr cloud server. Aborting!", e); - } + try { + Class<?> localSolrRunnerClz = Class.forName("org.apache.atlas.runner.LocalSolrRunner"); + Method startMethod = localSolrRunnerClz.getMethod("start"); + + startMethod.invoke(null); + } catch (Exception excp) { + LOG.error("startEmbeddedSolr(): failed", excp); + + throw new AtlasException("startEmbeddedSolr(): failed", excp); } + + LOG.info("<== startEmbeddedSolr()"); + } + + private static void stopEmbeddedSolr() throws AtlasException { + LOG.info("==> stopEmbeddedSolr()"); + + try { + Class<?> localSolrRunnerClz = Class.forName("org.apache.atlas.runner.LocalSolrRunner"); + Method stopMethod = localSolrRunnerClz.getMethod("stop"); + + stopMethod.invoke(null); + } catch (Exception excp) { + LOG.error("stopEmbeddedSolr(): failed", excp); + + throw new AtlasException("stopEmbeddedSolr(): failed", excp); + } + + LOG.info("<== stopEmbeddedSolr()"); } public static boolean isEmbeddedSolr() { diff --git a/graphdb/janus/src/main/java/org/janusgraph/diskstorage/solr/Solr6Index.java b/graphdb/janus/src/main/java/org/janusgraph/diskstorage/solr/Solr6Index.java index 6509fef..81ae202 100644 --- a/graphdb/janus/src/main/java/org/janusgraph/diskstorage/solr/Solr6Index.java +++ b/graphdb/janus/src/main/java/org/janusgraph/diskstorage/solr/Solr6Index.java @@ -274,13 +274,35 @@ public class Solr6Index implements IndexProvider { Mode mode = Mode.parse(configuration.get(SOLR_MODE)); switch (mode) { case CLOUD: - final CloudSolrClient cloudServer = new CloudSolrClient.Builder() + /* ATLAS-2920: Update JanusGraph Solr clients to use all zookeeper entries – start */ + List<String> zkHosts = new ArrayList<>(); + String chroot = null; + String[] zkUrls = configuration.get(ZOOKEEPER_URLS); + + if (zkUrls != null) { + for (int i = zkUrls.length - 1; i >= 0; i--) { + String zkUrl = zkUrls[i]; + int idxChroot = zkUrl.indexOf(CHROOT_START_CHAR); + + if (idxChroot != -1) { + if (chroot == null) { + chroot = zkUrl.substring(idxChroot); + } + + zkUrl = zkUrl.substring(0, idxChroot); + } + + zkHosts.add(zkUrl); + } + } + /* ATLAS-2920: - end */ + + final CloudSolrClient cloudServer = new CloudSolrClient.Builder().withZkHost(zkHosts).withZkChroot(chroot) .withLBHttpSolrClientBuilder( new LBHttpSolrClient.Builder() .withHttpSolrClientBuilder(new HttpSolrClient.Builder().withInvariantParams(clientParams)) .withBaseSolrUrls(configuration.get(HTTP_URLS)) ) - .withZkHost(getZookeeperURLs(configuration)) .sendUpdatesOnlyToShardLeaders() .build(); cloudServer.connect(); @@ -1240,35 +1262,4 @@ public class Solr6Index implements IndexProvider { logger.info("Exiting solr wait"); } } - - /* ATLAS-2920: Update JanusGraph Solr clients to use all zookeeper entries – start */ - private static List<String> getZookeeperURLs(Configuration config) { - List<String> ret = null; - String[] zkHosts = config.get(ZOOKEEPER_URLS); - - if (zkHosts != null) { - ret = new ArrayList<>(zkHosts.length); - - for (int i = 0; i < zkHosts.length; i++) { - String zkHost = zkHosts[i]; - - if (StringUtils.isEmpty(zkHost)) { - continue; - } - - int idxSlash = zkHost.indexOf(CHROOT_START_CHAR); - - if (idxSlash != -1 && i < zkHosts.length - 1) { - zkHost = zkHost.substring(0, idxSlash); - } - - if (StringUtils.isNotEmpty(zkHost)) { - ret.add(zkHost); - } - } - } - - return ret; - } - /* ATLAS-2920 – end */ } \ No newline at end of file diff --git a/graphdb/janus/src/test/java/org/apache/atlas/repository/graphdb/janus/AbstractGraphDatabaseTest.java b/graphdb/janus/src/test/java/org/apache/atlas/repository/graphdb/janus/AbstractGraphDatabaseTest.java index 3500415..10f618b 100644 --- a/graphdb/janus/src/test/java/org/apache/atlas/repository/graphdb/janus/AbstractGraphDatabaseTest.java +++ b/graphdb/janus/src/test/java/org/apache/atlas/repository/graphdb/janus/AbstractGraphDatabaseTest.java @@ -25,6 +25,7 @@ import org.apache.atlas.repository.graphdb.AtlasGraph; import org.apache.atlas.repository.graphdb.AtlasGraphManagement; import org.apache.atlas.repository.graphdb.AtlasPropertyKey; import org.apache.atlas.repository.graphdb.AtlasVertex; +import org.apache.atlas.runner.LocalSolrRunner; import org.testng.annotations.AfterClass; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeClass; @@ -33,6 +34,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import static org.apache.atlas.graph.GraphSandboxUtil.useLocalSolr; + public abstract class AbstractGraphDatabaseTest { protected static final String WEIGHT_PROPERTY = "weight"; @@ -48,6 +51,10 @@ public abstract class AbstractGraphDatabaseTest { public static void createIndices() throws Exception { GraphSandboxUtil.create(); + if (useLocalSolr()) { + LocalSolrRunner.start(); + } + AtlasJanusGraphDatabase db = new AtlasJanusGraphDatabase(); AtlasGraphManagement mgmt = db.getGraph().getManagementSystem(); @@ -75,9 +82,13 @@ public abstract class AbstractGraphDatabaseTest { } @AfterClass - public static void cleanUp() { + public static void cleanUp() throws Exception { AtlasJanusGraph graph = new AtlasJanusGraph(); graph.clear(); + + if (useLocalSolr()) { + LocalSolrRunner.stop(); + } } protected <V, E> void pushChangesAndFlushCache() { diff --git a/graphdb/janus/src/test/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusDatabaseTest.java b/graphdb/janus/src/test/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusDatabaseTest.java index 5cd5509..54d78c6 100644 --- a/graphdb/janus/src/test/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusDatabaseTest.java +++ b/graphdb/janus/src/test/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusDatabaseTest.java @@ -30,6 +30,7 @@ import org.apache.atlas.repository.graphdb.AtlasGraphQuery; import org.apache.atlas.repository.graphdb.AtlasGraphQuery.ComparisionOperator; import org.apache.atlas.repository.graphdb.AtlasPropertyKey; import org.apache.atlas.repository.graphdb.AtlasVertex; +import org.apache.atlas.runner.LocalSolrRunner; import org.apache.atlas.typesystem.types.DataTypes.TypeCategory; import org.apache.commons.configuration.Configuration; import org.testng.annotations.AfterClass; @@ -45,6 +46,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import static org.apache.atlas.graph.GraphSandboxUtil.useLocalSolr; import static org.apache.atlas.repository.graphdb.janus.AtlasJanusGraphDatabase.initJanusGraph; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; @@ -61,9 +63,13 @@ public class AtlasJanusDatabaseTest { private AtlasGraph<?, ?> atlasGraph; - private <V, E> AtlasGraph<V, E> getGraph() { + private <V, E> AtlasGraph<V, E> getGraph() throws Exception { GraphSandboxUtil.create(); + if (useLocalSolr()) { + LocalSolrRunner.start(); + } + if (atlasGraph == null) { AtlasJanusGraphDatabase db = new AtlasJanusGraphDatabase(); atlasGraph = db.getGraph(); @@ -83,11 +89,15 @@ public class AtlasJanusDatabaseTest { } @AfterClass - public void cleanup() { + public void cleanup() throws Exception { if (atlasGraph != null) { atlasGraph.clear(); atlasGraph = null; } + + if (useLocalSolr()) { + LocalSolrRunner.stop(); + } } @Test @@ -115,7 +125,7 @@ public class AtlasJanusDatabaseTest { } @Test - public <V, E> void testPropertyDataTypes() { + public <V, E> void testPropertyDataTypes() throws Exception { // primitives AtlasGraph<V, E> graph = getGraph(); @@ -177,7 +187,7 @@ public class AtlasJanusDatabaseTest { } @Test - public <V, E> void testMultiplicityOnePropertySupport() { + public <V, E> void testMultiplicityOnePropertySupport() throws Exception { AtlasGraph<V, E> graph = (AtlasGraph<V, E>) getGraph(); @@ -213,7 +223,7 @@ public class AtlasJanusDatabaseTest { } @Test - public <V, E> void testRemoveEdge() { + public <V, E> void testRemoveEdge() throws Exception { AtlasGraph<V, E> graph = (AtlasGraph<V, E>) getGraph(); AtlasVertex<V, E> v1 = graph.addVertex(); @@ -235,7 +245,7 @@ public class AtlasJanusDatabaseTest { } @Test - public <V, E> void testRemoveVertex() { + public <V, E> void testRemoveVertex() throws Exception { AtlasGraph<V, E> graph = (AtlasGraph<V, E>) getGraph(); @@ -249,7 +259,7 @@ public class AtlasJanusDatabaseTest { } @Test - public <V, E> void testGetEdges() { + public <V, E> void testGetEdges() throws Exception { AtlasGraph<V, E> graph = (AtlasGraph<V, E>) getGraph(); AtlasVertex<V, E> v1 = graph.addVertex(); @@ -285,7 +295,7 @@ public class AtlasJanusDatabaseTest { } @Test - public <V, E> void testMultiplictyManyPropertySupport() { + public <V, E> void testMultiplictyManyPropertySupport() throws Exception { AtlasGraph<V, E> graph = getGraph(); @@ -324,7 +334,7 @@ public class AtlasJanusDatabaseTest { } @Test - public <V, E> void testListProperties() throws AtlasException { + public <V, E> void testListProperties() throws Exception { AtlasGraph<V, E> graph = getGraph(); AtlasVertex<V, E> vertex = graph.addVertex(); @@ -347,7 +357,7 @@ public class AtlasJanusDatabaseTest { } @Test - public <V, E> void testRemoveProperty() { + public <V, E> void testRemoveProperty() throws Exception { AtlasGraph<V, E> graph = getGraph(); AtlasVertex<V, E> vertex = graph.addVertex(); @@ -375,7 +385,7 @@ public class AtlasJanusDatabaseTest { } @Test - public <V, E> void getGetGraphQueryForVertices() { + public <V, E> void getGetGraphQueryForVertices() throws Exception { AtlasGraph<V, E> graph = getGraph(); @@ -410,7 +420,7 @@ public class AtlasJanusDatabaseTest { } private <V, E> void testExecuteGraphQuery(String property, ComparisionOperator op, Object value, - AtlasVertex<V, E>... expected) { + AtlasVertex<V, E>... expected) throws Exception { AtlasGraph<V, E> graph = getGraph(); AtlasGraphQuery<V, E> query = graph.query(); if (op != null) { @@ -427,7 +437,7 @@ public class AtlasJanusDatabaseTest { } @Test - public <V, E> void testAddMultManyPropertyValueTwice() { + public <V, E> void testAddMultManyPropertyValueTwice() throws Exception { AtlasGraph<V, E> graph = getGraph(); String vertexId; diff --git a/graphdb/janus/src/test/java/org/apache/atlas/repository/graphdb/janus/JanusGraphProviderTest.java b/graphdb/janus/src/test/java/org/apache/atlas/repository/graphdb/janus/JanusGraphProviderTest.java index 54b1bc6..169d235 100644 --- a/graphdb/janus/src/test/java/org/apache/atlas/repository/graphdb/janus/JanusGraphProviderTest.java +++ b/graphdb/janus/src/test/java/org/apache/atlas/repository/graphdb/janus/JanusGraphProviderTest.java @@ -21,12 +21,15 @@ import org.apache.atlas.ApplicationProperties; import org.apache.atlas.AtlasException; import org.apache.atlas.graph.GraphSandboxUtil; import org.apache.atlas.repository.graphdb.AtlasGraph; +import org.apache.atlas.runner.LocalSolrRunner; import org.apache.commons.configuration.Configuration; import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; +import static org.apache.atlas.graph.GraphSandboxUtil.useLocalSolr; + @Test public class JanusGraphProviderTest { @@ -38,6 +41,10 @@ public class JanusGraphProviderTest { public void setUp() throws Exception { GraphSandboxUtil.create(); + if (useLocalSolr()) { + LocalSolrRunner.start(); + } + //First get Instance graph = new AtlasJanusGraph(); configuration = ApplicationProperties.getSubsetConfiguration(ApplicationProperties.get(), AtlasJanusGraphDatabase.GRAPH_PREFIX); @@ -56,6 +63,10 @@ public class JanusGraphProviderTest { } catch (Exception e) { e.printStackTrace(); } + + if (useLocalSolr()) { + LocalSolrRunner.stop(); + } } @Test diff --git a/pom.xml b/pom.xml index 4aa23d1..d6cd6de 100644 --- a/pom.xml +++ b/pom.xml @@ -669,6 +669,8 @@ <janus.version>0.5.1</janus.version> <tinkerpop.version>3.4.6</tinkerpop.version> <lucene-solr.version>7.3.0</lucene-solr.version> + <solr-test-framework.version>7.0.0</solr-test-framework.version> + <junit.version>4.13</junit.version> <hadoop.version>3.1.1</hadoop.version> <hbase.version>2.0.2</hbase.version> @@ -1235,12 +1237,54 @@ <dependency> <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-util</artifactId> + <version>${jetty.version}</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-util-ajax</artifactId> + <version>${jetty.version}</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-io</artifactId> + <version>${jetty.version}</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-http</artifactId> + <version>${jetty.version}</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-security</artifactId> + <version>${jetty.version}</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-webapp</artifactId> <version>${jetty.version}</version> <scope>compile</scope> </dependency> <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-servlet</artifactId> + <version>${jetty.version}</version> + <scope>compile</scope> + </dependency> + + <dependency> <groupId>net.sourceforge.findbugs</groupId> <artifactId>annotations</artifactId> <version>1.3.2</version> diff --git a/repository/pom.xml b/repository/pom.xml index 3ba0f7d..3de28f7 100755 --- a/repository/pom.xml +++ b/repository/pom.xml @@ -248,6 +248,13 @@ <version>${poi-ooxml.version}</version> </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>${junit.version}</version> + <scope>test</scope> + </dependency> + </dependencies> <profiles> @@ -263,6 +270,7 @@ <groupId>org.apache.atlas</groupId> <artifactId>atlas-testtools</artifactId> <version>${project.version}</version> + <scope>test</scope> <exclusions> <exclusion> <groupId>com.fasterxml.jackson.core</groupId> diff --git a/repository/src/main/java/org/apache/atlas/discovery/FreeTextSearchProcessor.java b/repository/src/main/java/org/apache/atlas/discovery/FreeTextSearchProcessor.java index d9981e6..56b514d 100644 --- a/repository/src/main/java/org/apache/atlas/discovery/FreeTextSearchProcessor.java +++ b/repository/src/main/java/org/apache/atlas/discovery/FreeTextSearchProcessor.java @@ -25,7 +25,6 @@ import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2; import org.apache.atlas.utils.AtlasPerfTracer; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; -import org.apache.solr.common.params.CommonParams; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -39,7 +38,7 @@ import java.util.*; public class FreeTextSearchProcessor extends SearchProcessor { private static final Logger LOG = LoggerFactory.getLogger(FreeTextSearchProcessor.class); private static final Logger PERF_LOG = AtlasPerfTracer.getPerfLogger("FreeTextSearchProcessor"); - public static final String SOLR_QT_PARAMETER = CommonParams.QT; + public static final String SOLR_QT_PARAMETER = "qt"; // org.apache.solr.common.params.CommonParams.QT; public static final String SOLR_REQUEST_HANDLER_NAME = "/freetext"; private final AtlasIndexQuery indexQuery; diff --git a/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java b/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java index e35f359..d0ffb85 100755 --- a/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java +++ b/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java @@ -45,7 +45,7 @@ import org.apache.atlas.type.*; import org.apache.atlas.type.AtlasStructType.AtlasAttribute; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.configuration.Configuration; -import org.apache.solr.common.StringUtils; +import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.core.annotation.Order; diff --git a/repository/src/test/java/org/apache/atlas/BasicTestSetup.java b/repository/src/test/java/org/apache/atlas/BasicTestSetup.java index 270051f..d733c16 100644 --- a/repository/src/test/java/org/apache/atlas/BasicTestSetup.java +++ b/repository/src/test/java/org/apache/atlas/BasicTestSetup.java @@ -26,6 +26,7 @@ import org.apache.atlas.model.glossary.AtlasGlossaryTerm; import org.apache.atlas.model.glossary.relations.AtlasGlossaryHeader; import org.apache.atlas.model.instance.*; import org.apache.atlas.model.typedef.*; +import org.apache.atlas.repository.AtlasTestBase; import org.apache.atlas.repository.store.graph.AtlasEntityStore; import org.apache.atlas.repository.store.graph.v2.AtlasEntityStream; import org.apache.atlas.store.AtlasTypeDefStore; @@ -42,7 +43,7 @@ import java.util.stream.Stream; import static org.apache.atlas.utils.TestLoadModelUtils.loadModelFromJson; import static org.testng.Assert.fail; -public abstract class BasicTestSetup { +public abstract class BasicTestSetup extends AtlasTestBase { // Entity type // protected static final String DATABASE_TYPE = "hive_db"; diff --git a/repository/src/test/java/org/apache/atlas/TestModules.java b/repository/src/test/java/org/apache/atlas/TestModules.java index a298934..71b0a4a 100644 --- a/repository/src/test/java/org/apache/atlas/TestModules.java +++ b/repository/src/test/java/org/apache/atlas/TestModules.java @@ -114,6 +114,8 @@ public class TestModules { @Override protected void configure() { + GraphSandboxUtil.create(); + if (useLocalSolr()) { try { LocalSolrRunner.start(); @@ -122,8 +124,6 @@ public class TestModules { } } - GraphSandboxUtil.create(); - bindAuditRepository(binder()); bind(AtlasGraph.class).toProvider(AtlasGraphProvider.class); diff --git a/repository/src/test/java/org/apache/atlas/discovery/AtlasDiscoveryServiceTest.java b/repository/src/test/java/org/apache/atlas/discovery/AtlasDiscoveryServiceTest.java index d8c1546..1839e76 100644 --- a/repository/src/test/java/org/apache/atlas/discovery/AtlasDiscoveryServiceTest.java +++ b/repository/src/test/java/org/apache/atlas/discovery/AtlasDiscoveryServiceTest.java @@ -18,7 +18,6 @@ package org.apache.atlas.discovery; import org.apache.atlas.ApplicationProperties; -import org.apache.atlas.AtlasException; import org.apache.atlas.BasicTestSetup; import org.apache.atlas.TestModules; import org.apache.atlas.exception.AtlasBaseException; @@ -49,7 +48,9 @@ public class AtlasDiscoveryServiceTest extends BasicTestSetup { private AtlasDiscoveryService discoveryService; @BeforeClass - public void setup() throws AtlasException, AtlasBaseException { + public void setup() throws Exception { + super.initialize(); + ApplicationProperties.get().setProperty(ApplicationProperties.ENABLE_FREETEXT_SEARCH_CONF, true); setupTestData(); createDimensionalTaggedEntity("sales"); @@ -332,7 +333,9 @@ public class AtlasDiscoveryServiceTest extends BasicTestSetup { } @AfterClass - public void teardown() { + public void teardown() throws Exception { AtlasGraphProvider.cleanup(); + + super.cleanup(); } } diff --git a/repository/src/test/java/org/apache/atlas/discovery/ClassificationSearchProcessorTest.java b/repository/src/test/java/org/apache/atlas/discovery/ClassificationSearchProcessorTest.java index 8693459..e1ebbfc 100644 --- a/repository/src/test/java/org/apache/atlas/discovery/ClassificationSearchProcessorTest.java +++ b/repository/src/test/java/org/apache/atlas/discovery/ClassificationSearchProcessorTest.java @@ -65,7 +65,9 @@ public class ClassificationSearchProcessorTest extends BasicTestSetup { private String dimensionalTagGuid; @BeforeClass - public void setup() throws AtlasBaseException { + public void setup() throws Exception { + super.initialize(); + setupTestData(); createDimensionTaggedEntityAndDelete(); createDimensionalTaggedEntityWithAttr(); @@ -298,7 +300,9 @@ public class ClassificationSearchProcessorTest extends BasicTestSetup { } @AfterClass - public void teardown() { + public void teardown() throws Exception { AtlasGraphProvider.cleanup(); + + super.cleanup(); } } diff --git a/repository/src/test/java/org/apache/atlas/discovery/EntitySearchProcessorTest.java b/repository/src/test/java/org/apache/atlas/discovery/EntitySearchProcessorTest.java index db107b3..7645689 100644 --- a/repository/src/test/java/org/apache/atlas/discovery/EntitySearchProcessorTest.java +++ b/repository/src/test/java/org/apache/atlas/discovery/EntitySearchProcessorTest.java @@ -63,7 +63,9 @@ public class EntitySearchProcessorTest extends BasicTestSetup { private EntityGraphRetriever entityRetriever; @BeforeClass - public void setup() { + public void setup() throws Exception { + super.initialize(); + setupTestData(); } @@ -363,8 +365,10 @@ public class EntitySearchProcessorTest extends BasicTestSetup { } @AfterClass - public void teardown() { + public void teardown() throws Exception { AtlasGraphProvider.cleanup(); + + super.cleanup(); } @Test diff --git a/repository/src/test/java/org/apache/atlas/discovery/FreeTextSearchProcessorTest.java b/repository/src/test/java/org/apache/atlas/discovery/FreeTextSearchProcessorTest.java index 2a38d87..e497bb7 100644 --- a/repository/src/test/java/org/apache/atlas/discovery/FreeTextSearchProcessorTest.java +++ b/repository/src/test/java/org/apache/atlas/discovery/FreeTextSearchProcessorTest.java @@ -52,7 +52,9 @@ public class FreeTextSearchProcessorTest extends BasicTestSetup { private EntityGraphRetriever entityRetriever; @BeforeClass - public void setup() { + public void setup() throws Exception { + super.initialize(); + setupTestData(); } @@ -131,8 +133,10 @@ public class FreeTextSearchProcessorTest extends BasicTestSetup { } @AfterClass - public void teardown() { + public void teardown() throws Exception { AtlasGraphProvider.cleanup(); + + super.cleanup(); } } \ No newline at end of file diff --git a/repository/src/test/java/org/apache/atlas/query/DSLQueriesTest.java b/repository/src/test/java/org/apache/atlas/query/DSLQueriesTest.java index 5ace379..191a1e1 100644 --- a/repository/src/test/java/org/apache/atlas/query/DSLQueriesTest.java +++ b/repository/src/test/java/org/apache/atlas/query/DSLQueriesTest.java @@ -23,7 +23,6 @@ import org.apache.atlas.discovery.EntityDiscoveryService; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.model.discovery.AtlasSearchResult; import org.apache.atlas.repository.graph.AtlasGraphProvider; -import org.apache.atlas.runner.LocalSolrRunner; import org.apache.commons.collections.CollectionUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,7 +39,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import static org.apache.atlas.graph.GraphSandboxUtil.useLocalSolr; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; @@ -57,7 +55,8 @@ public class DSLQueriesTest extends BasicTestSetup { @BeforeClass public void setup() throws Exception { - LocalSolrRunner.start(); + super.initialize(); + setupTestData(); pollForData(); @@ -127,9 +126,7 @@ public class DSLQueriesTest extends BasicTestSetup { public void teardown() throws Exception { AtlasGraphProvider.cleanup(); - if (useLocalSolr()) { - LocalSolrRunner.stop(); - } + super.cleanup(); } @DataProvider(name = "comparisonQueriesProvider") diff --git a/repository/src/test/java/org/apache/atlas/repository/AtlasTestBase.java b/repository/src/test/java/org/apache/atlas/repository/AtlasTestBase.java index c2668b1..a2efb76 100644 --- a/repository/src/test/java/org/apache/atlas/repository/AtlasTestBase.java +++ b/repository/src/test/java/org/apache/atlas/repository/AtlasTestBase.java @@ -23,6 +23,7 @@ import org.apache.atlas.model.impexp.ExportImportAuditEntry; import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.repository.impexp.ExportImportAuditService; import org.apache.atlas.repository.store.graph.v2.AtlasEntityStoreV2; +import org.apache.atlas.runner.LocalSolrRunner; import org.apache.atlas.store.AtlasTypeDefStore; import org.apache.atlas.type.AtlasTypeRegistry; import org.testng.SkipException; @@ -31,6 +32,7 @@ import java.io.IOException; import java.util.Arrays; import java.util.List; +import static org.apache.atlas.graph.GraphSandboxUtil.useLocalSolr; import static org.apache.atlas.utils.TestLoadModelUtils.createAtlasEntity; import static org.apache.atlas.utils.TestLoadModelUtils.loadBaseModel; import static org.apache.atlas.utils.TestLoadModelUtils.loadEntity; @@ -47,6 +49,17 @@ public class AtlasTestBase { protected static final String TABLE_VIEW_GUID = "56415119-7cb0-40dd-ace8-1e50efd54991"; protected static final String COLUMN_GUID_HIGH = "f87a5320-1529-4369-8d63-b637ebdf2c1c"; + protected void initialize() throws Exception { + if (useLocalSolr()) { + LocalSolrRunner.start(); + } + } + + protected void cleanup() throws Exception { + if (useLocalSolr()) { + LocalSolrRunner.stop(); + } + } protected void basicSetup(AtlasTypeDefStore typeDefStore, AtlasTypeRegistry typeRegistry) throws IOException, AtlasBaseException { loadBaseModel(typeDefStore, typeRegistry); diff --git a/repository/src/test/java/org/apache/atlas/repository/audit/AdminPurgeTest.java b/repository/src/test/java/org/apache/atlas/repository/audit/AdminPurgeTest.java index 173e446..d600261 100644 --- a/repository/src/test/java/org/apache/atlas/repository/audit/AdminPurgeTest.java +++ b/repository/src/test/java/org/apache/atlas/repository/audit/AdminPurgeTest.java @@ -30,7 +30,6 @@ import org.apache.atlas.repository.graph.AtlasGraphProvider; import org.apache.atlas.repository.store.bootstrap.AtlasTypeDefStoreInitializer; import org.apache.atlas.repository.store.graph.v2.AtlasEntityStoreV2; import org.apache.atlas.repository.store.graph.v2.AtlasEntityStream; -import org.apache.atlas.runner.LocalSolrRunner; import org.apache.atlas.store.AtlasTypeDefStore; import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.utils.TestResourceFileUtils; @@ -39,6 +38,7 @@ import org.slf4j.LoggerFactory; import org.testng.Assert; import org.testng.SkipException; import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeTest; import org.testng.annotations.Guice; import org.testng.annotations.Test; @@ -48,7 +48,6 @@ import java.io.IOException; import java.util.*; import java.util.stream.Collectors; -import static org.apache.atlas.graph.GraphSandboxUtil.useLocalSolr; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; @@ -72,6 +71,11 @@ public class AdminPurgeTest extends AtlasTestBase { @Inject private AtlasEntityStoreV2 entityStore; + @BeforeClass + public void initialize() throws Exception { + super.initialize(); + } + @BeforeTest public void setupTest() throws IOException, AtlasBaseException { RequestContext.clear(); @@ -84,9 +88,7 @@ public class AdminPurgeTest extends AtlasTestBase { Thread.sleep(1000); AtlasGraphProvider.cleanup(); - if (useLocalSolr()) { - LocalSolrRunner.stop(); - } + super.cleanup(); } @Test diff --git a/repository/src/test/java/org/apache/atlas/repository/impexp/ExportServiceTest.java b/repository/src/test/java/org/apache/atlas/repository/impexp/ExportServiceTest.java index 8e19dc4..d8218db 100644 --- a/repository/src/test/java/org/apache/atlas/repository/impexp/ExportServiceTest.java +++ b/repository/src/test/java/org/apache/atlas/repository/impexp/ExportServiceTest.java @@ -33,7 +33,6 @@ import org.apache.atlas.repository.graph.AtlasGraphProvider; import org.apache.atlas.repository.store.bootstrap.AtlasTypeDefStoreInitializer; import org.apache.atlas.repository.store.graph.v2.AtlasEntityStoreV2; import org.apache.atlas.repository.store.graph.v2.AtlasEntityStream; -import org.apache.atlas.runner.LocalSolrRunner; import org.apache.atlas.store.AtlasTypeDefStore; import org.apache.atlas.type.AtlasType; import org.apache.atlas.type.AtlasTypeRegistry; @@ -56,7 +55,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import static org.apache.atlas.graph.GraphSandboxUtil.useLocalSolr; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; @@ -88,7 +86,9 @@ public class ExportServiceTest extends AtlasTestBase { } @BeforeClass - public void setupSampleData() throws AtlasBaseException { + public void setupSampleData() throws Exception { + super.initialize(); + AtlasTypesDef sampleTypes = TestUtilsV2.defineDeptEmployeeTypes(); AtlasTypesDef typesToCreate = AtlasTypeDefStoreInitializer.getTypesToCreate(sampleTypes, typeRegistry); @@ -110,9 +110,7 @@ public class ExportServiceTest extends AtlasTestBase { assertExportImportAuditEntry(auditService); AtlasGraphProvider.cleanup(); - if (useLocalSolr()) { - LocalSolrRunner.stop(); - } + super.cleanup(); } private AtlasExportRequest getRequestForFullFetch() { diff --git a/repository/src/test/java/org/apache/atlas/repository/impexp/ImportReactivateTableTest.java b/repository/src/test/java/org/apache/atlas/repository/impexp/ImportReactivateTableTest.java index e06bf66..23e0cda 100644 --- a/repository/src/test/java/org/apache/atlas/repository/impexp/ImportReactivateTableTest.java +++ b/repository/src/test/java/org/apache/atlas/repository/impexp/ImportReactivateTableTest.java @@ -31,12 +31,12 @@ import org.apache.atlas.repository.AtlasTestBase; import org.apache.atlas.repository.graph.AtlasGraphProvider; import org.apache.atlas.repository.store.graph.AtlasEntityStore; import org.apache.atlas.repository.store.graph.v2.AtlasEntityStream; -import org.apache.atlas.runner.LocalSolrRunner; import org.apache.atlas.store.AtlasTypeDefStore; import org.apache.atlas.type.AtlasTypeRegistry; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeTest; import org.testng.annotations.Guice; import org.testng.annotations.Test; @@ -46,7 +46,6 @@ import java.io.InputStream; import java.util.List; import static org.apache.atlas.AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME; -import static org.apache.atlas.graph.GraphSandboxUtil.useLocalSolr; import static org.apache.atlas.repository.impexp.ZipFileResourceTestUtils.getInputStreamFrom; import static org.apache.atlas.repository.impexp.ZipFileResourceTestUtils.getDefaultImportRequest; import static org.apache.atlas.utils.TestLoadModelUtils.loadFsModel; @@ -87,6 +86,11 @@ public class ImportReactivateTableTest extends AtlasTestBase { @Inject private AtlasTypeDefStore typeDefStore; + @BeforeClass + public void initialize() throws Exception { + super.initialize(); + } + @BeforeTest public void setup() throws IOException, AtlasBaseException { RequestContext.clear(); @@ -98,9 +102,7 @@ public class ImportReactivateTableTest extends AtlasTestBase { public void clear() throws Exception { AtlasGraphProvider.cleanup(); - if (useLocalSolr()) { - LocalSolrRunner.stop(); - } + super.cleanup(); } private void importSeedData() throws AtlasBaseException, IOException { diff --git a/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceTest.java b/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceTest.java index 7367153..e3410aa 100644 --- a/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceTest.java +++ b/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceTest.java @@ -39,7 +39,6 @@ import org.apache.atlas.repository.graphdb.AtlasVertex; import org.apache.atlas.repository.store.graph.AtlasEntityStore; import org.apache.atlas.repository.store.graph.v2.AtlasEntityStream; import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2; -import org.apache.atlas.runner.LocalSolrRunner; import org.apache.atlas.store.AtlasTypeDefStore; import org.apache.atlas.type.AtlasClassificationType; import org.apache.atlas.type.AtlasTypeRegistry; @@ -48,6 +47,7 @@ import org.mockito.stubbing.Answer; import org.testng.ITestContext; import org.testng.annotations.AfterClass; import org.testng.annotations.AfterTest; +import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeTest; import org.testng.annotations.DataProvider; import org.testng.annotations.Guice; @@ -60,7 +60,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import static org.apache.atlas.graph.GraphSandboxUtil.useLocalSolr; import static org.apache.atlas.repository.impexp.ZipFileResourceTestUtils.getDefaultImportRequest; import static org.apache.atlas.repository.impexp.ZipFileResourceTestUtils.getZipSource; import static org.apache.atlas.repository.impexp.ZipFileResourceTestUtils.getInputStreamFrom; @@ -107,6 +106,11 @@ public class ImportServiceTest extends AtlasTestBase { this.importService = importService; } + @BeforeClass + public void initialize() throws Exception { + super.initialize(); + } + @BeforeTest public void setupTest() { RequestContext.clear(); @@ -117,9 +121,7 @@ public class ImportServiceTest extends AtlasTestBase { public void clear() throws Exception { AtlasGraphProvider.cleanup(); - if (useLocalSolr()) { - LocalSolrRunner.stop(); - } + super.cleanup(); } @AfterTest diff --git a/repository/src/test/java/org/apache/atlas/repository/impexp/RelationshipAttributesExtractorTest.java b/repository/src/test/java/org/apache/atlas/repository/impexp/RelationshipAttributesExtractorTest.java index 5f41cc9..7699d34 100644 --- a/repository/src/test/java/org/apache/atlas/repository/impexp/RelationshipAttributesExtractorTest.java +++ b/repository/src/test/java/org/apache/atlas/repository/impexp/RelationshipAttributesExtractorTest.java @@ -28,7 +28,6 @@ import org.apache.atlas.model.instance.AtlasObjectId; import org.apache.atlas.repository.AtlasTestBase; import org.apache.atlas.repository.graph.AtlasGraphProvider; import org.apache.atlas.repository.store.graph.v2.AtlasEntityStoreV2; -import org.apache.atlas.runner.LocalSolrRunner; import org.apache.atlas.store.AtlasTypeDefStore; import org.apache.atlas.type.AtlasTypeRegistry; import org.testng.ITestContext; @@ -49,7 +48,6 @@ import java.util.Map; import java.util.ArrayList; import java.util.HashMap; -import static org.apache.atlas.graph.GraphSandboxUtil.useLocalSolr; import static org.apache.atlas.repository.impexp.ZipFileResourceTestUtils.getZipSource; import static org.apache.atlas.utils.TestLoadModelUtils.loadModelFromJson; import static org.apache.atlas.repository.impexp.ZipFileResourceTestUtils.runImportWithNoParameters; @@ -105,7 +103,9 @@ public class RelationshipAttributesExtractorTest extends AtlasTestBase { private AtlasEntityStoreV2 entityStore; @BeforeClass - public void setup() throws IOException, AtlasBaseException { + public void setup() throws Exception { + super.initialize(); + loadBaseModel(); loadHiveModel(); } @@ -120,9 +120,7 @@ public class RelationshipAttributesExtractorTest extends AtlasTestBase { public void clear() throws Exception { AtlasGraphProvider.cleanup(); - if (useLocalSolr()) { - LocalSolrRunner.stop(); - } + super.cleanup(); } @DataProvider(name = "hiveDb") diff --git a/repository/src/test/java/org/apache/atlas/repository/impexp/TableReplicationRequestProcessorTest.java b/repository/src/test/java/org/apache/atlas/repository/impexp/TableReplicationRequestProcessorTest.java index 99df914..318f75b 100644 --- a/repository/src/test/java/org/apache/atlas/repository/impexp/TableReplicationRequestProcessorTest.java +++ b/repository/src/test/java/org/apache/atlas/repository/impexp/TableReplicationRequestProcessorTest.java @@ -27,7 +27,6 @@ import org.apache.atlas.model.impexp.ExportImportAuditEntry; import org.apache.atlas.repository.AtlasTestBase; import org.apache.atlas.repository.graph.AtlasGraphProvider; import org.apache.atlas.repository.store.graph.AtlasEntityStore; -import org.apache.atlas.runner.LocalSolrRunner; import org.apache.atlas.store.AtlasTypeDefStore; import org.apache.atlas.type.AtlasType; import org.apache.atlas.type.AtlasTypeRegistry; @@ -35,17 +34,17 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.ITestContext; import org.testng.SkipException; -import org.testng.annotations.Guice; -import org.testng.annotations.Test; import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeTest; import org.testng.annotations.DataProvider; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; import java.io.IOException; import java.io.InputStream; import java.util.List; -import static org.apache.atlas.graph.GraphSandboxUtil.useLocalSolr; import static org.apache.atlas.repository.impexp.ZipFileResourceTestUtils.getDefaultImportRequest; import static org.apache.atlas.repository.impexp.ZipFileResourceTestUtils.getZipSource; import static org.apache.atlas.repository.impexp.ZipFileResourceTestUtils.getInputStreamFrom; @@ -87,6 +86,11 @@ public class TableReplicationRequestProcessorTest extends AtlasTestBase { @Inject private AtlasTypeDefStore typeDefStore; + @BeforeClass + public void initialize() throws Exception { + super.initialize(); + } + @BeforeTest public void setupTest() throws IOException, AtlasBaseException { RequestContext.clear(); @@ -98,9 +102,7 @@ public class TableReplicationRequestProcessorTest extends AtlasTestBase { public void clear() throws Exception { AtlasGraphProvider.cleanup(); - if (useLocalSolr()) { - LocalSolrRunner.stop(); - } + super.cleanup(); } @DataProvider(name = "source1") diff --git a/repository/src/test/java/org/apache/atlas/repository/migration/MigrationBaseAsserts.java b/repository/src/test/java/org/apache/atlas/repository/migration/MigrationBaseAsserts.java index bd8359c..145f744 100644 --- a/repository/src/test/java/org/apache/atlas/repository/migration/MigrationBaseAsserts.java +++ b/repository/src/test/java/org/apache/atlas/repository/migration/MigrationBaseAsserts.java @@ -20,29 +20,29 @@ package org.apache.atlas.repository.migration; import com.google.inject.Inject; import org.apache.atlas.exception.AtlasBaseException; +import org.apache.atlas.repository.AtlasTestBase; import org.apache.atlas.repository.graph.AtlasGraphProvider; import org.apache.atlas.repository.graph.GraphBackedSearchIndexer; import org.apache.atlas.repository.graph.GraphHelper; import org.apache.atlas.repository.graphdb.*; import org.apache.atlas.repository.store.bootstrap.AtlasTypeDefStoreInitializer; import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2; -import org.apache.atlas.runner.LocalSolrRunner; import org.apache.atlas.store.AtlasTypeDefStore; import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.utils.TestResourceFileUtils; import org.apache.commons.lang.StringUtils; import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; import java.io.IOException; import java.util.Iterator; -import static org.apache.atlas.graph.GraphSandboxUtil.useLocalSolr; import static org.apache.atlas.utils.TestLoadModelUtils.loadModelFromJson; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; -public class MigrationBaseAsserts { +public class MigrationBaseAsserts extends AtlasTestBase { private static final String TYPE_NAME_PROPERTY = "__typeName"; private static final String R_GUID_PROPERTY_NAME = "_r__guid"; protected static final String ASSERT_NAME_PROPERTY = "Asset.name"; @@ -67,13 +67,16 @@ public class MigrationBaseAsserts { this.migrator = migrator; } + @BeforeClass + public void initialize() throws Exception { + super.initialize(); + } + @AfterClass public void clear() throws Exception { AtlasGraphProvider.cleanup(); - if (useLocalSolr()) { - LocalSolrRunner.stop(); - } + super.cleanup(); } protected void loadTypesFromJson() throws IOException, AtlasBaseException { diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java index b654638..ea978ad 100644 --- a/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java +++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java @@ -29,7 +29,7 @@ import org.apache.atlas.model.typedef.AtlasEntityDef; import org.apache.atlas.model.typedef.AtlasEnumDef; import org.apache.atlas.model.typedef.AtlasStructDef; import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef; -import org.apache.atlas.runner.LocalSolrRunner; +import org.apache.atlas.repository.AtlasTestBase; import org.apache.atlas.store.AtlasTypeDefStore; import org.apache.atlas.type.AtlasEntityType; import org.apache.atlas.type.AtlasClassificationType; @@ -39,10 +39,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.Assert; import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeTest; import org.testng.annotations.DataProvider; import org.testng.annotations.Guice; import org.testng.annotations.Test; + import java.util.Collections; import java.util.List; import java.util.Set; @@ -52,11 +54,10 @@ import java.io.IOException; import java.util.Arrays; import java.util.Date; -import static org.apache.atlas.graph.GraphSandboxUtil.useLocalSolr; import static org.testng.Assert.*; @Guice(modules = TestModules.TestOnlyModule.class) -public class AtlasTypeDefGraphStoreTest { +public class AtlasTypeDefGraphStoreTest extends AtlasTestBase { private static final Logger LOG = LoggerFactory.getLogger(AtlasTypeDefGraphStoreTest.class); @Inject @@ -69,11 +70,14 @@ public class AtlasTypeDefGraphStoreTest { RequestContext.get().setUser(TestUtilsV2.TEST_USER, null); } + @BeforeClass + public void initialize() throws Exception { + super.initialize(); + } + @AfterClass public void cleanup() throws Exception { - if (useLocalSolr()) { - LocalSolrRunner.stop(); - } + super.cleanup(); } @Test diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityDefStoreV2Test.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityDefStoreV2Test.java index 5876248..4192129 100644 --- a/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityDefStoreV2Test.java +++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityDefStoreV2Test.java @@ -24,24 +24,24 @@ import org.apache.atlas.AtlasException; import org.apache.atlas.TestModules; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.model.typedef.AtlasEntityDef; +import org.apache.atlas.repository.AtlasTestBase; import org.apache.atlas.repository.graph.AtlasGraphProvider; -import org.apache.atlas.runner.LocalSolrRunner; import org.apache.atlas.type.AtlasTypeUtil; import org.testng.Assert; import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; import org.testng.annotations.DataProvider; import org.testng.annotations.Guice; import org.testng.annotations.Test; import java.util.Collections; -import static org.apache.atlas.graph.GraphSandboxUtil.useLocalSolr; /** * Tests for AtlasEntityStoreV1 */ @Guice(modules = TestModules.TestOnlyModule.class) -public class AtlasEntityDefStoreV2Test { +public class AtlasEntityDefStoreV2Test extends AtlasTestBase { @Inject private @@ -69,12 +69,15 @@ public class AtlasEntityDefStoreV2Test { } } + @BeforeClass + public void initialize() throws Exception { + super.initialize(); + } + @AfterClass public void clear() throws Exception { AtlasGraphProvider.cleanup(); - if (useLocalSolr()) { - LocalSolrRunner.stop(); - } + super.cleanup(); } } diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityTestBase.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityTestBase.java index 752f1ac..397e2ab 100644 --- a/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityTestBase.java +++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityTestBase.java @@ -33,13 +33,13 @@ import org.apache.atlas.model.instance.EntityMutations.EntityOperation; import org.apache.atlas.model.typedef.AtlasClassificationDef; import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef; import org.apache.atlas.model.typedef.AtlasTypesDef; +import org.apache.atlas.repository.AtlasTestBase; import org.apache.atlas.repository.graph.AtlasGraphProvider; import org.apache.atlas.repository.graph.GraphBackedSearchIndexer; import org.apache.atlas.repository.graphdb.AtlasGraph; import org.apache.atlas.repository.store.bootstrap.AtlasTypeDefStoreInitializer; import org.apache.atlas.repository.store.graph.AtlasEntityStore; import org.apache.atlas.repository.store.graph.v1.DeleteHandlerDelegate; -import org.apache.atlas.runner.LocalSolrRunner; import org.apache.atlas.store.AtlasTypeDefStore; import org.apache.atlas.type.AtlasArrayType; import org.apache.atlas.type.AtlasMapType; @@ -62,12 +62,11 @@ import java.util.List; import java.util.Map; import static org.apache.atlas.TestUtilsV2.randomString; -import static org.apache.atlas.graph.GraphSandboxUtil.useLocalSolr; import static org.mockito.Mockito.mock; import static org.testng.Assert.fail; @Guice(modules = TestModules.TestOnlyModule.class) -public class AtlasEntityTestBase { +public class AtlasEntityTestBase extends AtlasTestBase { @Inject AtlasTypeRegistry typeRegistry; @@ -93,6 +92,8 @@ public class AtlasEntityTestBase { RequestContext.clear(); RequestContext.get().setUser(TestUtilsV2.TEST_USER, null); + super.initialize(); + new GraphBackedSearchIndexer(typeRegistry); } @@ -100,9 +101,7 @@ public class AtlasEntityTestBase { public void clear() throws Exception { AtlasGraphProvider.cleanup(); - if (useLocalSolr()) { - LocalSolrRunner.stop(); - } + super.cleanup(); } @BeforeTest diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasRelationshipDefStoreV2Test.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasRelationshipDefStoreV2Test.java index 1a774e2..6a60797 100644 --- a/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasRelationshipDefStoreV2Test.java +++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasRelationshipDefStoreV2Test.java @@ -26,23 +26,23 @@ import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.model.typedef.AtlasRelationshipDef; import org.apache.atlas.model.typedef.AtlasRelationshipEndDef; import org.apache.atlas.model.typedef.AtlasStructDef; +import org.apache.atlas.repository.AtlasTestBase; import org.apache.atlas.repository.graph.AtlasGraphProvider; -import org.apache.atlas.runner.LocalSolrRunner; import org.apache.atlas.type.AtlasTypeUtil; import org.testng.Assert; import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; import org.testng.annotations.DataProvider; import org.testng.annotations.Guice; import org.testng.annotations.Test; -import static org.apache.atlas.graph.GraphSandboxUtil.useLocalSolr; import static org.testng.AssertJUnit.fail; /** * Tests for AtlasRelationshipStoreV1 */ @Guice(modules = TestModules.TestOnlyModule.class) -public class AtlasRelationshipDefStoreV2Test { +public class AtlasRelationshipDefStoreV2Test extends AtlasTestBase { @Inject private @@ -325,12 +325,16 @@ public class AtlasRelationshipDefStoreV2Test { } } } + + @BeforeClass + public void initialize() throws Exception { + super.initialize(); + } + @AfterClass public void clear() throws Exception { AtlasGraphProvider.cleanup(); - if (useLocalSolr()) { - LocalSolrRunner.stop(); - } + super.cleanup(); } } diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasRelationshipStoreV2Test.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasRelationshipStoreV2Test.java index 4cdd677..9099924 100644 --- a/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasRelationshipStoreV2Test.java +++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasRelationshipStoreV2Test.java @@ -30,6 +30,7 @@ import org.apache.atlas.model.instance.AtlasObjectId; import org.apache.atlas.model.instance.AtlasRelatedObjectId; import org.apache.atlas.model.instance.EntityMutationResponse; import org.apache.atlas.model.typedef.AtlasTypesDef; +import org.apache.atlas.repository.AtlasTestBase; import org.apache.atlas.repository.graph.AtlasGraphProvider; import org.apache.atlas.repository.graph.GraphBackedSearchIndexer; import org.apache.atlas.repository.graphdb.AtlasGraph; @@ -37,7 +38,6 @@ import org.apache.atlas.repository.store.bootstrap.AtlasTypeDefStoreInitializer; import org.apache.atlas.repository.store.graph.AtlasEntityStore; import org.apache.atlas.repository.store.graph.AtlasRelationshipStore; import org.apache.atlas.repository.store.graph.v1.DeleteHandlerDelegate; -import org.apache.atlas.runner.LocalSolrRunner; import org.apache.atlas.store.AtlasTypeDefStore; import org.apache.atlas.DeleteType; import org.apache.atlas.type.AtlasEntityType; @@ -61,7 +61,6 @@ import static org.apache.atlas.TestRelationshipUtilsV2.getDepartmentEmployeeInst import static org.apache.atlas.TestRelationshipUtilsV2.getDepartmentEmployeeTypes; import static org.apache.atlas.TestRelationshipUtilsV2.getInverseReferenceTestTypes; import static org.apache.atlas.TestUtilsV2.NAME; -import static org.apache.atlas.graph.GraphSandboxUtil.useLocalSolr; import static org.apache.atlas.type.AtlasTypeUtil.getAtlasObjectId; import static org.mockito.Mockito.mock; import static org.testng.Assert.assertEquals; @@ -70,7 +69,7 @@ import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; @Guice(modules = TestModules.TestOnlyModule.class) -public abstract class AtlasRelationshipStoreV2Test { +public abstract class AtlasRelationshipStoreV2Test extends AtlasTestBase { @Inject AtlasTypeRegistry typeRegistry; @@ -103,6 +102,8 @@ public abstract class AtlasRelationshipStoreV2Test { @BeforeClass public void setUp() throws Exception { + super.initialize(); + new GraphBackedSearchIndexer(typeRegistry); // create employee relationship types @@ -140,9 +141,7 @@ public abstract class AtlasRelationshipStoreV2Test { public void clear() throws Exception { AtlasGraphProvider.cleanup(); - if (useLocalSolr()) { - LocalSolrRunner.stop(); - } + super.cleanup(); } @Test diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/InverseReferenceUpdateV2Test.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/InverseReferenceUpdateV2Test.java index 36aedae..d01ea30 100644 --- a/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/InverseReferenceUpdateV2Test.java +++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/InverseReferenceUpdateV2Test.java @@ -29,10 +29,10 @@ import org.apache.atlas.model.instance.AtlasEntityHeader; import org.apache.atlas.model.instance.AtlasObjectId; import org.apache.atlas.model.instance.EntityMutationResponse; import org.apache.atlas.model.typedef.AtlasTypesDef; +import org.apache.atlas.repository.AtlasTestBase; import org.apache.atlas.repository.graph.AtlasGraphProvider; import org.apache.atlas.repository.store.bootstrap.AtlasTypeDefStoreInitializer; import org.apache.atlas.repository.store.graph.AtlasEntityStore; -import org.apache.atlas.runner.LocalSolrRunner; import org.apache.atlas.store.AtlasTypeDefStore; import org.apache.atlas.DeleteType; import org.apache.atlas.type.AtlasEntityType; @@ -50,7 +50,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import static org.apache.atlas.graph.GraphSandboxUtil.useLocalSolr; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; @@ -62,7 +61,7 @@ import static org.apache.atlas.TestUtilsV2.NAME; * */ @Guice(modules = TestModules.TestOnlyModule.class) -public abstract class InverseReferenceUpdateV2Test { +public abstract class InverseReferenceUpdateV2Test extends AtlasTestBase { @Inject AtlasTypeRegistry typeRegistry; @@ -86,6 +85,8 @@ public abstract class InverseReferenceUpdateV2Test { RequestContext.clear(); RequestContext.get().setUser(TestUtilsV2.TEST_USER, null); + super.initialize(); + AtlasTypesDef[] testTypesDefs = new AtlasTypesDef[] { TestUtilsV2.defineDeptEmployeeTypes(), TestUtilsV2.defineInverseReferenceTestTypes() }; @@ -110,9 +111,7 @@ public abstract class InverseReferenceUpdateV2Test { public void clear() throws Exception { AtlasGraphProvider.cleanup(); - if (useLocalSolr()) { - LocalSolrRunner.stop(); - } + super.cleanup(); } @BeforeMethod diff --git a/repository/src/test/java/org/apache/atlas/repository/tagpropagation/ClassificationPropagationTest.java b/repository/src/test/java/org/apache/atlas/repository/tagpropagation/ClassificationPropagationTest.java index 80e20be..84e9bfa 100644 --- a/repository/src/test/java/org/apache/atlas/repository/tagpropagation/ClassificationPropagationTest.java +++ b/repository/src/test/java/org/apache/atlas/repository/tagpropagation/ClassificationPropagationTest.java @@ -33,12 +33,12 @@ import org.apache.atlas.model.lineage.AtlasLineageInfo.LineageRelation; import org.apache.atlas.model.typedef.AtlasClassificationDef; import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef; import org.apache.atlas.model.typedef.AtlasTypesDef; +import org.apache.atlas.repository.AtlasTestBase; import org.apache.atlas.repository.graph.AtlasGraphProvider; import org.apache.atlas.repository.impexp.ImportService; import org.apache.atlas.repository.impexp.ZipFileResourceTestUtils; import org.apache.atlas.repository.store.graph.AtlasEntityStore; import org.apache.atlas.repository.store.graph.AtlasRelationshipStore; -import org.apache.atlas.runner.LocalSolrRunner; import org.apache.atlas.store.AtlasTypeDefStore; import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.commons.collections.CollectionUtils; @@ -60,7 +60,6 @@ import java.util.Map; import java.util.Set; import static org.apache.atlas.AtlasErrorCode.PROPAGATED_CLASSIFICATION_REMOVAL_NOT_SUPPORTED; -import static org.apache.atlas.graph.GraphSandboxUtil.useLocalSolr; import static org.apache.atlas.model.lineage.AtlasLineageInfo.LineageDirection; import static org.apache.atlas.model.typedef.AtlasRelationshipDef.PropagateTags.BOTH; import static org.apache.atlas.model.typedef.AtlasRelationshipDef.PropagateTags.NONE; @@ -74,7 +73,7 @@ import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; @Guice(modules = TestModules.TestOnlyModule.class) -public class ClassificationPropagationTest { +public class ClassificationPropagationTest extends AtlasTestBase { public static final String HDFS_PATH_EMPLOYEES = "HDFS_PATH_EMPLOYEES"; public static final String EMPLOYEES1_TABLE = "EMPLOYEES1_TABLE"; public static final String EMPLOYEES2_TABLE = "EMPLOYEES2_TABLE"; @@ -113,9 +112,11 @@ public class ClassificationPropagationTest { private AtlasLineageInfo lineageInfo; @BeforeClass - public void setup() { + public void setup() throws Exception { RequestContext.clear(); + super.initialize(); + loadModelFilesAndImportTestData(); } @@ -123,9 +124,7 @@ public class ClassificationPropagationTest { public void clear() throws Exception { AtlasGraphProvider.cleanup(); - if (useLocalSolr()) { - LocalSolrRunner.stop(); - } + super.cleanup(); } /** This test uses the lineage graph: diff --git a/repository/src/test/java/org/apache/atlas/repository/userprofile/UserProfileServiceTest.java b/repository/src/test/java/org/apache/atlas/repository/userprofile/UserProfileServiceTest.java index eeab3bc..3b76ee3 100644 --- a/repository/src/test/java/org/apache/atlas/repository/userprofile/UserProfileServiceTest.java +++ b/repository/src/test/java/org/apache/atlas/repository/userprofile/UserProfileServiceTest.java @@ -26,13 +26,14 @@ import org.apache.atlas.model.profile.AtlasUserProfile; import org.apache.atlas.model.profile.AtlasUserSavedSearch; import org.apache.atlas.model.typedef.AtlasEntityDef; import org.apache.atlas.model.typedef.AtlasTypesDef; +import org.apache.atlas.repository.AtlasTestBase; import org.apache.atlas.repository.graph.AtlasGraphProvider; import org.apache.atlas.repository.util.FilterUtil; -import org.apache.atlas.runner.LocalSolrRunner; import org.apache.atlas.store.AtlasTypeDefStore; import org.apache.atlas.type.AtlasType; import org.apache.atlas.type.AtlasTypeRegistry; import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Guice; import org.testng.annotations.Test; @@ -42,7 +43,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; -import static org.apache.atlas.graph.GraphSandboxUtil.useLocalSolr; import static org.apache.atlas.model.profile.AtlasUserSavedSearch.SavedSearchType.BASIC; import static org.apache.atlas.utils.TestLoadModelUtils.loadModelFromJson; import static org.testng.Assert.assertEquals; @@ -51,7 +51,7 @@ import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; @Guice(modules = TestModules.TestOnlyModule.class) -public class UserProfileServiceTest { +public class UserProfileServiceTest extends AtlasTestBase { private UserProfileService userProfileService; private AtlasTypeDefStore typeDefStore; @@ -68,13 +68,16 @@ public class UserProfileServiceTest { loadModelFromJson("0010-base_model.json", typeDefStore, typeRegistry); } + @BeforeClass + public void initialize() throws Exception { + super.initialize(); + } + @AfterClass public void clear() throws Exception { AtlasGraphProvider.cleanup(); - if (useLocalSolr()) { - LocalSolrRunner.stop(); - } + super.cleanup(); } @Test diff --git a/repository/src/test/java/org/apache/atlas/services/MetricsServiceTest.java b/repository/src/test/java/org/apache/atlas/services/MetricsServiceTest.java index 4739bca..bea8eb8 100644 --- a/repository/src/test/java/org/apache/atlas/services/MetricsServiceTest.java +++ b/repository/src/test/java/org/apache/atlas/services/MetricsServiceTest.java @@ -21,10 +21,10 @@ import org.apache.atlas.RequestContext; import org.apache.atlas.TestModules; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.model.metrics.AtlasMetrics; +import org.apache.atlas.repository.AtlasTestBase; import org.apache.atlas.repository.graph.AtlasGraphProvider; import org.apache.atlas.repository.impexp.ImportService; import org.apache.atlas.repository.impexp.ZipFileResourceTestUtils; -import org.apache.atlas.runner.LocalSolrRunner; import org.apache.atlas.store.AtlasTypeDefStore; import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.util.AtlasMetricsCounter; @@ -45,7 +45,6 @@ import java.time.ZoneOffset; import java.util.HashMap; import java.util.Map; -import static org.apache.atlas.graph.GraphSandboxUtil.useLocalSolr; import static org.apache.atlas.model.metrics.AtlasMetrics.*; import static org.apache.atlas.utils.TestLoadModelUtils.loadModelFromJson; import static org.apache.atlas.repository.impexp.ZipFileResourceTestUtils.runImportWithNoParameters; @@ -62,7 +61,7 @@ import static org.apache.atlas.services.MetricsService.TAG; import static org.testng.Assert.*; @Guice(modules = TestModules.TestOnlyModule.class) -public class MetricsServiceTest { +public class MetricsServiceTest extends AtlasTestBase { public static final String IMPORT_FILE = "metrics-entities-data.zip"; @@ -121,9 +120,11 @@ public class MetricsServiceTest { }}; @BeforeClass - public void setup() { + public void setup() throws Exception { RequestContext.clear(); + super.initialize(); + loadModelFilesAndImportTestData(); // sleep for sometime for import to complete @@ -142,9 +143,7 @@ public class MetricsServiceTest { public void clear() throws Exception { AtlasGraphProvider.cleanup(); - if (useLocalSolr()) { - LocalSolrRunner.stop(); - } + super.cleanup(); } @Test diff --git a/test-tools/pom.xml b/test-tools/pom.xml index 434d15c..7e38ad7 100644 --- a/test-tools/pom.xml +++ b/test-tools/pom.xml @@ -37,7 +37,7 @@ <dependency> <groupId>org.apache.solr</groupId> <artifactId>solr-test-framework</artifactId> - <version>7.0.0</version> + <version>${solr-test-framework.version}</version> <scope>compile</scope> <exclusions> <exclusion> @@ -75,6 +75,19 @@ <artifactId>commons-fileupload</artifactId> <version>1.3.3</version> </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>${junit.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.atlas</groupId> + <artifactId>atlas-intg</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> </dependencies> <build> diff --git a/test-tools/src/main/java/org/apache/atlas/runner/LocalSolrRunner.java b/test-tools/src/main/java/org/apache/atlas/runner/LocalSolrRunner.java index 2c79e2f..7feea09 100644 --- a/test-tools/src/main/java/org/apache/atlas/runner/LocalSolrRunner.java +++ b/test-tools/src/main/java/org/apache/atlas/runner/LocalSolrRunner.java @@ -14,7 +14,9 @@ package org.apache.atlas.runner; +import org.apache.atlas.ApplicationProperties; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.configuration.Configuration; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.ArrayUtils; @@ -43,6 +45,9 @@ public class LocalSolrRunner { private static final String TEMPLATE_DIRECTORY = "core-template"; protected static final String[] COLLECTIONS = readCollections(); + // from org.apache.atlas.repository.graphdb.janus.AtlasJanusGraphDatabase + public static final String SOLR_ZOOKEEPER_URL = "atlas.graph.index.search.solr.zookeeper-url"; + private static final Logger LOG = LoggerFactory.getLogger(LocalSolrRunner.class); private static MiniSolrCloudCluster miniSolrCloudCluster; @@ -78,6 +83,15 @@ public class LocalSolrRunner { LOG.info("Uploading solr configurations for core: '{}', configPath: '{}'", coreName, coreConfigPath); } + try { + Configuration configuration = ApplicationProperties.get(); + + configuration.clearProperty(SOLR_ZOOKEEPER_URL); + configuration.setProperty(SOLR_ZOOKEEPER_URL, LocalSolrRunner.getZookeeperUrls()); + } catch (Exception e) { + throw new RuntimeException("Failed to start embedded solr cloud server. Aborting!", e); + } + LOG.info("<== LocalSolrRunner.start()"); } @@ -160,4 +174,4 @@ public class LocalSolrRunner { System.out.println("Bad first argument: " + Arrays.toString(args)); } } -} \ No newline at end of file +} diff --git a/webapp/pom.xml b/webapp/pom.xml index ffc3d37..259820b 100755 --- a/webapp/pom.xml +++ b/webapp/pom.xml @@ -496,6 +496,11 @@ <version>${keycloak.version}</version> </dependency> + <dependency> + <groupId>org.apache.atlas</groupId> + <artifactId>atlas-testtools</artifactId> + <version>${project.version}</version> + </dependency> </dependencies> <build> diff --git a/webapp/src/test/java/org/apache/atlas/web/security/SSLAndKerberosTest.java b/webapp/src/test/java/org/apache/atlas/web/security/SSLAndKerberosTest.java index 417a19a..4384aa1 100755 --- a/webapp/src/test/java/org/apache/atlas/web/security/SSLAndKerberosTest.java +++ b/webapp/src/test/java/org/apache/atlas/web/security/SSLAndKerberosTest.java @@ -21,15 +21,11 @@ package org.apache.atlas.web.security; import org.apache.atlas.ApplicationProperties; import org.apache.atlas.AtlasClient; import org.apache.atlas.web.TestUtils; -import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.PropertiesConfiguration; import org.apache.hadoop.fs.Path; import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.security.alias.JavaKeyStoreProvider; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import org.junit.Ignore; import java.io.File; import java.io.IOException; import java.net.URL; -- libgit2 0.27.1