Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/playwright/impact-map.generated.json
Original file line number Diff line number Diff line change
Expand Up @@ -4082,6 +4082,8 @@
"playwright/e2e/Features/Glossary/GlossaryP2Tests.spec.ts",
"playwright/e2e/Features/Glossary/GlossaryP3Tests.spec.ts",
"playwright/e2e/Features/Glossary/GlossaryRemoveOperations.spec.ts",
"playwright/e2e/Features/Glossary/GlossaryStatusFilterLargeDataset.spec.ts",
"playwright/e2e/Features/Glossary/GlossaryStatusFilterNestedTerms.spec.ts",
"playwright/e2e/Features/Glossary/GlossaryTermDetails.spec.ts",
"playwright/e2e/Features/Glossary/GlossaryTermRelatedTerms.spec.ts",
"playwright/e2e/Features/Glossary/GlossaryWorkflow.spec.ts",
Expand Down Expand Up @@ -11032,6 +11034,8 @@
"playwright/e2e/Features/Glossary/GlossaryP3Tests.spec.ts",
"playwright/e2e/Features/Glossary/GlossaryPersonaCustomization.spec.ts",
"playwright/e2e/Features/Glossary/GlossaryRemoveOperations.spec.ts",
"playwright/e2e/Features/Glossary/GlossaryStatusFilterLargeDataset.spec.ts",
"playwright/e2e/Features/Glossary/GlossaryStatusFilterNestedTerms.spec.ts",
"playwright/e2e/Features/Glossary/GlossaryTermDetails.spec.ts",
"playwright/e2e/Features/Glossary/GlossaryTermRelatedTerms.spec.ts",
"playwright/e2e/Features/Glossary/GlossaryWorkflow.spec.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,3 +329,36 @@ WHERE name IN (
UPDATE user_entity
SET json = JSON_SET(json, '$.email', LOWER(JSON_UNQUOTE(JSON_EXTRACT(json, '$.email'))))
WHERE BINARY JSON_UNQUOTE(JSON_EXTRACT(json, '$.email')) <> LOWER(JSON_UNQUOTE(JSON_EXTRACT(json, '$.email')));

-- Context memories move from their own Draft/Active/Archived `status` onto `entityStatus`, the
-- lifecycle stage every entity type shares: Active becomes Approved, and a memory with no status
-- was documented as Active, so it becomes Approved too. Version history is rewritten as well:
-- `status` is no longer part of the ContextMemory schema, so rows still carrying it would fail to
-- load. Idempotent: rows without `status` are untouched.
UPDATE context_memory
SET json = JSON_REMOVE(
JSON_SET(json, '$.entityStatus',
CASE JSON_UNQUOTE(JSON_EXTRACT(json, '$.status'))
WHEN 'Draft' THEN 'Draft'
WHEN 'Archived' THEN 'Archived'
ELSE 'Approved'
END),
'$.status')
WHERE JSON_CONTAINS_PATH(json, 'one', '$.status');

UPDATE context_memory
SET json = JSON_SET(json, '$.entityStatus', 'Approved')
WHERE JSON_EXTRACT(json, '$.entityStatus') IS NULL
OR JSON_TYPE(JSON_EXTRACT(json, '$.entityStatus')) = 'NULL';

