mirror of
				https://github.com/open-metadata/OpenMetadata.git
				synced 2025-10-31 02:29:03 +00:00 
			
		
		
		
	fix(ui): Runner getting wrong values in workflow API (#23827)
* fix runner issues * add unit tests for the fix
This commit is contained in:
		
							parent
							
								
									f2a9dd0015
								
							
						
					
					
						commit
						dd307a43e0
					
				| @ -24,6 +24,7 @@ export interface TestConnectionProps { | |||||||
|   shouldValidateForm?: boolean; |   shouldValidateForm?: boolean; | ||||||
|   onValidateFormRequiredFields?: () => boolean; |   onValidateFormRequiredFields?: () => boolean; | ||||||
|   hostIp?: string; |   hostIp?: string; | ||||||
|  |   extraInfo?: string; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export type TestStatus = Exclude<StatusType, 'Running'> | 'Warning' | undefined; | export type TestStatus = Exclude<StatusType, 'Running'> | 'Warning' | undefined; | ||||||
|  | |||||||
| @ -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 = { | export const WORKFLOW_DETAILS = { | ||||||
|   id: 'd6a5178d-06ba-4702-9b32-ce72349aa88c', |   id: 'd6a5178d-06ba-4702-9b32-ce72349aa88c', | ||||||
|   name: 'test-connection-Mysql-01', |   name: 'test-connection-Mysql-01', | ||||||
|  | |||||||
| @ -31,6 +31,7 @@ import { StatusType } from '../StatusBadge/StatusBadge.interface'; | |||||||
| import TestConnection from './TestConnection'; | import TestConnection from './TestConnection'; | ||||||
| import { | import { | ||||||
|   CREATE_WORKFLOW_PAYLOAD, |   CREATE_WORKFLOW_PAYLOAD, | ||||||
|  |   CREATE_WORKFLOW_PAYLOAD_WITH_RUNNER, | ||||||
|   FORM_DATA, |   FORM_DATA, | ||||||
|   TEST_CONNECTION_DEFINITION, |   TEST_CONNECTION_DEFINITION, | ||||||
|   WORKFLOW_DETAILS, |   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(<TestConnection {...mockProps} extraInfo="custom-runner-name" />); | ||||||
|  |     }); | ||||||
|  |     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 () => { |   it('Should show success message if test connection successful', async () => { | ||||||
|     jest.useFakeTimers(); |     jest.useFakeTimers(); | ||||||
|     await act(async () => { |     await act(async () => { | ||||||
|  | |||||||
| @ -33,11 +33,13 @@ import { | |||||||
| } from '../../../constants/Services.constant'; | } from '../../../constants/Services.constant'; | ||||||
| import { useAirflowStatus } from '../../../context/AirflowStatusProvider/AirflowStatusProvider'; | import { useAirflowStatus } from '../../../context/AirflowStatusProvider/AirflowStatusProvider'; | ||||||
| import { CreateWorkflow } from '../../../generated/api/automations/createWorkflow'; | import { CreateWorkflow } from '../../../generated/api/automations/createWorkflow'; | ||||||
|  | import { ConfigObject } from '../../../generated/entity/automations/testServiceConnection'; | ||||||
| import { | import { | ||||||
|   StatusType, |   StatusType, | ||||||
|   TestConnectionStepResult, |   TestConnectionStepResult, | ||||||
|   Workflow, |   Workflow, | ||||||
|   WorkflowStatus, |   WorkflowStatus, | ||||||
|  |   WorkflowType, | ||||||
| } from '../../../generated/entity/automations/workflow'; | } from '../../../generated/entity/automations/workflow'; | ||||||
| import { TestConnectionStep } from '../../../generated/entity/services/connections/testConnectionDefinition'; | import { TestConnectionStep } from '../../../generated/entity/services/connections/testConnectionDefinition'; | ||||||
| import useAbortController from '../../../hooks/AbortController/useAbortController'; | import useAbortController from '../../../hooks/AbortController/useAbortController'; | ||||||
| @ -50,9 +52,9 @@ import { | |||||||
| } from '../../../rest/workflowAPI'; | } from '../../../rest/workflowAPI'; | ||||||
| import { Transi18next } from '../../../utils/CommonUtils'; | import { Transi18next } from '../../../utils/CommonUtils'; | ||||||
| import { formatFormDataForSubmit } from '../../../utils/JSONSchemaFormUtils'; | import { formatFormDataForSubmit } from '../../../utils/JSONSchemaFormUtils'; | ||||||
| import serviceUtilClassBase from '../../../utils/ServiceUtilClassBase'; |  | ||||||
| import { | import { | ||||||
|   getServiceType, |   getServiceType, | ||||||
|  |   getTestConnectionName, | ||||||
|   shouldTestConnection, |   shouldTestConnection, | ||||||
| } from '../../../utils/ServiceUtils'; | } from '../../../utils/ServiceUtils'; | ||||||
| import { getErrorText } from '../../../utils/StringsUtils'; | import { getErrorText } from '../../../utils/StringsUtils'; | ||||||
| @ -71,6 +73,7 @@ const TestConnection: FC<TestConnectionProps> = ({ | |||||||
|   shouldValidateForm = true, |   shouldValidateForm = true, | ||||||
|   showDetails = true, |   showDetails = true, | ||||||
|   hostIp, |   hostIp, | ||||||
|  |   extraInfo, | ||||||
| }) => { | }) => { | ||||||
|   const { t } = useTranslation(); |   const { t } = useTranslation(); | ||||||
|   const { isAirflowAvailable } = useAirflowStatus(); |   const { isAirflowAvailable } = useAirflowStatus(); | ||||||
| @ -278,13 +281,17 @@ const TestConnection: FC<TestConnectionProps> = ({ | |||||||
|     } = {}; |     } = {}; | ||||||
| 
 | 
 | ||||||
|     try { |     try { | ||||||
|       const createWorkflowData: CreateWorkflow = |       const createWorkflowData: CreateWorkflow = { | ||||||
|         serviceUtilClassBase.getAddWorkflowData( |         name: getTestConnectionName(connectionType), | ||||||
|           connectionType, |         workflowType: WorkflowType.TestConnection, | ||||||
|  |         request: { | ||||||
|  |           connection: { config: updatedFormData as ConfigObject }, | ||||||
|           serviceType, |           serviceType, | ||||||
|  |           connectionType, | ||||||
|           serviceName, |           serviceName, | ||||||
|           updatedFormData |           ingestionRunner: extraInfo, | ||||||
|         ); |         }, | ||||||
|  |       }; | ||||||
| 
 | 
 | ||||||
|       // fetch the connection steps for current connectionType
 |       // fetch the connection steps for current connectionType
 | ||||||
|       await fetchConnectionDefinition(); |       await fetchConnectionDefinition(); | ||||||
|  | |||||||
| @ -1467,6 +1467,7 @@ const ServiceDetailsPage: FunctionComponent = () => { | |||||||
|             {allowTestConn && ( |             {allowTestConn && ( | ||||||
|               <TestConnection |               <TestConnection | ||||||
|                 connectionType={serviceDetails?.serviceType ?? ''} |                 connectionType={serviceDetails?.serviceType ?? ''} | ||||||
|  |                 extraInfo={extraInfoData?.name || extraInfoData?.displayName} | ||||||
|                 getData={() => connectionDetails} |                 getData={() => connectionDetails} | ||||||
|                 hostIp={hostIp} |                 hostIp={hostIp} | ||||||
|                 isTestingDisabled={isTestingDisabled} |                 isTestingDisabled={isTestingDisabled} | ||||||
|  | |||||||
| @ -135,8 +135,6 @@ import { | |||||||
|   StorageServiceTypeSmallCaseType, |   StorageServiceTypeSmallCaseType, | ||||||
| } from '../enums/service.enum'; | } from '../enums/service.enum'; | ||||||
| import { DriveServiceType } from '../generated/api/services/createDriveService'; | 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 { StorageServiceType } from '../generated/entity/data/container'; | ||||||
| import { DashboardServiceType } from '../generated/entity/data/dashboard'; | import { DashboardServiceType } from '../generated/entity/data/dashboard'; | ||||||
| import { DatabaseServiceType } from '../generated/entity/data/database'; | 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 { APIServiceType } from '../generated/entity/services/apiService'; | ||||||
| import { MetadataServiceType } from '../generated/entity/services/metadataService'; | import { MetadataServiceType } from '../generated/entity/services/metadataService'; | ||||||
| import { Type as SecurityServiceType } from '../generated/entity/services/securityService'; | import { Type as SecurityServiceType } from '../generated/entity/services/securityService'; | ||||||
| import { ServiceType } from '../generated/entity/services/serviceType'; |  | ||||||
| import { SearchSourceAlias } from '../interface/search.interface'; | import { SearchSourceAlias } from '../interface/search.interface'; | ||||||
| import { ConfigData, ServicesType } from '../interface/service.interface'; | import { ConfigData, ServicesType } from '../interface/service.interface'; | ||||||
| import { getAPIConfig } from './APIServiceUtils'; | import { getAPIConfig } from './APIServiceUtils'; | ||||||
| @ -160,7 +157,6 @@ import { getMlmodelConfig } from './MlmodelServiceUtils'; | |||||||
| import { getPipelineConfig } from './PipelineServiceUtils'; | import { getPipelineConfig } from './PipelineServiceUtils'; | ||||||
| import { getSearchServiceConfig } from './SearchServiceUtils'; | import { getSearchServiceConfig } from './SearchServiceUtils'; | ||||||
| import { getSecurityConfig } from './SecurityServiceUtils'; | import { getSecurityConfig } from './SecurityServiceUtils'; | ||||||
| import { getTestConnectionName } from './ServiceUtils'; |  | ||||||
| import { getStorageConfig } from './StorageServiceUtils'; | import { getStorageConfig } from './StorageServiceUtils'; | ||||||
| import { customServiceComparator } from './StringsUtils'; | import { customServiceComparator } from './StringsUtils'; | ||||||
| 
 | 
 | ||||||
| @ -262,24 +258,6 @@ class ServiceUtilClassBase { | |||||||
|     return this.serviceDetails; |     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: { |   public getServiceConfigData(data: { | ||||||
|     serviceName: string; |     serviceName: string; | ||||||
|     serviceType: string; |     serviceType: string; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Sweta Agarwalla
						Sweta Agarwalla