fix #14159: Added support for displayName in adding ingestion (#14384)

* added support for displayName in adding ingestion

* added test cases

* minor code fix

---------

Co-authored-by: Chirag Madlani <12962843+chirag-madlani@users.noreply.github.com>
This commit is contained in:
Harsh Vador 2023-12-19 11:32:20 +05:30 committed by GitHub
parent 6612ac9a51
commit c601dde801
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 97 additions and 6 deletions

View File

@ -129,7 +129,12 @@ const AddIngestion = ({
};
const createNewIngestion = (extraData: WorkflowExtraConfig) => {
const { name = '', enableDebugLog, ...rest } = workflowData ?? {};
const {
name = '',
enableDebugLog,
displayName,
...rest
} = workflowData ?? {};
const ingestionName = trim(name);
setSaveState(LOADING_STATE.WAITING);
@ -148,7 +153,7 @@ const AddIngestion = ({
},
loggerLevel: enableDebugLog ? LogLevels.Debug : LogLevels.Info,
name: ingestionName,
displayName: ingestionName,
displayName: displayName,
owner: {
id: currentUser?.id ?? '',
type: 'user',
@ -194,12 +199,14 @@ const AddIngestion = ({
: scheduleInterval,
retries: extraData.retries,
},
displayName: workflowData?.displayName,
loggerLevel: workflowData?.enableDebugLog
? LogLevels.Debug
: LogLevels.Info,
sourceConfig: {
config: {
...(omit(workflowData, ['name', 'enableDebugLog']) ?? {}),
...(omit(workflowData, ['name', 'enableDebugLog', 'displayName']) ??
{}),
},
},
};

View File

@ -123,6 +123,7 @@ export type ConfigData =
export type IngestionWorkflowData = Pipeline & {
name: string;
enableDebugLog?: boolean;
displayName?: string;
};
export interface IngestionWorkflowFormProps {

View File

@ -0,0 +1,82 @@
/*
* Copyright 2023 Collate.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ServiceCategory } from '../enums/service.enum';
import { PipelineType as WorkflowType } from '../generated/api/services/ingestionPipelines/createIngestionPipeline';
import {
getMetadataSchemaByServiceCategory,
getSchemaByWorkflowType,
} from './IngestionWorkflowUtils';
describe('Ingestion Workflow tests', () => {
it('should getMetadataSchemaByServiceCategory return the correct schema for each service category', () => {
const databaseSchema = getMetadataSchemaByServiceCategory(
ServiceCategory.DATABASE_SERVICES
);
const dashboardSchema = getMetadataSchemaByServiceCategory(
ServiceCategory.DASHBOARD_SERVICES
);
const messagingSchema = getMetadataSchemaByServiceCategory(
ServiceCategory.MESSAGING_SERVICES
);
expect(databaseSchema).toBeDefined();
expect(dashboardSchema).toBeDefined();
expect(messagingSchema).toBeDefined();
});
it('should getMetadataSchemaByServiceCategory return an empty object for an unknown service category', () => {
const unknownSchema = getMetadataSchemaByServiceCategory(
'unknown-category' as ServiceCategory
);
expect(unknownSchema).toEqual({});
});
it('should getSchemaByWorkflowType return the correct schema for each workflow type', () => {
const metadataSchema = getSchemaByWorkflowType(
WorkflowType.Metadata,
ServiceCategory.PIPELINE_SERVICES
);
const profilerSchema = getSchemaByWorkflowType(
WorkflowType.Profiler,
ServiceCategory.PIPELINE_SERVICES
);
const usageSchema = getSchemaByWorkflowType(
WorkflowType.Usage,
ServiceCategory.PIPELINE_SERVICES
);
expect(metadataSchema).toBeDefined();
expect(profilerSchema).toBeDefined();
expect(usageSchema).toBeDefined();
});
it('should getSchemaByWorkflowType return a default object with for an unknown workflow type', () => {
const unknownSchema = getSchemaByWorkflowType(
'unknown-type' as WorkflowType,
ServiceCategory.PIPELINE_SERVICES
);
expect(unknownSchema).toHaveProperty('properties.displayName');
});
it('should getSchemaByWorkflowType include display Name for each schema', () => {
const metadataSchema = getSchemaByWorkflowType(
WorkflowType.Metadata,
ServiceCategory.PIPELINE_SERVICES
);
expect(metadataSchema).toBeDefined();
expect(metadataSchema).toHaveProperty('properties.displayName');
});
});

View File

@ -61,6 +61,10 @@ export const getSchemaByWorkflowType = (
serviceCategory: ServiceCategory
) => {
const customProperties = {
displayName: {
description: 'Display Name of the workflow',
type: 'string',
},
name: {
description: 'Name of the workflow',
type: 'string',
@ -126,9 +130,6 @@ export const getSchemaByWorkflowType = (
break;
default:
schema = {};
break;
}
const rjsfSchema = schema as RJSFSchema;