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
65f7da17
Commit
65f7da17
authored
6 years ago
by
Ashutosh Mestry
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2602: Walkthrough includes relationship attribute.
Signed-off-by:
Ashutosh Mestry
<
amestry@hortonworks.com
>
parent
540129f5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
14 deletions
+57
-14
AtlasEntityGraphDiscoveryV1.java
...epository/store/graph/v1/AtlasEntityGraphDiscoveryV1.java
+1
-3
BulkImporterImpl.java
...che/atlas/repository/store/graph/v1/BulkImporterImpl.java
+2
-2
ImportServiceTest.java
...org/apache/atlas/repository/impexp/ImportServiceTest.java
+54
-9
stocks-glossary.zip
repository/src/test/resources/stocks-glossary.zip
+0
-0
No files found.
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityGraphDiscoveryV1.java
View file @
65f7da17
...
...
@@ -305,9 +305,7 @@ public class AtlasEntityGraphDiscoveryV1 implements EntityGraphDiscovery {
List
<
String
>
visitedAttributes
=
new
ArrayList
<>();
// visit relationship attributes
if
(!(
this
.
discoveryContext
.
getEntityStream
()
instanceof
EntityImportStream
))
{
visitRelationships
(
entityType
,
entity
,
visitedAttributes
);
}
visitRelationships
(
entityType
,
entity
,
visitedAttributes
);
// visit struct attributes
for
(
AtlasAttribute
attribute
:
entityType
.
getAllAttributes
().
values
())
{
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/BulkImporterImpl.java
View file @
65f7da17
...
...
@@ -73,10 +73,10 @@ public class BulkImporterImpl implements BulkImporter {
AtlasEntityWithExtInfo
entityWithExtInfo
=
entityImportStreamWithResidualList
.
getNextEntityWithExtInfo
();
AtlasEntity
entity
=
entityWithExtInfo
!=
null
?
entityWithExtInfo
.
getEntity
()
:
null
;
if
(
entity
==
null
||
processedGuids
.
contains
(
entity
.
getGuid
())
)
{
if
(
entity
==
null
)
{
continue
;
}
AtlasEntityStreamForImport
oneEntityStream
=
new
AtlasEntityStreamForImport
(
entityWithExtInfo
,
entityStream
);
try
{
...
...
This diff is collapsed.
Click to expand it.
repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceTest.java
View file @
65f7da17
...
...
@@ -22,13 +22,16 @@ import org.apache.atlas.AtlasErrorCode;
import
org.apache.atlas.RequestContextV1
;
import
org.apache.atlas.TestModules
;
import
org.apache.atlas.TestUtilsV2
;
import
org.apache.atlas.discovery.EntityDiscoveryService
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.model.impexp.AtlasImportRequest
;
import
org.apache.atlas.model.instance.AtlasEntityHeader
;
import
org.apache.atlas.repository.graph.AtlasGraphProvider
;
import
org.apache.atlas.runner.LocalSolrRunner
;
import
org.apache.atlas.store.AtlasTypeDefStore
;
import
org.apache.atlas.type.AtlasClassificationType
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.commons.lang.StringUtils
;
import
org.mockito.invocation.InvocationOnMock
;
import
org.mockito.stubbing.Answer
;
import
org.slf4j.Logger
;
...
...
@@ -42,6 +45,7 @@ import org.testng.annotations.Test;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
static
org
.
apache
.
atlas
.
graph
.
GraphSandboxUtil
.
useLocalSolr
;
...
...
@@ -54,6 +58,7 @@ import static org.testng.Assert.assertNotNull;
@Guice
(
modules
=
TestModules
.
TestOnlyModule
.
class
)
public
class
ImportServiceTest
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
ImportServiceTest
.
class
);
private
static
final
int
DEFAULT_LIMIT
=
25
;
private
final
ImportService
importService
;
@Inject
...
...
@@ -63,6 +68,9 @@ public class ImportServiceTest {
private
AtlasTypeDefStore
typeDefStore
;
@Inject
private
EntityDiscoveryService
discoveryService
;
@Inject
public
ImportServiceTest
(
ImportService
importService
)
{
this
.
importService
=
importService
;
}
...
...
@@ -104,10 +112,6 @@ public class ImportServiceTest {
runAndVerifyQuickStart_v1_Import
(
importService
,
zipSource
);
}
private
void
loadBaseModel
()
throws
IOException
,
AtlasBaseException
{
loadModelFromJson
(
"0000-Area0/0010-base_model.json"
,
typeDefStore
,
typeRegistry
);
}
@DataProvider
(
name
=
"logging"
)
public
static
Object
[][]
getDataFromLogging
(
ITestContext
context
)
throws
IOException
{
return
getZipSource
(
"logging-v1-full.zip"
);
...
...
@@ -180,6 +184,28 @@ public class ImportServiceTest {
runImportWithNoParameters
(
importService
,
zipSource
);
}
@DataProvider
(
name
=
"stocks-glossary"
)
public
static
Object
[][]
getDataFromGlossary
(
ITestContext
context
)
throws
IOException
{
return
getZipSource
(
"stocks-glossary.zip"
);
}
@Test
(
dataProvider
=
"stocks-glossary"
)
public
void
importGlossary
(
ZipSource
zipSource
)
throws
IOException
,
AtlasBaseException
{
loadBaseModel
();
loadGlossary
();
runImportWithNoParameters
(
importService
,
zipSource
);
assertEntityCount
(
"__AtlasGlossary"
,
"40c80052-3129-4f7c-8f2f-391677935416"
,
1
);
assertEntityCount
(
"__AtlasGlossaryTerm"
,
"e93ac426-de04-4d54-a7c9-d76c1e96369b"
,
1
);
assertEntityCount
(
"__AtlasGlossaryTerm"
,
"93ad3bf6-23dc-4e3f-b70e-f8fad6438203"
,
1
);
assertEntityCount
(
"__AtlasGlossaryTerm"
,
"105533b6-c125-4a87-bed5-cdf67fb68c39"
,
1
);
}
private
List
<
AtlasEntityHeader
>
getEntitiesFromDB
(
String
query
,
String
guid
)
throws
AtlasBaseException
{
String
q
=
StringUtils
.
isEmpty
(
guid
)
?
query
:
String
.
format
(
"%s where __guid = '%s'"
,
query
,
guid
);
return
discoveryService
.
searchUsingDslQuery
(
q
,
DEFAULT_LIMIT
,
0
).
getEntities
();
}
@DataProvider
(
name
=
"hdfs_path1"
)
public
static
Object
[][]
getDataFromHdfsPath1
(
ITestContext
context
)
throws
IOException
{
return
getZipSource
(
"hdfs_path1.zip"
);
...
...
@@ -226,6 +252,20 @@ public class ImportServiceTest {
loadHiveModel
();
AtlasImportRequest
request
=
getDefaultImportRequest
();
runImportWithParameters
(
importService
,
request
,
zipSource
);
assertEntityCount
(
"hive_db"
,
"d7dc0848-fbba-4d63-9264-a460798361f5"
,
1
);
assertEntityCount
(
"hive_table"
,
"2fb31eaa-4bb2-4eb8-b333-a888ba7c84fe"
,
1
);
assertEntityCount
(
"hive_column"
,
"13422f0c-9265-4960-91a9-290ffd83b7f1"
,
1
);
assertEntityCount
(
"hive_column"
,
"c1ae870f-ce0c-44ae-832f-ff77035b1f7e"
,
1
);
assertEntityCount
(
"hive_column"
,
"b84baab3-0664-4f13-82f1-e81d043db02f"
,
1
);
assertEntityCount
(
"hive_column"
,
"53ea1991-6ca8-44f2-a75e-61b8d4866fc8"
,
1
);
assertEntityCount
(
"hive_column"
,
"a973c04c-aa42-49f4-877c-66fbe6754fb5"
,
1
);
assertEntityCount
(
"hive_column"
,
"a4550803-f18e-4072-a1e8-1201e6022a58"
,
1
);
assertEntityCount
(
"hive_column"
,
"6c4f196a-4046-493b-8c3a-2b1a9ef255a2"
,
1
);
}
private
void
assertEntityCount
(
String
entityType
,
String
guid
,
int
expectedCount
)
throws
AtlasBaseException
{
assertEquals
(
getEntitiesFromDB
(
entityType
,
guid
).
size
(),
expectedCount
);
}
@Test
...
...
@@ -233,11 +273,8 @@ public class ImportServiceTest {
ImportService
importService
=
new
ImportService
(
typeDefStore
,
typeRegistry
,
null
);
AtlasImportRequest
req
=
mock
(
AtlasImportRequest
.
class
);
Answer
<
Map
>
answer
=
new
Answer
<
Map
>()
{
@Override
public
Map
answer
(
InvocationOnMock
invocationOnMock
)
throws
Throwable
{
throw
new
IOException
(
"file is read only"
);
}
Answer
<
Map
>
answer
=
invocationOnMock
->
{
throw
new
IOException
(
"file is read only"
);
};
when
(
req
.
getFileName
()).
thenReturn
(
"some-file.zip"
);
...
...
@@ -258,4 +295,12 @@ public class ImportServiceTest {
private
void
loadHiveModel
()
throws
IOException
,
AtlasBaseException
{
loadModelFromJson
(
"1000-Hadoop/1030-hive_model.json"
,
typeDefStore
,
typeRegistry
);
}
private
void
loadBaseModel
()
throws
IOException
,
AtlasBaseException
{
loadModelFromJson
(
"0000-Area0/0010-base_model.json"
,
typeDefStore
,
typeRegistry
);
}
private
void
loadGlossary
()
throws
IOException
,
AtlasBaseException
{
loadModelFromJson
(
"0000-Area0/0011-glossary_model.json"
,
typeDefStore
,
typeRegistry
);
}
}
This diff is collapsed.
Click to expand it.
repository/src/test/resources/stocks-glossary.zip
0 → 100644
View file @
65f7da17
File added
This diff is collapsed.
Click to expand it.
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