atlas-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apoorvn...@apache.org
Subject atlas git commit: ATLAS-2201: Test dependency, plugin version and test code fixes
Date Fri, 13 Oct 2017 20:56:10 GMT
Repository: atlas
Updated Branches:
  refs/heads/branch-0.8 816c9c72d -> f4683eec3


ATLAS-2201: Test dependency, plugin version and test code fixes


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

Branch: refs/heads/branch-0.8
Commit: f4683eec31b3e826cdf6c273aeb9da78342b469a
Parents: 816c9c7
Author: apoorvnaik <apoorvnaik@apache.org>
Authored: Wed Oct 11 23:13:57 2017 -0700
Committer: apoorvnaik <apoorvnaik@apache.org>
Committed: Fri Oct 13 13:56:01 2017 -0700

----------------------------------------------------------------------
 .../security/InMemoryJAASConfigurationTest.java |  22 +--
 ...ConfigurationTicketBasedKafkaClientTest.java |  23 +--
 pom.xml                                         |  17 +-
 .../GraphBackedMetadataRepositoryTest.java      | 178 +++++++++----------
 .../store/graph/AtlasTypeDefGraphStoreTest.java |   8 +-
 5 files changed, 118 insertions(+), 130 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/atlas/blob/f4683eec/intg/src/test/java/org/apache/atlas/security/InMemoryJAASConfigurationTest.java
----------------------------------------------------------------------
diff --git a/intg/src/test/java/org/apache/atlas/security/InMemoryJAASConfigurationTest.java
b/intg/src/test/java/org/apache/atlas/security/InMemoryJAASConfigurationTest.java
index b26ac7f..b0f24de 100644
--- a/intg/src/test/java/org/apache/atlas/security/InMemoryJAASConfigurationTest.java
+++ b/intg/src/test/java/org/apache/atlas/security/InMemoryJAASConfigurationTest.java
@@ -18,32 +18,24 @@
 
 package org.apache.atlas.security;
 
-import javax.security.auth.login.AppConfigurationEntry;
-import javax.security.auth.login.Configuration;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
 import org.apache.hadoop.util.StringUtils;
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
+import javax.security.auth.login.AppConfigurationEntry;
+import javax.security.auth.login.Configuration;
+
 
 //Unstable test. Disabling
 @Test(enabled=false)
