Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
atlas
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dataplatform
atlas
Commits
716afc53
Commit
716afc53
authored
Jan 03, 2018
by
Sarath Subramanian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2331: Provide option to start embedded Solr server for Integration Tests
parent
02a618af
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
307 additions
and
182 deletions
+307
-182
pom.xml
common/pom.xml
+0
-54
pom.xml
graphdb/janus/pom.xml
+16
-24
AtlasJanusGraphDatabase.java
...las/repository/graphdb/janus/AtlasJanusGraphDatabase.java
+46
-13
AbstractGraphDatabaseTest.java
...s/repository/graphdb/janus/AbstractGraphDatabaseTest.java
+1
-11
AtlasJanusDatabaseTest.java
...tlas/repository/graphdb/janus/AtlasJanusDatabaseTest.java
+1
-12
JanusGraphProviderTest.java
...tlas/repository/graphdb/janus/JanusGraphProviderTest.java
+0
-10
pom.xml
pom.xml
+25
-3
pom.xml
repository/pom.xml
+14
-24
pom.xml
test-tools/pom.xml
+100
-0
LocalSolrRunner.java
...rc/main/java/org/apache/atlas/runner/LocalSolrRunner.java
+68
-29
log4j.properties
test-tools/src/main/resources/log4j.properties
+34
-0
collections.txt
test-tools/src/main/resources/solr/collections.txt
+0
-0
currency.xml
...-tools/src/main/resources/solr/core-template/currency.xml
+0
-0
stopwords_en.txt
...c/main/resources/solr/core-template/lang/stopwords_en.txt
+0
-0
protwords.txt
...tools/src/main/resources/solr/core-template/protwords.txt
+0
-0
schema.xml
test-tools/src/main/resources/solr/core-template/schema.xml
+0
-0
solrconfig.xml
...ools/src/main/resources/solr/core-template/solrconfig.xml
+0
-0
stopwords.txt
...tools/src/main/resources/solr/core-template/stopwords.txt
+0
-0
synonyms.txt
...-tools/src/main/resources/solr/core-template/synonyms.txt
+0
-0
solr.xml
test-tools/src/main/resources/solr/solr.xml
+0
-0
EntityResource.java
...n/java/org/apache/atlas/web/resources/EntityResource.java
+1
-1
AdaptiveWaiterTest.java
...ava/org/apache/atlas/notification/AdaptiveWaiterTest.java
+1
-1
No files found.
common/pom.xml
View file @
716afc53
...
@@ -90,38 +90,6 @@
...
@@ -90,38 +90,6 @@
<artifactId>
atlas-intg
</artifactId>
<artifactId>
atlas-intg
</artifactId>
</dependency>
</dependency>
<!-- Local SolrRunner Dependencies-->
<dependency>
<groupId>
org.apache.solr
</groupId>
<artifactId>
solr-test-framework
</artifactId>
<version>
7.0.0
</version>
<scope>
compile
</scope>
<exclusions>
<exclusion>
<groupId>
org.codehaus.jackson
</groupId>
<artifactId>
*
</artifactId>
</exclusion>
<exclusion>
<groupId>
info.ganglia.gmetric4j
</groupId>
<artifactId>
gmetric4j
</artifactId>
</exclusion>
<exclusion>
<groupId>
org.slf4j
</groupId>
<artifactId>
jcl-over-slf4j
</artifactId>
</exclusion>
<exclusion>
<groupId>
com.github.ben-manes.caffeine
</groupId>
<artifactId>
caffeine
</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
com.vividsolutions
</groupId>
<artifactId>
jts
</artifactId>
<version>
1.13
</version>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
...
@@ -138,28 +106,6 @@
...
@@ -138,28 +106,6 @@
</execution>
</execution>
</executions>
</executions>
</plugin>
</plugin>
<plugin>
<artifactId>
maven-resources-plugin
</artifactId>
<version>
3.0.2
</version>
<executions>
<execution>
<id>
copy-resources
</id>
<phase>
validate
</phase>
<goals>
<goal>
copy-resources
</goal>
</goals>
<configuration>
<outputDirectory>
${basedir}/target/local_solr
</outputDirectory>
<resources>
<resource>
<directory>
src/test/resources
</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</plugins>
</build>
</build>
</project>
</project>
graphdb/janus/pom.xml
View file @
716afc53
...
@@ -54,6 +54,12 @@
...
@@ -54,6 +54,12 @@
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
org.apache.atlas
</groupId>
<artifactId>
atlas-testtools
</artifactId>
<version>
${project.version}
</version>
</dependency>
<dependency>
<groupId>
commons-configuration
</groupId>
<groupId>
commons-configuration
</groupId>
<artifactId>
commons-configuration
</artifactId>
<artifactId>
commons-configuration
</artifactId>
<scope>
provided
</scope>
<scope>
provided
</scope>
...
@@ -147,7 +153,6 @@
...
@@ -147,7 +153,6 @@
</dependency>
</dependency>
<!-- Test dependencies -->
<!-- Test dependencies -->
<dependency>
<dependency>
<groupId>
org.testng
</groupId>
<groupId>
org.testng
</groupId>
<artifactId>
testng
</artifactId>
<artifactId>
testng
</artifactId>
...
@@ -161,14 +166,6 @@
...
@@ -161,14 +166,6 @@
<scope>
test
</scope>
<scope>
test
</scope>
</dependency>
</dependency>
<dependency>
<groupId>
org.apache.atlas
</groupId>
<artifactId>
atlas-common
</artifactId>
<type>
test-jar
</type>
<version>
${project.version}
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
...
@@ -184,26 +181,21 @@
...
@@ -184,26 +181,21 @@
</plugin>
</plugin>
<plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-resources-plugin
</artifactId>
<artifactId>
maven-dependency-plugin
</artifactId>
<executions>
<executions>
<execution>
<execution>
<id>
unpack
</id>
<id>
copy-resources
</id>
<phase>
compil
e
</phase>
<phase>
validat
e
</phase>
<goals>
<goals>
<goal>
unpack
</goal>
<goal>
copy-resources
</goal>
</goals>
</goals>
<configuration>
<configuration>
<artifactItems>
<outputDirectory>
${project.build.directory}/solr
</outputDirectory>
<artifactItem>
<resources>
<groupId>
org.apache.atlas
</groupId>
<resource>
<artifactId>
atlas-common
</artifactId>
<directory>
${basedir}/../../test-tools/src/main/resources/solr
</directory>
<type>
test-jar
</type>
</resource>
<version>
${project.version}
</version>
</resources>
<excludes>
org/**, META-INF/**
</excludes>
<outputDirectory>
${project.build.directory}/local_solr
</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</configuration>
</execution>
</execution>
</executions>
</executions>
...
...
graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusGraphDatabase.java
View file @
716afc53
...
@@ -18,10 +18,6 @@
...
@@ -18,10 +18,6 @@
package
org
.
apache
.
atlas
.
repository
.
graphdb
.
janus
;
package
org
.
apache
.
atlas
.
repository
.
graphdb
.
janus
;
import
java.math.BigDecimal
;
import
java.math.BigInteger
;
import
java.util.ArrayList
;
import
org.apache.atlas.ApplicationProperties
;
import
org.apache.atlas.ApplicationProperties
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.repository.graphdb.AtlasGraph
;
import
org.apache.atlas.repository.graphdb.AtlasGraph
;
...
@@ -30,18 +26,20 @@ import org.apache.atlas.repository.graphdb.janus.serializer.BigDecimalSerializer
...
@@ -30,18 +26,20 @@ 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.BigIntegerSerializer
;
import
org.apache.atlas.repository.graphdb.janus.serializer.StringListSerializer
;
import
org.apache.atlas.repository.graphdb.janus.serializer.StringListSerializer
;
import
org.apache.atlas.repository.graphdb.janus.serializer.TypeCategorySerializer
;
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.typesystem.types.DataTypes.TypeCategory
;
import
org.apache.commons.configuration.Configuration
;
import
org.apache.commons.configuration.Configuration
;
import
org.apache.tinkerpop.gremlin.groovy.loaders.SugarLoader
;
import
org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper
;
import
org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.janusgraph.core.JanusGraphFactory
;
import
org.janusgraph.core.JanusGraph
;
import
org.janusgraph.core.JanusGraph
;
import
org.janusgraph.core.JanusGraphFactory
;
import
org.janusgraph.core.schema.JanusGraphManagement
;
import
org.janusgraph.core.schema.JanusGraphManagement
;
import
org.janusgraph.core.util.JanusGraphCleanup
;
import
org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry
;
import
org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.math.BigDecimal
;
import
java.math.BigInteger
;
import
java.util.ArrayList
;
/**
/**
* Default implementation for Graph Provider that doles out Titan Graph.
* Default implementation for Graph Provider that doles out Titan Graph.
...
@@ -54,11 +52,9 @@ public class AtlasJanusGraphDatabase implements GraphDatabase<AtlasJanusVertex,
...
@@ -54,11 +52,9 @@ public class AtlasJanusGraphDatabase implements GraphDatabase<AtlasJanusVertex,
* Constant for the configuration property that indicates the prefix.
* Constant for the configuration property that indicates the prefix.
*/
*/
public
static
final
String
GRAPH_PREFIX
=
"atlas.graph"
;
public
static
final
String
GRAPH_PREFIX
=
"atlas.graph"
;
public
static
final
String
INDEX_BACKEND_CONF
=
"index.search.backend"
;
public
static
final
String
INDEX_BACKEND_CONF
=
"index.search.backend"
;
public
static
final
String
SOLR_ZOOKEEPER_URL
=
"atlas.graph.index.search.solr.zookeeper-url"
;
public
static
final
String
INDEX_BACKEND_LUCENE
=
"lucene"
;
public
static
final
String
INDEX_BACKEND_LUCENE
=
"lucene"
;
public
static
final
String
INDEX_BACKEND_ES
=
"elasticsearch"
;
public
static
final
String
INDEX_BACKEND_ES
=
"elasticsearch"
;
private
static
volatile
AtlasJanusGraph
atlasGraphInstance
=
null
;
private
static
volatile
AtlasJanusGraph
atlasGraphInstance
=
null
;
...
@@ -71,6 +67,8 @@ public class AtlasJanusGraphDatabase implements GraphDatabase<AtlasJanusVertex,
...
@@ -71,6 +67,8 @@ public class AtlasJanusGraphDatabase implements GraphDatabase<AtlasJanusVertex,
}
}
public
static
Configuration
getConfiguration
()
throws
AtlasException
{
public
static
Configuration
getConfiguration
()
throws
AtlasException
{
startLocalSolr
();
Configuration
configProperties
=
ApplicationProperties
.
get
();
Configuration
configProperties
=
ApplicationProperties
.
get
();
Configuration
janusConfig
=
ApplicationProperties
.
getSubsetConfiguration
(
configProperties
,
GRAPH_PREFIX
);
Configuration
janusConfig
=
ApplicationProperties
.
getSubsetConfiguration
(
configProperties
,
GRAPH_PREFIX
);
...
@@ -166,6 +164,12 @@ public class AtlasJanusGraphDatabase implements GraphDatabase<AtlasJanusVertex,
...
@@ -166,6 +164,12 @@ public class AtlasJanusGraphDatabase implements GraphDatabase<AtlasJanusVertex,
LOG
.
warn
(
"Could not clear test JanusGraph"
,
t
);
LOG
.
warn
(
"Could not clear test JanusGraph"
,
t
);
t
.
printStackTrace
();
t
.
printStackTrace
();
}
}
try
{
LocalSolrRunner
.
stop
();
}
catch
(
Throwable
t
)
{
LOG
.
warn
(
"Could not stop local solr server"
,
t
);
}
}
}
@Override
@Override
...
@@ -173,4 +177,33 @@ public class AtlasJanusGraphDatabase implements GraphDatabase<AtlasJanusVertex,
...
@@ -173,4 +177,33 @@ public class AtlasJanusGraphDatabase implements GraphDatabase<AtlasJanusVertex,
getGraphInstance
();
getGraphInstance
();
return
atlasGraphInstance
;
return
atlasGraphInstance
;
}
}
private
static
void
startLocalSolr
()
{
if
(
isEmbeddedSolr
())
{
try
{
LocalSolrRunner
.
start
();
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
);
}
}
}
public
static
boolean
isEmbeddedSolr
()
{
boolean
ret
=
false
;
try
{
Configuration
conf
=
ApplicationProperties
.
get
();
Object
property
=
conf
.
getProperty
(
"atlas.graph.index.search.solr.embedded"
);
if
(
property
!=
null
&&
property
instanceof
String
)
{
ret
=
Boolean
.
valueOf
((
String
)
property
);
}
}
catch
(
AtlasException
ignored
)
{
}
return
ret
;
}
}
}
graphdb/janus/src/test/java/org/apache/atlas/repository/graphdb/janus/AbstractGraphDatabaseTest.java
View file @
716afc53
...
@@ -25,7 +25,6 @@ import org.apache.atlas.repository.graphdb.AtlasGraph;
...
@@ -25,7 +25,6 @@ import org.apache.atlas.repository.graphdb.AtlasGraph;
import
org.apache.atlas.repository.graphdb.AtlasGraphManagement
;
import
org.apache.atlas.repository.graphdb.AtlasGraphManagement
;
import
org.apache.atlas.repository.graphdb.AtlasPropertyKey
;
import
org.apache.atlas.repository.graphdb.AtlasPropertyKey
;
import
org.apache.atlas.repository.graphdb.AtlasVertex
;
import
org.apache.atlas.repository.graphdb.AtlasVertex
;
import
org.apache.atlas.runner.LocalSolrRunner
;
import
org.testng.annotations.AfterClass
;
import
org.testng.annotations.AfterClass
;
import
org.testng.annotations.AfterMethod
;
import
org.testng.annotations.AfterMethod
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.BeforeClass
;
...
@@ -34,7 +33,6 @@ import java.util.ArrayList;
...
@@ -34,7 +33,6 @@ import java.util.ArrayList;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
import
static
org
.
apache
.
atlas
.
graph
.
GraphSandboxUtil
.
useLocalSolr
;
/**
/**
*
*
...
@@ -52,10 +50,6 @@ public abstract class AbstractGraphDatabaseTest {
...
@@ -52,10 +50,6 @@ public abstract class AbstractGraphDatabaseTest {
@BeforeClass
@BeforeClass
public
static
void
createIndices
()
throws
Exception
{
public
static
void
createIndices
()
throws
Exception
{
if
(
useLocalSolr
())
{
LocalSolrRunner
.
start
();
}
GraphSandboxUtil
.
create
();
GraphSandboxUtil
.
create
();
AtlasJanusGraphDatabase
db
=
new
AtlasJanusGraphDatabase
();
AtlasJanusGraphDatabase
db
=
new
AtlasJanusGraphDatabase
();
...
@@ -86,13 +80,9 @@ public abstract class AbstractGraphDatabaseTest {
...
@@ -86,13 +80,9 @@ public abstract class AbstractGraphDatabaseTest {
}
}
@AfterClass
@AfterClass
public
static
void
cleanUp
()
throws
Exception
{
public
static
void
cleanUp
()
{
AtlasJanusGraph
graph
=
new
AtlasJanusGraph
();
AtlasJanusGraph
graph
=
new
AtlasJanusGraph
();
graph
.
clear
();
graph
.
clear
();
if
(
useLocalSolr
())
{
LocalSolrRunner
.
stop
();
}
}
}
protected
<
V
,
E
>
void
pushChangesAndFlushCache
()
{
protected
<
V
,
E
>
void
pushChangesAndFlushCache
()
{
...
...
graphdb/janus/src/test/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusDatabaseTest.java
View file @
716afc53
...
@@ -75,23 +75,12 @@ public class AtlasJanusDatabaseTest {
...
@@ -75,23 +75,12 @@ public class AtlasJanusDatabaseTest {
return
(
AtlasGraph
<
V
,
E
>)
atlasGraph
;
return
(
AtlasGraph
<
V
,
E
>)
atlasGraph
;
}
}
@BeforeClass
public
void
start
()
throws
Exception
{
if
(
useLocalSolr
())
{
LocalSolrRunner
.
start
();
}
}
@AfterClass
@AfterClass
public
void
cleanup
()
throws
Exception
{
public
void
cleanup
()
{
if
(
atlasGraph
!=
null
)
{
if
(
atlasGraph
!=
null
)
{
atlasGraph
.
clear
();
atlasGraph
.
clear
();
atlasGraph
=
null
;
atlasGraph
=
null
;
}
}
if
(
useLocalSolr
())
{
LocalSolrRunner
.
stop
();
}
}
}
@Test
@Test
...
...
graphdb/janus/src/test/java/org/apache/atlas/repository/graphdb/janus/JanusGraphProviderTest.java
View file @
716afc53
...
@@ -21,14 +21,12 @@ import org.apache.atlas.ApplicationProperties;
...
@@ -21,14 +21,12 @@ import org.apache.atlas.ApplicationProperties;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.graph.GraphSandboxUtil
;
import
org.apache.atlas.graph.GraphSandboxUtil
;
import
org.apache.atlas.repository.graphdb.AtlasGraph
;
import
org.apache.atlas.repository.graphdb.AtlasGraph
;
import
org.apache.atlas.runner.LocalSolrRunner
;
import
org.apache.commons.configuration.Configuration
;
import
org.apache.commons.configuration.Configuration
;
import
org.testng.Assert
;
import
org.testng.Assert
;
import
org.testng.annotations.AfterClass
;
import
org.testng.annotations.AfterClass
;
import
org.testng.annotations.BeforeTest
;
import
org.testng.annotations.BeforeTest
;
import
org.testng.annotations.Test
;
import
org.testng.annotations.Test
;
import
static
org
.
apache
.
atlas
.
graph
.
GraphSandboxUtil
.
useLocalSolr
;
@Test
@Test
public
class
JanusGraphProviderTest
{
public
class
JanusGraphProviderTest
{
...
@@ -38,10 +36,6 @@ public class JanusGraphProviderTest {
...
@@ -38,10 +36,6 @@ public class JanusGraphProviderTest {
@BeforeTest
@BeforeTest
public
void
setUp
()
throws
Exception
{
public
void
setUp
()
throws
Exception
{
if
(
useLocalSolr
())
{
LocalSolrRunner
.
start
();
}
GraphSandboxUtil
.
create
();
GraphSandboxUtil
.
create
();
//First get Instance
//First get Instance
...
@@ -62,10 +56,6 @@ public class JanusGraphProviderTest {
...
@@ -62,10 +56,6 @@ public class JanusGraphProviderTest {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
if
(
useLocalSolr
())
{
LocalSolrRunner
.
stop
();
}
}
}
@Test
@Test
...
...
pom.xml
View file @
716afc53
...
@@ -590,9 +590,9 @@
...
@@ -590,9 +590,9 @@
<entity.repository.impl>
org.apache.atlas.repository.audit.InMemoryEntityAuditRepository
</entity.repository.impl>
<entity.repository.impl>
org.apache.atlas.repository.audit.InMemoryEntityAuditRepository
</entity.repository.impl>
<surefire.version>
2.
20
.1
</surefire.version>
<surefire.version>
2.
18
.1
</surefire.version>
<surefire.forkCount>
2C
</surefire.forkCount>
<surefire.forkCount>
2C
</surefire.forkCount>
<failsafe.version>
2.
20
.1
</failsafe.version>
<failsafe.version>
2.
18
.1
</failsafe.version>
<atlas.surefire.options></atlas.surefire.options>
<atlas.surefire.options></atlas.surefire.options>
<aspectj.runtime.version>
1.8.7
</aspectj.runtime.version>
<aspectj.runtime.version>
1.8.7
</aspectj.runtime.version>
...
@@ -657,7 +657,7 @@
...
@@ -657,7 +657,7 @@
<graphdb.backend.impl>
org.apache.atlas.repository.graphdb.janus.AtlasJanusGraphDatabase
</graphdb.backend.impl>
<graphdb.backend.impl>
org.apache.atlas.repository.graphdb.janus.AtlasJanusGraphDatabase
</graphdb.backend.impl>
<graph.index.backend>
solr
</graph.index.backend>
<graph.index.backend>
solr
</graph.index.backend>
<tests.solr.embedded>
true
</tests.solr.embedded>
<tests.solr.embedded>
true
</tests.solr.embedded>
<distro.exclude.packages>
WEB-INF/lib/je-*.jar,WEB-INF/lib/elasticsearch-*.jar
</distro.exclude.packages>
<distro.exclude.packages>
WEB-INF/lib/je-*.jar,WEB-INF/lib/elasticsearch-*.jar
,WEB-INF/lib/solr-test-framework-*.jar
</distro.exclude.packages>
</properties>
</properties>
</profile>
</profile>
...
@@ -712,6 +712,7 @@
...
@@ -712,6 +712,7 @@
<modules>
<modules>
<module>
build-tools
</module>
<module>
build-tools
</module>
<module>
test-tools
</module>
<module>
intg
</module>
<module>
intg
</module>
<module>
common
</module>
<module>
common
</module>
<module>
server-api
</module>
<module>
server-api
</module>
...
@@ -2123,6 +2124,27 @@
...
@@ -2123,6 +2124,27 @@
<skipAssembly>
true
</skipAssembly>
<skipAssembly>
true
</skipAssembly>
</configuration>
</configuration>
</plugin>
</plugin>
<plugin>
<artifactId>
maven-resources-plugin
</artifactId>
<executions>
<execution>
<id>
copy-resources
</id>
<phase>
validate
</phase>
<goals>
<goal>
copy-resources
</goal>
</goals>
<configuration>
<outputDirectory>
${project.build.directory}/solr
</outputDirectory>
<resources>
<resource>
<directory>
${basedir}/test-tools/src/main/resources/solr
</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</plugins>
</build>
</build>
</project>
</project>
repository/pom.xml
View file @
716afc53
...
@@ -164,10 +164,8 @@
...
@@ -164,10 +164,8 @@
<dependencies>
<dependencies>
<dependency>
<dependency>
<groupId>
org.apache.atlas
</groupId>
<groupId>
org.apache.atlas
</groupId>
<artifactId>
atlas-common
</artifactId>
<artifactId>
atlas-testtools
</artifactId>
<type>
test-jar
</type>
<version>
${project.version}
</version>
<version>
${project.version}
</version>
<scope>
test
</scope>
<exclusions>
<exclusions>
<exclusion>
<exclusion>
<groupId>
com.fasterxml.jackson.core
</groupId>
<groupId>
com.fasterxml.jackson.core
</groupId>
...
@@ -189,10 +187,8 @@
...
@@ -189,10 +187,8 @@
<dependencies>
<dependencies>
<dependency>
<dependency>
<groupId>
org.apache.atlas
</groupId>
<groupId>
org.apache.atlas
</groupId>
<artifactId>
atlas-common
</artifactId>
<artifactId>
atlas-testtools
</artifactId>
<type>
test-jar
</type>
<version>
${project.version}
</version>
<version>
${project.version}
</version>
<scope>
test
</scope>
<exclusions>
<exclusions>
<exclusion>
<exclusion>
<groupId>
com.fasterxml.jackson.core
</groupId>
<groupId>
com.fasterxml.jackson.core
</groupId>
...
@@ -214,10 +210,8 @@
...
@@ -214,10 +210,8 @@
<dependencies>
<dependencies>
<dependency>
<dependency>
<groupId>
org.apache.atlas
</groupId>
<groupId>
org.apache.atlas
</groupId>
<artifactId>
atlas-common
</artifactId>
<artifactId>
atlas-testtools
</artifactId>
<type>
test-jar
</type>
<version>
${project.version}
</version>
<version>
${project.version}
</version>
<scope>
test
</scope>
<exclusions>
<exclusions>
<exclusion>
<exclusion>
<groupId>
org.apache.lucene
</groupId>
<groupId>
org.apache.lucene
</groupId>
...
@@ -257,27 +251,23 @@
...
@@ -257,27 +251,23 @@
</properties>
</properties>
</configuration>
</configuration>
</plugin>
</plugin>
<plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-resources-plugin
</artifactId>
<artifactId>
maven-dependency-plugin
</artifactId>
<executions>
<executions>
<execution>
<execution>
<id>
unpack
</id>
<id>
copy-resources
</id>
<phase>
compil
e
</phase>
<phase>
validat
e
</phase>
<goals>
<goals>
<goal>
unpack
</goal>
<goal>
copy-resources
</goal>
</goals>
</goals>
<configuration>
<configuration>
<artifactItems>
<outputDirectory>
${project.build.directory}/solr
</outputDirectory>
<artifactItem>
<resources>
<groupId>
org.apache.atlas
</groupId>
<resource>
<artifactId>
atlas-common
</artifactId>
<directory>
${basedir}/../test-tools/src/main/resources/solr
</directory>
<type>
test-jar
</type>
</resource>
<version>
${project.version}
</version>
</resources>
<excludes>
org/**, META-INF/**
</excludes>
<outputDirectory>
${project.build.directory}/local_solr
</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</configuration>
</execution>
</execution>
</executions>
</executions>
...
...
test-tools/pom.xml
0 → 100644
View file @
716afc53
<?xml version="1.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.
-->
<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"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
org.apache.atlas
</groupId>
<artifactId>
apache-atlas
</artifactId>
<version>
1.0.0-SNAPSHOT
</version>
</parent>
<artifactId>
atlas-testtools
</artifactId>
<name>
Apache Atlas Test Utility Tools
</name>
<packaging>
jar
</packaging>
<dependencies>
<!-- LocalSolrRunner Dependency-->
<dependency>
<groupId>
org.apache.solr
</groupId>
<artifactId>
solr-test-framework
</artifactId>
<version>
7.0.0
</version>
<scope>
compile
</scope>
<exclusions>
<exclusion>
<groupId>
org.codehaus.jackson
</groupId>
<artifactId>
*
</artifactId>
</exclusion>
<exclusion>
<groupId>
info.ganglia.gmetric4j
</groupId>
<artifactId>
gmetric4j
</artifactId>
</exclusion>
<exclusion>
<groupId>
org.slf4j
</groupId>
<artifactId>
jcl-over-slf4j
</artifactId>
</exclusion>
<exclusion>
<groupId>
com.github.ben-manes.caffeine
</groupId>
<artifactId>
caffeine
</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
com.vividsolutions
</groupId>
<artifactId>
jts
</artifactId>
<version>
1.13
</version>
</dependency>
<dependency>
<groupId>
commons-configuration
</groupId>
<artifactId>
commons-configuration
</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>
maven-resources-plugin
</artifactId>
<executions>
<execution>
<id>
copy-resources
</id>
<phase>
validate
</phase>
<goals>
<goal>
copy-resources
</goal>
</goals>
<configuration>
<outputDirectory>
${basedir}/target/solr
</outputDirectory>
<resources>
<resource>
<directory>
${basedir}/target/classes/solr
</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
common/src/test
/java/org/apache/atlas/runner/LocalSolrRunner.java
→
test-tools/src/main
/java/org/apache/atlas/runner/LocalSolrRunner.java
View file @
716afc53
...
@@ -14,9 +14,10 @@
...
@@ -14,9 +14,10 @@
package
org
.
apache
.
atlas
.
runner
;
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.FileUtils
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.lang.ArrayUtils
;
import
org.apache.solr.cloud.MiniSolrCloudCluster
;
import
org.apache.solr.cloud.MiniSolrCloudCluster
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -27,7 +28,6 @@ import java.io.IOException;
...
@@ -27,7 +28,6 @@ import java.io.IOException;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.io.InputStreamReader
;
import
java.nio.charset.Charset
;
import
java.nio.charset.Charset
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.nio.file.Paths
;
import
java.util.UUID
;
import
java.util.UUID
;
...
@@ -35,32 +35,32 @@ import java.util.regex.Pattern;
...
@@ -35,32 +35,32 @@ import java.util.regex.Pattern;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
public
class
LocalSolrRunner
{
public
class
LocalSolrRunner
{
protected
static
final
String
[]
COLLECTIONS
=
readCollections
();
protected
static
final
String
[]
COLLECTIONS
=
readCollections
();
private
static
final
String
TARGET_DIRECTORY
=
System
.
getProperty
(
"user.dir"
)
+
File
.
separator
+
"target"
;
private
static
final
String
COLLECTIONS_FILE
=
"collections.txt"
;
private
static
final
String
SOLR_XML
=
"solr.xml"
;
private
static
final
String
TEMPLATE_DIRECTORY
=
"core-template"
;
private
static
final
String
TEMPLATE_DIRECTORY
=
"core-template"
;
private
static
final
String
TARGET_DIRECTORY
=
System
.
getProperty
(
"user.dir"
)
+
"/target"
;
private
static
final
String
COLLECTIONS_FILE
=
"/collections.txt"
;
public
static
final
String
ZOOKEEPER_URLS
=
System
.
getProperty
(
"index.search.solr.zookeeper-url"
);
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
LocalSolrRunner
.
class
);
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
LocalSolrRunner
.
class
);
private
static
MiniSolrCloudCluster
miniSolrCloudCluster
;
private
static
MiniSolrCloudCluster
miniSolrCloudCluster
;
public
static
void
start
()
throws
Exception
{
public
static
void
start
()
throws
Exception
{
if
(
ZOOKEEPER_URLS
!=
null
)
{
if
(
isLocalSolrRunning
()
)
{
return
;
return
;
}
}
String
solrHome
=
TARGET_DIRECTORY
+
"/local_solr/solr"
;
LOG
.
info
(
"==> LocalSolrRunner.start()"
);
File
templateDirectory
=
new
File
(
solrHome
+
File
.
separator
+
TEMPLATE_DIRECTORY
);
File
temp
=
new
File
(
TARGET_DIRECTORY
+
"/data/index/"
+
getRandomString
());
File
templateDirectory
=
new
File
(
TARGET_DIRECTORY
+
File
.
separator
+
"solr"
+
File
.
separator
+
TEMPLATE_DIRECTORY
);
File
temp
=
new
File
(
TARGET_DIRECTORY
+
File
.
separator
+
"data"
+
File
.
separator
+
"index"
+
File
.
separator
+
getRandomString
());
temp
.
mkdirs
();
temp
.
mkdirs
();
temp
.
deleteOnExit
();
temp
.
deleteOnExit
();
final
String
solrXml
=
readXmlFile
(
solrHome
+
"/solr.xml"
,
Charset
.
forName
(
"UTF-8"
)
);
miniSolrCloudCluster
=
new
MiniSolrCloudCluster
(
1
,
null
,
temp
.
toPath
(),
readSolrXml
(),
null
,
null
);
miniSolrCloudCluster
=
new
MiniSolrCloudCluster
(
1
,
null
,
temp
.
toPath
(),
solrXml
,
null
,
null
);
LOG
.
info
(
"Started local solr server at: "
+
getZookeeperUrls
()
);
for
(
String
coreName
:
COLLECTIONS
)
{
for
(
String
coreName
:
COLLECTIONS
)
{
File
coreDirectory
=
new
File
(
temp
.
getAbsolutePath
()
+
File
.
separator
+
coreName
);
File
coreDirectory
=
new
File
(
temp
.
getAbsolutePath
()
+
File
.
separator
+
coreName
);
...
@@ -72,32 +72,39 @@ public class LocalSolrRunner {
...
@@ -72,32 +72,39 @@ public class LocalSolrRunner {
Path
coreConfigPath
=
Paths
.
get
(
coreDirectory
.
getAbsolutePath
());
Path
coreConfigPath
=
Paths
.
get
(
coreDirectory
.
getAbsolutePath
());
miniSolrCloudCluster
.
uploadConfigSet
(
coreConfigPath
,
coreName
);
miniSolrCloudCluster
.
uploadConfigSet
(
coreConfigPath
,
coreName
);
}
Configuration
configuration
=
ApplicationProperties
.
get
();
LOG
.
info
(
"Uploading solr configurations for core: '{}', configPath: '{}'"
,
coreName
,
coreConfigPath
);
configuration
.
setProperty
(
"atlas.graph.index.search.solr.zookeeper-url"
,
getZookeeperUrls
());
}
}
public
static
String
getZookeeperUrls
()
{
LOG
.
info
(
"<== LocalSolrRunner.start()"
);
final
String
zookeeperUrls
;
if
(
ZOOKEEPER_URLS
==
null
)
{
zookeeperUrls
=
miniSolrCloudCluster
.
getZkServer
().
getZkAddress
();
}
else
{
zookeeperUrls
=
ZOOKEEPER_URLS
;
}
return
zookeeperUrls
;
}
}
public
static
void
stop
()
throws
Exception
{
public
static
void
stop
()
throws
Exception
{
if
(
ZOOKEEPER_URLS
!=
null
)
{
if
(
!
isLocalSolrRunning
()
)
{
return
;
return
;
}
}
System
.
clearProperty
(
"solr.solrxml.location"
);
System
.
clearProperty
(
"solr.solrxml.location"
);
System
.
clearProperty
(
"zkHost"
);
System
.
clearProperty
(
"zkHost"
);
miniSolrCloudCluster
.
shutdown
();
}
public
static
String
getZookeeperUrls
()
{
return
miniSolrCloudCluster
.
getZkServer
().
getZkAddress
();
}
public
static
boolean
isLocalSolrRunning
()
{
boolean
ret
=
false
;
if
(
miniSolrCloudCluster
!=
null
)
{
ret
=
CollectionUtils
.
isNotEmpty
(
miniSolrCloudCluster
.
getJettySolrRunners
());
}
return
ret
;
}
}
private
static
String
[]
readCollections
()
{
private
static
String
[]
readCollections
()
{
try
(
InputStream
inputStream
=
LocalSolrRunner
.
class
.
getResourceAsStream
(
"/solr"
+
COLLECTIONS_FILE
);
try
(
InputStream
inputStream
=
LocalSolrRunner
.
class
.
getResourceAsStream
(
"/solr"
+
File
.
separator
+
COLLECTIONS_FILE
);
BufferedReader
buffer
=
new
BufferedReader
(
new
InputStreamReader
(
inputStream
)))
{
BufferedReader
buffer
=
new
BufferedReader
(
new
InputStreamReader
(
inputStream
)))
{
return
Pattern
.
compile
(
"\\s+"
).
split
(
buffer
.
lines
().
collect
(
Collectors
.
joining
(
"\n"
)));
return
Pattern
.
compile
(
"\\s+"
).
split
(
buffer
.
lines
().
collect
(
Collectors
.
joining
(
"\n"
)));
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
...
@@ -105,13 +112,44 @@ public class LocalSolrRunner {
...
@@ -105,13 +112,44 @@ public class LocalSolrRunner {
}
}
}
}
public
static
String
readXmlFile
(
String
path
,
Charset
encoding
)
throws
IOException
{
private
static
String
readSolrXml
()
throws
IOException
{
byte
[]
encoded
=
Files
.
readAllBytes
(
Paths
.
get
(
path
));
InputStream
inputStream
=
getClassLoader
().
getResourceAsStream
(
"solr"
+
File
.
separator
+
SOLR_XML
);
return
new
String
(
encoded
,
encoding
);
if
(
inputStream
==
null
)
{
throw
new
RuntimeException
(
"Unable to read solr xml"
);
}
return
IOUtils
.
toString
(
inputStream
,
Charset
.
forName
(
"UTF-8"
));
}
private
static
ClassLoader
getClassLoader
()
{
return
Thread
.
currentThread
().
getContextClassLoader
();
}
}
private
static
String
getRandomString
()
{
private
static
String
getRandomString
()
{
return
UUID
.
randomUUID
().
toString
();
return
UUID
.
randomUUID
().
toString
();
}
}
public
static
void
main
(
String
[]
args
)
{
if
(
ArrayUtils
.
isEmpty
(
args
))
{
System
.
out
.
println
(
"No arguments!"
);
}
else
if
(
args
[
0
].
equals
(
"start"
))
{
try
{
start
();
System
.
out
.
println
(
"Started Local Solr Server: "
+
getZookeeperUrls
());
}
catch
(
Exception
e
)
{
//do nothing
}
}
else
if
(
args
[
0
].
equals
(
"stop"
))
{
try
{
stop
();
System
.
out
.
println
(
"Shutting Local Solr Server."
);
}
catch
(
Exception
e
)
{
//do nothing
}
}
else
{
System
.
out
.
println
(
"Bad arguments!"
);
}
}
}
}
\ No newline at end of file
test-tools/src/main/resources/log4j.properties
0 → 100644
View file @
716afc53
#
# 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.
# A1 is set to be a FileAppender.
log4j.appender.A1
=
org.apache.log4j.FileAppender
log4j.appender.A1.File
=
target/test.log
log4j.appender.A1.Threshold
=
ALL
# A1 uses PatternLayout.
log4j.appender.A1.layout
=
org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern
=
%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5p %c{2}: %m%n
# A2 is a ConsoleAppender.
log4j.appender.A2
=
org.apache.log4j.ConsoleAppender
log4j.appender.A2.Threshold
=
ALL
# A2 uses PatternLayout.
log4j.appender.A2.layout
=
org.apache.log4j.PatternLayout
log4j.appender.A2.layout.ConversionPattern
=
%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5p %c{2}: %m%n
# Set both appenders (A1 and A2) on the root logger.
#log4j.rootLogger=INFO, A1, A2
log4j.rootLogger
=
ERROR, A1
common/src/test
/resources/solr/collections.txt
→
test-tools/src/main
/resources/solr/collections.txt
View file @
716afc53
File moved
common/src/test
/resources/solr/core-template/currency.xml
→
test-tools/src/main
/resources/solr/core-template/currency.xml
View file @
716afc53
File moved
common/src/test
/resources/solr/core-template/lang/stopwords_en.txt
→
test-tools/src/main
/resources/solr/core-template/lang/stopwords_en.txt
View file @
716afc53
File moved
common/src/test
/resources/solr/core-template/protwords.txt
→
test-tools/src/main
/resources/solr/core-template/protwords.txt
View file @
716afc53
File moved
common/src/test
/resources/solr/core-template/schema.xml
→
test-tools/src/main
/resources/solr/core-template/schema.xml
View file @
716afc53
File moved
common/src/test
/resources/solr/core-template/solrconfig.xml
→
test-tools/src/main
/resources/solr/core-template/solrconfig.xml
View file @
716afc53
File moved
common/src/test
/resources/solr/core-template/stopwords.txt
→
test-tools/src/main
/resources/solr/core-template/stopwords.txt
View file @
716afc53
File moved
common/src/test
/resources/solr/core-template/synonyms.txt
→
test-tools/src/main
/resources/solr/core-template/synonyms.txt
View file @
716afc53
File moved
common/src/test
/resources/solr/solr.xml
→
test-tools/src/main
/resources/solr/solr.xml
View file @
716afc53
File moved
webapp/src/main/java/org/apache/atlas/web/resources/EntityResource.java
View file @
716afc53
...
@@ -149,7 +149,7 @@ public class EntityResource {
...
@@ -149,7 +149,7 @@ public class EntityResource {
jsonStrings
=
new
String
[
jsonEntities
.
size
()];
jsonStrings
=
new
String
[
jsonEntities
.
size
()];
for
(
int
i
=
0
;
i
<
jsonEntities
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
jsonEntities
.
size
();
i
++)
{
jsonStrings
[
i
]
=
AtlasJson
.
toV1Json
(
jsonEntities
.
get
(
i
)
);
jsonStrings
[
i
]
=
jsonEntities
.
get
(
i
).
textValue
(
);
}
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
jsonStrings
=
new
String
[
1
];
jsonStrings
=
new
String
[
1
];
...
...
webapp/src/test/java/org/apache/atlas/notification/AdaptiveWaiterTest.java
View file @
716afc53
...
@@ -42,7 +42,7 @@ public class AdaptiveWaiterTest {
...
@@ -42,7 +42,7 @@ public class AdaptiveWaiterTest {
waiter
.
pause
(
new
IllegalStateException
());
waiter
.
pause
(
new
IllegalStateException
());
}
}
assertEquals
(
waiter
.
waitDuration
,
Math
.
min
((
pauseCount
+
1
)
*
minDuration
,
maxDuration
));
// waiter.waitDuration will be set to wait time for next pause()
assertEquals
(
waiter
.
waitDuration
,
Math
.
min
((
pauseCount
-
1
)
*
minDuration
,
maxDuration
));
// waiter.waitDuration will be set to wait time for next pause()
}
}
@Test
@Test
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment