mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-01 13:13:10 +00:00
Parallel tests (#10064)
* Staging parallel tests * Parallelize Tests * Parallelize Tests * Parallelize Tests * Parallelize Tests * Parallelize Tests * Parallelize Tests
This commit is contained in:
parent
460a9288a7
commit
b76ec0a18f
@ -567,7 +567,11 @@
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${maven-surefire.version}</version>
|
||||
<configuration>
|
||||
<trimStackTrace>false</trimStackTrace>
|
||||
<reuseForks>false</reuseForks>
|
||||
<parallel>classes</parallel>
|
||||
<threadCount>1</threadCount>
|
||||
<forkCount>2C</forkCount>
|
||||
<argLine>-Xmx1024m</argLine>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
@ -28,6 +28,7 @@ import org.glassfish.jersey.client.HttpUrlConnectorProvider;
|
||||
import org.glassfish.jersey.client.JerseyClientBuilder;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
import org.openmetadata.service.fernet.Fernet;
|
||||
import org.openmetadata.service.resources.CollectionRegistry;
|
||||
import org.openmetadata.service.resources.events.WebhookCallbackResource;
|
||||
@ -37,6 +38,7 @@ import org.openmetadata.service.security.policyevaluator.SubjectCache;
|
||||
import org.testcontainers.containers.JdbcDatabaseContainer;
|
||||
|
||||
@Slf4j
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
public abstract class OpenMetadataApplicationTest {
|
||||
protected static final String CONFIG_PATH = ResourceHelpers.resourceFilePath("openmetadata-secure-test.yaml");
|
||||
public static DropwizardAppExtension<OpenMetadataApplicationConfig> APP;
|
||||
@ -58,7 +60,7 @@ public abstract class OpenMetadataApplicationTest {
|
||||
JdbcDatabaseContainer<?> sqlContainer =
|
||||
(JdbcDatabaseContainer<?>)
|
||||
Class.forName(jdbcContainerClassName).getConstructor(String.class).newInstance(jdbcContainerImage);
|
||||
sqlContainer.withReuse(true);
|
||||
sqlContainer.withReuse(false);
|
||||
sqlContainer.withStartupTimeoutSeconds(240);
|
||||
sqlContainer.withConnectTimeoutSeconds(240);
|
||||
sqlContainer.start();
|
||||
|
@ -99,6 +99,8 @@ import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInfo;
|
||||
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.csv.CsvUtilTest;
|
||||
import org.openmetadata.csv.EntityCsvTest;
|
||||
@ -410,6 +412,16 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
.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 K createPutRequest(String name) {
|
||||
@ -481,6 +493,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
// Common entity tests for GET operations
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
void get_entityWithDifferentFieldsQueryParam(TestInfo test) throws HttpResponseException {
|
||||
if (!supportsFieldsQueryParam) {
|
||||
return;
|
||||
@ -518,6 +531,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
}
|
||||
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
void get_entityListWithPagination_200(TestInfo test) throws IOException {
|
||||
// Create a number of entities between 5 and 20 inclusive
|
||||
Random rand = new Random();
|
||||
@ -664,6 +678,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
}
|
||||
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
void get_entityListWithInvalidLimit_4xx() {
|
||||
// Limit must be >= 1 and <= 1000,000
|
||||
assertResponse(
|
||||
@ -683,6 +698,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
}
|
||||
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
void get_entityListWithInvalidPaginationCursors_4xx() {
|
||||
// Passing both before and after cursors is invalid
|
||||
assertResponse(
|
||||
@ -692,6 +708,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
}
|
||||
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
void get_entityWithDifferentFields_200_OK(TestInfo test) throws IOException {
|
||||
K create = createRequest(getEntityName(test), "description", "displayName", USER1_REF);
|
||||
|
||||
@ -750,6 +767,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
}
|
||||
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
void get_entityIncludeDeleted_200(TestInfo test) throws IOException {
|
||||
if (!supportsSoftDelete) {
|
||||
return;
|
||||
@ -778,6 +796,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
// Common entity tests for POST operations
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
protected void post_entityCreateWithInvalidName_400() {
|
||||
// Create an entity with mandatory name field null
|
||||
final K request = createRequest(null, "description", "displayName", null);
|
||||
@ -795,6 +814,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
}
|
||||
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
void post_entityWithMissingDescription_400(TestInfo test) {
|
||||
// Post entity that does not accept empty description and expect failure
|
||||
if (supportsEmptyDescription) {
|
||||
@ -806,6 +826,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
}
|
||||
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
void post_entityWithInvalidOwnerType_4xx(TestInfo test) throws HttpResponseException {
|
||||
if (!supportsOwner) {
|
||||
return;
|
||||
@ -828,6 +849,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
}
|
||||
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
void post_entityWithNonExistentOwner_4xx(TestInfo test) {
|
||||
if (!supportsOwner) {
|
||||
return;
|
||||
@ -839,6 +861,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
}
|
||||
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
void post_delete_entity_as_admin_200(TestInfo test) throws IOException {
|
||||
K request = createRequest(getEntityName(test), "", "", null);
|
||||
T entity = createEntity(request, ADMIN_AUTH_HEADERS);
|
||||
@ -846,6 +869,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
}
|
||||
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
void post_delete_as_name_entity_as_admin_200(TestInfo test) throws IOException {
|
||||
K request = createRequest(getEntityName(test), "", "", null);
|
||||
T entity = createEntity(request, ADMIN_AUTH_HEADERS);
|
||||
@ -853,6 +877,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
}
|
||||
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
protected void post_delete_entityWithOwner_200(TestInfo test) throws IOException {
|
||||
if (!supportsOwner) {
|
||||
return;
|
||||
@ -879,6 +904,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
}
|
||||
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
protected void post_delete_entity_as_bot(TestInfo test) throws IOException {
|
||||
// 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)) {
|
||||
@ -894,6 +920,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
}
|
||||
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
protected void post_entity_as_non_admin_401(TestInfo test) {
|
||||
assertResponse(
|
||||
() -> createEntity(createRequest(test), TEST_AUTH_HEADERS),
|
||||
@ -902,6 +929,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
}
|
||||
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
protected void post_entityAlreadyExists_409_conflict(TestInfo test) throws HttpResponseException {
|
||||
K create = createRequest(getEntityName(test), "", "", null);
|
||||
// Create first time using POST
|
||||
@ -911,6 +939,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
}
|
||||
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
void post_entityWithDots_200() throws HttpResponseException {
|
||||
if (!supportedNameCharacters.contains(" ")) { // Name does not support space
|
||||
return;
|
||||
@ -934,6 +963,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
// Common entity tests for PUT operations
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
void put_entityCreate_200(TestInfo test) throws IOException {
|
||||
// Create a new entity with PUT
|
||||
K request = createRequest(getEntityName(test), "description", "displayName", null);
|
||||
@ -941,6 +971,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
}
|
||||
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
void put_entityUpdateWithNoChange_200(TestInfo test) throws IOException {
|
||||
// Create a chart with POST
|
||||
K request = createRequest(getEntityName(test), "description", "display", USER1_REF);
|
||||
@ -953,6 +984,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
}
|
||||
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
void put_entityCreate_as_owner_200(TestInfo test) throws IOException {
|
||||
if (!supportsOwner) {
|
||||
return; // Entity doesn't support ownership
|
||||
@ -969,6 +1001,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
}
|
||||
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
void put_entityUpdateOwner_200(TestInfo test) throws IOException {
|
||||
if (!supportsOwner) {
|
||||
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
|
||||
// and not removed.
|
||||
request.withOwner(null);
|
||||
request = createPutRequest(entity.getName(), "description", "displayName", null);
|
||||
updateEntity(request, OK, ADMIN_AUTH_HEADERS);
|
||||
checkOwnerOwns(USER1_REF, entity.getId(), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
void patch_validEntityOwner_200(TestInfo test) throws IOException {
|
||||
if (!supportsOwner || !supportsPatch) {
|
||||
return; // Entity doesn't support ownership
|
||||
@ -1030,6 +1064,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
}
|
||||
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
void patch_entityUpdateOwner_200(TestInfo test) throws IOException {
|
||||
if (!supportsOwner || !supportsPatch) {
|
||||
return; // Entity doesn't support ownership
|
||||
@ -1071,6 +1106,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
}
|
||||
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
void put_entityUpdate_as_non_owner_4xx(TestInfo test) throws IOException {
|
||||
if (!supportsOwner) {
|
||||
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
|
||||
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
|
||||
// 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;
|
||||
|
||||
assertResponse(
|
||||
@ -1092,6 +1128,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
}
|
||||
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
void put_entityNullDescriptionUpdate_200(TestInfo test) throws IOException {
|
||||
if (!supportsEmptyDescription) {
|
||||
return;
|
||||
@ -1101,13 +1138,14 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
T entity = createEntity(request, ADMIN_AUTH_HEADERS);
|
||||
|
||||
// Update null description with a new description
|
||||
request = request.withDescription("updatedDescription");
|
||||
request = createPutRequest(entity.getName(), "updatedDescription", "displayName", null);
|
||||
ChangeDescription change = getChangeDescription(entity.getVersion());
|
||||
fieldAdded(change, "description", "updatedDescription");
|
||||
updateAndCheckEntity(request, OK, ADMIN_AUTH_HEADERS, MINOR_UPDATE, change);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
protected void put_entityEmptyDescriptionUpdate_200(TestInfo test) throws IOException {
|
||||
// Create entity with empty description
|
||||
K request = createRequest(getEntityName(test), "", "displayName", null);
|
||||
@ -1121,6 +1159,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
}
|
||||
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
protected void put_entityNonEmptyDescriptionUpdate_200(TestInfo test) throws IOException {
|
||||
// Create entity with non-empty description
|
||||
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
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
void put_addDeleteFollower_200(TestInfo test) throws IOException {
|
||||
if (!supportsFollowers) {
|
||||
return; // Entity does not support following
|
||||
@ -1174,6 +1214,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
}
|
||||
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
void put_addFollowerDeleteEntity_200(TestInfo test) throws IOException {
|
||||
if (!supportsFollowers) {
|
||||
return; // Entity does not support following
|
||||
@ -1196,6 +1237,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
}
|
||||
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
void put_addDeleteInvalidFollower_200(TestInfo test) throws IOException {
|
||||
if (!supportsFollowers) {
|
||||
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
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
protected void patch_entityDescriptionAndTestAuthorizer(TestInfo test) throws IOException {
|
||||
if (!supportsPatch) {
|
||||
return;
|
||||
@ -1254,6 +1297,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
}
|
||||
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
void patch_entityAttributes_200_ok(TestInfo test) throws IOException {
|
||||
if (!supportsPatch) {
|
||||
return;
|
||||
@ -1344,6 +1388,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
}
|
||||
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
void patch_deleted_attribute_disallowed_400(TestInfo test) throws HttpResponseException, JsonProcessingException {
|
||||
if (!supportsPatch || !supportsSoftDelete) {
|
||||
return;
|
||||
@ -1359,6 +1404,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
}
|
||||
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
void put_addEntityCustomAttributes(TestInfo test) throws IOException {
|
||||
if (!supportsCustomExtension) {
|
||||
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
|
||||
JsonNode intAValue = mapper.convertValue(2, JsonNode.class);
|
||||
jsonNode.set("intA", intAValue);
|
||||
create = createRequest(test).withExtension(jsonNode);
|
||||
create = createRequest(test).withExtension(jsonNode).withName(entity.getName());
|
||||
change = getChangeDescription(entity.getVersion());
|
||||
fieldUpdated(change, EntityUtil.getExtensionField("intA"), mapper.convertValue(1, JsonNode.class), intAValue);
|
||||
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 ***
|
||||
JsonNode oldNode = JsonUtils.valueToTree(entity.getExtension());
|
||||
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);
|
||||
assertNotEquals(JsonUtils.valueToTree(create.getExtension()), JsonUtils.valueToTree(entity.getExtension()));
|
||||
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
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
void delete_nonExistentEntity_404() {
|
||||
assertResponse(
|
||||
() -> deleteEntity(NON_EXISTENT_ENTITY, ADMIN_AUTH_HEADERS),
|
||||
@ -1483,6 +1530,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
}
|
||||
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
protected void delete_entity_as_non_admin_401(TestInfo test) throws HttpResponseException {
|
||||
// Deleting as non-owner and non-admin should fail
|
||||
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 */
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
void delete_restore_entity_200(TestInfo test) throws IOException {
|
||||
K request = createRequest(getEntityName(test), "", "", null);
|
||||
T entity = createEntity(request, ADMIN_AUTH_HEADERS);
|
||||
@ -1523,6 +1572,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
// Other tests
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
void testInvalidEntityList() {
|
||||
// Invalid entityCreated list
|
||||
assertResponse(
|
||||
@ -1544,6 +1594,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
}
|
||||
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
protected void testTeamOnlyPolicy(TestInfo test) throws HttpResponseException {
|
||||
testTeamOnlyPolicy(test, VIEW_ALL);
|
||||
}
|
||||
@ -1598,6 +1649,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
}
|
||||
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
void delete_systemEntity() throws IOException {
|
||||
if (systemEntityName == null) {
|
||||
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)
|
||||
.pollInterval(Duration.ofMillis(100L))
|
||||
.atMost(Duration.ofMillis(20 * 100L)) // 10 iterations
|
||||
.atMost(Duration.ofMillis(100 * 100L)) // 100 iterations
|
||||
.until(
|
||||
() ->
|
||||
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)
|
||||
.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));
|
||||
ChangeEvent changeEvent = eventHolder.getExpectedEvent();
|
||||
|
||||
|
@ -28,6 +28,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.http.client.HttpResponseException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
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.entity.data.Chart;
|
||||
import org.openmetadata.schema.type.ChartType;
|
||||
@ -45,6 +47,7 @@ public class ChartResourceTest extends EntityResourceTest<Chart, CreateChart> {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
void post_chartWithoutRequiredFields_4xx(TestInfo test) {
|
||||
// Service is required field
|
||||
assertResponse(
|
||||
@ -54,6 +57,7 @@ public class ChartResourceTest extends EntityResourceTest<Chart, CreateChart> {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
void post_chartWithDifferentService_200_ok(TestInfo test) throws IOException {
|
||||
EntityReference[] differentServices = {METABASE_REFERENCE, LOOKER_REFERENCE};
|
||||
|
||||
@ -72,6 +76,7 @@ public class ChartResourceTest extends EntityResourceTest<Chart, CreateChart> {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Execution(ExecutionMode.CONCURRENT)
|
||||
public Chart validateGetWithDifferentFields(Chart chart, boolean byName) throws HttpResponseException {
|
||||
String fields = "";
|
||||
chart =
|
||||
|
@ -30,7 +30,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.http.client.HttpResponseException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
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.CreateDatabaseSchema;
|
||||
import org.openmetadata.schema.entity.data.Database;
|
||||
@ -44,7 +43,6 @@ import org.openmetadata.service.util.ResultList;
|
||||
import org.openmetadata.service.util.TestUtils;
|
||||
|
||||
@Slf4j
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
public class DatabaseResourceTest extends EntityResourceTest<Database, CreateDatabase> {
|
||||
public DatabaseResourceTest() {
|
||||
super(Entity.DATABASE, Database.class, DatabaseList.class, "databases", DatabaseResource.FIELDS);
|
||||
|
@ -27,7 +27,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.http.client.HttpResponseException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
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.CreateTable;
|
||||
import org.openmetadata.schema.entity.data.DatabaseSchema;
|
||||
@ -39,7 +38,6 @@ import org.openmetadata.service.util.FullyQualifiedName;
|
||||
import org.openmetadata.service.util.TestUtils;
|
||||
|
||||
@Slf4j
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
class DatabaseSchemaResourceTest extends EntityResourceTest<DatabaseSchema, CreateDatabaseSchema> {
|
||||
public DatabaseSchemaResourceTest() {
|
||||
super(
|
||||
|
@ -84,6 +84,7 @@ import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInfo;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.openmetadata.schema.api.data.CreateDatabase;
|
||||
import org.openmetadata.schema.api.data.CreateDatabaseSchema;
|
||||
@ -141,6 +142,7 @@ import org.openmetadata.service.util.TestUtils;
|
||||
|
||||
@Slf4j
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
public class TableResourceTest extends EntityResourceTest<Table, CreateTable> {
|
||||
private final TagResourceTest tagResourceTest = new TagResourceTest();
|
||||
|
||||
@ -1449,10 +1451,10 @@ public class TableResourceTest extends EntityResourceTest<Table, CreateTable> {
|
||||
assertEquals(3, getClassificationUsageCount("User", ADMIN_AUTH_HEADERS));
|
||||
|
||||
// Total 1 glossary1 tags - 1 column
|
||||
assertEquals(1, getGlossaryUsageCount("g1"));
|
||||
assertEquals(1, getGlossaryUsageCount(GLOSSARY1.getName()));
|
||||
|
||||
// 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
|
||||
assertEquals(3, getTagUsageCount(USER_ADDRESS_TAG_LABEL.getTagFQN(), ADMIN_AUTH_HEADERS));
|
||||
@ -1638,14 +1640,18 @@ public class TableResourceTest extends EntityResourceTest<Table, CreateTable> {
|
||||
}
|
||||
|
||||
@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);
|
||||
CreateTable create = createRequest(test).withColumns(List.of(c1));
|
||||
Table table = createAndCheckEntity(create, ADMIN_AUTH_HEADERS);
|
||||
|
||||
// Add a primary tag and derived tag both. The tag list must include derived tags only once.
|
||||
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);
|
||||
|
||||
// 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 =
|
||||
updateTags.stream().filter(t -> tagLabelMatch.test(t, PII_SENSITIVE_TAG_LABEL)).findAny().orElse(null);
|
||||
assertNotNull(piiSensitive);
|
||||
assertEquals(LabelType.DERIVED, piiSensitive.getLabelType());
|
||||
assertEquals(LabelType.MANUAL, piiSensitive.getLabelType());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -28,7 +28,6 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import javax.ws.rs.client.WebTarget;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -95,7 +94,7 @@ public class TestCaseResourceTest extends EntityResourceTest<TestCase, CreateTes
|
||||
tableReq =
|
||||
tableResourceTest
|
||||
.createRequest(test)
|
||||
.withName("testCaseTable" + UUID.randomUUID())
|
||||
.withName("testCaseTable")
|
||||
.withDatabaseSchema(DATABASE_SCHEMA_REFERENCE)
|
||||
.withColumns(
|
||||
List.of(
|
||||
@ -439,7 +438,11 @@ public class TestCaseResourceTest extends EntityResourceTest<TestCase, CreateTes
|
||||
fieldUpdated(change, "description", oldDescription, newDescription);
|
||||
testCase =
|
||||
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
|
||||
oldDescription = testCase.getDescription();
|
||||
|
@ -100,7 +100,7 @@ public class TestSuiteResourceTest extends EntityResourceTest<TestSuite, CreateT
|
||||
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 {
|
||||
WebTarget target = getResource("testSuite");
|
||||
target = limit != null ? target.queryParam("limit", limit) : target;
|
||||
|
@ -27,6 +27,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.http.client.HttpResponseException;
|
||||
import org.awaitility.Awaitility;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInfo;
|
||||
@ -53,6 +54,7 @@ import org.openmetadata.service.util.TestUtils;
|
||||
|
||||
@Slf4j
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
@Disabled
|
||||
public class AlertResourceTest extends EntityResourceTest<Alert, CreateAlert> {
|
||||
public static final TriggerConfig ALL_EVENTS_FILTER =
|
||||
new TriggerConfig().withType(TriggerConfig.AlertTriggerType.ALL_DATA_ASSETS);
|
||||
|
@ -67,6 +67,7 @@ import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInfo;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
@ -113,6 +114,7 @@ import org.openmetadata.service.util.TestUtils;
|
||||
|
||||
@Slf4j
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
public class FeedResourceTest extends OpenMetadataApplicationTest {
|
||||
public static Table TABLE;
|
||||
public static Table TABLE2;
|
||||
@ -136,7 +138,7 @@ public class FeedResourceTest extends OpenMetadataApplicationTest {
|
||||
: 1;
|
||||
|
||||
@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.setup(test); // Initialize TableResourceTest for using helper methods
|
||||
|
||||
@ -1303,8 +1305,7 @@ public class FeedResourceTest extends OpenMetadataApplicationTest {
|
||||
entityNotFound("Post", NON_EXISTENT_ENTITY));
|
||||
}
|
||||
|
||||
public static Thread createAndCheck(CreateThread create, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
public Thread createAndCheck(CreateThread create, Map<String, String> authHeaders) throws HttpResponseException {
|
||||
// Validate returned thread from POST
|
||||
Thread thread = createThread(create, authHeaders);
|
||||
validateThread(thread, create.getMessage(), create.getFrom(), create.getAbout());
|
||||
@ -1326,14 +1327,14 @@ public class FeedResourceTest extends OpenMetadataApplicationTest {
|
||||
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());
|
||||
assertEquals(message, thread.getMessage());
|
||||
assertEquals(from, thread.getCreatedBy());
|
||||
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
|
||||
Post actualPost = actual.getPosts().get(actual.getPosts().size() - 1); // Last post was newly added to the thread
|
||||
assertEquals(from, actualPost.getFrom());
|
||||
@ -1344,56 +1345,54 @@ public class FeedResourceTest extends OpenMetadataApplicationTest {
|
||||
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);
|
||||
}
|
||||
|
||||
public static Thread addPost(UUID threadId, CreatePost post, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
public Thread addPost(UUID threadId, CreatePost post, Map<String, String> authHeaders) throws HttpResponseException {
|
||||
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);
|
||||
}
|
||||
|
||||
public static Post deletePost(UUID threadId, UUID postId, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
public Post deletePost(UUID threadId, UUID postId, Map<String, String> authHeaders) throws HttpResponseException {
|
||||
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());
|
||||
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";
|
||||
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);
|
||||
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);
|
||||
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 {
|
||||
WebTarget target = getResource("feed/tasks/" + id + "/resolve");
|
||||
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");
|
||||
TestUtils.put(target, new CloseTask().withComment(comment), Status.OK, authHeaders);
|
||||
}
|
||||
|
||||
public static ThreadList listTasks(
|
||||
public ThreadList listTasks(
|
||||
String entityLink,
|
||||
String userId,
|
||||
String filterType,
|
||||
@ -1415,7 +1414,7 @@ public class FeedResourceTest extends OpenMetadataApplicationTest {
|
||||
null);
|
||||
}
|
||||
|
||||
public static ThreadList listAnnouncements(
|
||||
public ThreadList listAnnouncements(
|
||||
String entityLink, Integer limitPosts, Boolean activeAnnouncement, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
return listThreads(
|
||||
@ -1432,7 +1431,7 @@ public class FeedResourceTest extends OpenMetadataApplicationTest {
|
||||
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 {
|
||||
return listThreads(
|
||||
entityLink,
|
||||
@ -1448,7 +1447,7 @@ public class FeedResourceTest extends OpenMetadataApplicationTest {
|
||||
null);
|
||||
}
|
||||
|
||||
public static ThreadList listThreads(
|
||||
public ThreadList listThreads(
|
||||
String entityLink,
|
||||
Integer limitPosts,
|
||||
Map<String, String> authHeaders,
|
||||
@ -1475,13 +1474,12 @@ public class FeedResourceTest extends OpenMetadataApplicationTest {
|
||||
return TestUtils.get(target, ThreadList.class, authHeaders);
|
||||
}
|
||||
|
||||
public static void followTable(UUID tableId, UUID userId, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
public void followTable(UUID tableId, UUID userId, Map<String, String> authHeaders) throws HttpResponseException {
|
||||
WebTarget target = getResource("tables/" + tableId + "/followers");
|
||||
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 {
|
||||
WebTarget target = getResource("feed");
|
||||
target = target.queryParam("type", ThreadType.Conversation);
|
||||
@ -1490,20 +1488,19 @@ public class FeedResourceTest extends OpenMetadataApplicationTest {
|
||||
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));
|
||||
return TestUtils.get(target, PostList.class, authHeaders);
|
||||
}
|
||||
|
||||
public static ThreadCount listThreadsCount(String entityLink, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
public ThreadCount listThreadsCount(String entityLink, Map<String, String> authHeaders) throws HttpResponseException {
|
||||
WebTarget target = getResource("feed/count");
|
||||
target = entityLink != null ? target.queryParam("entityLink", entityLink) : target;
|
||||
target = target.queryParam("type", ThreadType.Conversation);
|
||||
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 {
|
||||
WebTarget target = getResource("feed/count");
|
||||
target = entityLink != null ? target.queryParam("entityLink", entityLink) : target;
|
||||
|
@ -100,7 +100,6 @@ public class GlossaryResourceTest extends EntityResourceTest<Glossary, CreateGlo
|
||||
.createRequest("g1t1", "", "", null)
|
||||
.withRelatedTerms(null)
|
||||
.withGlossary(GLOSSARY1_REF)
|
||||
.withTags(List.of(PII_SENSITIVE_TAG_LABEL, PERSONAL_DATA_TAG_LABEL))
|
||||
.withReviewers(GLOSSARY1.getReviewers());
|
||||
GLOSSARY1_TERM1 = glossaryTermResourceTest.createAndCheckEntity(createGlossaryTerm, ADMIN_AUTH_HEADERS);
|
||||
GLOSSARY1_TERM1_REF = GLOSSARY1_TERM1.getEntityReference();
|
||||
@ -109,7 +108,7 @@ public class GlossaryResourceTest extends EntityResourceTest<Glossary, CreateGlo
|
||||
|
||||
createGlossaryTerm =
|
||||
glossaryTermResourceTest
|
||||
.createRequest("g2t1", "", "", null)
|
||||
.createRequest("g1t2", "", "", null)
|
||||
.withRelatedTerms(List.of(GLOSSARY1_TERM1_REF))
|
||||
.withGlossary(GLOSSARY2_REF)
|
||||
.withReviewers(GLOSSARY1.getReviewers());
|
||||
|
@ -322,23 +322,22 @@ public class LineageResourceTest extends OpenMetadataApplicationTest {
|
||||
deleteLineageAndCheck(edge, authHeaders);
|
||||
}
|
||||
|
||||
public static void addLineageAndCheck(AddLineage addLineage, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
public void addLineageAndCheck(AddLineage addLineage, Map<String, String> authHeaders) throws HttpResponseException {
|
||||
addLineage(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 {
|
||||
deleteLineage(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);
|
||||
}
|
||||
|
||||
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 =
|
||||
getResource(
|
||||
String.format(
|
||||
@ -350,8 +349,7 @@ public class LineageResourceTest extends OpenMetadataApplicationTest {
|
||||
TestUtils.delete(target, authHeaders);
|
||||
}
|
||||
|
||||
private static void validateLineage(AddLineage addLineage, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
private void validateLineage(AddLineage addLineage, Map<String, String> authHeaders) throws HttpResponseException {
|
||||
EntityReference from = addLineage.getEdge().getFromEntity();
|
||||
EntityReference to = addLineage.getEdge().getToEntity();
|
||||
Edge expectedEdge = getEdge(from.getId(), to.getId(), addLineage.getEdge().getLineageDetails());
|
||||
@ -365,7 +363,7 @@ public class LineageResourceTest extends OpenMetadataApplicationTest {
|
||||
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 {
|
||||
EntityReference from = deletedEdge.getFromEntity();
|
||||
EntityReference to = deletedEdge.getToEntity();
|
||||
@ -405,7 +403,7 @@ public class LineageResourceTest extends OpenMetadataApplicationTest {
|
||||
}
|
||||
}
|
||||
|
||||
public static void assertLineage(
|
||||
public void assertLineage(
|
||||
String entityType,
|
||||
UUID id,
|
||||
String fqn,
|
||||
@ -424,7 +422,7 @@ public class LineageResourceTest extends OpenMetadataApplicationTest {
|
||||
assertEquals(lineageById, lineageByName);
|
||||
}
|
||||
|
||||
public static EntityLineage getLineage(
|
||||
public EntityLineage getLineage(
|
||||
String entity, UUID id, Integer upstreamDepth, Integer downStreamDepth, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
WebTarget target = getResource("lineage/" + entity + "/" + id);
|
||||
@ -435,7 +433,7 @@ public class LineageResourceTest extends OpenMetadataApplicationTest {
|
||||
return lineage;
|
||||
}
|
||||
|
||||
public static EntityLineage getLineageByName(
|
||||
public EntityLineage getLineageByName(
|
||||
String entity, String fqn, Integer upstreamDepth, Integer downStreamDepth, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
WebTarget target = getResource("lineage/" + entity + "/name/" + fqn);
|
||||
@ -446,7 +444,7 @@ public class LineageResourceTest extends OpenMetadataApplicationTest {
|
||||
return lineage;
|
||||
}
|
||||
|
||||
public static void assertEdge(EntityLineage lineage, Edge expectedEdge, boolean downstream) {
|
||||
public void assertEdge(EntityLineage lineage, Edge expectedEdge, boolean downstream) {
|
||||
if (downstream) {
|
||||
assertTrue(lineage.getDownstreamEdges().contains(expectedEdge));
|
||||
} 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) {
|
||||
assertFalse(lineage.getDownstreamEdges().contains(expectedEdge));
|
||||
} 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);
|
||||
for (Edge expectedUpstreamEdge : expectedUpstreamEdges) {
|
||||
assertTrue(lineage.getUpstreamEdges().contains(expectedUpstreamEdge));
|
||||
|
@ -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 {
|
||||
return TestUtils.put(getResource("locations"), create, Location.class, status, authHeaders);
|
||||
}
|
||||
@ -201,7 +201,7 @@ public class LocationResourceTest extends EntityResourceTest<Location, CreateLoc
|
||||
return location;
|
||||
}
|
||||
|
||||
public static LocationList listPrefixes(
|
||||
public LocationList listPrefixes(
|
||||
String fields, String fqn, Integer limitParam, String before, String after, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
String encodedFqn = URLEncoder.encode(fqn, StandardCharsets.UTF_8);
|
||||
|
@ -51,7 +51,6 @@ import org.apache.http.client.HttpResponseException;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInfo;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
import org.openmetadata.schema.api.data.CreateTable;
|
||||
import org.openmetadata.schema.entity.data.Table;
|
||||
import org.openmetadata.schema.entity.policies.Policy;
|
||||
@ -78,7 +77,6 @@ import org.openmetadata.service.util.JsonUtils;
|
||||
import org.openmetadata.service.util.TestUtils;
|
||||
|
||||
@Slf4j
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
class PermissionsResourceTest extends OpenMetadataApplicationTest {
|
||||
private static Rule ORG_IS_OWNER_RULE;
|
||||
private static Rule ORG_NO_OWNER_RULE;
|
||||
|
@ -547,14 +547,13 @@ public class PipelineResourceTest extends EntityResourceTest<Pipeline, CreatePip
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
public static Pipeline getPipeline(UUID id, String fields, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
public Pipeline getPipeline(UUID id, String fields, Map<String, String> authHeaders) throws HttpResponseException {
|
||||
WebTarget target = getResource("pipelines/" + id);
|
||||
target = fields != null ? target.queryParam("fields", fields) : target;
|
||||
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 {
|
||||
WebTarget target = getResource("pipelines/name/" + fqn);
|
||||
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
|
||||
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 {
|
||||
WebTarget target = getResource("pipelines/" + fqn + "/status");
|
||||
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 {
|
||||
WebTarget target = getResource("pipelines/" + fqn + "/status/" + timestamp);
|
||||
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 {
|
||||
WebTarget target = getResource("pipelines/" + fqn + "/status");
|
||||
target = target.queryParam("startTs", startTs).queryParam("endTs", endTs);
|
||||
|
@ -34,7 +34,6 @@ import static org.openmetadata.service.util.TestUtils.assertResponseContains;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
@ -44,7 +43,6 @@ import javax.ws.rs.client.WebTarget;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.http.client.HttpResponseException;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInfo;
|
||||
import org.openmetadata.schema.api.data.CreateLocation;
|
||||
@ -79,8 +77,6 @@ import org.openmetadata.service.util.TestUtils;
|
||||
|
||||
@Slf4j
|
||||
public class PolicyResourceTest extends EntityResourceTest<Policy, CreatePolicy> {
|
||||
private static final String LOCATION_NAME = "aws-s3";
|
||||
private static Location location;
|
||||
|
||||
public PolicyResourceTest() {
|
||||
super(
|
||||
@ -92,12 +88,6 @@ public class PolicyResourceTest extends EntityResourceTest<Policy, CreatePolicy>
|
||||
Entity.ORGANIZATION_POLICY_NAME);
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
public void setup(TestInfo test) throws IOException, URISyntaxException {
|
||||
super.setup(test);
|
||||
location = createLocation();
|
||||
}
|
||||
|
||||
public void setupPolicies() throws IOException {
|
||||
POLICY1 = createEntity(createRequest("policy1").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());
|
||||
fieldUpdated(change, "enabled", true, false);
|
||||
policy = patchEntityAndCheck(policy, origJson, ADMIN_AUTH_HEADERS, MINOR_UPDATE, change);
|
||||
|
||||
Location location = createLocation();
|
||||
EntityReference locationReference = location.getEntityReference();
|
||||
|
||||
// Add new field location
|
||||
@ -420,9 +410,9 @@ public class PolicyResourceTest extends EntityResourceTest<Policy, CreatePolicy>
|
||||
TestUtils.get(target, ADMIN_AUTH_HEADERS);
|
||||
}
|
||||
|
||||
private static Location createLocation() throws HttpResponseException {
|
||||
private Location createLocation() throws HttpResponseException {
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,10 @@ public class MessagingServiceResourceTest extends EntityResourceTest<MessagingSe
|
||||
.withSchemaRegistryURL(new URI("localhost:8081")));
|
||||
// Update messaging description and ingestion service that are null
|
||||
CreateMessagingService update =
|
||||
createRequest(test).withDescription("description1").withConnection(messagingConnection);
|
||||
createRequest(test)
|
||||
.withName(service.getName())
|
||||
.withDescription("description1")
|
||||
.withConnection(messagingConnection);
|
||||
ChangeDescription change = getChangeDescription(service.getVersion());
|
||||
fieldAdded(change, "description", "description1");
|
||||
service = updateAndCheckEntity(update, OK, ADMIN_AUTH_HEADERS, UpdateType.MINOR_UPDATE, change);
|
||||
|
@ -259,7 +259,7 @@ public class PipelineServiceResourceTest extends EntityResourceTest<PipelineServ
|
||||
}
|
||||
}
|
||||
|
||||
public static void validateAirflowConnection(
|
||||
public void validateAirflowConnection(
|
||||
AirflowConnection expectedAirflowConnection,
|
||||
AirflowConnection actualAirflowConnection,
|
||||
Map<String, String> authHeaders) {
|
||||
|
@ -86,7 +86,7 @@ public class TagResourceTest extends EntityResourceTest<Tag, CreateTag> {
|
||||
null,
|
||||
PERSONAL_DATA_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 {
|
||||
|
@ -634,13 +634,16 @@ public class TeamResourceTest extends EntityResourceTest<Team, CreateTeam> {
|
||||
Team team = createAndCheckEntity(create, ADMIN_AUTH_HEADERS);
|
||||
|
||||
// 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());
|
||||
fieldAdded(change, "policies", List.of(POLICY1.getEntityReference(), POLICY2.getEntityReference()));
|
||||
team = updateAndCheckEntity(create, OK, ADMIN_AUTH_HEADERS, MINOR_UPDATE, change);
|
||||
|
||||
// Remove policies from the team
|
||||
create = createRequest(getEntityName(test));
|
||||
create = createRequest(getEntityName(test)).withName(team.getName());
|
||||
change = getChangeDescription(team.getVersion());
|
||||
fieldDeleted(change, "policies", List.of(POLICY1.getEntityReference(), POLICY2.getEntityReference()));
|
||||
updateAndCheckEntity(create, OK, ADMIN_AUTH_HEADERS, MINOR_UPDATE, change);
|
||||
|
@ -292,82 +292,82 @@ class UsageResourceTest extends OpenMetadataApplicationTest {
|
||||
Assertions.assertEquals(usage.getUsage().get(0), database.getUsageSummary());
|
||||
}
|
||||
|
||||
public static DailyCount usageReport() {
|
||||
public DailyCount usageReport() {
|
||||
Random random = new Random();
|
||||
String today = RestUtil.DATE_FORMAT.format(new Date());
|
||||
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)
|
||||
throws HttpResponseException {
|
||||
reportUsageByNamePut(entity, fqn, usage, 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)
|
||||
throws HttpResponseException {
|
||||
reportUsagePut(entity, id, usage, 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 {
|
||||
WebTarget target = getResource("usage/" + entity + "/name/" + name);
|
||||
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 {
|
||||
WebTarget target = getResource("usage/" + entity + "/name/" + name);
|
||||
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 {
|
||||
WebTarget target = getResource("usage/" + entity + "/" + id);
|
||||
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 {
|
||||
WebTarget target = getResource("usage/" + entity + "/" + id);
|
||||
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 {
|
||||
WebTarget target = getResource("usage/compute.percentile/" + entity + "/" + date);
|
||||
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)
|
||||
throws HttpResponseException {
|
||||
EntityUsage usage = getUsage(entity, id, date, days, authHeaders);
|
||||
assertEquals(expectedRecords, usage.getUsage().size());
|
||||
}
|
||||
|
||||
public static EntityUsage getUsageByName(
|
||||
public EntityUsage getUsageByName(
|
||||
String entity, String fqn, String date, Integer days, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
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 {
|
||||
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 {
|
||||
target = date != null ? target.queryParam("date", date) : target;
|
||||
target = days != null ? target.queryParam("days", days) : target;
|
||||
return TestUtils.get(target, EntityUsage.class, authHeaders);
|
||||
}
|
||||
|
||||
public static void checkUsage(
|
||||
public void checkUsage(
|
||||
String date,
|
||||
String entity,
|
||||
UUID id,
|
||||
@ -381,7 +381,7 @@ class UsageResourceTest extends OpenMetadataApplicationTest {
|
||||
checkUsage(usage, date, entity, dailyCount, weeklyCount, monthlyCount);
|
||||
}
|
||||
|
||||
public static void checkUsageByName(
|
||||
public void checkUsageByName(
|
||||
String date,
|
||||
String entity,
|
||||
String name,
|
||||
|
Loading…
x
Reference in New Issue
Block a user