-public class InMemoryJAASConfigurationTest extends TestCase {
+public class InMemoryJAASConfigurationTest {
 
     private static final String ATLAS_JAAS_PROP_FILE = "atlas-jaas.properties";
 
+    @BeforeClass
     protected void setUp() throws Exception {
-        super.setUp();
-        try {
             InMemoryJAASConfiguration.init(ATLAS_JAAS_PROP_FILE);
-        } catch(Throwable t) {
-            fail("InMemoryJAASConfiguration.init() is not expected to throw Exception:" +
 t);
-        }
-    }
-
-    protected void tearDown() throws Exception {
-        super.tearDown();
     }
 
     @Test(enabled=false)

http://git-wip-us.apache.org/repos/asf/atlas/blob/f4683eec/intg/src/test/java/org/apache/atlas/security/InMemoryJAASConfigurationTicketBasedKafkaClientTest.java
----------------------------------------------------------------------
diff --git a/intg/src/test/java/org/apache/atlas/security/InMemoryJAASConfigurationTicketBasedKafkaClientTest.java
b/intg/src/test/java/org/apache/atlas/security/InMemoryJAASConfigurationTicketBasedKafkaClientTest.java
index 3d8175f..75c6e87 100644
--- a/intg/src/test/java/org/apache/atlas/security/InMemoryJAASConfigurationTicketBasedKafkaClientTest.java
+++ b/intg/src/test/java/org/apache/atlas/security/InMemoryJAASConfigurationTicketBasedKafkaClientTest.java
@@ -18,34 +18,25 @@
 
 package org.apache.atlas.security;
 
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
 import javax.security.auth.login.AppConfigurationEntry;
 import javax.security.auth.login.Configuration;
 
-import junit.framework.Assert;
-import junit.framework.TestCase;
-import org.testng.annotations.Test;
-
 
 @Test
-public class InMemoryJAASConfigurationTicketBasedKafkaClientTest extends TestCase {
+public class InMemoryJAASConfigurationTicketBasedKafkaClientTest {
 
     private static final String ATLAS_JAAS_PROP_FILE = "atlas-jaas.properties";
 
-    protected void setUp() throws Exception {
-        super.setUp();
-        try {
+    @BeforeClass
+    public void setUp() throws Exception {
             InMemoryJAASConfiguration.init(ATLAS_JAAS_PROP_FILE);
             InMemoryJAASConfiguration.setConfigSectionRedirect("KafkaClient", "ticketBased-KafkaClient");
-        } catch (Throwable t) {
-            fail("InMemoryJAASConfiguration.init() is not expected to throw Exception:" +
t);
-        }
     }
 
-    protected void tearDown() throws Exception {
-        super.tearDown();
-    }
-
-
     @Test
     public void testGetAppConfigurationEntryStringForticketBasedKafkaClient() {
 

http://git-wip-us.apache.org/repos/asf/atlas/blob/f4683eec/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index f18e95a..5f00288 100644
--- a/pom.xml
+++ b/pom.xml
@@ -563,10 +563,14 @@
         <titan.index.backend>elasticsearch</titan.index.backend>
         <entity.repository.impl>org.apache.atlas.repository.audit.InMemoryEntityAuditRepository</entity.repository.impl>
         <graphdb.backend.impl>org.apache.atlas.repository.graphdb.titan0.Titan0GraphDatabase</graphdb.backend.impl>
+        <surefire.version>2.18.1</surefire.version>
+        <surefire.forkCount>2C</surefire.forkCount>
+        <failsafe.version>2.18.1</failsafe.version>
         <atlas.surefire.options></atlas.surefire.options>
 
         <aspectj.runtime.version>1.8.7</aspectj.runtime.version>
         <project.build.dashboardv2.gruntBuild>build-minify</project.build.dashboardv2.gruntBuild>
+        <testng.version>6.9.4</testng.version>
     </properties>
 
     <profiles>
@@ -1357,6 +1361,7 @@
                 <groupId>org.apache.atlas</groupId>
                 <artifactId>atlas-client</artifactId>
                 <version>${project.version}</version>
+                <type>pom</type>
             </dependency>
 
             <dependency>
@@ -1630,7 +1635,7 @@
             <dependency>
                 <groupId>org.testng</groupId>
                 <artifactId>testng</artifactId>
-                <version>6.1.1</version>
+                <version>${testng.version}</version>
                 <scope>test</scope>
             </dependency>
 
@@ -1780,13 +1785,13 @@
                 <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-surefire-plugin</artifactId>
-                    <version>2.16</version>
+                    <version>${surefire.version}</version>
                 </plugin>
 
                 <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-failsafe-plugin</artifactId>
-                    <version>2.18.1</version>
+                    <version>${failsafe.version}</version>
                 </plugin>
 
                 <plugin>
@@ -1909,7 +1914,7 @@
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-surefire-plugin</artifactId>
-                <version>2.18.1</version>
+                <version>${surefire.version}</version>
                 <configuration>
                     <systemProperties>
                         <user.dir>${project.basedir}</user.dir>
@@ -1917,7 +1922,7 @@
                         <log4j.configuration>atlas-log4j.xml</log4j.configuration>
                     </systemProperties>
                     <skipTests>${skipTests}</skipTests>
-                    <forkCount>2C</forkCount>
+                    <forkCount>${surefire.forkCount}</forkCount>
                     <reuseForks>false</reuseForks>
                     <redirectTestOutputToFile>true</redirectTestOutputToFile>
                     <argLine>-Djava.awt.headless=true -Dproject.version=${project.version}
@@ -1938,7 +1943,7 @@
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-failsafe-plugin</artifactId>
-                <version>2.19.1</version>
+                <version>${failsafe.version}</version>
                 <configuration>
                     <systemPropertyVariables>
                         <projectBaseDir>${projectBaseDir}</projectBaseDir>

http://git-wip-us.apache.org/repos/asf/atlas/blob/f4683eec/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryTest.java
----------------------------------------------------------------------
diff --git a/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryTest.java
b/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryTest.java
index 6444328..eb779ff 100755
--- a/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryTest.java
+++ b/repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryTest.java
@@ -124,7 +124,7 @@ public class GraphBackedMetadataRepositoryTest {
     }
 
     @AfterClass
-    public void tearDown() throws Exception {
+    public void tearDown() {
         TypeSystem.getInstance().reset();
 //        AtlasGraphProvider.cleanup();
     }
@@ -180,19 +180,6 @@ public class GraphBackedMetadataRepositoryTest {
         assertTrue(validated1 | validated2);
     }
 
-    private boolean assertEdge(String id, String typeName) throws Exception {
-        AtlasGraph graph = TestUtils.getGraph();
-        Iterable<AtlasVertex> vertices = graph.query().has(Constants.GUID_PROPERTY_KEY,
id).vertices();
-        AtlasVertex AtlasVertex = vertices.iterator().next();
-        Iterable<AtlasEdge> edges = AtlasVertex.getEdges(AtlasEdgeDirection.OUT, Constants.INTERNAL_PROPERTY_KEY_PREFIX
+ typeName + ".ref");
-        if (!edges.iterator().hasNext()) {
-            ITypedReferenceableInstance entity = repositoryService.getEntityDefinition(id);
-            assertNotNull(entity.get("ref"));
-            return true;
-        }
-        return false;
-    }
-
     @Test
     public void testSubmitEntity() throws Exception {
         ITypedReferenceableInstance hrDept = TestUtils.createDeptEg1(typeSystem);
@@ -363,22 +350,6 @@ public class GraphBackedMetadataRepositoryTest {
         validateGuidMapping(toVerify, result);
     }
 
-    private void validateGuidMapping(List<Referenceable> toVerify, CreateUpdateEntitiesResult
result)
-            throws AtlasException {
-        Map<String,String> guids = result.getGuidMapping().getGuidAssignments();
-
-        TestUtils.assertContentsSame(result.getCreatedEntities(), guids.values());
-        assertEquals(guids.size(), toVerify.size());
-        for(Referenceable r : toVerify) {
-            loadAndDoSimpleValidation(guids.get(r.getId()._getId()), r);
-        }
-    }
-
-    private ITypedReferenceableInstance loadAndDoSimpleValidation(String guid, Referenceable
inst) throws AtlasException {
-        return TestUtils.loadAndDoSimpleValidation(guid, inst, repositoryService);
-    }
-
-
     @Test(dependsOnMethods = "testSubmitEntity")
     public void testGetEntityDefinitionForDepartment() throws Exception {
         ITypedReferenceableInstance entity = repositoryService.getEntityDefinition(guid);
@@ -452,41 +423,6 @@ public class GraphBackedMetadataRepositoryTest {
         System.out.println("*** table = " + table);
     }
 
-    private List<String> createEntities(ITypedReferenceableInstance... instances) throws
Exception {
-        RequestContext.createContext();
-        return repositoryService.createEntities(instances).getCreatedEntities();
-    }
-
-    private List<String> createEntity(Referenceable entity) throws Exception {
-        ClassType type = typeSystem.getDataType(ClassType.class, entity.getTypeName());
-        ITypedReferenceableInstance instance = type.convert(entity, Multiplicity.REQUIRED);
-        return createEntities(instance);
-    }
-
-    @GraphTransaction
-    String getGUID() {
-        AtlasVertex tableVertex = getTableEntityVertex();
-
-        String guid = GraphHelper.getSingleValuedProperty(tableVertex, Constants.GUID_PROPERTY_KEY,
String.class);
-        if (guid == null) {
-            Assert.fail();
-        }
-        return guid;
-    }
-
-    AtlasVertex getTableEntityVertex() {
-        AtlasGraph graph = TestUtils.getGraph();
-        AtlasGraphQuery query = graph.query().has(Constants.ENTITY_TYPE_PROPERTY_KEY, ComparisionOperator.EQUAL,
TestUtils.TABLE_TYPE);
-        Iterator<AtlasVertex> results = query.vertices().iterator();
-        // returning one since guid should be unique
-        AtlasVertex tableVertex = results.hasNext() ? results.next() : null;
-        if (tableVertex == null) {
-            Assert.fail();
-        }
-
-        return tableVertex;
-    }
-
     @Test(dependsOnMethods = "testCreateEntity")
     public void testGetTraitNames() throws Exception {
         final List<String> traitNames = repositoryService.getTraitNames(getGUID());
@@ -593,7 +529,7 @@ public class GraphBackedMetadataRepositoryTest {
         Assert.assertEquals(type, "SSN");
     }
 
-    @Test(expectedExceptions = NullPointerException.class)
+    @Test(dependsOnMethods = "testCreateEntity", expectedExceptions = NullPointerException.class)
     public void testAddTraitWithNullInstance() throws Exception {
         repositoryService.addTrait(getGUID(), null);
         Assert.fail();
@@ -798,7 +734,8 @@ public class GraphBackedMetadataRepositoryTest {
         //verify limit and offset
         //higher limit should return all results
         results = new JSONArray(discoveryService.searchByFullText("Department", queryParams));
-        assertEquals(results.length(), 5);
+        assertTrue(results.length() > 0);
+        int maxResults = results.length();
 
         //smaller limit should return those many rows
         results = new JSONArray(discoveryService.searchByFullText("Department", new QueryParams(2,
0)));
@@ -806,11 +743,94 @@ public class GraphBackedMetadataRepositoryTest {
 
         //offset should offset the results
         results = new JSONArray(discoveryService.searchByFullText("Department", new QueryParams(5,
2)));
-        assertEquals(results.length(), 3);
+        assertEquals(results.length(), maxResults > 5 ? 5 : Math.min((maxResults - 2)
% 5, 5));
 
         //higher offset shouldn't return any rows
         results = new JSONArray(discoveryService.searchByFullText("Department", new QueryParams(2,
6)));
-        assertEquals(results.length(), 0);
+        assertEquals(results.length(), maxResults > 6 ? Math.min(maxResults - 6, 2) :
0);
+    }
+
+    @Test
+    public void testUTFValues() throws Exception {
+        Referenceable hrDept = new Referenceable("Department");
+        Referenceable john = new Referenceable("Person");
+        john.set("name", randomUTF());
+        john.set("department", hrDept);
+
+        hrDept.set("name", randomUTF());
+        hrDept.set("employees", ImmutableList.of(john));
+
+        ClassType deptType = typeSystem.getDataType(ClassType.class, "Department");
+        ITypedReferenceableInstance hrDept2 = deptType.convert(hrDept, Multiplicity.REQUIRED);
+
+        List<String> guids = repositoryService.createEntities(hrDept2).getCreatedEntities();
+        Assert.assertNotNull(guids);
+        Assert.assertEquals(guids.size(), 2);
+        Assert.assertNotNull(guids.get(0));
+        Assert.assertNotNull(guids.get(1));
+    }
+
+    @GraphTransaction
+    String getGUID() {
+        AtlasVertex tableVertex = getTableEntityVertex();
+
+        String guid = GraphHelper.getSingleValuedProperty(tableVertex, Constants.GUID_PROPERTY_KEY,
String.class);
+        if (guid == null) {
+            Assert.fail();
+        }
+        return guid;
+    }
+
+    AtlasVertex getTableEntityVertex() {
+        AtlasGraph graph = TestUtils.getGraph();
+        AtlasGraphQuery query = graph.query().has(Constants.ENTITY_TYPE_PROPERTY_KEY, ComparisionOperator.EQUAL,
TestUtils.TABLE_TYPE);
+        Iterator<AtlasVertex> results = query.vertices().iterator();
+        // returning one since guid should be unique
+        AtlasVertex tableVertex = results.hasNext() ? results.next() : null;
+        if (tableVertex == null) {
+            Assert.fail();
+        }
+
+        return tableVertex;
+    }
+
+    private boolean assertEdge(String id, String typeName) throws Exception {
+        AtlasGraph graph = TestUtils.getGraph();
+        Iterable<AtlasVertex> vertices = graph.query().has(Constants.GUID_PROPERTY_KEY,
id).vertices();
+        AtlasVertex AtlasVertex = vertices.iterator().next();
+        Iterable<AtlasEdge> edges = AtlasVertex.getEdges(AtlasEdgeDirection.OUT, Constants.INTERNAL_PROPERTY_KEY_PREFIX
+ typeName + ".ref");
+        if (!edges.iterator().hasNext()) {
+            ITypedReferenceableInstance entity = repositoryService.getEntityDefinition(id);
+            assertNotNull(entity.get("ref"));
+            return true;
+        }
+        return false;
+    }
+
+    private void validateGuidMapping(List<Referenceable> toVerify, CreateUpdateEntitiesResult
result)
+            throws AtlasException {
+        Map<String,String> guids = result.getGuidMapping().getGuidAssignments();
+
+        TestUtils.assertContentsSame(result.getCreatedEntities(), guids.values());
+        assertEquals(guids.size(), toVerify.size());
+        for(Referenceable r : toVerify) {
+            loadAndDoSimpleValidation(guids.get(r.getId()._getId()), r);
+        }
+    }
+
+    private ITypedReferenceableInstance loadAndDoSimpleValidation(String guid, Referenceable
inst) throws AtlasException {
+        return TestUtils.loadAndDoSimpleValidation(guid, inst, repositoryService);
+    }
+
+    private List<String> createEntities(ITypedReferenceableInstance... instances) throws
Exception {
+        RequestContext.createContext();
+        return repositoryService.createEntities(instances).getCreatedEntities();
+    }
+
+    private List<String> createEntity(Referenceable entity) throws Exception {
+        ClassType type = typeSystem.getDataType(ClassType.class, entity.getTypeName());
+        ITypedReferenceableInstance instance = type.convert(entity, Multiplicity.REQUIRED);
+        return createEntities(instance);
     }
 
     private ITypedReferenceableInstance createHiveTableInstance(Referenceable databaseInstance)
throws Exception {
@@ -891,24 +911,4 @@ public class GraphBackedMetadataRepositoryTest {
     private String randomString() {
         return TestUtils.randomString(10);
     }
-
-    @Test
-    public void testUTFValues() throws Exception {
-        Referenceable hrDept = new Referenceable("Department");
-        Referenceable john = new Referenceable("Person");
-        john.set("name", randomUTF());
-        john.set("department", hrDept);
-
-        hrDept.set("name", randomUTF());
-        hrDept.set("employees", ImmutableList.of(john));
-
-        ClassType deptType = typeSystem.getDataType(ClassType.class, "Department");
-        ITypedReferenceableInstance hrDept2 = deptType.convert(hrDept, Multiplicity.REQUIRED);
-
-        List<String> guids = repositoryService.createEntities(hrDept2).getCreatedEntities();
-        Assert.assertNotNull(guids);
-        Assert.assertEquals(guids.size(), 2);
-        Assert.assertNotNull(guids.get(0));
-        Assert.assertNotNull(guids.get(1));
-    }
 }

http://git-wip-us.apache.org/repos/asf/atlas/blob/f4683eec/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java
----------------------------------------------------------------------
diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java
b/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java
index 728d418..242c07f 100644
--- a/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java
+++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java
@@ -60,7 +60,7 @@ public class AtlasTypeDefGraphStoreTest {
         RequestContextV1.get().setUser(TestUtilsV2.TEST_USER);
     }
 
-    @Test(priority = 1)
+    @Test
     public void testGet() {
         try {
             AtlasTypesDef typesDef = typeDefStore.searchTypesDef(new SearchFilter());
@@ -76,7 +76,7 @@ public class AtlasTypeDefGraphStoreTest {
         }
     }
 
-    @Test(dataProvider = "invalidGetProvider", priority = 2)
+    @Test(dataProvider = "invalidGetProvider", dependsOnMethods = "testGet")
     public void testInvalidGet(String name, String guid){
         try {
             assertNull(typeDefStore.getEnumDefByName(name));
@@ -403,7 +403,7 @@ public class AtlasTypeDefGraphStoreTest {
         }
     }
 
-    @Test
+    @Test(dependsOnMethods = "testGet")
     public void testTypeDeletionAndRecreate() {
         AtlasClassificationDef aTag = new AtlasClassificationDef("testTag");
         AtlasAttributeDef attributeDef = new AtlasAttributeDef("testAttribute", "string",
true,
@@ -442,7 +442,7 @@ public class AtlasTypeDefGraphStoreTest {
         }
     }
 
-    @Test
+    @Test(dependsOnMethods = "testGet")
     public void testTypeRegistryIsUpdatedAfterGraphStorage() throws AtlasBaseException {
       String classificationDef = "{"
           + "\"name\":\"test_classification_11\","


Mime
View raw message