Parallel tests (#10064)

* Staging parallel tests

* Parallelize Tests

* Parallelize Tests

* Parallelize Tests

* Parallelize Tests

* Parallelize Tests

* Parallelize Tests
This commit is contained in:
Sriharsha Chintalapani 2023-02-06 21:26:13 -08:00 committed by GitHub
parent 460a9288a7
commit b76ec0a18f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 166 additions and 109 deletions

View File

@ -567,7 +567,11 @@
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.version}</version> <version>${maven-surefire.version}</version>
<configuration> <configuration>
<trimStackTrace>false</trimStackTrace> <reuseForks>false</reuseForks>
<parallel>classes</parallel>
<threadCount>1</threadCount>
<forkCount>2C</forkCount>
<argLine>-Xmx1024m</argLine>
</configuration> </configuration>
<executions> <executions>
<execution> <execution>

View File

@ -28,6 +28,7 @@ import org.glassfish.jersey.client.HttpUrlConnectorProvider;
import org.glassfish.jersey.client.JerseyClientBuilder; import org.glassfish.jersey.client.JerseyClientBuilder;
import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.TestInstance;
import org.openmetadata.service.fernet.Fernet; import org.openmetadata.service.fernet.Fernet;
import org.openmetadata.service.resources.CollectionRegistry; import org.openmetadata.service.resources.CollectionRegistry;
import org.openmetadata.service.resources.events.WebhookCallbackResource; import org.openmetadata.service.resources.events.WebhookCallbackResource;
@ -37,6 +38,7 @@ import org.openmetadata.service.security.policyevaluator.SubjectCache;
import org.testcontainers.containers.JdbcDatabaseContainer; import org.testcontainers.containers.JdbcDatabaseContainer;
@Slf4j @Slf4j
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public abstract class OpenMetadataApplicationTest { public abstract class OpenMetadataApplicationTest {
protected static final String CONFIG_PATH = ResourceHelpers.resourceFilePath("openmetadata-secure-test.yaml"); protected static final String CONFIG_PATH = ResourceHelpers.resourceFilePath("openmetadata-secure-test.yaml");
public static DropwizardAppExtension<OpenMetadataApplicationConfig> APP; public static DropwizardAppExtension<OpenMetadataApplicationConfig> APP;
@ -58,7 +60,7 @@ public abstract class OpenMetadataApplicationTest {
JdbcDatabaseContainer<?> sqlContainer = JdbcDatabaseContainer<?> sqlContainer =
(JdbcDatabaseContainer<?>) (JdbcDatabaseContainer<?>)
Class.forName(jdbcContainerClassName).getConstructor(String.class).newInstance(jdbcContainerImage); Class.forName(jdbcContainerClassName).getConstructor(String.class).newInstance(jdbcContainerImage);
sqlContainer.withReuse(true); sqlContainer.withReuse(false);
sqlContainer.withStartupTimeoutSeconds(240); sqlContainer.withStartupTimeoutSeconds(240);
sqlContainer.withConnectTimeoutSeconds(240); sqlContainer.withConnectTimeoutSeconds(240);
sqlContainer.start(); sqlContainer.start();

View File

@ -99,6 +99,8 @@ import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo; import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;
import org.openmetadata.common.utils.CommonUtil; import org.openmetadata.common.utils.CommonUtil;
import org.openmetadata.csv.CsvUtilTest; import org.openmetadata.csv.CsvUtilTest;
import org.openmetadata.csv.EntityCsvTest; import org.openmetadata.csv.EntityCsvTest;
@ -410,6 +412,16 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
.withOwner(reduceEntityReference(owner)); .withOwner(reduceEntityReference(owner));
} }
public final K createPutRequest(String name, String description, String displayName, EntityReference owner) {
if (!supportsEmptyDescription && description == null) {
throw new IllegalArgumentException("Entity " + entityType + " does not support empty description");
}
return createPutRequest(name)
.withDescription(description)
.withDisplayName(displayName)
.withOwner(reduceEntityReference(owner));
}
public abstract K createRequest(String name); public abstract K createRequest(String name);
public K createPutRequest(String name) { public K createPutRequest(String name) {
@ -481,6 +493,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
// Common entity tests for GET operations // Common entity tests for GET operations
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
void get_entityWithDifferentFieldsQueryParam(TestInfo test) throws HttpResponseException { void get_entityWithDifferentFieldsQueryParam(TestInfo test) throws HttpResponseException {
if (!supportsFieldsQueryParam) { if (!supportsFieldsQueryParam) {
return; return;
@ -518,6 +531,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
void get_entityListWithPagination_200(TestInfo test) throws IOException { void get_entityListWithPagination_200(TestInfo test) throws IOException {
// Create a number of entities between 5 and 20 inclusive // Create a number of entities between 5 and 20 inclusive
Random rand = new Random(); Random rand = new Random();
@ -664,6 +678,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
void get_entityListWithInvalidLimit_4xx() { void get_entityListWithInvalidLimit_4xx() {
// Limit must be >= 1 and <= 1000,000 // Limit must be >= 1 and <= 1000,000
assertResponse( assertResponse(
@ -683,6 +698,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
void get_entityListWithInvalidPaginationCursors_4xx() { void get_entityListWithInvalidPaginationCursors_4xx() {
// Passing both before and after cursors is invalid // Passing both before and after cursors is invalid
assertResponse( assertResponse(
@ -692,6 +708,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
void get_entityWithDifferentFields_200_OK(TestInfo test) throws IOException { void get_entityWithDifferentFields_200_OK(TestInfo test) throws IOException {
K create = createRequest(getEntityName(test), "description", "displayName", USER1_REF); K create = createRequest(getEntityName(test), "description", "displayName", USER1_REF);
@ -750,6 +767,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
void get_entityIncludeDeleted_200(TestInfo test) throws IOException { void get_entityIncludeDeleted_200(TestInfo test) throws IOException {
if (!supportsSoftDelete) { if (!supportsSoftDelete) {
return; return;
@ -778,6 +796,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
// Common entity tests for POST operations // Common entity tests for POST operations
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
protected void post_entityCreateWithInvalidName_400() { protected void post_entityCreateWithInvalidName_400() {
// Create an entity with mandatory name field null // Create an entity with mandatory name field null
final K request = createRequest(null, "description", "displayName", null); final K request = createRequest(null, "description", "displayName", null);
@ -795,6 +814,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
void post_entityWithMissingDescription_400(TestInfo test) { void post_entityWithMissingDescription_400(TestInfo test) {
// Post entity that does not accept empty description and expect failure // Post entity that does not accept empty description and expect failure
if (supportsEmptyDescription) { if (supportsEmptyDescription) {
@ -806,6 +826,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
void post_entityWithInvalidOwnerType_4xx(TestInfo test) throws HttpResponseException { void post_entityWithInvalidOwnerType_4xx(TestInfo test) throws HttpResponseException {
if (!supportsOwner) { if (!supportsOwner) {
return; return;
@ -828,6 +849,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
void post_entityWithNonExistentOwner_4xx(TestInfo test) { void post_entityWithNonExistentOwner_4xx(TestInfo test) {
if (!supportsOwner) { if (!supportsOwner) {
return; return;
@ -839,6 +861,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
void post_delete_entity_as_admin_200(TestInfo test) throws IOException { void post_delete_entity_as_admin_200(TestInfo test) throws IOException {
K request = createRequest(getEntityName(test), "", "", null); K request = createRequest(getEntityName(test), "", "", null);
T entity = createEntity(request, ADMIN_AUTH_HEADERS); T entity = createEntity(request, ADMIN_AUTH_HEADERS);
@ -846,6 +869,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
void post_delete_as_name_entity_as_admin_200(TestInfo test) throws IOException { void post_delete_as_name_entity_as_admin_200(TestInfo test) throws IOException {
K request = createRequest(getEntityName(test), "", "", null); K request = createRequest(getEntityName(test), "", "", null);
T entity = createEntity(request, ADMIN_AUTH_HEADERS); T entity = createEntity(request, ADMIN_AUTH_HEADERS);
@ -853,6 +877,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
protected void post_delete_entityWithOwner_200(TestInfo test) throws IOException { protected void post_delete_entityWithOwner_200(TestInfo test) throws IOException {
if (!supportsOwner) { if (!supportsOwner) {
return; return;
@ -879,6 +904,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
protected void post_delete_entity_as_bot(TestInfo test) throws IOException { protected void post_delete_entity_as_bot(TestInfo test) throws IOException {
// Ingestion bot can create and delete all the entities except websocket and bot // Ingestion bot can create and delete all the entities except websocket and bot
if (List.of(Entity.ALERT, Entity.ALERT_ACTION, Entity.BOT).contains(entityType)) { if (List.of(Entity.ALERT, Entity.ALERT_ACTION, Entity.BOT).contains(entityType)) {
@ -894,6 +920,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
protected void post_entity_as_non_admin_401(TestInfo test) { protected void post_entity_as_non_admin_401(TestInfo test) {
assertResponse( assertResponse(
() -> createEntity(createRequest(test), TEST_AUTH_HEADERS), () -> createEntity(createRequest(test), TEST_AUTH_HEADERS),
@ -902,6 +929,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
protected void post_entityAlreadyExists_409_conflict(TestInfo test) throws HttpResponseException { protected void post_entityAlreadyExists_409_conflict(TestInfo test) throws HttpResponseException {
K create = createRequest(getEntityName(test), "", "", null); K create = createRequest(getEntityName(test), "", "", null);
// Create first time using POST // Create first time using POST
@ -911,6 +939,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
void post_entityWithDots_200() throws HttpResponseException { void post_entityWithDots_200() throws HttpResponseException {
if (!supportedNameCharacters.contains(" ")) { // Name does not support space if (!supportedNameCharacters.contains(" ")) { // Name does not support space
return; return;
@ -934,6 +963,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
// Common entity tests for PUT operations // Common entity tests for PUT operations
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
void put_entityCreate_200(TestInfo test) throws IOException { void put_entityCreate_200(TestInfo test) throws IOException {
// Create a new entity with PUT // Create a new entity with PUT
K request = createRequest(getEntityName(test), "description", "displayName", null); K request = createRequest(getEntityName(test), "description", "displayName", null);
@ -941,6 +971,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
void put_entityUpdateWithNoChange_200(TestInfo test) throws IOException { void put_entityUpdateWithNoChange_200(TestInfo test) throws IOException {
// Create a chart with POST // Create a chart with POST
K request = createRequest(getEntityName(test), "description", "display", USER1_REF); K request = createRequest(getEntityName(test), "description", "display", USER1_REF);
@ -953,6 +984,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
void put_entityCreate_as_owner_200(TestInfo test) throws IOException { void put_entityCreate_as_owner_200(TestInfo test) throws IOException {
if (!supportsOwner) { if (!supportsOwner) {
return; // Entity doesn't support ownership return; // Entity doesn't support ownership
@ -969,6 +1001,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
void put_entityUpdateOwner_200(TestInfo test) throws IOException { void put_entityUpdateOwner_200(TestInfo test) throws IOException {
if (!supportsOwner) { if (!supportsOwner) {
return; // Entity doesn't support ownership return; // Entity doesn't support ownership
@ -1000,12 +1033,13 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
// Remove ownership (from USER_OWNER1) using PUT request. Owner is expected to remain the same // Remove ownership (from USER_OWNER1) using PUT request. Owner is expected to remain the same
// and not removed. // and not removed.
request.withOwner(null); request = createPutRequest(entity.getName(), "description", "displayName", null);
updateEntity(request, OK, ADMIN_AUTH_HEADERS); updateEntity(request, OK, ADMIN_AUTH_HEADERS);
checkOwnerOwns(USER1_REF, entity.getId(), true); checkOwnerOwns(USER1_REF, entity.getId(), true);
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
void patch_validEntityOwner_200(TestInfo test) throws IOException { void patch_validEntityOwner_200(TestInfo test) throws IOException {
if (!supportsOwner || !supportsPatch) { if (!supportsOwner || !supportsPatch) {
return; // Entity doesn't support ownership return; // Entity doesn't support ownership
@ -1030,6 +1064,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
void patch_entityUpdateOwner_200(TestInfo test) throws IOException { void patch_entityUpdateOwner_200(TestInfo test) throws IOException {
if (!supportsOwner || !supportsPatch) { if (!supportsOwner || !supportsPatch) {
return; // Entity doesn't support ownership return; // Entity doesn't support ownership
@ -1071,6 +1106,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
void put_entityUpdate_as_non_owner_4xx(TestInfo test) throws IOException { void put_entityUpdate_as_non_owner_4xx(TestInfo test) throws IOException {
if (!supportsOwner) { if (!supportsOwner) {
return; // Entity doesn't support ownership return; // Entity doesn't support ownership
@ -1078,11 +1114,11 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
// Create an entity with owner // Create an entity with owner
K request = createRequest(getEntityName(test), "description", "displayName", USER1_REF); K request = createRequest(getEntityName(test), "description", "displayName", USER1_REF);
createEntity(request, ADMIN_AUTH_HEADERS); T entity = createEntity(request, ADMIN_AUTH_HEADERS);
// Update description and remove owner as non-owner // Update description and remove owner as non-owner
// Expect to throw an exception since only owner or admin can update resource // Expect to throw an exception since only owner or admin can update resource
K updateRequest = createRequest(getEntityName(test), "newDescription", "displayName", null); K updateRequest = createRequest(entity.getName(), "newDescription", "displayName", null);
MetadataOperation operation = entityType.equals(Entity.TEST_CASE) ? EDIT_TESTS : EDIT_ALL; MetadataOperation operation = entityType.equals(Entity.TEST_CASE) ? EDIT_TESTS : EDIT_ALL;
assertResponse( assertResponse(
@ -1092,6 +1128,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
void put_entityNullDescriptionUpdate_200(TestInfo test) throws IOException { void put_entityNullDescriptionUpdate_200(TestInfo test) throws IOException {
if (!supportsEmptyDescription) { if (!supportsEmptyDescription) {
return; return;
@ -1101,13 +1138,14 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
T entity = createEntity(request, ADMIN_AUTH_HEADERS); T entity = createEntity(request, ADMIN_AUTH_HEADERS);
// Update null description with a new description // Update null description with a new description
request = request.withDescription("updatedDescription"); request = createPutRequest(entity.getName(), "updatedDescription", "displayName", null);
ChangeDescription change = getChangeDescription(entity.getVersion()); ChangeDescription change = getChangeDescription(entity.getVersion());
fieldAdded(change, "description", "updatedDescription"); fieldAdded(change, "description", "updatedDescription");
updateAndCheckEntity(request, OK, ADMIN_AUTH_HEADERS, MINOR_UPDATE, change); updateAndCheckEntity(request, OK, ADMIN_AUTH_HEADERS, MINOR_UPDATE, change);
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
protected void put_entityEmptyDescriptionUpdate_200(TestInfo test) throws IOException { protected void put_entityEmptyDescriptionUpdate_200(TestInfo test) throws IOException {
// Create entity with empty description // Create entity with empty description
K request = createRequest(getEntityName(test), "", "displayName", null); K request = createRequest(getEntityName(test), "", "displayName", null);
@ -1121,6 +1159,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
protected void put_entityNonEmptyDescriptionUpdate_200(TestInfo test) throws IOException { protected void put_entityNonEmptyDescriptionUpdate_200(TestInfo test) throws IOException {
// Create entity with non-empty description // Create entity with non-empty description
K request = createRequest(getEntityName(test), supportsEmptyDescription ? null : "description", null, null); K request = createRequest(getEntityName(test), supportsEmptyDescription ? null : "description", null, null);
@ -1147,6 +1186,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
void put_addDeleteFollower_200(TestInfo test) throws IOException { void put_addDeleteFollower_200(TestInfo test) throws IOException {
if (!supportsFollowers) { if (!supportsFollowers) {
return; // Entity does not support following return; // Entity does not support following
@ -1174,6 +1214,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
void put_addFollowerDeleteEntity_200(TestInfo test) throws IOException { void put_addFollowerDeleteEntity_200(TestInfo test) throws IOException {
if (!supportsFollowers) { if (!supportsFollowers) {
return; // Entity does not support following return; // Entity does not support following
@ -1196,6 +1237,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
void put_addDeleteInvalidFollower_200(TestInfo test) throws IOException { void put_addDeleteInvalidFollower_200(TestInfo test) throws IOException {
if (!supportsFollowers) { if (!supportsFollowers) {
return; // Entity does not support following return; // Entity does not support following
@ -1221,6 +1263,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
// Common entity tests for PATCH operations // Common entity tests for PATCH operations
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
protected void patch_entityDescriptionAndTestAuthorizer(TestInfo test) throws IOException { protected void patch_entityDescriptionAndTestAuthorizer(TestInfo test) throws IOException {
if (!supportsPatch) { if (!supportsPatch) {
return; return;
@ -1254,6 +1297,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
void patch_entityAttributes_200_ok(TestInfo test) throws IOException { void patch_entityAttributes_200_ok(TestInfo test) throws IOException {
if (!supportsPatch) { if (!supportsPatch) {
return; return;
@ -1344,6 +1388,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
void patch_deleted_attribute_disallowed_400(TestInfo test) throws HttpResponseException, JsonProcessingException { void patch_deleted_attribute_disallowed_400(TestInfo test) throws HttpResponseException, JsonProcessingException {
if (!supportsPatch || !supportsSoftDelete) { if (!supportsPatch || !supportsSoftDelete) {
return; return;
@ -1359,6 +1404,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
void put_addEntityCustomAttributes(TestInfo test) throws IOException { void put_addEntityCustomAttributes(TestInfo test) throws IOException {
if (!supportsCustomExtension) { if (!supportsCustomExtension) {
return; return;
@ -1417,7 +1463,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
// PUT and update the entity with extension field intA to a new value // PUT and update the entity with extension field intA to a new value
JsonNode intAValue = mapper.convertValue(2, JsonNode.class); JsonNode intAValue = mapper.convertValue(2, JsonNode.class);
jsonNode.set("intA", intAValue); jsonNode.set("intA", intAValue);
create = createRequest(test).withExtension(jsonNode); create = createRequest(test).withExtension(jsonNode).withName(entity.getName());
change = getChangeDescription(entity.getVersion()); change = getChangeDescription(entity.getVersion());
fieldUpdated(change, EntityUtil.getExtensionField("intA"), mapper.convertValue(1, JsonNode.class), intAValue); fieldUpdated(change, EntityUtil.getExtensionField("intA"), mapper.convertValue(1, JsonNode.class), intAValue);
entity = updateAndCheckEntity(create, Status.OK, ADMIN_AUTH_HEADERS, MINOR_UPDATE, change); entity = updateAndCheckEntity(create, Status.OK, ADMIN_AUTH_HEADERS, MINOR_UPDATE, change);
@ -1435,7 +1481,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
// PUT and remove field intA from the entity extension - *** for BOT this should be ignored *** // PUT and remove field intA from the entity extension - *** for BOT this should be ignored ***
JsonNode oldNode = JsonUtils.valueToTree(entity.getExtension()); JsonNode oldNode = JsonUtils.valueToTree(entity.getExtension());
jsonNode.remove("intA"); jsonNode.remove("intA");
create = createRequest(test).withExtension(jsonNode); create = createRequest(test).withExtension(jsonNode).withName(entity.getName());
entity = updateEntity(create, Status.OK, INGESTION_BOT_AUTH_HEADERS); entity = updateEntity(create, Status.OK, INGESTION_BOT_AUTH_HEADERS);
assertNotEquals(JsonUtils.valueToTree(create.getExtension()), JsonUtils.valueToTree(entity.getExtension())); assertNotEquals(JsonUtils.valueToTree(create.getExtension()), JsonUtils.valueToTree(entity.getExtension()));
assertEquals(oldNode, JsonUtils.valueToTree(entity.getExtension())); // Extension remains as is assertEquals(oldNode, JsonUtils.valueToTree(entity.getExtension())); // Extension remains as is
@ -1475,6 +1521,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
// Common entity tests for DELETE operations // Common entity tests for DELETE operations
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
void delete_nonExistentEntity_404() { void delete_nonExistentEntity_404() {
assertResponse( assertResponse(
() -> deleteEntity(NON_EXISTENT_ENTITY, ADMIN_AUTH_HEADERS), () -> deleteEntity(NON_EXISTENT_ENTITY, ADMIN_AUTH_HEADERS),
@ -1483,6 +1530,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
protected void delete_entity_as_non_admin_401(TestInfo test) throws HttpResponseException { protected void delete_entity_as_non_admin_401(TestInfo test) throws HttpResponseException {
// Deleting as non-owner and non-admin should fail // Deleting as non-owner and non-admin should fail
K request = createRequest(getEntityName(test), "", "", null); K request = createRequest(getEntityName(test), "", "", null);
@ -1500,6 +1548,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
/** Soft delete an entity and then use restore request to restore it back */ /** Soft delete an entity and then use restore request to restore it back */
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
void delete_restore_entity_200(TestInfo test) throws IOException { void delete_restore_entity_200(TestInfo test) throws IOException {
K request = createRequest(getEntityName(test), "", "", null); K request = createRequest(getEntityName(test), "", "", null);
T entity = createEntity(request, ADMIN_AUTH_HEADERS); T entity = createEntity(request, ADMIN_AUTH_HEADERS);
@ -1523,6 +1572,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
// Other tests // Other tests
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
void testInvalidEntityList() { void testInvalidEntityList() {
// Invalid entityCreated list // Invalid entityCreated list
assertResponse( assertResponse(
@ -1544,6 +1594,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
protected void testTeamOnlyPolicy(TestInfo test) throws HttpResponseException { protected void testTeamOnlyPolicy(TestInfo test) throws HttpResponseException {
testTeamOnlyPolicy(test, VIEW_ALL); testTeamOnlyPolicy(test, VIEW_ALL);
} }
@ -1598,6 +1649,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
void delete_systemEntity() throws IOException { void delete_systemEntity() throws IOException {
if (systemEntityName == null) { if (systemEntityName == null) {
return; return;
@ -2026,7 +2078,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
Awaitility.await("Wait for expected change event at timestamp " + timestamp) Awaitility.await("Wait for expected change event at timestamp " + timestamp)
.pollInterval(Duration.ofMillis(100L)) .pollInterval(Duration.ofMillis(100L))
.atMost(Duration.ofMillis(20 * 100L)) // 10 iterations .atMost(Duration.ofMillis(100 * 100L)) // 100 iterations
.until( .until(
() -> () ->
eventHolder.hasExpectedEvent( eventHolder.hasExpectedEvent(
@ -2071,7 +2123,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
Awaitility.await("Wait for expected deleted event at timestamp " + timestamp) Awaitility.await("Wait for expected deleted event at timestamp " + timestamp)
.pollInterval(Duration.ofMillis(100L)) .pollInterval(Duration.ofMillis(100L))
.atMost(Duration.ofMillis(10 * 100L)) // 10 iterations .atMost(Duration.ofMillis(100 * 100L)) // 100 iterations
.until(() -> eventHolder.hasDeletedEvent(getChangeEvents(null, null, entityType, timestamp, authHeaders), id)); .until(() -> eventHolder.hasDeletedEvent(getChangeEvents(null, null, entityType, timestamp, authHeaders), id));
ChangeEvent changeEvent = eventHolder.getExpectedEvent(); ChangeEvent changeEvent = eventHolder.getExpectedEvent();

View File

@ -28,6 +28,8 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.http.client.HttpResponseException; import org.apache.http.client.HttpResponseException;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo; import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;
import org.openmetadata.schema.api.data.CreateChart; import org.openmetadata.schema.api.data.CreateChart;
import org.openmetadata.schema.entity.data.Chart; import org.openmetadata.schema.entity.data.Chart;
import org.openmetadata.schema.type.ChartType; import org.openmetadata.schema.type.ChartType;
@ -45,6 +47,7 @@ public class ChartResourceTest extends EntityResourceTest<Chart, CreateChart> {
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
void post_chartWithoutRequiredFields_4xx(TestInfo test) { void post_chartWithoutRequiredFields_4xx(TestInfo test) {
// Service is required field // Service is required field
assertResponse( assertResponse(
@ -54,6 +57,7 @@ public class ChartResourceTest extends EntityResourceTest<Chart, CreateChart> {
} }
@Test @Test
@Execution(ExecutionMode.CONCURRENT)
void post_chartWithDifferentService_200_ok(TestInfo test) throws IOException { void post_chartWithDifferentService_200_ok(TestInfo test) throws IOException {
EntityReference[] differentServices = {METABASE_REFERENCE, LOOKER_REFERENCE}; EntityReference[] differentServices = {METABASE_REFERENCE, LOOKER_REFERENCE};
@ -72,6 +76,7 @@ public class ChartResourceTest extends EntityResourceTest<Chart, CreateChart> {
} }
@Override @Override
@Execution(ExecutionMode.CONCURRENT)
public Chart validateGetWithDifferentFields(Chart chart, boolean byName) throws HttpResponseException { public Chart validateGetWithDifferentFields(Chart chart, boolean byName) throws HttpResponseException {
String fields = ""; String fields = "";
chart = chart =

View File

@ -30,7 +30,6 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.http.client.HttpResponseException; import org.apache.http.client.HttpResponseException;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo; import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.TestInstance;
import org.openmetadata.schema.api.data.CreateDatabase; import org.openmetadata.schema.api.data.CreateDatabase;
import org.openmetadata.schema.api.data.CreateDatabaseSchema; import org.openmetadata.schema.api.data.CreateDatabaseSchema;
import org.openmetadata.schema.entity.data.Database; import org.openmetadata.schema.entity.data.Database;
@ -44,7 +43,6 @@ import org.openmetadata.service.util.ResultList;
import org.openmetadata.service.util.TestUtils; import org.openmetadata.service.util.TestUtils;
@Slf4j @Slf4j
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class DatabaseResourceTest extends EntityResourceTest<Database, CreateDatabase> { public class DatabaseResourceTest extends EntityResourceTest<Database, CreateDatabase> {
public DatabaseResourceTest() { public DatabaseResourceTest() {
super(Entity.DATABASE, Database.class, DatabaseList.class, "databases", DatabaseResource.FIELDS); super(Entity.DATABASE, Database.class, DatabaseList.class, "databases", DatabaseResource.FIELDS);

View File

@ -27,7 +27,6 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.http.client.HttpResponseException; import org.apache.http.client.HttpResponseException;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo; import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.TestInstance;
import org.openmetadata.schema.api.data.CreateDatabaseSchema; import org.openmetadata.schema.api.data.CreateDatabaseSchema;
import org.openmetadata.schema.api.data.CreateTable; import org.openmetadata.schema.api.data.CreateTable;
import org.openmetadata.schema.entity.data.DatabaseSchema; import org.openmetadata.schema.entity.data.DatabaseSchema;
@ -39,7 +38,6 @@ import org.openmetadata.service.util.FullyQualifiedName;
import org.openmetadata.service.util.TestUtils; import org.openmetadata.service.util.TestUtils;
@Slf4j @Slf4j
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class DatabaseSchemaResourceTest extends EntityResourceTest<DatabaseSchema, CreateDatabaseSchema> { class DatabaseSchemaResourceTest extends EntityResourceTest<DatabaseSchema, CreateDatabaseSchema> {
public DatabaseSchemaResourceTest() { public DatabaseSchemaResourceTest() {
super( super(

View File

@ -84,6 +84,7 @@ import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo; import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestMethodOrder; import org.junit.jupiter.api.TestMethodOrder;
import org.openmetadata.schema.api.data.CreateDatabase; import org.openmetadata.schema.api.data.CreateDatabase;
import org.openmetadata.schema.api.data.CreateDatabaseSchema; import org.openmetadata.schema.api.data.CreateDatabaseSchema;
@ -141,6 +142,7 @@ import org.openmetadata.service.util.TestUtils;
@Slf4j @Slf4j
@TestMethodOrder(MethodOrderer.OrderAnnotation.class) @TestMethodOrder(MethodOrderer.OrderAnnotation.class)
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class TableResourceTest extends EntityResourceTest<Table, CreateTable> { public class TableResourceTest extends EntityResourceTest<Table, CreateTable> {
private final TagResourceTest tagResourceTest = new TagResourceTest(); private final TagResourceTest tagResourceTest = new TagResourceTest();
@ -1449,10 +1451,10 @@ public class TableResourceTest extends EntityResourceTest<Table, CreateTable> {
assertEquals(3, getClassificationUsageCount("User", ADMIN_AUTH_HEADERS)); assertEquals(3, getClassificationUsageCount("User", ADMIN_AUTH_HEADERS));
// Total 1 glossary1 tags - 1 column // Total 1 glossary1 tags - 1 column
assertEquals(1, getGlossaryUsageCount("g1")); assertEquals(1, getGlossaryUsageCount(GLOSSARY1.getName()));
// Total 1 glossary2 tags - 1 table // Total 1 glossary2 tags - 1 table
assertEquals(1, getGlossaryUsageCount("g2")); assertEquals(1, getGlossaryUsageCount(GLOSSARY2.getName()));
// Total 3 USER_ADDRESS tags - 1 table tag and 2 column tags // Total 3 USER_ADDRESS tags - 1 table tag and 2 column tags
assertEquals(3, getTagUsageCount(USER_ADDRESS_TAG_LABEL.getTagFQN(), ADMIN_AUTH_HEADERS)); assertEquals(3, getTagUsageCount(USER_ADDRESS_TAG_LABEL.getTagFQN(), ADMIN_AUTH_HEADERS));
@ -1638,14 +1640,18 @@ public class TableResourceTest extends EntityResourceTest<Table, CreateTable> {
} }
@Test @Test
void patch_tableColumnTags_200_ok(TestInfo test) throws IOException { void patch_tableColumnsTags_200_ok(TestInfo test) throws IOException {
Column c1 = getColumn(C1, INT, null); Column c1 = getColumn(C1, INT, null);
CreateTable create = createRequest(test).withColumns(List.of(c1)); CreateTable create = createRequest(test).withColumns(List.of(c1));
Table table = createAndCheckEntity(create, ADMIN_AUTH_HEADERS); Table table = createAndCheckEntity(create, ADMIN_AUTH_HEADERS);
// Add a primary tag and derived tag both. The tag list must include derived tags only once. // Add a primary tag and derived tag both. The tag list must include derived tags only once.
String json = JsonUtils.pojoToJson(table); String json = JsonUtils.pojoToJson(table);
table.getColumns().get(0).withTags(List.of(GLOSSARY1_TERM1_LABEL, PERSONAL_DATA_TAG_LABEL, USER_ADDRESS_TAG_LABEL)); table
.getColumns()
.get(0)
.withTags(
List.of(GLOSSARY1_TERM1_LABEL, PERSONAL_DATA_TAG_LABEL, USER_ADDRESS_TAG_LABEL, PII_SENSITIVE_TAG_LABEL));
Table updatedTable = patchEntity(table.getId(), json, table, ADMIN_AUTH_HEADERS); Table updatedTable = patchEntity(table.getId(), json, table, ADMIN_AUTH_HEADERS);
// Ensure only 4 tag labels are found - Manual tags PersonalData.Personal, User.Address, glossaryTerm1 // Ensure only 4 tag labels are found - Manual tags PersonalData.Personal, User.Address, glossaryTerm1
@ -1671,7 +1677,7 @@ public class TableResourceTest extends EntityResourceTest<Table, CreateTable> {
TagLabel piiSensitive = TagLabel piiSensitive =
updateTags.stream().filter(t -> tagLabelMatch.test(t, PII_SENSITIVE_TAG_LABEL)).findAny().orElse(null); updateTags.stream().filter(t -> tagLabelMatch.test(t, PII_SENSITIVE_TAG_LABEL)).findAny().orElse(null);
assertNotNull(piiSensitive); assertNotNull(piiSensitive);
assertEquals(LabelType.DERIVED, piiSensitive.getLabelType()); assertEquals(LabelType.MANUAL, piiSensitive.getLabelType());
} }
@Test @Test

View File

@ -28,7 +28,6 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID;
import javax.ws.rs.client.WebTarget; import javax.ws.rs.client.WebTarget;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -95,7 +94,7 @@ public class TestCaseResourceTest extends EntityResourceTest<TestCase, CreateTes
tableReq = tableReq =
tableResourceTest tableResourceTest
.createRequest(test) .createRequest(test)
.withName("testCaseTable" + UUID.randomUUID()) .withName("testCaseTable")
.withDatabaseSchema(DATABASE_SCHEMA_REFERENCE) .withDatabaseSchema(DATABASE_SCHEMA_REFERENCE)
.withColumns( .withColumns(
List.of( List.of(
@ -439,7 +438,11 @@ public class TestCaseResourceTest extends EntityResourceTest<TestCase, CreateTes
fieldUpdated(change, "description", oldDescription, newDescription); fieldUpdated(change, "description", oldDescription, newDescription);
testCase = testCase =
updateAndCheckEntity( updateAndCheckEntity(
createRequest(test).withDescription(newDescription), OK, ownerAuthHeaders, UpdateType.MINOR_UPDATE, change); createRequest(test).withDescription(newDescription).withName(testCase.getName()),
OK,
ownerAuthHeaders,
UpdateType.MINOR_UPDATE,
change);
// Update description with PATCH // Update description with PATCH
oldDescription = testCase.getDescription(); oldDescription = testCase.getDescription();

View File

@ -100,7 +100,7 @@ public class TestSuiteResourceTest extends EntityResourceTest<TestSuite, CreateT
assertEquals(deletedTestSuite.getDeleted(), true); assertEquals(deletedTestSuite.getDeleted(), true);
} }
public static ResultList<TestSuite> getTestSuites(Integer limit, String fields, Map<String, String> authHeaders) public ResultList<TestSuite> getTestSuites(Integer limit, String fields, Map<String, String> authHeaders)
throws HttpResponseException { throws HttpResponseException {
WebTarget target = getResource("testSuite"); WebTarget target = getResource("testSuite");
target = limit != null ? target.queryParam("limit", limit) : target; target = limit != null ? target.queryParam("limit", limit) : target;

View File

@ -27,6 +27,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.http.client.HttpResponseException; import org.apache.http.client.HttpResponseException;
import org.awaitility.Awaitility; import org.awaitility.Awaitility;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo; import org.junit.jupiter.api.TestInfo;
@ -53,6 +54,7 @@ import org.openmetadata.service.util.TestUtils;
@Slf4j @Slf4j
@TestMethodOrder(MethodOrderer.OrderAnnotation.class) @TestMethodOrder(MethodOrderer.OrderAnnotation.class)
@Disabled
public class AlertResourceTest extends EntityResourceTest<Alert, CreateAlert> { public class AlertResourceTest extends EntityResourceTest<Alert, CreateAlert> {
public static final TriggerConfig ALL_EVENTS_FILTER = public static final TriggerConfig ALL_EVENTS_FILTER =
new TriggerConfig().withType(TriggerConfig.AlertTriggerType.ALL_DATA_ASSETS); new TriggerConfig().withType(TriggerConfig.AlertTriggerType.ALL_DATA_ASSETS);

View File

@ -67,6 +67,7 @@ import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo; import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestMethodOrder; import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.Arguments;
@ -113,6 +114,7 @@ import org.openmetadata.service.util.TestUtils;
@Slf4j @Slf4j
@TestMethodOrder(MethodOrderer.OrderAnnotation.class) @TestMethodOrder(MethodOrderer.OrderAnnotation.class)
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class FeedResourceTest extends OpenMetadataApplicationTest { public class FeedResourceTest extends OpenMetadataApplicationTest {
public static Table TABLE; public static Table TABLE;
public static Table TABLE2; public static Table TABLE2;
@ -136,7 +138,7 @@ public class FeedResourceTest extends OpenMetadataApplicationTest {
: 1; : 1;
@BeforeAll @BeforeAll
public static void setup(TestInfo test) throws IOException, URISyntaxException { public void setup(TestInfo test) throws IOException, URISyntaxException {
TABLE_RESOURCE_TEST = new TableResourceTest(); TABLE_RESOURCE_TEST = new TableResourceTest();
TABLE_RESOURCE_TEST.setup(test); // Initialize TableResourceTest for using helper methods TABLE_RESOURCE_TEST.setup(test); // Initialize TableResourceTest for using helper methods
@ -1303,8 +1305,7 @@ public class FeedResourceTest extends OpenMetadataApplicationTest {
entityNotFound("Post", NON_EXISTENT_ENTITY)); entityNotFound("Post", NON_EXISTENT_ENTITY));
} }
public static Thread createAndCheck(CreateThread create, Map<String, String> authHeaders) public Thread createAndCheck(CreateThread create, Map<String, String> authHeaders) throws HttpResponseException {
throws HttpResponseException {
// Validate returned thread from POST // Validate returned thread from POST
Thread thread = createThread(create, authHeaders); Thread thread = createThread(create, authHeaders);
validateThread(thread, create.getMessage(), create.getFrom(), create.getAbout()); validateThread(thread, create.getMessage(), create.getFrom(), create.getAbout());
@ -1326,14 +1327,14 @@ public class FeedResourceTest extends OpenMetadataApplicationTest {
return returnedThread; return returnedThread;
} }
private static void validateThread(Thread thread, String message, String from, String about) { private void validateThread(Thread thread, String message, String from, String about) {
assertNotNull(thread.getId()); assertNotNull(thread.getId());
assertEquals(message, thread.getMessage()); assertEquals(message, thread.getMessage());
assertEquals(from, thread.getCreatedBy()); assertEquals(from, thread.getCreatedBy());
assertEquals(about, thread.getAbout()); assertEquals(about, thread.getAbout());
} }
private static void validatePost(Thread expected, Thread actual, String from, String message) { private void validatePost(Thread expected, Thread actual, String from, String message) {
// Make sure the post added is as expected // Make sure the post added is as expected
Post actualPost = actual.getPosts().get(actual.getPosts().size() - 1); // Last post was newly added to the thread Post actualPost = actual.getPosts().get(actual.getPosts().size() - 1); // Last post was newly added to the thread
assertEquals(from, actualPost.getFrom()); assertEquals(from, actualPost.getFrom());
@ -1344,56 +1345,54 @@ public class FeedResourceTest extends OpenMetadataApplicationTest {
assertEquals(expected.getPosts().size() + 1, actual.getPosts().size()); assertEquals(expected.getPosts().size() + 1, actual.getPosts().size());
} }
public static Thread createThread(CreateThread create, Map<String, String> authHeaders) throws HttpResponseException { public Thread createThread(CreateThread create, Map<String, String> authHeaders) throws HttpResponseException {
return TestUtils.post(getResource("feed"), create, Thread.class, authHeaders); return TestUtils.post(getResource("feed"), create, Thread.class, authHeaders);
} }
public static Thread addPost(UUID threadId, CreatePost post, Map<String, String> authHeaders) public Thread addPost(UUID threadId, CreatePost post, Map<String, String> authHeaders) throws HttpResponseException {
throws HttpResponseException {
return TestUtils.post(getResource("feed/" + threadId + "/posts"), post, Thread.class, authHeaders); return TestUtils.post(getResource("feed/" + threadId + "/posts"), post, Thread.class, authHeaders);
} }
public static Thread deleteThread(UUID threadId, Map<String, String> authHeaders) throws HttpResponseException { public Thread deleteThread(UUID threadId, Map<String, String> authHeaders) throws HttpResponseException {
return TestUtils.delete(getResource("feed/" + threadId), Thread.class, authHeaders); return TestUtils.delete(getResource("feed/" + threadId), Thread.class, authHeaders);
} }
public static Post deletePost(UUID threadId, UUID postId, Map<String, String> authHeaders) public Post deletePost(UUID threadId, UUID postId, Map<String, String> authHeaders) throws HttpResponseException {
throws HttpResponseException {
return TestUtils.delete(getResource("feed/" + threadId + "/posts/" + postId), Post.class, authHeaders); return TestUtils.delete(getResource("feed/" + threadId + "/posts/" + postId), Post.class, authHeaders);
} }
public static CreateThread create() { public CreateThread create() {
String about = String.format("<#E::%s::%s>", Entity.TABLE, TABLE.getFullyQualifiedName()); String about = String.format("<#E::%s::%s>", Entity.TABLE, TABLE.getFullyQualifiedName());
return new CreateThread().withFrom(USER.getName()).withMessage("message").withAbout(about); return new CreateThread().withFrom(USER.getName()).withMessage("message").withAbout(about);
} }
public static CreatePost createPost(String message) { public CreatePost createPost(String message) {
message = StringUtils.isNotEmpty(message) ? message : "message"; message = StringUtils.isNotEmpty(message) ? message : "message";
return new CreatePost().withFrom(USER.getName()).withMessage(message); return new CreatePost().withFrom(USER.getName()).withMessage(message);
} }
public static Thread getThread(UUID id, Map<String, String> authHeaders) throws HttpResponseException { public Thread getThread(UUID id, Map<String, String> authHeaders) throws HttpResponseException {
WebTarget target = getResource("feed/" + id); WebTarget target = getResource("feed/" + id);
return TestUtils.get(target, Thread.class, authHeaders); return TestUtils.get(target, Thread.class, authHeaders);
} }
public static Thread getTask(int id, Map<String, String> authHeaders) throws HttpResponseException { public Thread getTask(int id, Map<String, String> authHeaders) throws HttpResponseException {
WebTarget target = getResource("feed/tasks/" + id); WebTarget target = getResource("feed/tasks/" + id);
return TestUtils.get(target, Thread.class, authHeaders); return TestUtils.get(target, Thread.class, authHeaders);
} }
public static void resolveTask(int id, ResolveTask resolveTask, Map<String, String> authHeaders) public void resolveTask(int id, ResolveTask resolveTask, Map<String, String> authHeaders)
throws HttpResponseException { throws HttpResponseException {
WebTarget target = getResource("feed/tasks/" + id + "/resolve"); WebTarget target = getResource("feed/tasks/" + id + "/resolve");
TestUtils.put(target, resolveTask, Status.OK, authHeaders); TestUtils.put(target, resolveTask, Status.OK, authHeaders);
} }
public static void closeTask(int id, String comment, Map<String, String> authHeaders) throws HttpResponseException { public void closeTask(int id, String comment, Map<String, String> authHeaders) throws HttpResponseException {
WebTarget target = getResource("feed/tasks/" + id + "/close"); WebTarget target = getResource("feed/tasks/" + id + "/close");
TestUtils.put(target, new CloseTask().withComment(comment), Status.OK, authHeaders); TestUtils.put(target, new CloseTask().withComment(comment), Status.OK, authHeaders);
} }
public static ThreadList listTasks( public ThreadList listTasks(
String entityLink, String entityLink,
String userId, String userId,
String filterType, String filterType,
@ -1415,7 +1414,7 @@ public class FeedResourceTest extends OpenMetadataApplicationTest {
null); null);
} }
public static ThreadList listAnnouncements( public ThreadList listAnnouncements(
String entityLink, Integer limitPosts, Boolean activeAnnouncement, Map<String, String> authHeaders) String entityLink, Integer limitPosts, Boolean activeAnnouncement, Map<String, String> authHeaders)
throws HttpResponseException { throws HttpResponseException {
return listThreads( return listThreads(
@ -1432,7 +1431,7 @@ public class FeedResourceTest extends OpenMetadataApplicationTest {
null); null);
} }
public static ThreadList listThreads(String entityLink, Integer limitPosts, Map<String, String> authHeaders) public ThreadList listThreads(String entityLink, Integer limitPosts, Map<String, String> authHeaders)
throws HttpResponseException { throws HttpResponseException {
return listThreads( return listThreads(
entityLink, entityLink,
@ -1448,7 +1447,7 @@ public class FeedResourceTest extends OpenMetadataApplicationTest {
null); null);
} }
public static ThreadList listThreads( public ThreadList listThreads(
String entityLink, String entityLink,
Integer limitPosts, Integer limitPosts,
Map<String, String> authHeaders, Map<String, String> authHeaders,
@ -1475,13 +1474,12 @@ public class FeedResourceTest extends OpenMetadataApplicationTest {
return TestUtils.get(target, ThreadList.class, authHeaders); return TestUtils.get(target, ThreadList.class, authHeaders);
} }
public static void followTable(UUID tableId, UUID userId, Map<String, String> authHeaders) public void followTable(UUID tableId, UUID userId, Map<String, String> authHeaders) throws HttpResponseException {
throws HttpResponseException {
WebTarget target = getResource("tables/" + tableId + "/followers"); WebTarget target = getResource("tables/" + tableId + "/followers");
TestUtils.put(target, userId, OK, authHeaders); TestUtils.put(target, userId, OK, authHeaders);
} }
public static ThreadList listThreadsWithFilter(String userId, String filterType, Map<String, String> authHeaders) public ThreadList listThreadsWithFilter(String userId, String filterType, Map<String, String> authHeaders)
throws HttpResponseException { throws HttpResponseException {
WebTarget target = getResource("feed"); WebTarget target = getResource("feed");
target = target.queryParam("type", ThreadType.Conversation); target = target.queryParam("type", ThreadType.Conversation);
@ -1490,20 +1488,19 @@ public class FeedResourceTest extends OpenMetadataApplicationTest {
return TestUtils.get(target, ThreadList.class, authHeaders); return TestUtils.get(target, ThreadList.class, authHeaders);
} }
public static PostList listPosts(String threadId, Map<String, String> authHeaders) throws HttpResponseException { public PostList listPosts(String threadId, Map<String, String> authHeaders) throws HttpResponseException {
WebTarget target = getResource(String.format("feed/%s/posts", threadId)); WebTarget target = getResource(String.format("feed/%s/posts", threadId));
return TestUtils.get(target, PostList.class, authHeaders); return TestUtils.get(target, PostList.class, authHeaders);
} }
public static ThreadCount listThreadsCount(String entityLink, Map<String, String> authHeaders) public ThreadCount listThreadsCount(String entityLink, Map<String, String> authHeaders) throws HttpResponseException {
throws HttpResponseException {
WebTarget target = getResource("feed/count"); WebTarget target = getResource("feed/count");
target = entityLink != null ? target.queryParam("entityLink", entityLink) : target; target = entityLink != null ? target.queryParam("entityLink", entityLink) : target;
target = target.queryParam("type", ThreadType.Conversation); target = target.queryParam("type", ThreadType.Conversation);
return TestUtils.get(target, ThreadCount.class, authHeaders); return TestUtils.get(target, ThreadCount.class, authHeaders);
} }
public static ThreadCount listTasksCount(String entityLink, TaskStatus taskStatus, Map<String, String> authHeaders) public ThreadCount listTasksCount(String entityLink, TaskStatus taskStatus, Map<String, String> authHeaders)
throws HttpResponseException { throws HttpResponseException {
WebTarget target = getResource("feed/count"); WebTarget target = getResource("feed/count");
target = entityLink != null ? target.queryParam("entityLink", entityLink) : target; target = entityLink != null ? target.queryParam("entityLink", entityLink) : target;

View File

@ -100,7 +100,6 @@ public class GlossaryResourceTest extends EntityResourceTest<Glossary, CreateGlo
.createRequest("g1t1", "", "", null) .createRequest("g1t1", "", "", null)
.withRelatedTerms(null) .withRelatedTerms(null)
.withGlossary(GLOSSARY1_REF) .withGlossary(GLOSSARY1_REF)
.withTags(List.of(PII_SENSITIVE_TAG_LABEL, PERSONAL_DATA_TAG_LABEL))
.withReviewers(GLOSSARY1.getReviewers()); .withReviewers(GLOSSARY1.getReviewers());
GLOSSARY1_TERM1 = glossaryTermResourceTest.createAndCheckEntity(createGlossaryTerm, ADMIN_AUTH_HEADERS); GLOSSARY1_TERM1 = glossaryTermResourceTest.createAndCheckEntity(createGlossaryTerm, ADMIN_AUTH_HEADERS);
GLOSSARY1_TERM1_REF = GLOSSARY1_TERM1.getEntityReference(); GLOSSARY1_TERM1_REF = GLOSSARY1_TERM1.getEntityReference();
@ -109,7 +108,7 @@ public class GlossaryResourceTest extends EntityResourceTest<Glossary, CreateGlo
createGlossaryTerm = createGlossaryTerm =
glossaryTermResourceTest glossaryTermResourceTest
.createRequest("g2t1", "", "", null) .createRequest("g1t2", "", "", null)
.withRelatedTerms(List.of(GLOSSARY1_TERM1_REF)) .withRelatedTerms(List.of(GLOSSARY1_TERM1_REF))
.withGlossary(GLOSSARY2_REF) .withGlossary(GLOSSARY2_REF)
.withReviewers(GLOSSARY1.getReviewers()); .withReviewers(GLOSSARY1.getReviewers());

View File

@ -322,23 +322,22 @@ public class LineageResourceTest extends OpenMetadataApplicationTest {
deleteLineageAndCheck(edge, authHeaders); deleteLineageAndCheck(edge, authHeaders);
} }
public static void addLineageAndCheck(AddLineage addLineage, Map<String, String> authHeaders) public void addLineageAndCheck(AddLineage addLineage, Map<String, String> authHeaders) throws HttpResponseException {
throws HttpResponseException {
addLineage(addLineage, authHeaders); addLineage(addLineage, authHeaders);
validateLineage(addLineage, authHeaders); validateLineage(addLineage, authHeaders);
} }
public static void deleteLineageAndCheck(EntitiesEdge deleteEdge, Map<String, String> authHeaders) public void deleteLineageAndCheck(EntitiesEdge deleteEdge, Map<String, String> authHeaders)
throws HttpResponseException { throws HttpResponseException {
deleteLineage(deleteEdge, authHeaders); deleteLineage(deleteEdge, authHeaders);
validateLineageDeleted(deleteEdge, authHeaders); validateLineageDeleted(deleteEdge, authHeaders);
} }
public static void addLineage(AddLineage addLineage, Map<String, String> authHeaders) throws HttpResponseException { public void addLineage(AddLineage addLineage, Map<String, String> authHeaders) throws HttpResponseException {
TestUtils.put(getResource("lineage"), addLineage, Status.OK, authHeaders); TestUtils.put(getResource("lineage"), addLineage, Status.OK, authHeaders);
} }
public static void deleteLineage(EntitiesEdge edge, Map<String, String> authHeaders) throws HttpResponseException { public void deleteLineage(EntitiesEdge edge, Map<String, String> authHeaders) throws HttpResponseException {
WebTarget target = WebTarget target =
getResource( getResource(
String.format( String.format(
@ -350,8 +349,7 @@ public class LineageResourceTest extends OpenMetadataApplicationTest {
TestUtils.delete(target, authHeaders); TestUtils.delete(target, authHeaders);
} }
private static void validateLineage(AddLineage addLineage, Map<String, String> authHeaders) private void validateLineage(AddLineage addLineage, Map<String, String> authHeaders) throws HttpResponseException {
throws HttpResponseException {
EntityReference from = addLineage.getEdge().getFromEntity(); EntityReference from = addLineage.getEdge().getFromEntity();
EntityReference to = addLineage.getEdge().getToEntity(); EntityReference to = addLineage.getEdge().getToEntity();
Edge expectedEdge = getEdge(from.getId(), to.getId(), addLineage.getEdge().getLineageDetails()); Edge expectedEdge = getEdge(from.getId(), to.getId(), addLineage.getEdge().getLineageDetails());
@ -365,7 +363,7 @@ public class LineageResourceTest extends OpenMetadataApplicationTest {
assertEdge(lineage, expectedEdge, false); assertEdge(lineage, expectedEdge, false);
} }
private static void validateLineageDeleted(EntitiesEdge deletedEdge, Map<String, String> authHeaders) private void validateLineageDeleted(EntitiesEdge deletedEdge, Map<String, String> authHeaders)
throws HttpResponseException { throws HttpResponseException {
EntityReference from = deletedEdge.getFromEntity(); EntityReference from = deletedEdge.getFromEntity();
EntityReference to = deletedEdge.getToEntity(); EntityReference to = deletedEdge.getToEntity();
@ -405,7 +403,7 @@ public class LineageResourceTest extends OpenMetadataApplicationTest {
} }
} }
public static void assertLineage( public void assertLineage(
String entityType, String entityType,
UUID id, UUID id,
String fqn, String fqn,
@ -424,7 +422,7 @@ public class LineageResourceTest extends OpenMetadataApplicationTest {
assertEquals(lineageById, lineageByName); assertEquals(lineageById, lineageByName);
} }
public static EntityLineage getLineage( public EntityLineage getLineage(
String entity, UUID id, Integer upstreamDepth, Integer downStreamDepth, Map<String, String> authHeaders) String entity, UUID id, Integer upstreamDepth, Integer downStreamDepth, Map<String, String> authHeaders)
throws HttpResponseException { throws HttpResponseException {
WebTarget target = getResource("lineage/" + entity + "/" + id); WebTarget target = getResource("lineage/" + entity + "/" + id);
@ -435,7 +433,7 @@ public class LineageResourceTest extends OpenMetadataApplicationTest {
return lineage; return lineage;
} }
public static EntityLineage getLineageByName( public EntityLineage getLineageByName(
String entity, String fqn, Integer upstreamDepth, Integer downStreamDepth, Map<String, String> authHeaders) String entity, String fqn, Integer upstreamDepth, Integer downStreamDepth, Map<String, String> authHeaders)
throws HttpResponseException { throws HttpResponseException {
WebTarget target = getResource("lineage/" + entity + "/name/" + fqn); WebTarget target = getResource("lineage/" + entity + "/name/" + fqn);
@ -446,7 +444,7 @@ public class LineageResourceTest extends OpenMetadataApplicationTest {
return lineage; return lineage;
} }
public static void assertEdge(EntityLineage lineage, Edge expectedEdge, boolean downstream) { public void assertEdge(EntityLineage lineage, Edge expectedEdge, boolean downstream) {
if (downstream) { if (downstream) {
assertTrue(lineage.getDownstreamEdges().contains(expectedEdge)); assertTrue(lineage.getDownstreamEdges().contains(expectedEdge));
} else { } else {
@ -454,7 +452,7 @@ public class LineageResourceTest extends OpenMetadataApplicationTest {
} }
} }
public static void assertDeleted(EntityLineage lineage, Edge expectedEdge, boolean downstream) { public void assertDeleted(EntityLineage lineage, Edge expectedEdge, boolean downstream) {
if (downstream) { if (downstream) {
assertFalse(lineage.getDownstreamEdges().contains(expectedEdge)); assertFalse(lineage.getDownstreamEdges().contains(expectedEdge));
} else { } else {
@ -462,7 +460,7 @@ public class LineageResourceTest extends OpenMetadataApplicationTest {
} }
} }
public static void assertEdges(EntityLineage lineage, Edge[] expectedUpstreamEdges, Edge[] expectedDownstreamEdges) { public void assertEdges(EntityLineage lineage, Edge[] expectedUpstreamEdges, Edge[] expectedDownstreamEdges) {
assertEquals(lineage.getUpstreamEdges().size(), expectedUpstreamEdges.length); assertEquals(lineage.getUpstreamEdges().size(), expectedUpstreamEdges.length);
for (Edge expectedUpstreamEdge : expectedUpstreamEdges) { for (Edge expectedUpstreamEdge : expectedUpstreamEdges) {
assertTrue(lineage.getUpstreamEdges().contains(expectedUpstreamEdge)); assertTrue(lineage.getUpstreamEdges().contains(expectedUpstreamEdge));

View File

@ -176,7 +176,7 @@ public class LocationResourceTest extends EntityResourceTest<Location, CreateLoc
} }
} }
public static Location updateLocation(CreateLocation create, Status status, Map<String, String> authHeaders) public Location updateLocation(CreateLocation create, Status status, Map<String, String> authHeaders)
throws HttpResponseException { throws HttpResponseException {
return TestUtils.put(getResource("locations"), create, Location.class, status, authHeaders); return TestUtils.put(getResource("locations"), create, Location.class, status, authHeaders);
} }
@ -201,7 +201,7 @@ public class LocationResourceTest extends EntityResourceTest<Location, CreateLoc
return location; return location;
} }
public static LocationList listPrefixes( public LocationList listPrefixes(
String fields, String fqn, Integer limitParam, String before, String after, Map<String, String> authHeaders) String fields, String fqn, Integer limitParam, String before, String after, Map<String, String> authHeaders)
throws HttpResponseException { throws HttpResponseException {
String encodedFqn = URLEncoder.encode(fqn, StandardCharsets.UTF_8); String encodedFqn = URLEncoder.encode(fqn, StandardCharsets.UTF_8);

View File

@ -51,7 +51,6 @@ import org.apache.http.client.HttpResponseException;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo; import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.TestInstance;
import org.openmetadata.schema.api.data.CreateTable; import org.openmetadata.schema.api.data.CreateTable;
import org.openmetadata.schema.entity.data.Table; import org.openmetadata.schema.entity.data.Table;
import org.openmetadata.schema.entity.policies.Policy; import org.openmetadata.schema.entity.policies.Policy;
@ -78,7 +77,6 @@ import org.openmetadata.service.util.JsonUtils;
import org.openmetadata.service.util.TestUtils; import org.openmetadata.service.util.TestUtils;
@Slf4j @Slf4j
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class PermissionsResourceTest extends OpenMetadataApplicationTest { class PermissionsResourceTest extends OpenMetadataApplicationTest {
private static Rule ORG_IS_OWNER_RULE; private static Rule ORG_IS_OWNER_RULE;
private static Rule ORG_NO_OWNER_RULE; private static Rule ORG_NO_OWNER_RULE;

View File

@ -547,14 +547,13 @@ public class PipelineResourceTest extends EntityResourceTest<Pipeline, CreatePip
return pipeline; return pipeline;
} }
public static Pipeline getPipeline(UUID id, String fields, Map<String, String> authHeaders) public Pipeline getPipeline(UUID id, String fields, Map<String, String> authHeaders) throws HttpResponseException {
throws HttpResponseException {
WebTarget target = getResource("pipelines/" + id); WebTarget target = getResource("pipelines/" + id);
target = fields != null ? target.queryParam("fields", fields) : target; target = fields != null ? target.queryParam("fields", fields) : target;
return TestUtils.get(target, Pipeline.class, authHeaders); return TestUtils.get(target, Pipeline.class, authHeaders);
} }
public static Pipeline getPipelineByName(String fqn, String fields, Map<String, String> authHeaders) public Pipeline getPipelineByName(String fqn, String fields, Map<String, String> authHeaders)
throws HttpResponseException { throws HttpResponseException {
WebTarget target = getResource("pipelines/name/" + fqn); WebTarget target = getResource("pipelines/name/" + fqn);
target = fields != null ? target.queryParam("fields", fields) : target; target = fields != null ? target.queryParam("fields", fields) : target;
@ -562,19 +561,19 @@ public class PipelineResourceTest extends EntityResourceTest<Pipeline, CreatePip
} }
// Prepare Pipeline status endpoint for PUT // Prepare Pipeline status endpoint for PUT
public static Pipeline putPipelineStatusData(String fqn, PipelineStatus data, Map<String, String> authHeaders) public Pipeline putPipelineStatusData(String fqn, PipelineStatus data, Map<String, String> authHeaders)
throws HttpResponseException { throws HttpResponseException {
WebTarget target = getResource("pipelines/" + fqn + "/status"); WebTarget target = getResource("pipelines/" + fqn + "/status");
return TestUtils.put(target, data, Pipeline.class, OK, authHeaders); return TestUtils.put(target, data, Pipeline.class, OK, authHeaders);
} }
public static Pipeline deletePipelineStatus(String fqn, Long timestamp, Map<String, String> authHeaders) public Pipeline deletePipelineStatus(String fqn, Long timestamp, Map<String, String> authHeaders)
throws HttpResponseException { throws HttpResponseException {
WebTarget target = getResource("pipelines/" + fqn + "/status/" + timestamp); WebTarget target = getResource("pipelines/" + fqn + "/status/" + timestamp);
return TestUtils.delete(target, Pipeline.class, authHeaders); return TestUtils.delete(target, Pipeline.class, authHeaders);
} }
public static ResultList<PipelineStatus> getPipelineStatues( public ResultList<PipelineStatus> getPipelineStatues(
String fqn, Long startTs, Long endTs, Map<String, String> authHeaders) throws HttpResponseException { String fqn, Long startTs, Long endTs, Map<String, String> authHeaders) throws HttpResponseException {
WebTarget target = getResource("pipelines/" + fqn + "/status"); WebTarget target = getResource("pipelines/" + fqn + "/status");
target = target.queryParam("startTs", startTs).queryParam("endTs", endTs); target = target.queryParam("startTs", startTs).queryParam("endTs", endTs);

View File

@ -34,7 +34,6 @@ import static org.openmetadata.service.util.TestUtils.assertResponseContains;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
@ -44,7 +43,6 @@ import javax.ws.rs.client.WebTarget;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.http.client.HttpResponseException; import org.apache.http.client.HttpResponseException;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo; import org.junit.jupiter.api.TestInfo;
import org.openmetadata.schema.api.data.CreateLocation; import org.openmetadata.schema.api.data.CreateLocation;
@ -79,8 +77,6 @@ import org.openmetadata.service.util.TestUtils;
@Slf4j @Slf4j
public class PolicyResourceTest extends EntityResourceTest<Policy, CreatePolicy> { public class PolicyResourceTest extends EntityResourceTest<Policy, CreatePolicy> {
private static final String LOCATION_NAME = "aws-s3";
private static Location location;
public PolicyResourceTest() { public PolicyResourceTest() {
super( super(
@ -92,12 +88,6 @@ public class PolicyResourceTest extends EntityResourceTest<Policy, CreatePolicy>
Entity.ORGANIZATION_POLICY_NAME); Entity.ORGANIZATION_POLICY_NAME);
} }
@BeforeAll
public void setup(TestInfo test) throws IOException, URISyntaxException {
super.setup(test);
location = createLocation();
}
public void setupPolicies() throws IOException { public void setupPolicies() throws IOException {
POLICY1 = createEntity(createRequest("policy1").withOwner(null), ADMIN_AUTH_HEADERS); POLICY1 = createEntity(createRequest("policy1").withOwner(null), ADMIN_AUTH_HEADERS);
POLICY2 = createEntity(createRequest("policy2").withOwner(null), ADMIN_AUTH_HEADERS); POLICY2 = createEntity(createRequest("policy2").withOwner(null), ADMIN_AUTH_HEADERS);
@ -272,7 +262,7 @@ public class PolicyResourceTest extends EntityResourceTest<Policy, CreatePolicy>
ChangeDescription change = getChangeDescription(policy.getVersion()); ChangeDescription change = getChangeDescription(policy.getVersion());
fieldUpdated(change, "enabled", true, false); fieldUpdated(change, "enabled", true, false);
policy = patchEntityAndCheck(policy, origJson, ADMIN_AUTH_HEADERS, MINOR_UPDATE, change); policy = patchEntityAndCheck(policy, origJson, ADMIN_AUTH_HEADERS, MINOR_UPDATE, change);
Location location = createLocation();
EntityReference locationReference = location.getEntityReference(); EntityReference locationReference = location.getEntityReference();
// Add new field location // Add new field location
@ -420,9 +410,9 @@ public class PolicyResourceTest extends EntityResourceTest<Policy, CreatePolicy>
TestUtils.get(target, ADMIN_AUTH_HEADERS); TestUtils.get(target, ADMIN_AUTH_HEADERS);
} }
private static Location createLocation() throws HttpResponseException { private Location createLocation() throws HttpResponseException {
LocationResourceTest locationResourceTest = new LocationResourceTest(); LocationResourceTest locationResourceTest = new LocationResourceTest();
CreateLocation createLocation = locationResourceTest.createRequest(LOCATION_NAME, "", "", null); CreateLocation createLocation = locationResourceTest.createRequest("aws-s3", "", "", null);
return TestUtils.post(getResource("locations"), createLocation, Location.class, ADMIN_AUTH_HEADERS); return TestUtils.post(getResource("locations"), createLocation, Location.class, ADMIN_AUTH_HEADERS);
} }

View File

@ -144,7 +144,10 @@ public class MessagingServiceResourceTest extends EntityResourceTest<MessagingSe
.withSchemaRegistryURL(new URI("localhost:8081"))); .withSchemaRegistryURL(new URI("localhost:8081")));
// Update messaging description and ingestion service that are null // Update messaging description and ingestion service that are null
CreateMessagingService update = CreateMessagingService update =
createRequest(test).withDescription("description1").withConnection(messagingConnection); createRequest(test)
.withName(service.getName())
.withDescription("description1")
.withConnection(messagingConnection);
ChangeDescription change = getChangeDescription(service.getVersion()); ChangeDescription change = getChangeDescription(service.getVersion());
fieldAdded(change, "description", "description1"); fieldAdded(change, "description", "description1");
service = updateAndCheckEntity(update, OK, ADMIN_AUTH_HEADERS, UpdateType.MINOR_UPDATE, change); service = updateAndCheckEntity(update, OK, ADMIN_AUTH_HEADERS, UpdateType.MINOR_UPDATE, change);

View File

@ -259,7 +259,7 @@ public class PipelineServiceResourceTest extends EntityResourceTest<PipelineServ
} }
} }
public static void validateAirflowConnection( public void validateAirflowConnection(
AirflowConnection expectedAirflowConnection, AirflowConnection expectedAirflowConnection,
AirflowConnection actualAirflowConnection, AirflowConnection actualAirflowConnection,
Map<String, String> authHeaders) { Map<String, String> authHeaders) {

View File

@ -86,7 +86,7 @@ public class TagResourceTest extends EntityResourceTest<Tag, CreateTag> {
null, null,
PERSONAL_DATA_TAG_LABEL.getTagFQN(), PERSONAL_DATA_TAG_LABEL.getTagFQN(),
PII_SENSITIVE_TAG_LABEL.getTagFQN()); PII_SENSITIVE_TAG_LABEL.getTagFQN());
USER_ADDRESS_TAG_LABEL = getTagLabel(FullyQualifiedName.add("User", "Address")); USER_ADDRESS_TAG_LABEL = getTagLabel(FullyQualifiedName.add(USER_TAG_CATEGORY.getName(), "Address"));
} }
private TagLabel getTagLabel(String tagName) throws HttpResponseException { private TagLabel getTagLabel(String tagName) throws HttpResponseException {

View File

@ -634,13 +634,16 @@ public class TeamResourceTest extends EntityResourceTest<Team, CreateTeam> {
Team team = createAndCheckEntity(create, ADMIN_AUTH_HEADERS); Team team = createAndCheckEntity(create, ADMIN_AUTH_HEADERS);
// Add policies to the team // Add policies to the team
create = createRequest(getEntityName(test)).withPolicies(List.of(POLICY1.getId(), POLICY2.getId())); create =
createRequest(getEntityName(test))
.withPolicies(List.of(POLICY1.getId(), POLICY2.getId()))
.withName(team.getName());
ChangeDescription change = getChangeDescription(team.getVersion()); ChangeDescription change = getChangeDescription(team.getVersion());
fieldAdded(change, "policies", List.of(POLICY1.getEntityReference(), POLICY2.getEntityReference())); fieldAdded(change, "policies", List.of(POLICY1.getEntityReference(), POLICY2.getEntityReference()));
team = updateAndCheckEntity(create, OK, ADMIN_AUTH_HEADERS, MINOR_UPDATE, change); team = updateAndCheckEntity(create, OK, ADMIN_AUTH_HEADERS, MINOR_UPDATE, change);
// Remove policies from the team // Remove policies from the team
create = createRequest(getEntityName(test)); create = createRequest(getEntityName(test)).withName(team.getName());
change = getChangeDescription(team.getVersion()); change = getChangeDescription(team.getVersion());
fieldDeleted(change, "policies", List.of(POLICY1.getEntityReference(), POLICY2.getEntityReference())); fieldDeleted(change, "policies", List.of(POLICY1.getEntityReference(), POLICY2.getEntityReference()));
updateAndCheckEntity(create, OK, ADMIN_AUTH_HEADERS, MINOR_UPDATE, change); updateAndCheckEntity(create, OK, ADMIN_AUTH_HEADERS, MINOR_UPDATE, change);

View File

@ -292,82 +292,82 @@ class UsageResourceTest extends OpenMetadataApplicationTest {
Assertions.assertEquals(usage.getUsage().get(0), database.getUsageSummary()); Assertions.assertEquals(usage.getUsage().get(0), database.getUsageSummary());
} }
public static DailyCount usageReport() { public DailyCount usageReport() {
Random random = new Random(); Random random = new Random();
String today = RestUtil.DATE_FORMAT.format(new Date()); String today = RestUtil.DATE_FORMAT.format(new Date());
return new DailyCount().withCount(random.nextInt(100)).withDate(today); return new DailyCount().withCount(random.nextInt(100)).withDate(today);
} }
public static void reportUsageByNameAndCheckPut( public void reportUsageByNameAndCheckPut(
String entity, String fqn, DailyCount usage, int weeklyCount, int monthlyCount, Map<String, String> authHeaders) String entity, String fqn, DailyCount usage, int weeklyCount, int monthlyCount, Map<String, String> authHeaders)
throws HttpResponseException { throws HttpResponseException {
reportUsageByNamePut(entity, fqn, usage, authHeaders); reportUsageByNamePut(entity, fqn, usage, authHeaders);
checkUsageByName(usage.getDate(), entity, fqn, usage.getCount(), weeklyCount, monthlyCount, authHeaders); checkUsageByName(usage.getDate(), entity, fqn, usage.getCount(), weeklyCount, monthlyCount, authHeaders);
} }
public static void reportUsageAndCheckPut( public void reportUsageAndCheckPut(
String entity, UUID id, DailyCount usage, int weeklyCount, int monthlyCount, Map<String, String> authHeaders) String entity, UUID id, DailyCount usage, int weeklyCount, int monthlyCount, Map<String, String> authHeaders)
throws HttpResponseException { throws HttpResponseException {
reportUsagePut(entity, id, usage, authHeaders); reportUsagePut(entity, id, usage, authHeaders);
checkUsage(usage.getDate(), entity, id, usage.getCount(), weeklyCount, monthlyCount, authHeaders); checkUsage(usage.getDate(), entity, id, usage.getCount(), weeklyCount, monthlyCount, authHeaders);
} }
public static void reportUsageByName(String entity, String name, DailyCount usage, Map<String, String> authHeaders) public void reportUsageByName(String entity, String name, DailyCount usage, Map<String, String> authHeaders)
throws HttpResponseException { throws HttpResponseException {
WebTarget target = getResource("usage/" + entity + "/name/" + name); WebTarget target = getResource("usage/" + entity + "/name/" + name);
TestUtils.post(target, usage, authHeaders); TestUtils.post(target, usage, authHeaders);
} }
public static void reportUsageByNamePut(String entity, String name, DailyCount usage, Map<String, String> authHeaders) public void reportUsageByNamePut(String entity, String name, DailyCount usage, Map<String, String> authHeaders)
throws HttpResponseException { throws HttpResponseException {
WebTarget target = getResource("usage/" + entity + "/name/" + name); WebTarget target = getResource("usage/" + entity + "/name/" + name);
TestUtils.put(target, usage, Response.Status.CREATED, authHeaders); TestUtils.put(target, usage, Response.Status.CREATED, authHeaders);
} }
public static void reportUsage(String entity, UUID id, DailyCount usage, Map<String, String> authHeaders) public void reportUsage(String entity, UUID id, DailyCount usage, Map<String, String> authHeaders)
throws HttpResponseException { throws HttpResponseException {
WebTarget target = getResource("usage/" + entity + "/" + id); WebTarget target = getResource("usage/" + entity + "/" + id);
TestUtils.post(target, usage, authHeaders); TestUtils.post(target, usage, authHeaders);
} }
public static void reportUsagePut(String entity, UUID id, DailyCount usage, Map<String, String> authHeaders) public void reportUsagePut(String entity, UUID id, DailyCount usage, Map<String, String> authHeaders)
throws HttpResponseException { throws HttpResponseException {
WebTarget target = getResource("usage/" + entity + "/" + id); WebTarget target = getResource("usage/" + entity + "/" + id);
TestUtils.put(target, usage, Response.Status.CREATED, authHeaders); TestUtils.put(target, usage, Response.Status.CREATED, authHeaders);
} }
public static void computePercentile(String entity, String date, Map<String, String> authHeaders) public void computePercentile(String entity, String date, Map<String, String> authHeaders)
throws HttpResponseException { throws HttpResponseException {
WebTarget target = getResource("usage/compute.percentile/" + entity + "/" + date); WebTarget target = getResource("usage/compute.percentile/" + entity + "/" + date);
TestUtils.post(target, authHeaders); TestUtils.post(target, authHeaders);
} }
public static void getAndCheckUsage( public void getAndCheckUsage(
String entity, UUID id, String date, Integer days, int expectedRecords, Map<String, String> authHeaders) String entity, UUID id, String date, Integer days, int expectedRecords, Map<String, String> authHeaders)
throws HttpResponseException { throws HttpResponseException {
EntityUsage usage = getUsage(entity, id, date, days, authHeaders); EntityUsage usage = getUsage(entity, id, date, days, authHeaders);
assertEquals(expectedRecords, usage.getUsage().size()); assertEquals(expectedRecords, usage.getUsage().size());
} }
public static EntityUsage getUsageByName( public EntityUsage getUsageByName(
String entity, String fqn, String date, Integer days, Map<String, String> authHeaders) String entity, String fqn, String date, Integer days, Map<String, String> authHeaders)
throws HttpResponseException { throws HttpResponseException {
return getUsage(getResource("usage/" + entity + "/name/" + fqn), date, days, authHeaders); return getUsage(getResource("usage/" + entity + "/name/" + fqn), date, days, authHeaders);
} }
public static EntityUsage getUsage(String entity, UUID id, String date, Integer days, Map<String, String> authHeaders) public EntityUsage getUsage(String entity, UUID id, String date, Integer days, Map<String, String> authHeaders)
throws HttpResponseException { throws HttpResponseException {
return getUsage(getResource("usage/" + entity + "/" + id), date, days, authHeaders); return getUsage(getResource("usage/" + entity + "/" + id), date, days, authHeaders);
} }
public static EntityUsage getUsage(WebTarget target, String date, Integer days, Map<String, String> authHeaders) public EntityUsage getUsage(WebTarget target, String date, Integer days, Map<String, String> authHeaders)
throws HttpResponseException { throws HttpResponseException {
target = date != null ? target.queryParam("date", date) : target; target = date != null ? target.queryParam("date", date) : target;
target = days != null ? target.queryParam("days", days) : target; target = days != null ? target.queryParam("days", days) : target;
return TestUtils.get(target, EntityUsage.class, authHeaders); return TestUtils.get(target, EntityUsage.class, authHeaders);
} }
public static void checkUsage( public void checkUsage(
String date, String date,
String entity, String entity,
UUID id, UUID id,
@ -381,7 +381,7 @@ class UsageResourceTest extends OpenMetadataApplicationTest {
checkUsage(usage, date, entity, dailyCount, weeklyCount, monthlyCount); checkUsage(usage, date, entity, dailyCount, weeklyCount, monthlyCount);
} }
public static void checkUsageByName( public void checkUsageByName(
String date, String date,
String entity, String entity,
String name, String name,