UPDATE entity_extension
SET json = JSON_REMOVE(
JSON_SET(json, '$.entityStatus',
CASE JSON_UNQUOTE(JSON_EXTRACT(json, '$.status'))
WHEN 'Draft' THEN 'Draft'
WHEN 'Archived' THEN 'Archived'
ELSE 'Approved'
END),
'$.status')
WHERE jsonSchema = 'contextMemory'
AND JSON_CONTAINS_PATH(json, 'one', '$.status');
Original file line number Diff line number Diff line change
Expand Up @@ -303,3 +303,33 @@ WHERE name IN (
UPDATE user_entity
SET json = jsonb_set(json, '{email}', to_jsonb(lower(json ->> 'email')))
WHERE json ->> 'email' <> lower(json ->> 'email');

-- Context memories move from their own Draft/Active/Archived `status` onto `entityStatus`, the
-- lifecycle stage every entity type shares: Active becomes Approved, and a memory with no status
-- was documented as Active, so it becomes Approved too. Version history is rewritten as well:
-- `status` is no longer part of the ContextMemory schema, so rows still carrying it would fail to
-- load. Idempotent: rows without `status` are untouched.
UPDATE context_memory
SET json = (json::jsonb - 'status') || jsonb_build_object(
'entityStatus',
CASE json::jsonb ->> 'status'
WHEN 'Draft' THEN 'Draft'
WHEN 'Archived' THEN 'Archived'
ELSE 'Approved'
END)
WHERE json::jsonb -> 'status' IS NOT NULL;

UPDATE context_memory
SET json = jsonb_set(json::jsonb, '{entityStatus}', '"Approved"'::jsonb)
WHERE json::jsonb ->> 'entityStatus' IS NULL;

UPDATE entity_extension
SET json = (json::jsonb - 'status') || jsonb_build_object(
'entityStatus',
CASE json::jsonb ->> 'status'
WHEN 'Draft' THEN 'Draft'
WHEN 'Archived' THEN 'Archived'
ELSE 'Approved'
END)
WHERE jsonSchema = 'contextMemory'
AND json::jsonb -> 'status' IS NOT NULL;
4 changes: 4 additions & 0 deletions ingestion/tests/integration/amundsen/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
)
from metadata.generated.schema.security.credentials.awsCredentials import AWSCredentials
from metadata.generated.schema.type.basic import Href
from metadata.generated.schema.type.status import EntityStatus
from metadata.ingestion.ometa.ometa_api import OpenMetadata
from metadata.ingestion.source.metadata.amundsen.metadata import AmundsenSource

