You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by sa...@apache.org on 2018/09/25 18:03:57 UTC
atlas git commit: ATLAS-2890: Fix intermittent UT and IT failures for
atlas in apache CI
Repository: atlas
Updated Branches:
refs/heads/branch-0.8 c0dd78d52 -> 60104c18a
ATLAS-2890: Fix intermittent UT and IT failures for atlas in apache CI
Project: http://git-wip-us.apache.org/repos/asf/atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/60104c18
Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/60104c18
Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/60104c18
Branch: refs/heads/branch-0.8
Commit: 60104c18ab808eee2c777adea2795411c0d4de4b
Parents: c0dd78d
Author: Sarath Subramanian <ss...@hortonworks.com>
Authored: Tue Sep 25 10:27:31 2018 -0700
Committer: Sarath Subramanian <ss...@hortonworks.com>
Committed: Tue Sep 25 10:27:31 2018 -0700
----------------------------------------------------------------------
.../integration/TypedefsJerseyResourceIT.java | 42 +++++++++++++++-----
1 file changed, 33 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/atlas/blob/60104c18/webapp/src/test/java/org/apache/atlas/web/integration/TypedefsJerseyResourceIT.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/web/integration/TypedefsJerseyResourceIT.java b/webapp/src/test/java/org/apache/atlas/web/integration/TypedefsJerseyResourceIT.java
index c46689c..3d1cefb 100644
--- a/webapp/src/test/java/org/apache/atlas/web/integration/TypedefsJerseyResourceIT.java
+++ b/webapp/src/test/java/org/apache/atlas/web/integration/TypedefsJerseyResourceIT.java
@@ -21,7 +21,9 @@ package org.apache.atlas.web.integration;
import com.google.common.collect.ImmutableSet;
import com.sun.jersey.core.util.MultivaluedMapImpl;
import org.apache.atlas.AtlasClientV2;
+import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.AtlasServiceException;
+import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.SearchFilter;
import org.apache.atlas.model.TypeCategory;
import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
@@ -45,6 +47,7 @@ import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import java.util.Collections;
+import static org.apache.atlas.AtlasErrorCode.TYPE_NAME_NOT_FOUND;
import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef.Cardinality;
import static org.apache.atlas.type.AtlasTypeUtil.createClassTypeDef;
import static org.testng.Assert.assertEquals;
@@ -83,23 +86,22 @@ public class TypedefsJerseyResourceIT extends BaseResourceIT {
public void testCreate() throws Exception {
createType(typeDefinitions);
+ // validate if all types created successfully
for (AtlasEnumDef enumDef : typeDefinitions.getEnumDefs()) {
- AtlasEnumDef byName = atlasClientV2.getEnumDefByName(enumDef.getName());
- assertNotNull(byName);
+ checkIfTypeExists(enumDef.getName());
}
+
for (AtlasStructDef structDef : typeDefinitions.getStructDefs()) {
- AtlasStructDef byName = atlasClientV2.getStructDefByName(structDef.getName());
- assertNotNull(byName);
+ checkIfTypeExists(structDef.getName());
}
+
for (AtlasClassificationDef classificationDef : typeDefinitions.getClassificationDefs()) {
- AtlasClassificationDef byName = atlasClientV2.getClassificationDefByName(classificationDef.getName());
- assertNotNull(byName);
+ checkIfTypeExists(classificationDef.getName());
}
+
for (AtlasEntityDef entityDef : typeDefinitions.getEntityDefs()) {
- AtlasEntityDef byName = atlasClientV2.getEntityDefByName(entityDef.getName());
- assertNotNull(byName);
+ checkIfTypeExists(entityDef.getName());
}
-
}
@Test
@@ -367,4 +369,26 @@ public class TypedefsJerseyResourceIT extends BaseResourceIT {
def.getClassificationDefs().clear();
def.getEntityDefs().clear();
}
+
+ private void checkIfTypeExists(String typeName) throws Exception {
+ int retryCount = 0;
+ int maxRetries = 3;
+ int sleepTime = 5000;
+
+ while (true) {
+ try {
+ boolean typeExists = atlasClientV2.typeWithNameExists(typeName);
+
+ if (!typeExists) {
+ throw new AtlasBaseException(TYPE_NAME_NOT_FOUND, typeName);
+ } else {
+ break;
+ }
+ } catch (AtlasBaseException e) {
+ Thread.sleep(sleepTime);
+
+ if (++retryCount == maxRetries) throw e;
+ }
+ }
+ }
}