mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-10-30 01:59:23 +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;
|
||||
onValidateFormRequiredFields?: () => boolean;
|
||||
hostIp?: string;
|
||||
extraInfo?: string;
|
||||
}
|
||||
|
||||
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 = {
|
||||
id: 'd6a5178d-06ba-4702-9b32-ce72349aa88c',
|
||||
name: 'test-connection-Mysql-01',
|
||||
|
||||
@ -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(<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 () => {
|
||||
jest.useFakeTimers();
|
||||
await act(async () => {
|
||||
|
||||
@ -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<TestConnectionProps> = ({
|
||||
shouldValidateForm = true,
|
||||
showDetails = true,
|
||||
hostIp,
|
||||
extraInfo,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { isAirflowAvailable } = useAirflowStatus();
|
||||
@ -278,13 +281,17 @@ const TestConnection: FC<TestConnectionProps> = ({
|
||||
} = {};
|
||||
|
||||
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();
|
||||
|
||||
@ -1467,6 +1467,7 @@ const ServiceDetailsPage: FunctionComponent = () => {
|
||||
{allowTestConn && (
|
||||
<TestConnection
|
||||
connectionType={serviceDetails?.serviceType ?? ''}
|
||||
extraInfo={extraInfoData?.name || extraInfoData?.displayName}
|
||||
getData={() => connectionDetails}
|
||||
hostIp={hostIp}
|
||||
isTestingDisabled={isTestingDisabled}
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user