From dd307a43e03c47fca23e7274cca566928a2f31d1 Mon Sep 17 00:00:00 2001 From: Sweta Agarwalla <105535990+sweta1308@users.noreply.github.com> Date: Tue, 14 Oct 2025 17:13:55 +0530 Subject: [PATCH] fix(ui): Runner getting wrong values in workflow API (#23827) * fix runner issues * add unit tests for the fix --- .../TestConnection.interface.ts | 1 + .../TestConnection/TestConnection.mock.ts | 19 +++++++++++ .../TestConnection/TestConnection.test.tsx | 32 +++++++++++++++++++ .../common/TestConnection/TestConnection.tsx | 19 +++++++---- .../ServiceDetailsPage/ServiceDetailsPage.tsx | 1 + .../ui/src/utils/ServiceUtilClassBase.ts | 22 ------------- 6 files changed, 66 insertions(+), 28 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/TestConnection.interface.ts b/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/TestConnection.interface.ts index eda75584c30..448fc374ef7 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/TestConnection.interface.ts +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/TestConnection.interface.ts @@ -24,6 +24,7 @@ export interface TestConnectionProps { shouldValidateForm?: boolean; onValidateFormRequiredFields?: () => boolean; hostIp?: string; + extraInfo?: string; } export type TestStatus = Exclude | 'Warning' | undefined; diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/TestConnection.mock.ts b/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/TestConnection.mock.ts index b6d97b5fe7b..c3d5ce1b342 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/TestConnection.mock.ts +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/TestConnection.mock.ts @@ -36,6 +36,25 @@ export const CREATE_WORKFLOW_PAYLOAD = { }, }; +export const CREATE_WORKFLOW_PAYLOAD_WITH_RUNNER = { + name: 'test-connection-Mysql-01', + workflowType: 'TEST_CONNECTION', + request: { + connection: { + config: { + type: 'Mysql', + scheme: 'mysql+pymysql', + username: 'openmetadata_user', + password: 'openmetadata_password', + hostPort: 'mysql:3306', + }, + }, + serviceType: 'Database', + connectionType: 'Mysql', + ingestionRunner: 'custom-runner-name', + }, +}; + export const WORKFLOW_DETAILS = { id: 'd6a5178d-06ba-4702-9b32-ce72349aa88c', name: 'test-connection-Mysql-01', diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/TestConnection.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/TestConnection.test.tsx index 6f09ce63a13..85b8d370a27 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/TestConnection.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/TestConnection.test.tsx @@ -31,6 +31,7 @@ import { StatusType } from '../StatusBadge/StatusBadge.interface'; import TestConnection from './TestConnection'; import { CREATE_WORKFLOW_PAYLOAD, + CREATE_WORKFLOW_PAYLOAD_WITH_RUNNER, FORM_DATA, TEST_CONNECTION_DEFINITION, WORKFLOW_DETAILS, @@ -206,6 +207,37 @@ describe('Test Connection Component', () => { ); }); + it('Should create workflow with ingestionRunner when extraInfo is provided', async () => { + jest.useFakeTimers(); + await act(async () => { + render(); + }); + const controller = new AbortController(); + + const testConnectionButton = screen.getByTestId('test-connection-btn'); + + await act(async () => { + fireEvent.click(testConnectionButton); + }); + + expect(addWorkflow).toHaveBeenCalledWith( + CREATE_WORKFLOW_PAYLOAD_WITH_RUNNER, + controller.signal + ); + + expect(triggerWorkflowById).toHaveBeenCalledWith( + WORKFLOW_DETAILS.id, + controller.signal + ); + + jest.advanceTimersByTime(2000); + + expect(getWorkflowById).toHaveBeenCalledWith( + WORKFLOW_DETAILS.id, + controller.signal + ); + }); + it('Should show success message if test connection successful', async () => { jest.useFakeTimers(); await act(async () => { diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/TestConnection.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/TestConnection.tsx index 5828f4b311d..45ad5a28190 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/TestConnection.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/TestConnection.tsx @@ -33,11 +33,13 @@ import { } from '../../../constants/Services.constant'; import { useAirflowStatus } from '../../../context/AirflowStatusProvider/AirflowStatusProvider'; import { CreateWorkflow } from '../../../generated/api/automations/createWorkflow'; +import { ConfigObject } from '../../../generated/entity/automations/testServiceConnection'; import { StatusType, TestConnectionStepResult, Workflow, WorkflowStatus, + WorkflowType, } from '../../../generated/entity/automations/workflow'; import { TestConnectionStep } from '../../../generated/entity/services/connections/testConnectionDefinition'; import useAbortController from '../../../hooks/AbortController/useAbortController'; @@ -50,9 +52,9 @@ import { } from '../../../rest/workflowAPI'; import { Transi18next } from '../../../utils/CommonUtils'; import { formatFormDataForSubmit } from '../../../utils/JSONSchemaFormUtils'; -import serviceUtilClassBase from '../../../utils/ServiceUtilClassBase'; import { getServiceType, + getTestConnectionName, shouldTestConnection, } from '../../../utils/ServiceUtils'; import { getErrorText } from '../../../utils/StringsUtils'; @@ -71,6 +73,7 @@ const TestConnection: FC = ({ shouldValidateForm = true, showDetails = true, hostIp, + extraInfo, }) => { const { t } = useTranslation(); const { isAirflowAvailable } = useAirflowStatus(); @@ -278,13 +281,17 @@ const TestConnection: FC = ({ } = {}; try { - const createWorkflowData: CreateWorkflow = - serviceUtilClassBase.getAddWorkflowData( - connectionType, + const createWorkflowData: CreateWorkflow = { + name: getTestConnectionName(connectionType), + workflowType: WorkflowType.TestConnection, + request: { + connection: { config: updatedFormData as ConfigObject }, serviceType, + connectionType, serviceName, - updatedFormData - ); + ingestionRunner: extraInfo, + }, + }; // fetch the connection steps for current connectionType await fetchConnectionDefinition(); diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/ServiceDetailsPage/ServiceDetailsPage.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/ServiceDetailsPage/ServiceDetailsPage.tsx index b6ea0ee555c..c8245a339d1 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/ServiceDetailsPage/ServiceDetailsPage.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/ServiceDetailsPage/ServiceDetailsPage.tsx @@ -1467,6 +1467,7 @@ const ServiceDetailsPage: FunctionComponent = () => { {allowTestConn && ( connectionDetails} hostIp={hostIp} isTestingDisabled={isTestingDisabled} diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/ServiceUtilClassBase.ts b/openmetadata-ui/src/main/resources/ui/src/utils/ServiceUtilClassBase.ts index 72157774a4a..ba557a7ab8d 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/ServiceUtilClassBase.ts +++ b/openmetadata-ui/src/main/resources/ui/src/utils/ServiceUtilClassBase.ts @@ -135,8 +135,6 @@ import { StorageServiceTypeSmallCaseType, } from '../enums/service.enum'; import { DriveServiceType } from '../generated/api/services/createDriveService'; -import { ConfigObject } from '../generated/entity/automations/testServiceConnection'; -import { WorkflowType } from '../generated/entity/automations/workflow'; import { StorageServiceType } from '../generated/entity/data/container'; import { DashboardServiceType } from '../generated/entity/data/dashboard'; import { DatabaseServiceType } from '../generated/entity/data/database'; @@ -147,7 +145,6 @@ import { MessagingServiceType } from '../generated/entity/data/topic'; import { APIServiceType } from '../generated/entity/services/apiService'; import { MetadataServiceType } from '../generated/entity/services/metadataService'; import { Type as SecurityServiceType } from '../generated/entity/services/securityService'; -import { ServiceType } from '../generated/entity/services/serviceType'; import { SearchSourceAlias } from '../interface/search.interface'; import { ConfigData, ServicesType } from '../interface/service.interface'; import { getAPIConfig } from './APIServiceUtils'; @@ -160,7 +157,6 @@ import { getMlmodelConfig } from './MlmodelServiceUtils'; import { getPipelineConfig } from './PipelineServiceUtils'; import { getSearchServiceConfig } from './SearchServiceUtils'; import { getSecurityConfig } from './SecurityServiceUtils'; -import { getTestConnectionName } from './ServiceUtils'; import { getStorageConfig } from './StorageServiceUtils'; import { customServiceComparator } from './StringsUtils'; @@ -262,24 +258,6 @@ class ServiceUtilClassBase { return this.serviceDetails; } - public getAddWorkflowData( - connectionType: string, - serviceType: ServiceType, - serviceName?: string, - configData?: ConfigData - ) { - return { - name: getTestConnectionName(connectionType), - workflowType: WorkflowType.TestConnection, - request: { - connection: { config: configData as ConfigObject }, - serviceType, - connectionType, - serviceName, - }, - }; - } - public getServiceConfigData(data: { serviceName: string; serviceType: string;