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
71ac0a94
Commit
71ac0a94
authored
Dec 15, 2014
by
Venkatesh Seetharam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ISSUE-5 Enable integration tests and add a few. Contributed by Venkatesh Seetharam
parent
5279a71c
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
284 additions
and
57 deletions
+284
-57
InstallationSteps.txt
InstallationSteps.txt
+57
-0
ServiceInitializer.java
...rg/apache/hadoop/metadata/service/ServiceInitializer.java
+3
-3
pom.xml
pom.xml
+27
-0
GraphBackedMetadataRepositoryService.java
...tadata/services/GraphBackedMetadataRepositoryService.java
+1
-0
Main.java
webapp/src/main/java/org/apache/hadoop/metadata/Main.java
+5
-3
AdminResource.java
...g/apache/hadoop/metadata/web/resources/AdminResource.java
+3
-4
EntityResource.java
.../apache/hadoop/metadata/web/resources/EntityResource.java
+3
-2
RexsterGraphResource.java
...e/hadoop/metadata/web/resources/RexsterGraphResource.java
+3
-3
TypesResource.java
...g/apache/hadoop/metadata/web/resources/TypesResource.java
+1
-1
application.properties
webapp/src/main/resources/application.properties
+18
-0
GraphRepositoryServiceIT.java
.../org/apache/hadoop/metadata/GraphRepositoryServiceIT.java
+2
-1
TitanGraphServiceIT.java
.../java/org/apache/hadoop/metadata/TitanGraphServiceIT.java
+1
-1
BaseResourceIT.java
.../apache/hadoop/metadata/web/resources/BaseResourceIT.java
+24
-0
EntityJerseyResourceIT.java
...hadoop/metadata/web/resources/EntityJerseyResourceIT.java
+71
-39
RexsterGraphJerseyResourceIT.java
.../metadata/web/resources/RexsterGraphJerseyResourceIT.java
+65
-0
No files found.
InstallationSteps.txt
0 → 100644
View file @
71ac0a94
# 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.
A. Building & Installing Metadata
=================================
0. Prerequisites
------------------
You would need the following installed:
* JDK 1.7
* Maven 3.x
1. Building Metadata
--------------------
Building metadata from the source repository
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* git clone git@github.com:hortonworks/metadata.git metadata
* cd metadata
* export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=256m" && mvn clean verify
2. Deploying Metadata
---------------------
Once the build successfully completes, artifacts can be packaged for deployment.
* mvn clean assembly:assembly -DskipTests -DskipITs
Tar can be found in {project dir}/target/apache-metadata-${project.version}-bin.tar.gz
Tar is structured as follows
TBD
3. Installing & running Metadata
--------------------------------
TBD
\ No newline at end of file
common/src/main/java/org/apache/hadoop/metadata/service/ServiceInitializer.java
View file @
71ac0a94
...
@@ -34,16 +34,16 @@ public class ServiceInitializer {
...
@@ -34,16 +34,16 @@ public class ServiceInitializer {
private
final
Services
services
=
Services
.
get
();
private
final
Services
services
=
Services
.
get
();
public
void
initialize
()
throws
MetadataException
{
public
void
initialize
()
throws
MetadataException
{
String
serviceClassNames
;
String
[]
serviceClassNames
;
try
{
try
{
PropertiesConfiguration
configuration
=
PropertiesConfiguration
configuration
=
new
PropertiesConfiguration
(
"application.properties"
);
new
PropertiesConfiguration
(
"application.properties"
);
serviceClassNames
=
configuration
.
getString
(
"application.services"
);
serviceClassNames
=
configuration
.
getString
Array
(
"application.services"
);
}
catch
(
ConfigurationException
e
)
{
}
catch
(
ConfigurationException
e
)
{
throw
new
RuntimeException
(
"unable to get server properties"
);
throw
new
RuntimeException
(
"unable to get server properties"
);
}
}
for
(
String
serviceClassName
:
serviceClassNames
.
split
(
","
)
)
{
for
(
String
serviceClassName
:
serviceClassNames
)
{
serviceClassName
=
serviceClassName
.
trim
();
serviceClassName
=
serviceClassName
.
trim
();
if
(
serviceClassName
.
isEmpty
())
{
if
(
serviceClassName
.
isEmpty
())
{
continue
;
continue
;
...
...
pom.xml
View file @
71ac0a94
...
@@ -724,6 +724,33 @@
...
@@ -724,6 +724,33 @@
</configuration>
</configuration>
</plugin>
</plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-failsafe-plugin
</artifactId>
<version>
2.16
</version>
<configuration>
<redirectTestOutputToFile>
true
</redirectTestOutputToFile>
<forkMode>
always
</forkMode>
<argLine>
-Djava.security.krb5.realm= -Djava.security.krb5.kdc=
-Dhadoop.tmp.dir=${project.build.directory}/tmp-hadoop-${user.name}
</argLine>
<excludedGroups>
${excluded.test.groups}
</excludedGroups>
</configuration>
<executions>
<execution>
<id>
integration-test
</id>
<goals>
<goal>
integration-test
</goal>
</goals>
</execution>
<execution>
<id>
verify
</id>
<goals>
<goal>
verify
</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Run the application using "mvn jetty:run" -->
<!-- Run the application using "mvn jetty:run" -->
<plugin>
<plugin>
<groupId>
org.mortbay.jetty
</groupId>
<groupId>
org.mortbay.jetty
</groupId>
...
...
repository/src/main/java/org/apache/hadoop/metadata/services/GraphBackedMetadataRepositoryService.java
View file @
71ac0a94
...
@@ -102,6 +102,7 @@ public class GraphBackedMetadataRepositoryService implements MetadataRepositoryS
...
@@ -102,6 +102,7 @@ public class GraphBackedMetadataRepositoryService implements MetadataRepositoryS
@Override
@Override
public
String
submitEntity
(
String
entity
,
String
entityType
)
{
public
String
submitEntity
(
String
entity
,
String
entityType
)
{
LOG
.
info
(
"adding entity={} type={}"
,
entity
,
entityType
);
LOG
.
info
(
"adding entity={} type={}"
,
entity
,
entityType
);
@SuppressWarnings
(
"unchecked"
)
Map
<
String
,
String
>
properties
=
(
Map
<
String
,
String
>)
JSONValue
.
parse
(
entity
);
Map
<
String
,
String
>
properties
=
(
Map
<
String
,
String
>)
JSONValue
.
parse
(
entity
);
final
String
entityName
=
properties
.
get
(
"entityName"
);
final
String
entityName
=
properties
.
get
(
"entityName"
);
...
...
webapp/src/main/java/org/apache/hadoop/metadata/Main.java
View file @
71ac0a94
...
@@ -23,7 +23,6 @@ import org.apache.commons.cli.GnuParser;
...
@@ -23,7 +23,6 @@ import org.apache.commons.cli.GnuParser;
import
org.apache.commons.cli.Option
;
import
org.apache.commons.cli.Option
;
import
org.apache.commons.cli.Options
;
import
org.apache.commons.cli.Options
;
import
org.apache.commons.cli.ParseException
;
import
org.apache.commons.cli.ParseException
;
import
org.apache.commons.configuration.ConfigurationException
;
import
org.apache.commons.configuration.PropertiesConfiguration
;
import
org.apache.commons.configuration.PropertiesConfiguration
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.hadoop.metadata.web.service.EmbeddedServer
;
import
org.apache.hadoop.metadata.web.service.EmbeddedServer
;
...
@@ -61,7 +60,8 @@ public final class Main {
...
@@ -61,7 +60,8 @@ public final class Main {
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
CommandLine
cmd
=
parseArgs
(
args
);
CommandLine
cmd
=
parseArgs
(
args
);
String
projectVersion
=
getProjectVersion
();
// todo: enable version for webapp
// String projectVersion = getProjectVersion();
// String appPath = "webapp/target/metadata-webapp-" + projectVersion;
// String appPath = "webapp/target/metadata-webapp-" + projectVersion;
String
appPath
=
"webapp/target/metadata-governance"
;
String
appPath
=
"webapp/target/metadata-governance"
;
...
@@ -82,11 +82,13 @@ public final class Main {
...
@@ -82,11 +82,13 @@ public final class Main {
server
.
start
();
server
.
start
();
}
}
/*
private static String getProjectVersion() throws ConfigurationException {
private static String getProjectVersion() throws ConfigurationException {
PropertiesConfiguration configuration =
PropertiesConfiguration configuration =
new PropertiesConfiguration("metadata-buildinfo.properties");
new PropertiesConfiguration("metadata-buildinfo.properties");
return configuration.getString("project.version");
return configuration.getString("project.version");
}
}
*/
private
static
int
getApplicationPort
(
CommandLine
cmd
,
String
enableTLSFlag
)
{
private
static
int
getApplicationPort
(
CommandLine
cmd
,
String
enableTLSFlag
)
{
final
int
appPort
;
final
int
appPort
;
...
@@ -95,7 +97,7 @@ public final class Main {
...
@@ -95,7 +97,7 @@ public final class Main {
}
else
{
}
else
{
// default : metadata.enableTLS is true
// default : metadata.enableTLS is true
appPort
=
StringUtils
.
isEmpty
(
enableTLSFlag
)
appPort
=
StringUtils
.
isEmpty
(
enableTLSFlag
)
||
enableTLSFlag
.
equals
(
"true"
)
?
15443
:
15
000
;
||
enableTLSFlag
.
equals
(
"true"
)
?
21443
:
21
000
;
}
}
return
appPort
;
return
appPort
;
...
...
webapp/src/main/java/org/apache/hadoop/metadata/web/resources/AdminResource.java
View file @
71ac0a94
...
@@ -20,7 +20,6 @@ package org.apache.hadoop.metadata.web.resources;
...
@@ -20,7 +20,6 @@ package org.apache.hadoop.metadata.web.resources;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.hadoop.metadata.web.util.Servlets
;
import
org.apache.hadoop.metadata.web.util.Servlets
;
import
org.apache.hadoop.util.VersionInfo
;
import
org.codehaus.jettison.json.JSONException
;
import
org.codehaus.jettison.json.JSONException
;
import
org.codehaus.jettison.json.JSONObject
;
import
org.codehaus.jettison.json.JSONObject
;
...
@@ -69,7 +68,8 @@ public class AdminResource {
...
@@ -69,7 +68,8 @@ public class AdminResource {
try
{
try
{
JSONObject
response
=
new
JSONObject
();
JSONObject
response
=
new
JSONObject
();
response
.
put
(
"Version"
,
"v0.1"
);
// todo: get version
response
.
put
(
"Version"
,
"v0.1"
);
// todo: get version
response
.
put
(
"Hadoop"
,
VersionInfo
.
getVersion
()
+
"-r"
+
VersionInfo
.
getRevision
());
// todo: add hadoop version?
// response.put("Hadoop", VersionInfo.getVersion() + "-r" + VersionInfo.getRevision());
version
=
Response
.
ok
(
response
).
build
();
version
=
Response
.
ok
(
response
).
build
();
}
catch
(
JSONException
e
)
{
}
catch
(
JSONException
e
)
{
throw
new
WebApplicationException
(
throw
new
WebApplicationException
(
...
@@ -79,4 +79,4 @@ public class AdminResource {
...
@@ -79,4 +79,4 @@ public class AdminResource {
return
version
;
return
version
;
}
}
}
}
\ No newline at end of file
webapp/src/main/java/org/apache/hadoop/metadata/web/resources/EntityResource.java
View file @
71ac0a94
...
@@ -108,9 +108,10 @@ public class EntityResource {
...
@@ -108,9 +108,10 @@ public class EntityResource {
@Produces
(
MediaType
.
APPLICATION_JSON
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
public
Response
getEntityDefinition
(
@PathParam
(
"entityType"
)
String
entityType
,
public
Response
getEntityDefinition
(
@PathParam
(
"entityType"
)
String
entityType
,
@PathParam
(
"entityName"
)
String
entityName
)
{
@PathParam
(
"entityName"
)
String
entityName
)
{
final
String
entityDefinition
=
repositoryService
.
getEntityDefinition
(
entityName
,
entityType
);
final
String
entityDefinition
=
repositoryService
.
getEntityDefinition
(
entityName
,
entityType
);
return
Response
.
ok
(
entityDefinition
).
build
();
return
(
entityDefinition
==
null
)
?
Response
.
status
(
Response
.
Status
.
NOT_FOUND
).
build
()
:
Response
.
ok
(
entityDefinition
).
build
();
}
}
@POST
@POST
...
...
webapp/src/main/java/org/apache/hadoop/metadata/web/resources/GraphResource.java
→
webapp/src/main/java/org/apache/hadoop/metadata/web/resources/
Rexster
GraphResource.java
View file @
71ac0a94
...
@@ -56,15 +56,15 @@ import java.util.Set;
...
@@ -56,15 +56,15 @@ import java.util.Set;
* https://github.com/tinkerpop/rexster/wiki/Basic-REST-API
* https://github.com/tinkerpop/rexster/wiki/Basic-REST-API
*/
*/
@Path
(
"graph"
)
@Path
(
"graph"
)
public
class
GraphResource
{
public
class
Rexster
GraphResource
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
GraphResource
.
class
);
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
Rexster
GraphResource
.
class
);
public
static
final
String
RESULTS
=
"results"
;
public
static
final
String
RESULTS
=
"results"
;
public
static
final
String
TOTAL_SIZE
=
"totalSize"
;
public
static
final
String
TOTAL_SIZE
=
"totalSize"
;
private
GraphService
graphService
;
private
GraphService
graphService
;
public
GraphResource
()
{
public
Rexster
GraphResource
()
{
graphService
=
Services
.
get
().
getService
(
TitanGraphService
.
NAME
);
graphService
=
Services
.
get
().
getService
(
TitanGraphService
.
NAME
);
if
(
graphService
==
null
)
{
if
(
graphService
==
null
)
{
throw
new
WebApplicationException
(
Response
throw
new
WebApplicationException
(
Response
...
...
webapp/src/main/java/org/apache/hadoop/metadata/web/resources/TypesResource.java
View file @
71ac0a94
...
@@ -32,7 +32,7 @@ public class TypesResource {
...
@@ -32,7 +32,7 @@ public class TypesResource {
@POST
@POST
@Path
(
"submit/{type}"
)
@Path
(
"submit/{type}"
)
@Consumes
(
MediaType
.
TEXT_XML
)
@Consumes
(
MediaType
.
APPLICATION_JSON
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
public
Response
submit
(
@Context
HttpServletRequest
request
,
public
Response
submit
(
@Context
HttpServletRequest
request
,
@PathParam
(
"type"
)
String
type
)
{
@PathParam
(
"type"
)
String
type
)
{
...
...
webapp/src/main/resources/application.properties
View file @
71ac0a94
...
@@ -20,6 +20,16 @@ application.services=org.apache.hadoop.metadata.services.TitanGraphService,\
...
@@ -20,6 +20,16 @@ application.services=org.apache.hadoop.metadata.services.TitanGraphService,\
org.apache.hadoop.metadata.services.GraphBackedMetadataRepositoryService
org.apache.hadoop.metadata.services.GraphBackedMetadataRepositoryService
######### Implementation classes #########
## DO NOT MODIFY UNLESS SURE ABOUT CHANGE ##
metadata.GraphService.impl
=
org.apache.hadoop.metadata.services.TitanGraphService
metadata.MetadataRepositoryService.impl
=
org.apache.hadoop.metadata.services.GraphBackedMetadataRepositoryService
######### Implementation classes #########
######### Graph Database Configs #########
# Graph implementation
# Graph implementation
#metadata.graph.blueprints.graph=com.thinkaurelius.titan.core.TitanFactory
#metadata.graph.blueprints.graph=com.thinkaurelius.titan.core.TitanFactory
...
@@ -33,4 +43,12 @@ metadata.graph.index.search.directory=target/data/es
...
@@ -33,4 +43,12 @@ metadata.graph.index.search.directory=target/data/es
metadata.graph.index.search.elasticsearch.client-only
=
false
metadata.graph.index.search.elasticsearch.client-only
=
false
metadata.graph.index.search.elasticsearch.local-mode
=
true
metadata.graph.index.search.elasticsearch.local-mode
=
true
######### Graph Database Configs #########
######### Security Properties #########
# SSL config
metadata.enableTLS
=
false
metadata.enableTLS
=
false
######### Security Properties #########
webapp/src/test/java/org/apache/hadoop/metadata/GraphRepositoryServiceI
ntegrationTest
.java
→
webapp/src/test/java/org/apache/hadoop/metadata/GraphRepositoryServiceI
T
.java
View file @
71ac0a94
...
@@ -12,7 +12,7 @@ import org.testng.annotations.Test;
...
@@ -12,7 +12,7 @@ import org.testng.annotations.Test;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
public
class
GraphRepositoryServiceI
ntegrationTest
{
public
class
GraphRepositoryServiceI
T
{
private
static
final
String
ENTITY_NAME
=
"clicks-table"
;
private
static
final
String
ENTITY_NAME
=
"clicks-table"
;
private
static
final
String
ENTITY_TYPE
=
"hive-table"
;
private
static
final
String
ENTITY_TYPE
=
"hive-table"
;
...
@@ -48,6 +48,7 @@ public class GraphRepositoryServiceIntegrationTest {
...
@@ -48,6 +48,7 @@ public class GraphRepositoryServiceIntegrationTest {
Assert
.
assertNotNull
(
guid
);
Assert
.
assertNotNull
(
guid
);
String
entity
=
repositoryService
.
getEntityDefinition
(
ENTITY_NAME
,
ENTITY_TYPE
);
String
entity
=
repositoryService
.
getEntityDefinition
(
ENTITY_NAME
,
ENTITY_TYPE
);
@SuppressWarnings
(
"unchecked"
)
Map
<
String
,
String
>
entityProperties
=
Map
<
String
,
String
>
entityProperties
=
(
Map
<
String
,
String
>)
JSONValue
.
parseWithException
(
entity
);
(
Map
<
String
,
String
>)
JSONValue
.
parseWithException
(
entity
);
Assert
.
assertEquals
(
entityProperties
.
get
(
"guid"
),
guid
);
Assert
.
assertEquals
(
entityProperties
.
get
(
"guid"
),
guid
);
...
...
webapp/src/test/java/org/apache/hadoop/metadata/TitanGraphServiceI
ntegrationTest
.java
→
webapp/src/test/java/org/apache/hadoop/metadata/TitanGraphServiceI
T
.java
View file @
71ac0a94
...
@@ -13,7 +13,7 @@ import java.util.UUID;
...
@@ -13,7 +13,7 @@ import java.util.UUID;
/**
/**
* End to end graph put/get test.
* End to end graph put/get test.
*/
*/
public
class
TitanGraphServiceI
ntegrationTest
{
public
class
TitanGraphServiceI
T
{
@Test
@Test
public
void
testTitanGraph
()
throws
Exception
{
public
void
testTitanGraph
()
throws
Exception
{
...
...
webapp/src/test/java/org/apache/hadoop/metadata/web/resources/BaseResourceIT.java
0 → 100644
View file @
71ac0a94
package
org
.
apache
.
hadoop
.
metadata
.
web
.
resources
;
import
com.sun.jersey.api.client.Client
;
import
com.sun.jersey.api.client.WebResource
;
import
com.sun.jersey.api.client.config.DefaultClientConfig
;
import
org.testng.annotations.BeforeClass
;
import
javax.ws.rs.core.UriBuilder
;
public
class
BaseResourceIT
{
protected
WebResource
service
;
@BeforeClass
public
void
setUp
()
throws
Exception
{
String
baseUrl
=
"http://localhost:21000/"
;
DefaultClientConfig
config
=
new
DefaultClientConfig
();
Client
client
=
Client
.
create
(
config
);
client
.
resource
(
UriBuilder
.
fromUri
(
baseUrl
).
build
());
service
=
client
.
resource
(
UriBuilder
.
fromUri
(
baseUrl
).
build
());
}
}
webapp/src/test/java/org/apache/hadoop/metadata/
MetadataJerseyIntegrationTest
.java
→
webapp/src/test/java/org/apache/hadoop/metadata/
web/resources/EntityJerseyResourceIT
.java
View file @
71ac0a94
...
@@ -16,85 +16,117 @@
...
@@ -16,85 +16,117 @@
* limitations under the License.
* limitations under the License.
*/
*/
package
org
.
apache
.
hadoop
.
metadata
;
package
org
.
apache
.
hadoop
.
metadata
.
web
.
resources
;
import
com.sun.jersey.api.client.Client
;
import
com.sun.jersey.api.client.ClientResponse
;
import
com.sun.jersey.api.client.ClientResponse
;
import
com.sun.jersey.api.client.WebResource
;
import
com.sun.jersey.api.client.WebResource
;
import
com.sun.jersey.api.client.config.DefaultClientConfig
;
import
org.json.simple.JSONValue
;
import
org.json.simple.JSONValue
;
import
org.testng.Assert
;
import
org.testng.annotations.Test
;
import
org.testng.annotations.Test
;
import
javax.ws.rs.HttpMethod
;
import
javax.ws.rs.HttpMethod
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.
UriBuilder
;
import
javax.ws.rs.core.
Response
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.UUID
;
public
class
MetadataJerseyIntegrationTest
{
/**
* Integration tests for Entity Jersey Resource.
*/
public
class
EntityJerseyResourceIT
extends
BaseResourceIT
{
@Test
(
enabled
=
false
)
private
static
final
String
ENTITY_NAME
=
"clicks-table"
;
public
void
testMetadataRESTAPI
()
throws
Exception
{
private
static
final
String
ENTITY_TYPE
=
"hive-table"
;
String
baseUrl
=
"http://localhost:15000/"
;
private
static
final
String
DATABASE_NAME
=
"ads"
;
private
static
final
String
TABLE_NAME
=
"clicks-table"
;
DefaultClientConfig
config
=
new
DefaultClientConfig
();
@Test
Client
client
=
Client
.
create
(
config
);
public
void
testSubmitEntity
()
{
client
.
resource
(
UriBuilder
.
fromUri
(
baseUrl
).
build
()
);
String
entityStream
=
getTestEntityJSON
(
);
WebResource
service
=
client
.
resource
(
UriBuilder
.
fromUri
(
baseUrl
).
build
());
WebResource
resource
=
service
.
path
(
"api/metadata/entities/submit"
)
.
path
(
ENTITY_TYPE
);
/*
ClientResponse
clientResponse
=
resource
ClientResponse clientResponse = service.path("api/metadata/entities/list/blah")
.
accept
(
MediaType
.
APPLICATION_JSON
)
.
accept
(
MediaType
.
APPLICATION_JSON
)
.
type
(
MediaType
.
APPLICATION_JSON
)
.
type
(
MediaType
.
APPLICATION_JSON
)
.method(HttpMethod.GET, ClientResponse.class);
.
method
(
HttpMethod
.
POST
,
ClientResponse
.
class
,
entityStream
);
Assert
.
assertEquals
(
clientResponse
.
getStatus
(),
Response
.
Status
.
OK
.
getStatusCode
());
String
response
=
clientResponse
.
getEntity
(
String
.
class
);
String
response
=
clientResponse
.
getEntity
(
String
.
class
);
System.out.println("response = " + response);
Assert
.
assertNotNull
(
response
);
*/
// String filePath = "/tmp/metadata/sampleentity.json";
try
{
// InputStream entityStream = getServletInputStream(filePath);
Assert
.
assertNotNull
(
UUID
.
fromString
(
response
));
}
catch
(
IllegalArgumentException
e
)
{
final
String
entityName
=
"clicks-table"
;
Assert
.
fail
(
"Response is not a guid, "
+
response
);
final
String
entityType
=
"hive-table"
;
}
}
submitEntity
(
service
,
entityName
,
entityType
);
@Test
(
dependsOnMethods
=
"testSubmitEntity"
)
public
void
testGetEntityDefinition
()
{
WebResource
resource
=
service
WebResource
resource
=
service
.
path
(
"api/metadata/entities/definition"
)
.
path
(
"api/metadata/entities/definition"
)
.
path
(
entityType
)
.
path
(
ENTITY_TYPE
)
.
path
(
entityName
);
.
path
(
ENTITY_NAME
);
ClientResponse
clientResponse
=
resource
ClientResponse
clientResponse
=
resource
.
accept
(
MediaType
.
APPLICATION_JSON
)
.
accept
(
MediaType
.
APPLICATION_JSON
)
.
type
(
MediaType
.
APPLICATION_JSON
)
.
type
(
MediaType
.
APPLICATION_JSON
)
.
method
(
HttpMethod
.
GET
,
ClientResponse
.
class
);
.
method
(
HttpMethod
.
GET
,
ClientResponse
.
class
);
Assert
.
assertEquals
(
clientResponse
.
getStatus
(),
Response
.
Status
.
OK
.
getStatusCode
());
String
response
=
clientResponse
.
getEntity
(
String
.
class
);
String
response
=
clientResponse
.
getEntity
(
String
.
class
);
System
.
out
.
println
(
"response = "
+
response
);
System
.
out
.
println
(
"response = "
+
response
);
}
}
private
static
void
submitEntity
(
WebResource
service
,
String
entityName
,
String
entityType
)
{
private
static
String
getTestEntityJSON
()
{
String
entityStream
=
getTestEntityJSON
(
entityName
,
entityType
);
Map
<
String
,
String
>
props
=
new
HashMap
<>();
props
.
put
(
"entityName"
,
ENTITY_NAME
);
props
.
put
(
"entityType"
,
ENTITY_TYPE
);
props
.
put
(
"database"
,
DATABASE_NAME
);
props
.
put
(
"table"
,
TABLE_NAME
);
return
JSONValue
.
toJSONString
(
props
);
}
@Test
public
void
testGetInvalidEntityDefinition
()
{
WebResource
resource
=
service
WebResource
resource
=
service
.
path
(
"api/metadata/entities/submit"
)
.
path
(
"api/metadata/entities/definition"
)
.
path
(
entityType
);
.
path
(
ENTITY_TYPE
)
.
path
(
"blah"
);
ClientResponse
clientResponse
=
resource
ClientResponse
clientResponse
=
resource
.
accept
(
MediaType
.
APPLICATION_JSON
)
.
accept
(
MediaType
.
APPLICATION_JSON
)
.
type
(
MediaType
.
APPLICATION_JSON
)
.
type
(
MediaType
.
APPLICATION_JSON
)
.
method
(
HttpMethod
.
POST
,
ClientResponse
.
class
,
entityStream
);
.
method
(
HttpMethod
.
GET
,
ClientResponse
.
class
);
Assert
.
assertEquals
(
clientResponse
.
getStatus
(),
Response
.
Status
.
NOT_FOUND
.
getStatusCode
());
String
response
=
clientResponse
.
getEntity
(
String
.
class
);
String
response
=
clientResponse
.
getEntity
(
String
.
class
);
System
.
out
.
println
(
"response = "
+
response
);
System
.
out
.
println
(
"response = "
+
response
);
}
}
private
static
String
getTestEntityJSON
(
String
entityName
,
String
entityType
)
{
@Test
(
dependsOnMethods
=
"testSubmitEntity"
)
Map
<
String
,
String
>
props
=
new
HashMap
<>();
public
void
testGetEntityList
()
{
props
.
put
(
"entityName"
,
entityName
);
ClientResponse
clientResponse
=
service
props
.
put
(
"entityType"
,
entityType
);
.
path
(
"api/metadata/entities/list/"
)
props
.
put
(
"database"
,
"foo"
);
.
path
(
ENTITY_TYPE
)
props
.
put
(
"blah"
,
"blah"
);
.
accept
(
MediaType
.
APPLICATION_JSON
)
return
JSONValue
.
toJSONString
(
props
);
.
type
(
MediaType
.
APPLICATION_JSON
)
.
method
(
HttpMethod
.
GET
,
ClientResponse
.
class
);
Assert
.
assertEquals
(
clientResponse
.
getStatus
(),
Response
.
Status
.
OK
.
getStatusCode
());
String
response
=
clientResponse
.
getEntity
(
String
.
class
);
System
.
out
.
println
(
"response = "
+
response
);
}
@Test
(
enabled
=
false
)
// todo: enable this later
public
void
testGetEntityListForBadEntityType
()
{
ClientResponse
clientResponse
=
service
.
path
(
"api/metadata/entities/list/blah"
)
.
accept
(
MediaType
.
APPLICATION_JSON
)
.
type
(
MediaType
.
APPLICATION_JSON
)
.
method
(
HttpMethod
.
GET
,
ClientResponse
.
class
);
Assert
.
assertEquals
(
clientResponse
.
getStatus
(),
Response
.
Status
.
NOT_FOUND
.
getStatusCode
());
String
response
=
clientResponse
.
getEntity
(
String
.
class
);
System
.
out
.
println
(
"response = "
+
response
);
}
}
}
}
webapp/src/test/java/org/apache/hadoop/metadata/web/resources/RexsterGraphJerseyResourceIT.java
0 → 100644
View file @
71ac0a94
package
org
.
apache
.
hadoop
.
metadata
.
web
.
resources
;
import
com.sun.jersey.api.client.ClientResponse
;
import
com.sun.jersey.api.client.WebResource
;
import
org.testng.Assert
;
import
org.testng.annotations.Test
;
import
javax.ws.rs.HttpMethod
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.Response
;
/**
* Integration tests for Rexster Graph Jersey Resource.
*/
public
class
RexsterGraphJerseyResourceIT
extends
BaseResourceIT
{
@Test
(
enabled
=
false
)
public
void
testGetVertex
()
throws
Exception
{
// todo: add a vertex before fetching it
WebResource
resource
=
service
.
path
(
"api/metadata/graph/vertices"
)
.
path
(
"0"
);
ClientResponse
clientResponse
=
resource
.
accept
(
MediaType
.
APPLICATION_JSON
)
.
type
(
MediaType
.
APPLICATION_JSON
)
.
method
(
HttpMethod
.
GET
,
ClientResponse
.
class
);
Assert
.
assertEquals
(
clientResponse
.
getStatus
(),
Response
.
Status
.
OK
.
getStatusCode
());
String
response
=
clientResponse
.
getEntity
(
String
.
class
);
Assert
.
assertNotNull
(
response
);
}
@Test
public
void
testGetVertexWithInvalidId
()
throws
Exception
{
WebResource
resource
=
service
.
path
(
"api/metadata/graph/vertices/blah"
);
ClientResponse
clientResponse
=
resource
.
accept
(
MediaType
.
APPLICATION_JSON
)
.
type
(
MediaType
.
APPLICATION_JSON
)
.
method
(
HttpMethod
.
GET
,
ClientResponse
.
class
);
Assert
.
assertEquals
(
clientResponse
.
getStatus
(),
Response
.
Status
.
NOT_FOUND
.
getStatusCode
());
}
@Test
public
void
testGetVertexProperties
()
throws
Exception
{
}
@Test
public
void
testGetVertices
()
throws
Exception
{
}
@Test
public
void
testGetVertexEdges
()
throws
Exception
{
}
@Test
public
void
testGetEdge
()
throws
Exception
{
}
}
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