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
ecf8095f
Commit
ecf8095f
authored
7 years ago
by
Sarath Subramanian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2355: Fix IT failures in webapp module
parent
8253653b
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
138 additions
and
66 deletions
+138
-66
HiveITBase.java
...ridge/src/test/java/org/apache/atlas/hive/HiveITBase.java
+1
-1
HiveHookIT.java
.../src/test/java/org/apache/atlas/hive/hook/HiveHookIT.java
+2
-2
AtlasClient.java
...client-v1/src/main/java/org/apache/atlas/AtlasClient.java
+5
-2
AtlasJson.java
intg/src/main/java/org/apache/atlas/utils/AtlasJson.java
+11
-3
pom.xml
webapp/pom.xml
+0
-13
EntityResource.java
...n/java/org/apache/atlas/web/resources/EntityResource.java
+16
-9
BaseResourceIT.java
...java/org/apache/atlas/web/integration/BaseResourceIT.java
+0
-7
EntityJerseyResourceIT.java
.../apache/atlas/web/integration/EntityJerseyResourceIT.java
+4
-4
AdminResourceTest.java
...ava/org/apache/atlas/web/resources/AdminResourceTest.java
+8
-4
entity-filters.json
...test/resources/json/search-parameters/entity-filters.json
+91
-21
No files found.
addons/hive-bridge/src/test/java/org/apache/atlas/hive/HiveITBase.java
View file @
ecf8095f
...
...
@@ -155,7 +155,7 @@ public class HiveITBase {
protected
String
assertEntityIsRegistered
(
final
String
typeName
,
final
String
property
,
final
String
value
,
final
HiveHookIT
.
AssertPredicate
assertPredicate
)
throws
Exception
{
waitFor
(
80
000
,
new
HiveHookIT
.
Predicate
()
{
waitFor
(
2
000
,
new
HiveHookIT
.
Predicate
()
{
@Override
public
void
evaluate
()
throws
Exception
{
Referenceable
entity
=
atlasClient
.
getEntity
(
typeName
,
property
,
value
);
...
...
This diff is collapsed.
Click to expand it.
addons/hive-bridge/src/test/java/org/apache/atlas/hive/hook/HiveHookIT.java
View file @
ecf8095f
...
...
@@ -876,7 +876,7 @@ public class HiveHookIT extends HiveITBase {
String
tableId
=
assertTableIsRegistered
(
DEFAULT_DB
,
tableName
);
Referenceable
tableEntity
=
atlasClient
.
getEntity
(
tableId
);
final
String
createTime
=
(
String
)
tableEntity
.
get
(
HiveMetaStoreBridge
.
CREATE_TIME
);
final
String
createTime
=
String
.
valueOf
(
tableEntity
.
get
(
HiveMetaStoreBridge
.
CREATE_TIME
)
);
Assert
.
assertNotNull
(
createTime
);
String
columnGuid
=
assertColumnIsRegistered
(
HiveMetaStoreBridge
.
getColumnQualifiedName
(
HiveMetaStoreBridge
.
getTableQualifiedName
(
CLUSTER_NAME
,
DEFAULT_DB
,
tableName
),
NAME
));
...
...
@@ -917,7 +917,7 @@ public class HiveHookIT extends HiveITBase {
Referenceable
sd
=
((
Referenceable
)
entity
.
get
(
HiveMetaStoreBridge
.
STORAGE_DESC
));
String
location
=
(
String
)
sd
.
get
(
HiveMetaStoreBridge
.
LOCATION
);
assertTrue
(
location
.
contains
(
newTableName
));
Assert
.
assertEquals
(
entity
.
get
(
HiveMetaStoreBridge
.
CREATE_TIME
),
createTime
);
Assert
.
assertEquals
(
String
.
valueOf
(
entity
.
get
(
HiveMetaStoreBridge
.
CREATE_TIME
)
),
createTime
);
}
});
}
...
...
This diff is collapsed.
Click to expand it.
client/client-v1/src/main/java/org/apache/atlas/AtlasClient.java
View file @
ecf8095f
...
...
@@ -799,7 +799,7 @@ public class AtlasClient extends AtlasBaseClient {
public
ArrayNode
searchByDSL
(
final
String
query
,
final
int
limit
,
final
int
offset
)
throws
AtlasServiceException
{
LOG
.
debug
(
"DSL query: {}"
,
query
);
final
API
api
=
API_V1
.
SEARCH_DSL
;
ObjectNode
res
ult
=
callAPIWithRetries
(
api
,
null
,
new
ResourceCreator
()
{
ObjectNode
res
ponse
=
callAPIWithRetries
(
api
,
null
,
new
ResourceCreator
()
{
@Override
public
WebResource
createResource
()
{
WebResource
resource
=
getResource
(
api
);
...
...
@@ -809,7 +809,10 @@ public class AtlasClient extends AtlasBaseClient {
return
resource
;
}
});
return
(
ArrayNode
)
result
.
get
(
RESULTS
);
JsonNode
results
=
response
.
get
(
RESULTS
);
return
(
results
.
isNull
())
?
AtlasJson
.
createV1ArrayNode
():
(
ArrayNode
)
response
.
get
(
RESULTS
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
intg/src/main/java/org/apache/atlas/utils/AtlasJson.java
View file @
ecf8095f
...
...
@@ -87,7 +87,11 @@ public class AtlasJson {
public
static
String
toJson
(
Object
obj
)
{
String
ret
;
try
{
ret
=
mapper
.
writeValueAsString
(
obj
);
if
(
obj
instanceof
JsonNode
&&
((
JsonNode
)
obj
).
isTextual
())
{
ret
=
((
JsonNode
)
obj
).
textValue
();
}
else
{
ret
=
mapperV1
.
writeValueAsString
(
obj
);
}
}
catch
(
IOException
e
){
LOG
.
error
(
"AtlasJson.toJson()"
,
e
);
...
...
@@ -115,8 +119,12 @@ public class AtlasJson {
public
static
String
toV1Json
(
Object
obj
)
{
String
ret
;
try
{
ret
=
mapperV1
.
writeValueAsString
(
obj
);
}
catch
(
IOException
e
){
if
(
obj
instanceof
JsonNode
&&
((
JsonNode
)
obj
).
isTextual
())
{
ret
=
((
JsonNode
)
obj
).
textValue
();
}
else
{
ret
=
mapperV1
.
writeValueAsString
(
obj
);
}
}
catch
(
IOException
e
)
{
LOG
.
error
(
"AtlasType.toV1Json()"
,
e
);
ret
=
null
;
...
...
This diff is collapsed.
Click to expand it.
webapp/pom.xml
View file @
ecf8095f
...
...
@@ -237,19 +237,6 @@
</dependency>
<dependency>
<groupId>
com.sun.jersey
</groupId>
<artifactId>
jersey-json
</artifactId>
<version>
${jersey.version}
</version>
</dependency>
<dependency>
<groupId>
javax.ws.rs
</groupId>
<artifactId>
jsr311-api
</artifactId>
<version>
${jsr.version}
</version>
</dependency>
<dependency>
<groupId>
org.mockito
</groupId>
<artifactId>
mockito-all
</artifactId>
</dependency>
...
...
This diff is collapsed.
Click to expand it.
webapp/src/main/java/org/apache/atlas/web/resources/EntityResource.java
View file @
ecf8095f
...
...
@@ -18,6 +18,7 @@
package
org
.
apache
.
atlas
.
web
.
resources
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.node.ArrayNode
;
import
com.google.common.annotations.VisibleForTesting
;
import
com.google.common.base.Preconditions
;
...
...
@@ -264,19 +265,25 @@ public class EntityResource {
entityJson
=
Servlets
.
getRequestPayload
(
request
);
ArrayNode
jsonEntities
=
AtlasJson
.
parseToV1ArrayNode
(
entityJson
);
String
[]
jsonStrings
=
new
String
[
jsonEntities
.
size
()]
;
//Handle backward compatibility - if entities is not JSONArray, convert to JSONArray
String
[]
jsonStrings
;
for
(
int
i
=
0
;
i
<
jsonEntities
.
size
();
i
++)
{
jsonStrings
[
i
]
=
AtlasJson
.
toV1Json
(
jsonEntities
.
get
(
i
));
}
try
{
ArrayNode
jsonEntities
=
AtlasJson
.
parseToV1ArrayNode
(
entityJson
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"updateEntities(): count={}, entityJson={} "
,
jsonEntities
.
size
(),
entityJson
);
jsonStrings
=
new
String
[
jsonEntities
.
size
()];
for
(
int
i
=
0
;
i
<
json
Strings
.
length
;
i
++)
{
LOG
.
debug
(
"updateEntities(): entity[{}]={}"
,
i
,
jsonStrings
[
i
]
);
for
(
int
i
=
0
;
i
<
json
Entities
.
size
()
;
i
++)
{
jsonStrings
[
i
]
=
AtlasJson
.
toV1Json
(
jsonEntities
.
get
(
i
)
);
}
}
catch
(
IOException
e
)
{
jsonStrings
=
new
String
[
1
];
jsonStrings
[
0
]
=
entityJson
;
}
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Updating entities: count={}; entities-json={}"
,
jsonStrings
.
length
,
entityJson
);
}
AtlasEntitiesWithExtInfo
entitiesInfo
=
restAdapters
.
toAtlasEntities
(
jsonStrings
);
...
...
This diff is collapsed.
Click to expand it.
webapp/src/test/java/org/apache/atlas/web/integration/BaseResourceIT.java
View file @
ecf8095f
...
...
@@ -100,7 +100,6 @@ public abstract class BaseResourceIT {
protected
NotificationInterface
notificationInterface
=
null
;
protected
EmbeddedKafkaServer
kafkaServer
=
null
;
protected
KafkaNotification
kafkaNotification
=
null
;
@BeforeClass
...
...
@@ -689,13 +688,10 @@ public abstract class BaseResourceIT {
applicationProperties
.
setProperty
(
"atlas.kafka.data"
,
"target/"
+
RandomStringUtils
.
randomAlphanumeric
(
5
));
kafkaServer
=
new
EmbeddedKafkaServer
(
applicationProperties
);
kafkaNotification
=
new
KafkaNotification
(
applicationProperties
);
notificationInterface
=
kafkaNotification
;
kafkaServer
.
start
();
kafkaNotification
.
start
();
Thread
.
sleep
(
2000
);
}
...
...
@@ -705,8 +701,5 @@ public abstract class BaseResourceIT {
kafkaNotification
.
stop
();
}
if
(
kafkaServer
!=
null
)
{
kafkaServer
.
stop
();
}
}
}
This diff is collapsed.
Click to expand it.
webapp/src/test/java/org/apache/atlas/web/integration/EntityJerseyResourceIT.java
View file @
ecf8095f
...
...
@@ -878,8 +878,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
LOG
.
debug
(
"Updating entity= {}"
,
tableUpdated
);
EntityResult
entityResult
=
atlasClientV1
.
updateEntity
(
guid
,
tableUpdated
);
assertEquals
(
entityResult
.
getUpdateEntities
().
size
(),
2
);
assertEquals
(
entityResult
.
getUpdateEntities
().
get
(
1
),
guid
);
assertEquals
(
entityResult
.
getUpdateEntities
().
size
(),
1
);
assertEquals
(
entityResult
.
getUpdateEntities
().
get
(
0
),
guid
);
Referenceable
entity
=
atlasClientV1
.
getEntity
(
guid
);
List
<
Referenceable
>
refs
=
(
List
<
Referenceable
>)
entity
.
get
(
"columns"
);
...
...
@@ -935,8 +935,8 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
LOG
.
debug
(
"Updating entity= {}"
,
tableUpdated
);
EntityResult
entityResult
=
atlasClientV1
.
updateEntity
(
BaseResourceIT
.
HIVE_TABLE_TYPE_BUILTIN
,
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
,
(
String
)
hiveTableInstance
.
get
(
QUALIFIED_NAME
),
tableUpdated
);
assertEquals
(
entityResult
.
getUpdateEntities
().
size
(),
2
);
assertEquals
(
entityResult
.
getUpdateEntities
().
get
(
1
),
guid
);
assertEquals
(
entityResult
.
getUpdateEntities
().
size
(),
1
);
assertEquals
(
entityResult
.
getUpdateEntities
().
get
(
0
),
guid
);
Referenceable
entity
=
atlasClientV1
.
getEntity
(
guid
);
List
<
Referenceable
>
refs
=
(
List
<
Referenceable
>)
entity
.
get
(
"columns"
);
...
...
This diff is collapsed.
Click to expand it.
webapp/src/test/java/org/apache/atlas/web/resources/AdminResourceTest.java
View file @
ecf8095f
...
...
@@ -18,7 +18,9 @@
package
org
.
apache
.
atlas
.
web
.
resources
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
import
org.apache.atlas.utils.AtlasJson
;
import
org.apache.atlas.web.service.ServiceState
;
import
org.mockito.Mock
;
import
org.mockito.MockitoAnnotations
;
...
...
@@ -28,6 +30,8 @@ import org.testng.annotations.Test;
import
javax.servlet.http.HttpServletResponse
;
import
javax.ws.rs.core.Response
;
import
java.io.IOException
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
static
org
.
testng
.
Assert
.
assertEquals
;
...
...
@@ -43,26 +47,26 @@ public class AdminResourceTest {
}
@Test
public
void
testStatusOfActiveServerIsReturned
()
{
public
void
testStatusOfActiveServerIsReturned
()
throws
IOException
{
when
(
serviceState
.
getState
()).
thenReturn
(
ServiceState
.
ServiceStateValue
.
ACTIVE
);
AdminResource
adminResource
=
new
AdminResource
(
serviceState
,
null
,
null
,
null
,
null
);
Response
response
=
adminResource
.
getStatus
();
assertEquals
(
response
.
getStatus
(),
HttpServletResponse
.
SC_OK
);
ObjectNode
entity
=
(
ObjectNode
)
response
.
getEntity
(
);
JsonNode
entity
=
AtlasJson
.
parseToV1JsonNode
((
String
)
response
.
getEntity
()
);
assertEquals
(
entity
.
get
(
"Status"
).
asText
(),
"ACTIVE"
);
}
@Test
public
void
testResourceGetsValueFromServiceState
()
{
public
void
testResourceGetsValueFromServiceState
()
throws
IOException
{
when
(
serviceState
.
getState
()).
thenReturn
(
ServiceState
.
ServiceStateValue
.
PASSIVE
);
AdminResource
adminResource
=
new
AdminResource
(
serviceState
,
null
,
null
,
null
,
null
);
Response
response
=
adminResource
.
getStatus
();
verify
(
serviceState
).
getState
();
ObjectNode
entity
=
(
ObjectNode
)
response
.
getEntity
(
);
JsonNode
entity
=
AtlasJson
.
parseToV1JsonNode
((
String
)
response
.
getEntity
()
);
assertEquals
(
entity
.
get
(
"Status"
).
asText
(),
"PASSIVE"
);
}
...
...
This diff is collapsed.
Click to expand it.
webapp/src/test/resources/json/search-parameters/entity-filters.json
View file @
ecf8095f
...
...
@@ -74,9 +74,19 @@
"limit"
:
50
,
"offset"
:
0
,
"entityFilters"
:
{
"attributeName"
:
"name"
,
"operator"
:
"neq"
,
"attributeValue"
:
"dummy /Table_1@0"
"condition"
:
"AND"
,
"criterion"
:
[
{
"attributeName"
:
"name"
,
"operator"
:
"neq"
,
"attributeValue"
:
"dummy /Table_1@0"
},
{
"attributeName"
:
"description"
,
"operator"
:
"isNull"
,
"attributeValue"
:
""
}
]
},
"tagFilters"
:
null
,
"attributes"
:
[
...
...
@@ -96,9 +106,19 @@
"limit"
:
25
,
"offset"
:
0
,
"entityFilters"
:
{
"attributeName"
:
"temporary"
,
"operator"
:
"eq"
,
"attributeValue"
:
"false"
"condition"
:
"AND"
,
"criterion"
:
[
{
"attributeName"
:
"temporary"
,
"operator"
:
"eq"
,
"attributeValue"
:
"false"
},
{
"attributeName"
:
"description"
,
"operator"
:
"isNull"
,
"attributeValue"
:
""
}
]
},
"tagFilters"
:
null
,
"attributes"
:
[
...
...
@@ -118,9 +138,19 @@
"limit"
:
50
,
"offset"
:
0
,
"entityFilters"
:
{
"attributeName"
:
"temporary"
,
"operator"
:
"neq"
,
"attributeValue"
:
"true"
"condition"
:
"AND"
,
"criterion"
:
[
{
"attributeName"
:
"temporary"
,
"operator"
:
"neq"
,
"attributeValue"
:
"true"
},
{
"attributeName"
:
"description"
,
"operator"
:
"isNull"
,
"attributeValue"
:
""
}
]
},
"tagFilters"
:
null
,
"attributes"
:
[
...
...
@@ -162,9 +192,19 @@
"limit"
:
25
,
"offset"
:
0
,
"entityFilters"
:
{
"attributeName"
:
"name"
,
"operator"
:
"endsWith"
,
"attributeValue"
:
"0"
"condition"
:
"AND"
,
"criterion"
:
[
{
"attributeName"
:
"name"
,
"operator"
:
"endsWith"
,
"attributeValue"
:
"0"
},
{
"attributeName"
:
"description"
,
"operator"
:
"isNull"
,
"attributeValue"
:
""
}
]
},
"tagFilters"
:
null
,
"attributes"
:
[
...
...
@@ -184,9 +224,19 @@
"limit"
:
25
,
"offset"
:
0
,
"entityFilters"
:
{
"attributeName"
:
"name"
,
"operator"
:
"endsWith"
,
"attributeValue"
:
"8"
"condition"
:
"AND"
,
"criterion"
:
[
{
"attributeName"
:
"name"
,
"operator"
:
"endsWith"
,
"attributeValue"
:
"8"
},
{
"attributeName"
:
"description"
,
"operator"
:
"isNull"
,
"attributeValue"
:
""
}
]
},
"tagFilters"
:
null
,
"attributes"
:
[
...
...
@@ -206,9 +256,19 @@
"limit"
:
25
,
"offset"
:
0
,
"entityFilters"
:
{
"attributeName"
:
"createTime"
,
"operator"
:
"lte"
,
"attributeValue"
:
"1491250084794"
"condition"
:
"AND"
,
"criterion"
:
[
{
"attributeName"
:
"createTime"
,
"operator"
:
"lte"
,
"attributeValue"
:
"1491250084794"
},
{
"attributeName"
:
"description"
,
"operator"
:
"isNull"
,
"attributeValue"
:
""
}
]
},
"tagFilters"
:
null
,
"attributes"
:
[
...
...
@@ -228,9 +288,19 @@
"limit"
:
25
,
"offset"
:
0
,
"entityFilters"
:
{
"attributeName"
:
"lastAccessTime"
,
"operator"
:
"gte"
,
"attributeValue"
:
"1491248907000"
"condition"
:
"AND"
,
"criterion"
:
[
{
"attributeName"
:
"lastAccessTime"
,
"operator"
:
"gte"
,
"attributeValue"
:
"1491248907000"
},
{
"attributeName"
:
"description"
,
"operator"
:
"isNull"
,
"attributeValue"
:
""
}
]
},
"tagFilters"
:
null
,
"attributes"
:
[
...
...
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