atlas-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From svimal2...@apache.org
Subject incubator-atlas git commit: V2 API webapp tests are failing(ayubkhan via svimal2106)
Date Thu, 24 Nov 2016 10:36:33 GMT
Repository: incubator-atlas
Updated Branches:
  refs/heads/master d4efc3784 -> b9525a576


V2 API webapp tests are failing(ayubkhan via svimal2106)


Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/b9525a57
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/b9525a57
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/b9525a57

Branch: refs/heads/master
Commit: b9525a576d1f4149883fad494f4d4e8310cc7f85
Parents: d4efc37
Author: Vimal Sharma <svimal2106@apache.org>
Authored: Thu Nov 24 16:06:05 2016 +0530
Committer: Vimal Sharma <svimal2106@apache.org>
Committed: Thu Nov 24 16:06:05 2016 +0530

----------------------------------------------------------------------
 pom.xml                                         |  1 -
 release-log.txt                                 |  1 +
 .../DataSetLineageJerseyResourceIT.java         | 15 +++++++
 .../MetadataDiscoveryJerseyResourceIT.java      | 47 ++++++++++----------
 .../web/resources/TypedefsJerseyResourceIT.java | 16 +++++--
 .../web/resources/TypesJerseyResourceIT.java    | 42 +++++++++--------
 webapp/src/test/webapp/WEB-INF/web.xml          | 17 ++++---
 7 files changed, 88 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/b9525a57/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 641165e..2b65a38 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1751,7 +1751,6 @@
                     <redirectTestOutputToFile>true</redirectTestOutputToFile>
                     <!-- ATLAS-1317: Disable problematic tests. Need to revisit and fix
them later -->
                     <excludes>
-                        <exclude>**/TypedefsJerseyResourceIT.java</exclude>
                         <exclude>**/TypesJerseyResourceIT.java</exclude>
                         <exclude>**/MetadataDiscoveryJerseyResourceIT.java</exclude>
                         <exclude>**/HiveHookIT.java</exclude>

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/b9525a57/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index e49b269..9b9657d 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -9,6 +9,7 @@ ATLAS-1060 Add composite indexes for exact match performance improvements
for al
 ATLAS-1127 Modify creation and modification timestamps to Date instead of Long(sumasai)
 
 ALL CHANGES:
+ATLAS-1316 V2 API webapp tests are failing (ayubkhan via svimal2106)
 ATLAS-1315 Fix webapp Integration tests (ayubkhan,apoorvnaik via svimal2106)
 ATLAS-1313 Tests SSLAndKerberosTest.testService and SSLTest.testService are failing (ayubkhan
via svimal2106)
 ATLAS-1116 Performance monitoring of backend methods in API requests (shwethags)

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/b9525a57/webapp/src/test/java/org/apache/atlas/web/resources/DataSetLineageJerseyResourceIT.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/web/resources/DataSetLineageJerseyResourceIT.java
b/webapp/src/test/java/org/apache/atlas/web/resources/DataSetLineageJerseyResourceIT.java
index f9e4c40..d9f14d0 100644
--- a/webapp/src/test/java/org/apache/atlas/web/resources/DataSetLineageJerseyResourceIT.java
+++ b/webapp/src/test/java/org/apache/atlas/web/resources/DataSetLineageJerseyResourceIT.java
@@ -32,6 +32,10 @@ import org.codehaus.jettison.json.JSONObject;
 import org.testng.Assert;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
+import org.apache.atlas.typesystem.types.HierarchicalTypeDefinition;
+import org.apache.atlas.typesystem.types.TraitType;
+import org.apache.atlas.typesystem.types.utils.TypesUtil;
+import com.google.common.collect.ImmutableSet;
 
 import javax.ws.rs.HttpMethod;
 import javax.ws.rs.core.Response;
