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
bd513f25
Commit
bd513f25
authored
Sep 29, 2017
by
apoorvnaik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1954: Integration tests for Basic search
parent
c08bac80
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
795 additions
and
28 deletions
+795
-28
AtlasClientTest.java
...nt-v1/src/test/java/org/apache/atlas/AtlasClientTest.java
+3
-0
AtlasBaseClient.java
...ommon/src/main/java/org/apache/atlas/AtlasBaseClient.java
+48
-7
pom.xml
client/pom.xml
+5
-0
pom.xml
pom.xml
+1
-0
EntityDiscoveryServiceTest.java
...rg/apache/atlas/discovery/EntityDiscoveryServiceTest.java
+19
-0
ZipFileResourceTestUtils.java
...che/atlas/repository/impexp/ZipFileResourceTestUtils.java
+7
-21
TestResourceFileUtils.java
...st/java/org/apache/atlas/utils/TestResourceFileUtils.java
+90
-0
BasicSearchIT.java
.../java/org/apache/atlas/web/integration/BasicSearchIT.java
+176
-0
DefaultDB-3-New.zip
webapp/src/test/resources/DefaultDB-3-New.zip
+0
-0
hive-db-50-tables.zip
webapp/src/test/resources/hive-db-50-tables.zip
+0
-0
combination-filters.json
...resources/json/search-parameters/combination-filters.json
+186
-0
entity-filters.json
...test/resources/json/search-parameters/entity-filters.json
+243
-0
tag-filters.json
...rc/test/resources/json/search-parameters/tag-filters.json
+17
-0
No files found.
client/client-v1/src/test/java/org/apache/atlas/AtlasClientTest.java
View file @
bd513f25
...
...
@@ -33,6 +33,7 @@ import org.mockito.MockitoAnnotations;
import
org.testng.annotations.BeforeMethod
;
import
org.testng.annotations.Test
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.core.UriBuilder
;
import
java.net.ConnectException
;
...
...
@@ -436,7 +437,9 @@ public class AtlasClientTest {
when
(
resourceObject
.
getRequestBuilder
()).
thenReturn
(
resourceBuilderMock
);
when
(
resourceObject
.
path
(
anyString
())).
thenReturn
(
resourceObject
);
when
(
resourceBuilderMock
.
accept
(
AtlasBaseClient
.
JSON_MEDIA_TYPE
)).
thenReturn
(
resourceBuilderMock
);
when
(
resourceBuilderMock
.
accept
(
MediaType
.
APPLICATION_JSON
)).
thenReturn
(
resourceBuilderMock
);
when
(
resourceBuilderMock
.
type
(
AtlasBaseClient
.
JSON_MEDIA_TYPE
)).
thenReturn
(
resourceBuilderMock
);
when
(
resourceBuilderMock
.
type
(
MediaType
.
MULTIPART_FORM_DATA
)).
thenReturn
(
resourceBuilderMock
);
return
resourceBuilderMock
;
}
...
...
client/common/src/main/java/org/apache/atlas/AtlasBaseClient.java
View file @
bd513f25
...
...
@@ -27,8 +27,14 @@ import com.sun.jersey.api.client.config.DefaultClientConfig;
import
com.sun.jersey.api.client.filter.HTTPBasicAuthFilter
;
import
com.sun.jersey.api.json.JSONConfiguration
;
import
com.sun.jersey.client.urlconnection.URLConnectionClientHandler
;
import
com.sun.jersey.multipart.FormDataMultiPart
;
import
com.sun.jersey.multipart.MultiPart
;
import
com.sun.jersey.multipart.file.FileDataBodyPart
;
import
org.apache.atlas.model.impexp.AtlasImportRequest
;
import
org.apache.atlas.model.impexp.AtlasImportResult
;
import
org.apache.atlas.model.metrics.AtlasMetrics
;
import
org.apache.atlas.security.SecureClientUtils
;
import
org.apache.atlas.type.AtlasType
;
import
org.apache.atlas.utils.AuthenticationUtil
;
import
org.apache.commons.configuration.Configuration
;
import
org.apache.commons.lang.StringUtils
;
...
...
@@ -44,6 +50,7 @@ import javax.ws.rs.core.MediaType;
import
javax.ws.rs.core.MultivaluedMap
;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.core.UriBuilder
;
import
java.io.File
;
import
java.io.IOException
;
import
java.net.ConnectException
;
import
java.nio.file.Paths
;
...
...
@@ -58,6 +65,7 @@ public abstract class AtlasBaseClient {
public
static
final
String
ADMIN_VERSION
=
"admin/version"
;
public
static
final
String
ADMIN_STATUS
=
"admin/status"
;
public
static
final
String
ADMIN_METRICS
=
"admin/metrics"
;
public
static
final
String
ADMIN_IMPORT
=
"admin/import"
;
public
static
final
String
HTTP_AUTHENTICATION_ENABLED
=
"atlas.http.authentication.enabled"
;
public
static
final
String
QUERY
=
"query"
;
...
...
@@ -78,6 +86,7 @@ public abstract class AtlasBaseClient {
// With number of retries, this gives a total time of about 20s for the server to start.
static
final
int
DEFAULT_SLEEP_BETWEEN_RETRIES_MS
=
5000
;
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
AtlasBaseClient
.
class
);
private
static
final
API
IMPORT
=
new
API
(
BASE_URI
+
ADMIN_IMPORT
,
HttpMethod
.
POST
,
Response
.
Status
.
OK
,
MediaType
.
MULTIPART_FORM_DATA
,
MediaType
.
APPLICATION_JSON
);
protected
WebResource
service
;
protected
Configuration
configuration
;
private
String
basicAuthUser
;
...
...
@@ -315,16 +324,20 @@ public abstract class AtlasBaseClient {
ClientResponse
clientResponse
=
null
;
int
i
=
0
;
do
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Calling API [ {} : {} ] {}"
,
api
.
getMethod
(),
api
.
getNormalizedPath
(),
requestObject
!=
null
?
"<== "
+
requestObject
:
""
);
LOG
.
info
(
"------------------------------------------------------"
);
LOG
.
info
(
"Call : {} {}"
,
api
.
getMethod
(),
api
.
getNormalizedPath
());
LOG
.
info
(
"Content-type : {} "
,
api
.
getConsumes
());
LOG
.
info
(
"Accept : {} "
,
api
.
getProduces
());
if
(
requestObject
!=
null
)
{
LOG
.
info
(
"Request : {}"
,
requestObject
);
}
WebResource
.
Builder
requestBuilder
=
resource
.
getRequestBuilder
();
// Set content headers
requestBuilder
.
accept
(
JSON_MEDIA_TYPE
)
.
type
(
JSON_MEDIA_TYPE
);
.
accept
(
api
.
getProduces
()
)
.
type
(
api
.
getConsumes
()
);
// Set cookie if present
if
(
cookie
!=
null
)
{
...
...
@@ -338,21 +351,24 @@ public abstract class AtlasBaseClient {
}
if
(
clientResponse
.
getStatus
()
==
api
.
getExpectedStatus
().
getStatusCode
())
{
if
(
null
==
responseType
)
{
if
(
responseType
==
null
)
{
return
null
;
}
try
{
if
(
responseType
.
getRawClass
()
==
JSONObject
.
class
)
{
if
(
responseType
.
getRawClass
()
.
equals
(
JSONObject
.
class
)
)
{
String
stringEntity
=
clientResponse
.
getEntity
(
String
.
class
);
try
{
JSONObject
jsonObject
=
new
JSONObject
(
stringEntity
);
LOG
.
info
(
"Response = {}"
,
jsonObject
);
LOG
.
debug
(
"Response = {}"
,
jsonObject
);
LOG
.
info
(
"------------------------------------------------------"
);
return
(
T
)
jsonObject
;
}
catch
(
JSONException
e
)
{
throw
new
AtlasServiceException
(
api
,
e
);
}
}
else
{
T
entity
=
clientResponse
.
getEntity
(
responseType
);
LOG
.
debug
(
"Response = {}"
,
entity
);
LOG
.
info
(
"------------------------------------------------------"
);
return
entity
;
}
}
catch
(
ClientHandlerException
e
)
{
...
...
@@ -418,6 +434,15 @@ public abstract class AtlasBaseClient {
return
configuration
.
getInt
(
AtlasBaseClient
.
ATLAS_CLIENT_HA_RETRIES_KEY
,
AtlasBaseClient
.
DEFAULT_NUM_RETRIES
);
}
public
AtlasImportResult
importData
(
AtlasImportRequest
request
,
String
absoluteFilePath
)
throws
AtlasServiceException
{
FileDataBodyPart
filePart
=
new
FileDataBodyPart
(
"data"
,
new
File
(
absoluteFilePath
));
MultiPart
multipartEntity
=
new
FormDataMultiPart
()
.
field
(
"request"
,
AtlasType
.
toJson
(
request
),
MediaType
.
APPLICATION_JSON_TYPE
)
.
bodyPart
(
filePart
);
return
callAPI
(
IMPORT
,
AtlasImportResult
.
class
,
multipartEntity
);
}
boolean
isRetryableException
(
ClientHandlerException
che
)
{
return
che
.
getCause
().
getClass
().
equals
(
IOException
.
class
)
||
che
.
getCause
().
getClass
().
equals
(
ConnectException
.
class
);
...
...
@@ -563,12 +588,20 @@ public abstract class AtlasBaseClient {
public
static
class
API
{
private
final
String
method
;
private
final
String
path
;
private
final
String
consumes
;
private
final
String
produces
;
private
final
Response
.
Status
status
;
public
API
(
String
path
,
String
method
,
Response
.
Status
status
)
{
this
(
path
,
method
,
status
,
JSON_MEDIA_TYPE
,
MediaType
.
APPLICATION_JSON
);
}
public
API
(
String
path
,
String
method
,
Response
.
Status
status
,
String
consumes
,
String
produces
)
{
this
.
path
=
path
;
this
.
method
=
method
;
this
.
status
=
status
;
this
.
consumes
=
consumes
;
this
.
produces
=
produces
;
}
public
String
getMethod
()
{
...
...
@@ -586,6 +619,14 @@ public abstract class AtlasBaseClient {
public
Response
.
Status
getExpectedStatus
()
{
return
status
;
}
public
String
getConsumes
()
{
return
consumes
;
}
public
String
getProduces
()
{
return
produces
;
}
}
/**
...
...
client/pom.xml
View file @
bd513f25
...
...
@@ -44,6 +44,11 @@
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
com.sun.jersey.contribs
</groupId>
<artifactId>
jersey-multipart
</artifactId>
</dependency>
<dependency>
<groupId>
org.testng
</groupId>
<artifactId>
testng
</artifactId>
<scope>
test
</scope>
...
...
pom.xml
View file @
bd513f25
...
...
@@ -1867,6 +1867,7 @@
<version>
2.7
</version>
<configuration>
<encoding>
UTF-8
</encoding>
<nonFilteredFileExtensions>
zip
</nonFilteredFileExtensions>
</configuration>
</plugin>
...
...
repository/src/test/java/org/apache/atlas/discovery/EntityDiscoveryServiceTest.java
View file @
bd513f25
...
...
@@ -19,16 +19,28 @@ package org.apache.atlas.discovery;
import
org.apache.atlas.TestModules
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.model.discovery.AtlasSearchResult
;
import
org.apache.atlas.model.discovery.SearchParameters
;
import
org.apache.atlas.model.impexp.AtlasImportRequest
;
import
org.apache.atlas.model.typedef.AtlasEntityDef
;
import
org.apache.atlas.repository.impexp.ImportService
;
import
org.apache.atlas.repository.impexp.ZipSource
;
import
org.apache.atlas.repository.store.graph.AtlasEntityStore
;
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.BeforeClass
;
import
org.testng.annotations.Guice
;
import
org.testng.annotations.Test
;
import
javax.inject.Inject
;
import
java.io.IOException
;
import
static
org
.
apache
.
atlas
.
repository
.
impexp
.
ZipFileResourceTestUtils
.
LOG
;
import
static
org
.
apache
.
atlas
.
repository
.
impexp
.
ZipFileResourceTestUtils
.
loadModelFromJson
;
import
static
org
.
testng
.
Assert
.*;
import
static
org
.
testng
.
Assert
.
fail
;
@Guice
(
modules
=
TestModules
.
TestOnlyModule
.
class
)
public
class
EntityDiscoveryServiceTest
{
...
...
@@ -50,6 +62,12 @@ public class EntityDiscoveryServiceTest {
@Inject
EntityDiscoveryService
discoveryService
;
@Inject
AtlasTypeDefStore
typeDefStore
;
@Inject
AtlasEntityStore
entityStore
;
@Inject
ImportService
importService
;
@BeforeClass
...
...
@@ -122,4 +140,5 @@ public class EntityDiscoveryServiceTest {
assertNotNull
(
s
);
return
s
;
}
}
repository/src/test/java/org/apache/atlas/repository/impexp/ZipFileResourceTestUtils.java
View file @
bd513f25
...
...
@@ -29,6 +29,7 @@ import org.apache.atlas.repository.store.bootstrap.AtlasTypeDefStoreInitializer;
import
org.apache.atlas.store.AtlasTypeDefStore
;
import
org.apache.atlas.type.AtlasType
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.utils.TestResourceFileUtils
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.solr.common.StringUtils
;
import
org.slf4j.Logger
;
...
...
@@ -36,7 +37,6 @@ import org.slf4j.LoggerFactory;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
import
java.util.Arrays
;
import
java.util.HashMap
;
...
...
@@ -44,30 +44,16 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Set
;
import
static
org
.
testng
.
Assert
.*;
import
static
org
.
testng
.
Assert
.
assertEquals
;
import
static
org
.
testng
.
Assert
.
assertFalse
;
import
static
org
.
testng
.
Assert
.
assertNotNull
;
import
static
org
.
testng
.
Assert
.
assertTrue
;
public
class
ZipFileResourceTestUtils
{
public
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
ZipFileResourceTestUtils
.
class
);
public
static
FileInputStream
getFileInputStream
(
String
fileName
)
{
String
filePath
=
getFileFromResources
(
fileName
);
File
f
=
new
File
(
filePath
);
FileInputStream
fs
=
null
;
try
{
fs
=
new
FileInputStream
(
f
);
}
catch
(
FileNotFoundException
e
)
{
LOG
.
error
(
"File could not be found at: %s"
,
filePath
,
e
);
}
return
fs
;
}
private
static
String
getFileFromResources
(
String
fileName
)
{
final
String
userDir
=
System
.
getProperty
(
"user.dir"
);
return
getFilePath
(
userDir
,
fileName
);
}
private
static
String
getFilePath
(
String
startPath
,
String
fileName
)
{
return
startPath
+
"/src/test/resources/"
+
fileName
;
return
TestResourceFileUtils
.
getFileInputStream
(
fileName
);
}
public
static
String
getModelJson
(
String
fileName
)
throws
IOException
{
...
...
@@ -113,7 +99,7 @@ public class ZipFileResourceTestUtils {
}
public
static
String
getModelJsonFromResources
(
String
fileName
)
throws
IOException
{
String
filePath
=
getFileFromResources
(
fileName
);
String
filePath
=
TestResourceFileUtils
.
getTestFilePath
(
fileName
);
File
f
=
new
File
(
filePath
);
String
s
=
FileUtils
.
readFileToString
(
f
);
assertFalse
(
StringUtils
.
isEmpty
(
s
),
"Model file read correctly from resources!"
);
...
...
repository/src/test/java/org/apache/atlas/utils/TestResourceFileUtils.java
0 → 100644
View file @
bd513f25
/**
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
apache
.
atlas
.
utils
;
import
org.apache.atlas.type.AtlasType
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
public
class
TestResourceFileUtils
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
TestResourceFileUtils
.
class
);
public
static
String
getTestFilePath
(
String
fileName
)
{
final
String
userDir
=
System
.
getProperty
(
"user.dir"
);
String
filePath
=
getTestFilePath
(
userDir
,
""
,
fileName
);
return
filePath
;
}
public
static
FileInputStream
getFileInputStream
(
String
fileName
)
{
return
getFileInputStream
(
""
,
fileName
);
}
public
static
FileInputStream
getFileInputStream
(
String
subDir
,
String
fileName
)
{
final
String
userDir
=
System
.
getProperty
(
"user.dir"
);
String
filePath
=
getTestFilePath
(
userDir
,
subDir
,
fileName
);
File
f
=
new
File
(
filePath
);
FileInputStream
fs
=
null
;
try
{
fs
=
new
FileInputStream
(
f
);
}
catch
(
FileNotFoundException
e
)
{
LOG
.
error
(
"File could not be found at: {}"
,
filePath
,
e
);
}
return
fs
;
}
public
static
<
T
>
T
readObjectFromJson
(
String
subDir
,
String
filename
,
Class
<
T
>
objectClass
)
throws
IOException
{
final
String
userDir
=
System
.
getProperty
(
"user.dir"
);
String
filePath
=
getTestJsonPath
(
userDir
,
subDir
,
filename
);
String
json
=
FileUtils
.
readFileToString
(
new
File
(
filePath
));
return
AtlasType
.
fromJson
(
json
,
objectClass
);
}
public
static
<
T
>
T
readObjectFromJson
(
String
filename
,
Class
<
T
>
objectClass
)
throws
IOException
{
return
readObjectFromJson
(
""
,
filename
,
objectClass
);
}
public
static
String
getJson
(
String
subDir
,
String
filename
)
throws
IOException
{
final
String
userDir
=
System
.
getProperty
(
"user.dir"
);
String
filePath
=
getTestJsonPath
(
userDir
,
subDir
,
filename
);
return
FileUtils
.
readFileToString
(
new
File
(
filePath
));
}
public
static
String
getJson
(
String
filename
)
throws
IOException
{
return
getJson
(
""
,
filename
);
}
private
static
String
getTestFilePath
(
String
startPath
,
String
subDir
,
String
fileName
)
{
if
(
StringUtils
.
isNotEmpty
(
subDir
))
{
return
startPath
+
"/src/test/resources/"
+
subDir
+
"/"
+
fileName
;
}
else
{
return
startPath
+
"/src/test/resources/"
+
fileName
;
}
}
private
static
String
getTestJsonPath
(
String
startPath
,
String
subDir
,
String
fileName
)
{
return
startPath
+
"/src/test/resources/json/"
+
subDir
+
"/"
+
fileName
+
".json"
;
}
}
webapp/src/test/java/org/apache/atlas/web/integration/BasicSearchIT.java
0 → 100644
View file @
bd513f25
/**
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
apache
.
atlas
.
web
.
integration
;
import
com.google.common.collect.ImmutableSet
;
import
org.apache.atlas.AtlasServiceException
;
import
org.apache.atlas.model.discovery.AtlasSearchResult
;
import
org.apache.atlas.model.discovery.SearchParameters
;
import
org.apache.atlas.model.impexp.AtlasImportRequest
;
import
org.apache.atlas.model.instance.AtlasClassification
;
import
org.apache.atlas.model.instance.AtlasEntity
;
import
org.apache.atlas.model.instance.EntityMutationResponse
;
import
org.apache.atlas.model.typedef.AtlasClassificationDef
;
import
org.apache.atlas.model.typedef.AtlasTypesDef
;
import
org.apache.atlas.type.AtlasTypeUtil
;
import
org.apache.atlas.utils.TestResourceFileUtils
;
import
org.codehaus.jackson.annotate.JsonAutoDetect
;
import
org.codehaus.jackson.annotate.JsonIgnoreProperties
;
import
org.codehaus.jackson.map.annotate.JsonSerialize
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.DataProvider
;
import
org.testng.annotations.Test
;
import
java.io.IOException
;
import
java.net.URLEncoder
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
static
org
.
codehaus
.
jackson
.
annotate
.
JsonAutoDetect
.
Visibility
.
NONE
;
import
static
org
.
codehaus
.
jackson
.
annotate
.
JsonAutoDetect
.
Visibility
.
PUBLIC_ONLY
;
import
static
org
.
testng
.
Assert
.
assertEquals
;
import
static
org
.
testng
.
Assert
.
assertNotNull
;
import
static
org
.
testng
.
Assert
.
fail
;
public
class
BasicSearchIT
extends
BaseResourceIT
{
@BeforeClass
@Override
public
void
setUp
()
throws
Exception
{
super
.
setUp
();
String
smallDatasetFileName
=
"hive-db-50-tables.zip"
;
atlasClientV2
.
importData
(
new
AtlasImportRequest
(),
TestResourceFileUtils
.
getTestFilePath
(
smallDatasetFileName
));
// Create a entity with name/qualified name having special characters
// Create a test tag
if
(!
atlasClientV2
.
typeWithNameExists
(
"fooTag"
))
{
AtlasClassificationDef
testClassificationDef
=
AtlasTypeUtil
.
createTraitTypeDef
(
"fooTag"
,
"Test tag"
,
"1.0"
,
ImmutableSet
.<
String
>
of
());
AtlasTypesDef
typesDef
=
new
AtlasTypesDef
();
typesDef
.
getClassificationDefs
().
add
(
testClassificationDef
);
atlasClientV2
.
createAtlasTypeDefs
(
typesDef
);
}
try
{
atlasClientV2
.
getEntityByAttribute
(
"hdfs_path"
,
new
HashMap
<
String
,
String
>()
{{
put
(
"qualifiedName"
,
URLEncoder
.
encode
(
"test$1test+ - && || ! ( ) { } [ ] ^ < > ; : \" % * ` ~"
,
"UTF-8"
));
}});
}
catch
(
AtlasServiceException
e
)
{
AtlasEntity
hdfsEntity
=
new
AtlasEntity
(
"hdfs_path"
);
hdfsEntity
.
setGuid
(
"-1"
);
hdfsEntity
.
setAttribute
(
"description"
,
"1test+ - && || ! ( ) { } [ ] ^ < > ; : \" % * ` ~"
);
hdfsEntity
.
setAttribute
(
"name"
,
"1test+ - && || ! ( ) { } [ ] ^ < > ; : \" % * ` ~"
);
hdfsEntity
.
setAttribute
(
"owner"
,
"test"
);
hdfsEntity
.
setAttribute
(
"qualifiedName"
,
"test$1test+ - && || ! ( ) { } [ ] ^ < > ; : \" % * ` ~"
);
hdfsEntity
.
setAttribute
(
"path"
,
"/test/foo"
);
hdfsEntity
.
setClassifications
(
new
ArrayList
<
AtlasClassification
>());
hdfsEntity
.
getClassifications
().
add
(
new
AtlasClassification
(
"fooTag"
));
EntityMutationResponse
entityMutationResponse
=
atlasClientV2
.
createEntity
(
new
AtlasEntity
.
AtlasEntityWithExtInfo
(
hdfsEntity
));
if
(
entityMutationResponse
.
getCreatedEntities
()
!=
null
)
{
assertEquals
(
entityMutationResponse
.
getCreatedEntities
().
size
(),
1
);
}
else
if
(
entityMutationResponse
.
getUpdatedEntities
()
!=
null
)
{
assertEquals
(
entityMutationResponse
.
getUpdatedEntities
().
size
(),
1
);
}
else
{
fail
(
"Entity should've been created or updated"
);
}
}
// Add a 5s mandatory sleep for allowing index to catch up
try
{
Thread
.
sleep
(
5000
);
}
catch
(
InterruptedException
e
)
{
LOG
.
error
(
"Sleep was interrupted. The search results might be inconsistent."
);
}
}
@DataProvider
public
Object
[][]
basicSearchJSONNames
()
{
return
new
String
[][]{
{
"search-parameters/entity-filters"
},
{
"search-parameters/tag-filters"
},
{
"search-parameters/combination-filters"
}
};
}
@Test
(
dataProvider
=
"basicSearchJSONNames"
)
public
void
testDiscoveryWithSearchParameters
(
String
jsonFile
)
{
try
{
BasicSearchParametersWithExpectation
[]
testExpectations
=
TestResourceFileUtils
.
readObjectFromJson
(
jsonFile
,
BasicSearchParametersWithExpectation
[].
class
);
assertNotNull
(
testExpectations
);
for
(
BasicSearchParametersWithExpectation
testExpectation
:
testExpectations
)
{
LOG
.
info
(
"TestDescription :{}"
,
testExpectation
.
testDescription
);
LOG
.
info
(
"SearchParameters :{}"
,
testExpectation
.
searchParameters
);
AtlasSearchResult
searchResult
=
atlasClientV2
.
facetedSearch
(
testExpectation
.
searchParameters
);
if
(
testExpectation
.
expectedCount
>
0
)
{
assertNotNull
(
searchResult
.
getEntities
());
assertEquals
(
searchResult
.
getEntities
().
size
(),
testExpectation
.
expectedCount
);
}
}
}
catch
(
IOException
|
AtlasServiceException
e
)
{
fail
(
e
.
getMessage
());
}
}
@JsonAutoDetect
(
getterVisibility
=
PUBLIC_ONLY
,
setterVisibility
=
PUBLIC_ONLY
,
fieldVisibility
=
NONE
)
@JsonSerialize
(
include
=
JsonSerialize
.
Inclusion
.
NON_NULL
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
private
static
class
BasicSearchParametersWithExpectation
{
private
String
testDescription
;
private
SearchParameters
searchParameters
;
private
int
expectedCount
;
public
BasicSearchParametersWithExpectation
()
{
}
public
BasicSearchParametersWithExpectation
(
final
String
testDescription
,
final
SearchParameters
searchParameters
,
final
int
expectedCount
)
{
this
.
testDescription
=
testDescription
;
this
.
searchParameters
=
searchParameters
;
this
.
expectedCount
=
expectedCount
;
}
public
SearchParameters
getSearchParameters
()
{
return
searchParameters
;
}
public
void
setSearchParameters
(
final
SearchParameters
searchParameters
)
{
this
.
searchParameters
=
searchParameters
;
}
public
int
getExpectedCount
()
{
return
expectedCount
;
}
public
void
setExpectedCount
(
final
int
expectedCount
)
{
this
.
expectedCount
=
expectedCount
;
}
public
String
getTestDescription
()
{
return
testDescription
;
}
public
void
setTestDescription
(
final
String
testDescription
)
{
this
.
testDescription
=
testDescription
;
}
}
}
webapp/src/test/resources/DefaultDB-3-New.zip
0 → 100644
View file @
bd513f25
File added
webapp/src/test/resources/hive-db-50-tables.zip
0 → 100644
View file @
bd513f25
File added
webapp/src/test/resources/json/search-parameters/combination-filters.json
0 → 100644
View file @
bd513f25
[
{
"testDescription"
:
"hdfs_path tagged with fooTag"
,
"searchParameters"
:
{
"typeName"
:
"hdfs_path"
,
"excludeDeletedEntities"
:
true
,
"classification"
:
"fooTag"
,
"query"
:
""
,
"limit"
:
25
,
"offset"
:
0
,
"entityFilters"
:
null
,
"tagFilters"
:
null
,
"attributes"
:
[
""
]
},
"expectedCount"
:
1
},
{
"testDescription"
:
"hive_table tagged with fooTag"
,
"searchParameters"
:
{
"typeName"
:
"hive_table"
,
"excludeDeletedEntities"
:
true
,
"classification"
:
"fooTag"
,
"query"
:
""
,
"limit"
:
25
,
"offset"
:
0
,
"entityFilters"
:
null
,
"tagFilters"
:
null
,
"attributes"
:
[
""
]
},
"expectedCount"
:
0
},
{
"testDescription"
:
"Check entity attributes containing special characters"
,
"searchParameters"
:
{
"typeName"
:
"hdfs_path"
,
"excludeDeletedEntities"
:
true
,
"classification"
:
""
,
"query"
:
""
,
"limit"
:
25
,
"offset"
:
0
,
"entityFilters"
:
{
"condition"
:
"OR"
,
"criterion"
:
[
{
"attributeName"
:
"name"
,
"operator"
:
"contains"
,
"attributeValue"
:
"!"
},
{
"attributeName"
:
"name"
,
"operator"
:
"contains"
,
"attributeValue"
:
"["
},
{
"attributeName"
:
"name"
,
"operator"
:
"contains"
,
"attributeValue"
:
"{"
},
{
"attributeName"
:
"name"
,
"operator"
:
"contains"
,
"attributeValue"
:
"#"
},
{
"attributeName"
:
"name"
,
"operator"
:
"contains"
,
"attributeValue"
:
"$"
},
{
"attributeName"
:
"name"
,
"operator"
:
"contains"
,
"attributeValue"
:
"|"
},
{
"attributeName"
:
"name"
,
"operator"
:
"contains"
,
"attributeValue"
:
"&"
},
{
"attributeName"
:
"name"
,
"operator"
:
"contains"
,
"attributeValue"
:
"`"
},
{
"attributeName"
:
"name"
,
"operator"
:
"contains"
,
"attributeValue"
:
"
\"
"
},
{
"attributeName"
:
"name"
,
"operator"
:
"contains"
,
"attributeValue"
:
"^"
},
{
"attributeName"
:
"name"
,
"operator"
:
"contains"
,
"attributeValue"
:
"%"
},
{
"attributeName"
:
"name"
,
"operator"
:
"contains"
,
"attributeValue"
:
"~"
},
{
"attributeName"
:
"name"
,
"operator"
:
"contains"
,
"attributeValue"
:
"*"
},
{
"attributeName"
:
"name"
,
"operator"
:
"contains"
,
"attributeValue"
:
":"
},
{
"attributeName"
:
"name"
,
"operator"
:
"contains"
,
"attributeValue"
:
","
},
{
"attributeName"
:
"name"
,
"operator"
:
"contains"
,
"attributeValue"
:
"< >"
},
{
"attributeName"
:
"name"
,
"operator"
:
"contains"
,
"attributeValue"
:
"( )"
}
]
},
"tagFilters"
:
null
,
"attributes"
:
[
""
]
},
"expectedCount"
:
1
},
{
"testDescription"
:
"Search using fulltext, entity type and tag"
,
"searchParameters"
:
{
"typeName"
:
"hdfs_path"
,
"excludeDeletedEntities"
:
true
,
"classification"
:
"fooTag"
,
"query"
:
"test ;
\\
{
\\
}
\\
[
\\
]"
,
"limit"
:
25
,
"offset"
:
0
,
"entityFilters"
:
null
,
"tagFilters"
:
null
,
"attributes"
:
[
""
]
},
"expectedCount"
:
1
},
{
"testDescription"
:
"hive_column with fulltext query"
,
"searchParameters"
:
{
"typeName"
:
"hive_column"
,
"excludeDeletedEntities"
:
true
,
"classification"
:
""
,
"query"
:
"*col104*"
,
"limit"
:
25
,
"offset"
:
0
,
"entityFilters"
:
null
,
"tagFilters"
:
null
,
"attributes"
:
[
""
]
},
"expectedCount"
:
3
},
{
"testDescription"
:
"hdfs_path tagged with fooTag"
,
"searchParameters"
:
{
"typeName"
:
"hdfs_path"
,
"excludeDeletedEntities"
:
true
,
"classification"
:
"fooTag"
,
"query"
:
"test ;
\\
{
\\
}
\\
[
\\
]"
,
"limit"
:
25
,
"offset"
:
0
,
"entityFilters"
:
{
"attributeName"
:
"qualifiedName"
,
"operator"
:
"contains"
,
"attributeValue"
:
"+"
},
"tagFilters"
:
null
,
"attributes"
:
[
""
]
},
"expectedCount"
:
1
}
]
\ No newline at end of file
webapp/src/test/resources/json/search-parameters/entity-filters.json
0 → 100644
View file @
bd513f25
[
{
"testDescription"
:
"Asset.name contains testtable"
,
"searchParameters"
:
{
"typeName"
:
"hive_table"
,
"excludeDeletedEntities"
:
true
,
"classification"
:
""
,
"query"
:
""
,
"limit"
:
25
,
"offset"
:
0
,
"entityFilters"
:
{
"attributeName"
:
"name"
,
"operator"
:
"contains"
,
"attributeValue"
:
"testtable"
},
"tagFilters"
:
null
,
"attributes"
:
[
""
]
},
"expectedCount"
:
3
},
{
"testDescription"
:
"hive_column.name contains 30"
,
"searchParameters"
:
{
"typeName"
:
"hive_column"
,
"excludeDeletedEntities"
:
true
,
"classification"
:
""
,
"query"
:
""
,
"limit"
:
25
,
"offset"
:
25
,
"entityFilters"
:
{
"attributeName"
:
"name"
,
"operator"
:
"contains"
,
"attributeValue"
:
"30"
},
"tagFilters"
:
null
,
"attributes"
:
[
""
]
},
"expectedCount"
:
2
},
{
"testDescription"
:
"hive_table matches name testtable_0"
,
"searchParameters"
:
{
"typeName"
:
"hive_table"
,
"excludeDeletedEntities"
:
true
,
"classification"
:
""
,
"query"
:
""
,
"limit"
:
25
,
"offset"
:
0
,
"entityFilters"
:
{
"attributeName"
:
"name"
,
"operator"
:
"eq"
,
"attributeValue"
:
"testtable_0"
},
"tagFilters"
:
null
,
"attributes"
:
[
""
]
},
"expectedCount"
:
1
},
{
"testDescription"
:
""
,
"searchParameters"
:
{
"typeName"
:
"hive_table"
,
"excludeDeletedEntities"
:
true
,
"classification"
:
""
,
"query"
:
""
,
"limit"
:
50
,
"offset"
:
0
,
"entityFilters"
:
{
"attributeName"
:
"name"
,
"operator"
:
"neq"
,
"attributeValue"
:
"dummy /Table_1@0"
},
"tagFilters"
:
null
,
"attributes"
:
[
""
]
},
"expectedCount"
:
3
},
{
"testDescription"
:
""
,
"searchParameters"
:
{
"typeName"
:
"hive_table"
,
"excludeDeletedEntities"
:
true
,
"classification"
:
""
,
"query"
:
""
,
"limit"
:
25
,
"offset"
:
0
,
"entityFilters"
:
{
"attributeName"
:
"temporary"
,
"operator"
:
"eq"
,
"attributeValue"
:
"false"
},
"tagFilters"
:
null
,
"attributes"
:
[
""
]
},
"expectedCount"
:
3
},
{
"testDescription"
:
""
,
"searchParameters"
:
{
"typeName"
:
"hive_table"
,
"excludeDeletedEntities"
:
true
,
"classification"
:
""
,
"query"
:
""
,
"limit"
:
50
,
"offset"
:
0
,
"entityFilters"
:
{
"attributeName"
:
"temporary"
,
"operator"
:
"neq"
,
"attributeValue"
:
"true"
},
"tagFilters"
:
null
,
"attributes"
:
[
""
]
},
"expectedCount"
:
3
},
{
"testDescription"
:
""
,
"searchParameters"
:
{
"typeName"
:
"hive_table"
,
"excludeDeletedEntities"
:
true
,
"classification"
:
""
,
"query"
:
""
,
"limit"
:
25
,
"offset"
:
0
,
"entityFilters"
:
{
"attributeName"
:
"name"
,
"operator"
:
"startsWith"
,
"attributeValue"
:
"test"
},
"tagFilters"
:
null
,
"attributes"
:
[
""
]
},
"expectedCount"
:
3
},
{
"testDescription"
:
""
,
"searchParameters"
:
{
"typeName"
:
"hive_table"
,
"excludeDeletedEntities"
:
true
,
"classification"
:
""
,
"query"
:
""
,
"limit"
:
25
,
"offset"
:
0
,
"entityFilters"
:
{
"attributeName"
:
"name"
,
"operator"
:
"endsWith"
,
"attributeValue"
:
"0"
},
"tagFilters"
:
null
,
"attributes"
:
[
""
]
},
"expectedCount"
:
1
},
{
"testDescription"
:
""
,
"searchParameters"
:
{
"typeName"
:
"hive_column"
,
"excludeDeletedEntities"
:
true
,
"classification"
:
""
,
"query"
:
""
,
"limit"
:
25
,
"offset"
:
0
,
"entityFilters"
:
{
"attributeName"
:
"name"
,
"operator"
:
"endsWith"
,
"attributeValue"
:
"8"
},
"tagFilters"
:
null
,
"attributes"
:
[
""
]
},
"expectedCount"
:
18
},
{
"testDescription"
:
""
,
"searchParameters"
:
{
"typeName"
:
"hive_table"
,
"excludeDeletedEntities"
:
true
,
"classification"
:
""
,
"query"
:
""
,
"limit"
:
25
,
"offset"
:
0
,
"entityFilters"
:
{
"attributeName"
:
"createTime"
,
"operator"
:
"lte"
,
"attributeValue"
:
"1491250084794"
},
"tagFilters"
:
null
,
"attributes"
:
[
""
]
},
"expectedCount"
:
3
},
{
"testDescription"
:
""
,
"searchParameters"
:
{
"typeName"
:
"hive_table"
,
"excludeDeletedEntities"
:
true
,
"classification"
:
""
,
"query"
:
""
,
"limit"
:
25
,
"offset"
:
0
,
"entityFilters"
:
{
"attributeName"
:
"lastAccessTime"
,
"operator"
:
"gte"
,
"attributeValue"
:
"1491248907000"
},
"tagFilters"
:
null
,
"attributes"
:
[
""
]
},
"expectedCount"
:
3
}
]
\ No newline at end of file
webapp/src/test/resources/json/search-parameters/tag-filters.json
0 → 100644
View file @
bd513f25
[
{
"testDescription"
:
"Search for exact Tag name"
,
"searchParameters"
:
{
"entityFilters"
:
null
,
"tagFilters"
:
null
,
"attributes"
:
null
,
"query"
:
null
,
"excludeDeletedEntities"
:
true
,
"limit"
:
25
,
"typeName"
:
null
,
"classification"
:
"fooTag"
},
"expectedCount"
:
1
}
]
\ No newline at end of file
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