Skip to content

Commit d8265b7

Browse files
authored
Fix: Flaky Workflow Test cross polluted by SystemResource test (#25789)
1 parent 293d7d3 commit d8265b7

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/SystemResourceIT.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,21 @@ void test_assetCertificationSettings() throws Exception {
10271027

10281028
assertEquals("NewCertification", updatedCertificationConfig.getAllowedClassification());
10291029
assertEquals("P60D", updatedCertificationConfig.getValidityPeriod());
1030+
1031+
// Reset to original values to avoid cross-test pollution
1032+
certificationConfig.setAllowedClassification("Certification");
1033+
certificationConfig.setValidityPeriod("P30D");
1034+
1035+
Settings resetSettings =
1036+
new Settings()
1037+
.withConfigType(SettingsType.ASSET_CERTIFICATION_SETTINGS)
1038+
.withConfigValue(certificationConfig);
1039+
1040+
String resetJson = MAPPER.writeValueAsString(resetSettings);
1041+
client
1042+
.getHttpClient()
1043+
.executeForString(
1044+
HttpMethod.PUT, "/v1/system/settings", resetJson, RequestOptions.builder().build());
10301045
}
10311046

10321047
@Test

openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/WorkflowDefinitionResourceIT.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
import org.openmetadata.schema.api.teams.CreateUser;
5858
import org.openmetadata.schema.api.tests.CreateTestCase;
5959
import org.openmetadata.schema.api.tests.CreateTestDefinition;
60+
import org.openmetadata.schema.configuration.AssetCertificationSettings;
6061
import org.openmetadata.schema.entity.classification.Classification;
6162
import org.openmetadata.schema.entity.classification.Tag;
6263
import org.openmetadata.schema.entity.data.APICollection;
@@ -82,6 +83,8 @@
8283
import org.openmetadata.schema.services.connections.database.MysqlConnection;
8384
import org.openmetadata.schema.services.connections.database.PostgresConnection;
8485
import org.openmetadata.schema.services.connections.database.common.basicAuth;
86+
import org.openmetadata.schema.settings.Settings;
87+
import org.openmetadata.schema.settings.SettingsType;
8588
import org.openmetadata.schema.tests.TestCase;
8689
import org.openmetadata.schema.tests.TestPlatform;
8790
import org.openmetadata.schema.type.APIRequestMethod;
@@ -5880,6 +5883,24 @@ private void setupCertificationTags_SDK() {
58805883
}
58815884
}
58825885

5886+
// Ensure Gold tag exists (bootstrapped at startup, but ensure defensively)
5887+
try {
5888+
Tag goldTag = SdkClients.adminClient().tags().getByName("Certification.Gold");
5889+
LOG.debug("Gold tag already exists: {}", goldTag.getFullyQualifiedName());
5890+
} catch (ApiException e) {
5891+
if (e.getStatusCode() == 404) {
5892+
CreateTag createGoldTag =
5893+
new CreateTag()
5894+
.withName("Gold")
5895+
.withDescription("Gold certified Data Asset.")
5896+
.withClassification("Certification");
5897+
Tag goldTag = SdkClients.adminClient().tags().create(createGoldTag);
5898+
LOG.debug("Gold tag created: {}", goldTag.getFullyQualifiedName());
5899+
} else {
5900+
throw e;
5901+
}
5902+
}
5903+
58835904
// Check if Brass tag already exists
58845905
try {
58855906
Tag brassTag = SdkClients.adminClient().tags().getByName("Certification.Brass");
@@ -5898,6 +5919,31 @@ private void setupCertificationTags_SDK() {
58985919
throw e;
58995920
}
59005921
}
5922+
5923+
// Defensively ensure AssetCertificationSettings has correct allowedClassification.
5924+
// This guards against cross-test pollution (e.g., SystemResourceIT changing it).
5925+
try {
5926+
OpenMetadataClient client = SdkClients.adminClient();
5927+
AssetCertificationSettings certSettings =
5928+
new AssetCertificationSettings()
5929+
.withAllowedClassification("Certification")
5930+
.withValidityPeriod("P30D");
5931+
Settings settings =
5932+
new Settings()
5933+
.withConfigType(SettingsType.ASSET_CERTIFICATION_SETTINGS)
5934+
.withConfigValue(certSettings);
5935+
String settingsJson = MAPPER.writeValueAsString(settings);
5936+
client
5937+
.getHttpClient()
5938+
.executeForString(
5939+
HttpMethod.PUT,
5940+
"/v1/system/settings",
5941+
settingsJson,
5942+
RequestOptions.builder().build());
5943+
LOG.debug("AssetCertificationSettings reset to allowedClassification=Certification");
5944+
} catch (Exception e) {
5945+
LOG.warn("Failed to reset AssetCertificationSettings: {}", e.getMessage());
5946+
}
59015947
}
59025948

59035949
private void createTestEntities_SDK(TestNamespace ns, TestInfo test) {

0 commit comments

Comments
 (0)