@@ -213,6 +217,17 @@ public class DataSetLineageJerseyResourceIT extends BaseResourceIT {
     }
 
     private void setupInstances() throws Exception {
+        HierarchicalTypeDefinition<TraitType> factTrait =
+                TypesUtil.createTraitTypeDef("Fact", ImmutableSet.<String>of());
+        HierarchicalTypeDefinition<TraitType> etlTrait =
+                TypesUtil.createTraitTypeDef("ETL", ImmutableSet.<String>of());
+        HierarchicalTypeDefinition<TraitType> dimensionTrait =
+                TypesUtil.createTraitTypeDef("Dimension", ImmutableSet.<String>of());
+        HierarchicalTypeDefinition<TraitType> metricTrait =
+                TypesUtil.createTraitTypeDef("Metric", ImmutableSet.<String>of());
+        createType(getTypesDef(null, null,
+                        ImmutableList.of(factTrait, etlTrait, dimensionTrait, metricTrait),
null));
+
         salesDBName = "Sales" + randomString();
         Id salesDB = database(salesDBName, "Sales Database", "John ETL",
                 "hdfs://host:8000/apps/warehouse/sales");

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/b9525a57/webapp/src/test/java/org/apache/atlas/web/resources/MetadataDiscoveryJerseyResourceIT.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/web/resources/MetadataDiscoveryJerseyResourceIT.java
b/webapp/src/test/java/org/apache/atlas/web/resources/MetadataDiscoveryJerseyResourceIT.java
index 9aff145..13ef503 100755
--- a/webapp/src/test/java/org/apache/atlas/web/resources/MetadataDiscoveryJerseyResourceIT.java
+++ b/webapp/src/test/java/org/apache/atlas/web/resources/MetadataDiscoveryJerseyResourceIT.java
@@ -57,18 +57,19 @@ import static org.testng.Assert.fail;
 public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT {
 
     private String tagName;
+    private String dbName;
 
     @BeforeClass
     public void setUp() throws Exception {
         super.setUp();
+        dbName = "db"+randomString();
 
-        createTypes();
-        createInstance();
+        createInstance( createHiveDBInstance(dbName) );
     }
 
     @Test
     public void testSearchByDSL() throws Exception {
-        String dslQuery = "from dsl_test_type";
+        String dslQuery = "from "+ DATABASE_TYPE + " qualifiedName=\"" + dbName + "\"";
         WebResource resource = service.path("api/atlas/discovery/search/dsl").queryParam("query",
dslQuery);
 
         ClientResponse clientResponse = resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
@@ -86,21 +87,17 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT
{
 
         JSONArray results = response.getJSONArray(AtlasClient.RESULTS);
         Assert.assertNotNull(results);
-        assertEquals(results.length(), 2);
+        assertEquals(results.length(), 1);
 
         int numRows = response.getInt(AtlasClient.COUNT);
-        assertEquals(numRows, 2);
+        assertEquals(numRows, 1);
     }
 
     @Test
     public void testSearchDSLLimits() throws Exception {
-        Referenceable entity = new Referenceable("dsl_test_type");
-        entity.set("name", randomString());
-        entity.set("description", randomString());
-        createInstance(entity);
 
         //search without new parameters of limit and offset should work
-        String dslQuery = "from dsl_test_type";
+        String dslQuery = "from "+ DATABASE_TYPE + " qualifiedName=\"" + dbName + "\"";
         WebResource resource = service.path("api/atlas/discovery/search/dsl").queryParam("query",
dslQuery);
 
         ClientResponse clientResponse = resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
@@ -109,11 +106,11 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT
{
 
         //higher limit, all results returned
         JSONArray results = serviceClient.searchByDSL(dslQuery, 10, 0);
-        assertEquals(results.length(), 2);
+        assertEquals(results.length(), 1);
 
         //default limit and offset -1, all results returned
         results = serviceClient.searchByDSL(dslQuery, -1, -1);
-        assertEquals(results.length(), 2);
+        assertEquals(results.length(), 1);
 
         //uses the limit parameter passed
         results = serviceClient.searchByDSL(dslQuery, 1, 0);
@@ -121,7 +118,7 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT
{
 
         //uses the offset parameter passed
         results = serviceClient.searchByDSL(dslQuery, 10, 1);
-        assertEquals(results.length(), 1);
+        assertEquals(results.length(), 0);
 
         //limit > 0
         try {
@@ -160,7 +157,7 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT
{
 
     @Test
     public void testSearchUsingGremlin() throws Exception {
-        String query = "g.V.has('type', 'dsl_test_type').toList()";
+        String query = "g.V.has('type', 'hive_db').toList()";
         WebResource resource = service.path("api/atlas/discovery/search/gremlin").queryParam("query",
query);
 
         ClientResponse clientResponse = resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
@@ -179,7 +176,8 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT
{
 
     @Test
     public void testSearchUsingDSL() throws Exception {
-        String query = "from dsl_test_type";
+        //String query = "from dsl_test_type";
+        String query = "from "+ DATABASE_TYPE + " qualifiedName=\"" + dbName +"\"";
         WebResource resource = service.path("api/atlas/discovery/search").queryParam("query",
query);
 
         ClientResponse clientResponse = resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
@@ -217,10 +215,10 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT
{
 
     @Test(dependsOnMethods = "testSearchDSLLimits")
     public void testSearchUsingFullText() throws Exception {
-        JSONObject response = serviceClient.searchByFullText(tagName, 10, 0);
+        JSONObject response = serviceClient.searchByFullText(dbName, 10, 0);
         Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
 
-        assertEquals(response.getString("query"), tagName);
+        assertEquals(response.getString("query"), dbName);
         assertEquals(response.getString("queryType"), "full-text");
 
         JSONArray results = response.getJSONArray(AtlasClient.RESULTS);
@@ -228,29 +226,29 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT
{
 
         JSONObject row = results.getJSONObject(0);
         Assert.assertNotNull(row.get("guid"));
-        assertEquals(row.getString("typeName"), "dsl_test_type");
+        assertEquals(row.getString("typeName"), DATABASE_TYPE);
         Assert.assertNotNull(row.get("score"));
 
         int numRows = response.getInt(AtlasClient.COUNT);
         assertEquals(numRows, 1);
 
         //API works without limit and offset
-        String query = "dsl_test_type";
+        String query = dbName;
         WebResource resource = service.path("api/atlas/discovery/search/fulltext").queryParam("query",
query);
         ClientResponse clientResponse = resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
                                                 .method(HttpMethod.GET, ClientResponse.class);
         assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode());
         results = new JSONObject(clientResponse.getEntity(String.class)).getJSONArray(AtlasClient.RESULTS);
-        assertEquals(results.length(), 2);
+        assertEquals(results.length(), 1);
 
         //verify passed in limits and offsets are used
         //higher limit and 0 offset returns all results
         results = serviceClient.searchByFullText(query, 10, 0).getJSONArray(AtlasClient.RESULTS);
-        assertEquals(results.length(), 2);
+        assertEquals(results.length(), 1);
 
         //offset is used
         results = serviceClient.searchByFullText(query, 10, 1).getJSONArray(AtlasClient.RESULTS);
-        assertEquals(results.length(), 1);
+        assertEquals(results.length(), 0);
 
         //limit is used
         results = serviceClient.searchByFullText(query, 1, 0).getJSONArray(AtlasClient.RESULTS);
@@ -277,8 +275,9 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT
{
 
     private Id createInstance() throws Exception {
         Referenceable entityInstance = new Referenceable("dsl_test_type", "Classification");
-        entityInstance.set("name", "foo name");
-        entityInstance.set("description", "bar description");
+        entityInstance.set("name", randomString());
+        entityInstance.set("description", randomString());
+
 
         Struct traitInstance = (Struct) entityInstance.getTrait("Classification");
         tagName = randomString();

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/b9525a57/webapp/src/test/java/org/apache/atlas/web/resources/TypedefsJerseyResourceIT.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/web/resources/TypedefsJerseyResourceIT.java
b/webapp/src/test/java/org/apache/atlas/web/resources/TypedefsJerseyResourceIT.java
index ea55698..2fa1602 100644
--- a/webapp/src/test/java/org/apache/atlas/web/resources/TypedefsJerseyResourceIT.java
+++ b/webapp/src/test/java/org/apache/atlas/web/resources/TypedefsJerseyResourceIT.java
@@ -52,6 +52,7 @@ import static org.apache.atlas.type.AtlasTypeUtil.createClassTypeDef;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertFalse;
 import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
 import static org.testng.Assert.fail;
 
 /**
@@ -108,8 +109,9 @@ public class TypedefsJerseyResourceIT extends BaseResourceIT {
 
     @Test
     public void testUpdate() throws Exception {
+        String entityType = randomString();
         AtlasEntityDef typeDefinition =
-                createClassTypeDef(randomString(), ImmutableSet.<String>of(),
+                createClassTypeDef(entityType, ImmutableSet.<String>of(),
                         AtlasTypeUtil.createUniqueRequiredAttrDef("name", "string"));
 
         AtlasTypesDef atlasTypesDef = new AtlasTypesDef();
@@ -135,10 +137,18 @@ public class TypedefsJerseyResourceIT extends BaseResourceIT {
         assertEquals(updatedTypeDefs.getEntityDefs().get(0).getName(), atlasTypesDef.getEntityDefs().get(0).getName());
 
         Map<String, String> filterParams = new HashMap<>();
-        filterParams.put(SearchFilter.PARAM_TYPE, "entity");
+        filterParams.put(SearchFilter.PARAM_TYPE, "ENTITY");
         AtlasTypesDef allTypeDefs = clientV2.getAllTypeDefs(new SearchFilter(filterParams));
         assertNotNull(allTypeDefs);
-        assertEquals(allTypeDefs.getEntityDefs().get(0).getAttributeDefs().size(), 2);
+        Boolean entityDefFound = false;
+        for (AtlasEntityDef atlasEntityDef : allTypeDefs.getEntityDefs()){
+            if (atlasEntityDef.getName().equals(typeDefinition.getName())) {
+                assertEquals(atlasEntityDef.getAttributeDefs().size(), 2);
+                entityDefFound = true;
+                break;
+            }
+        }
+        assertTrue(entityDefFound, "Required entityDef not found.");
     }
 
     @Test(dependsOnMethods = "testCreate")

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/b9525a57/webapp/src/test/java/org/apache/atlas/web/resources/TypesJerseyResourceIT.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/web/resources/TypesJerseyResourceIT.java
b/webapp/src/test/java/org/apache/atlas/web/resources/TypesJerseyResourceIT.java
index b6dae4d..fd15544 100755
--- a/webapp/src/test/java/org/apache/atlas/web/resources/TypesJerseyResourceIT.java
+++ b/webapp/src/test/java/org/apache/atlas/web/resources/TypesJerseyResourceIT.java
@@ -78,23 +78,27 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
     @Test
     public void testSubmit() throws Exception {
         for (HierarchicalTypeDefinition typeDefinition : typeDefinitions) {
-            String typesAsJSON = TypesSerialization.toJson(typeDefinition, false);
-            System.out.println("typesAsJSON = " + typesAsJSON);
-
-            WebResource resource = service.path("api/atlas/types");
-
-            ClientResponse clientResponse = resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
-                    .method(HttpMethod.POST, ClientResponse.class, typesAsJSON);
-            assertEquals(clientResponse.getStatus(), Response.Status.CREATED.getStatusCode());
-
-            String responseAsString = clientResponse.getEntity(String.class);
-            Assert.assertNotNull(responseAsString);
-
-            JSONObject response = new JSONObject(responseAsString);
-            JSONArray typesAdded = response.getJSONArray(AtlasClient.TYPES);
-            assertEquals(typesAdded.length(), 1);
-            assertEquals(typesAdded.getJSONObject(0).getString("name"), typeDefinition.typeName);
-            Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
+            try{
+                serviceClient.getType(typeDefinition.typeName);
+            } catch (AtlasServiceException ase){
+                String typesAsJSON = TypesSerialization.toJson(typeDefinition, false);
+                System.out.println("typesAsJSON = " + typesAsJSON);
+
+                WebResource resource = service.path("api/atlas/types");
+
+                ClientResponse clientResponse = resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
+                        .method(HttpMethod.POST, ClientResponse.class, typesAsJSON);
+                assertEquals(clientResponse.getStatus(), Response.Status.CREATED.getStatusCode());
+
+                String responseAsString = clientResponse.getEntity(String.class);
+                Assert.assertNotNull(responseAsString);
+
+                JSONObject response = new JSONObject(responseAsString);
+                JSONArray typesAdded = response.getJSONArray(AtlasClient.TYPES);
+                assertEquals(typesAdded.length(), 1);
+                assertEquals(typesAdded.getJSONObject(0).getString("name"), typeDefinition.typeName);
+                Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
+            }
         }
     }
 
@@ -263,13 +267,15 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
         HierarchicalTypeDefinition<ClassType> databaseTypeDefinition = TypesUtil
                 .createClassTypeDef("database", ImmutableSet.<String>of(),
                         TypesUtil.createUniqueRequiredAttrDef("name", DataTypes.STRING_TYPE),
-                        TypesUtil.createRequiredAttrDef("description", DataTypes.STRING_TYPE));
+                        TypesUtil.createRequiredAttrDef("description", DataTypes.STRING_TYPE),
+                        TypesUtil.createRequiredAttrDef("qualifiedName", DataTypes.STRING_TYPE));
         typeDefinitions.add(databaseTypeDefinition);
 
         HierarchicalTypeDefinition<ClassType> tableTypeDefinition = TypesUtil
                 .createClassTypeDef("table", ImmutableSet.<String>of(),
                         TypesUtil.createUniqueRequiredAttrDef("name", DataTypes.STRING_TYPE),
                         TypesUtil.createRequiredAttrDef("description", DataTypes.STRING_TYPE),
+                        TypesUtil.createRequiredAttrDef("qualifiedName", DataTypes.STRING_TYPE),
                         createOptionalAttrDef("columnNames", DataTypes.arrayTypeName(DataTypes.STRING_TYPE)),
                         createOptionalAttrDef("created", DataTypes.DATE_TYPE),
                         createOptionalAttrDef("parameters",

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/b9525a57/webapp/src/test/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/webapp/src/test/webapp/WEB-INF/web.xml b/webapp/src/test/webapp/WEB-INF/web.xml
index 6649043..f7e2028 100755
--- a/webapp/src/test/webapp/WEB-INF/web.xml
+++ b/webapp/src/test/webapp/WEB-INF/web.xml
@@ -27,9 +27,14 @@
     <context-param>
         <param-name>guice.packages</param-name>
         <param-value>
-            org.apache.atlas.web.resources,org.apache.atlas.web.params
+            org.apache.atlas.web.resources,org.apache.atlas.web.params,org.apache.atlas.web.rest,org.apache.atlas.web.errors
         </param-value>
     </context-param>
+  
+    <context-param>
+        <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
+        <param-value>true</param-value>
+    </context-param>
 
     <!--
         More information can be found here:
@@ -46,7 +51,7 @@
         <filter-name>guiceFilter</filter-name>
         <filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
     </filter>
-
+    
     <filter-mapping>
         <filter-name>springSecurityFilterChain</filter-name>
         <url-pattern>/*</url-pattern>
@@ -58,11 +63,11 @@
     </filter-mapping>
 
     <listener>
-        <listener-class>org.apache.atlas.web.listeners.TestGuiceServletConfig</listener-class>
+        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
     </listener>
-
+    
     <listener>
-        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
+        <listener-class>org.apache.atlas.web.listeners.GuiceServletConfig</listener-class>
     </listener>
 
     <listener>
@@ -73,6 +78,7 @@
         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
     </listener>
 
+
     <session-config>
         <session-timeout>60</session-timeout>
         <tracking-mode>COOKIE</tracking-mode>
@@ -82,4 +88,5 @@
         </cookie-config>
     </session-config>
 
+	
 </web-app>


Mime
View raw message