Expand Down Expand Up @@ -71,6 +72,7 @@
fullyQualifiedName="hive",
displayName="hive",
serviceType="Hive",
entityStatus=EntityStatus.Unprocessed,
description=None,
connection=DatabaseConnection(
config=HiveConnection(
Expand Down Expand Up @@ -108,6 +110,7 @@
fullyQualifiedName="delta",
displayName="delta",
serviceType="DeltaLake",
entityStatus=EntityStatus.Unprocessed,
description=None,
connection=DatabaseConnection(
config=DeltaLakeConnection(
Expand Down Expand Up @@ -139,6 +142,7 @@
fullyQualifiedName="dynamo",
displayName="dynamo",
serviceType="DynamoDB",
entityStatus=EntityStatus.Unprocessed,
description=None,
connection=DatabaseConnection(
config=DynamoDBConnection(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
package org.openmetadata.it.bootstrap;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import es.co.elastic.clients.transport.rest5_client.low_level.Rest5Client;
import es.co.elastic.clients.transport.rest5_client.low_level.Rest5ClientBuilder;
import io.dropwizard.configuration.ConfigurationException;
Expand Down Expand Up @@ -49,12 +51,15 @@
import org.jdbi.v3.sqlobject.SqlObjects;
import org.junit.platform.launcher.LauncherSession;
import org.junit.platform.launcher.LauncherSessionListener;
import org.openmetadata.it.factories.GlossaryTestFactory;
import org.openmetadata.it.util.SdkClients;
import org.openmetadata.schema.api.configuration.pipelineServiceClient.Parameters;
import org.openmetadata.schema.api.configuration.pipelineServiceClient.PipelineServiceClientConfiguration;
import org.openmetadata.schema.api.configuration.rdf.RdfConfiguration;
import org.openmetadata.schema.service.configuration.elasticsearch.ElasticSearchConfiguration;
import org.openmetadata.schema.type.IndexMappingLanguage;
import org.openmetadata.schema.utils.JsonUtils;
import org.openmetadata.sdk.network.HttpMethod;
import org.openmetadata.search.IndexMappingLoader;
import org.openmetadata.service.Entity;
import org.openmetadata.service.OpenMetadataApplication;
Expand Down Expand Up @@ -237,6 +242,7 @@ public void launcherSessionOpened(LauncherSession session) {
System.setProperty("IT_BASE_URL", "http://localhost:" + APP.getLocalPort() + "/api");

SharedEntities.initialize(SdkClients.adminClient());
excludeGlossaryStatusFixturesFromApproval();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Edge Case: Status-fixture exclusion is skipped in external (JPW) mode

The four GlossaryTermResourceIT status tests now set term stages with a direct PATCH. They only pass because excludeGlossaryStatusFixturesFromApproval() adds an exclusion filter to GlossaryTermApprovalWorkflow. That call runs inside launcherSessionOpened, after the early return taken when JPW_MODE=external or skip.embedded.bootstrap=true. Against an external server the workflow still owns these terms, so each PATCH gets the new 403 ("stage owned by workflow") and the tests fail. To fix this, apply the exclusion whenever the suite starts, including the external path (for example, run it lazily and idempotently from GlossaryTestFactory.createForStatusTests). Alternatively, skip these tests when the exclusion isn't in place.

Was this helpful? React with 👍 / 👎


} catch (Exception e) {
LOG.error("Failed to start test infrastructure", e);
Expand All @@ -245,6 +251,30 @@ public void launcherSessionOpened(LauncherSession session) {
}
}

// Status and search tests seed their own stages. Exclude their marked glossaries before any
// tests run so queued approval events cannot overwrite them or require draining the event stream.
private static void excludeGlossaryStatusFixturesFromApproval() {
String exclusion =
JsonUtils.pojoToJson(
Map.of(
"in",
List.of(
GlossaryTestFactory.STATUS_TEST_GLOSSARY_PREFIX + "__",
Map.of("var", "fullyQualifiedName"))));
ArrayNode patch = JsonNodeFactory.instance.arrayNode();
patch
.addObject()
.put("op", "add")
.put("path", "/trigger/config/filter/glossaryTerm")
.put("value", exclusion);
SdkClients.adminClient()
.getHttpClient()
.executeForString(
HttpMethod.PATCH,
"/v1/governance/workflowDefinitions/name/GlossaryTermApprovalWorkflow",
patch);
}

@Override
public void launcherSessionClosed(LauncherSession session) {
if (isEmbeddedBootstrapDisabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
* SdkClients.initializeFluentAPIs).
*/
public class GlossaryTestFactory {
public static final String STATUS_TEST_GLOSSARY_PREFIX = "status_fixture_glossary";

/** Glossary whose terms the test bootstrap excludes from automatic approval. */
public static Glossary createForStatusTests(TestNamespace ns) {
return createWithName(ns, STATUS_TEST_GLOSSARY_PREFIX);
}

/**
* Create a glossary with default settings using fluent API.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.openmetadata.schema.entity.teams.Team;
import org.openmetadata.schema.entity.teams.User;
import org.openmetadata.schema.type.EntityReference;
import org.openmetadata.schema.type.EntityStatus;
import org.openmetadata.schema.utils.JsonUtils;
import org.openmetadata.schema.utils.ResultList;
import org.openmetadata.sdk.client.OpenMetadataClient;
Expand Down Expand Up @@ -69,6 +70,23 @@ private EntityReference getOrganizationRef() {
return org.getEntityReference();
}

@Test
void testNewArticleStartsUnprocessedUnlessItsRequestSetsAStage(TestNamespace ns)
throws HttpResponseException {
RestClient rest = RestClient.admin();
EntityReference orgRef = getOrganizationRef();

Page draft = createPage(rest, buildCreateRequest(ns.prefix("articleDraft"), orgRef));
Page requested =
createPage(
rest,
buildCreateRequest(ns.prefix("articleApproved"), orgRef)
.withEntityStatus(EntityStatus.APPROVED));

assertEquals(EntityStatus.UNPROCESSED, draft.getEntityStatus());
assertEquals(EntityStatus.APPROVED, requested.getEntityStatus());
}

@Test
void testRelatedEntitiesExcludesDomainsAndDataProducts(TestNamespace ns)
throws HttpResponseException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.openmetadata.schema.entity.ai.ModelConfiguration;
import org.openmetadata.schema.entity.ai.ModelPurpose;
import org.openmetadata.schema.entity.services.McpService;
import org.openmetadata.schema.type.EntityStatus;
import org.openmetadata.sdk.fluent.AIApplications;
import org.openmetadata.sdk.network.HttpMethod;
import org.openmetadata.sdk.network.RequestOptions;
Expand All @@ -47,6 +48,18 @@ static void setup() {
AIApplications.setDefaultClient(SdkClients.adminClient());
}

@Test
void test_newAIApplicationStartsUnprocessed(TestNamespace ns) {
AIApplication app =
AIApplications.create()
.name(ns.prefix("draftApp"))
.withApplicationType(ApplicationType.Chatbot)
.withDescription("AI Application with no registration status")
.execute();

assertEquals(EntityStatus.UNPROCESSED, app.getEntityStatus());
}

@Test
void test_createAIApplication(TestNamespace ns) {
AIApplication app =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
public class AnnouncementResourceIT extends BaseEntityIT<Announcement, CreateAnnouncement> {

public AnnouncementResourceIT() {
supportsEntityStatus = false;
supportsFollowers = false;
supportsTags = false;
supportsDomains = true;
Expand Down
Loading
Loading