feat(ui): support debug option for dbt config (#10538)

* feat(ui): support debug option for dbt config

* fix tests and address comments
This commit is contained in:
Chirag Madlani 2023-03-14 16:37:23 +05:30 committed by GitHub
parent 83a1858434
commit 8a5b54aebb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 97 additions and 1 deletions

View File

@ -24,6 +24,7 @@ const mockDbtCloudProjectId = jest.fn();
const mockDbtCloudJobId = jest.fn();
const mockUpdateDBTClassification = jest.fn();
const mockUpdateDBTCloudUrl = jest.fn();
const mockHandleEnableDebugLogCheck = jest.fn();
const mockProps = {
dbtCloudAccountId: '',
@ -41,6 +42,8 @@ const mockProps = {
handleDbtCloudJobId: mockDbtCloudJobId,
handleDbtCloudUrl: mockUpdateDBTCloudUrl,
handleUpdateDBTClassification: mockUpdateDBTClassification,
enableDebugLog: false,
handleEnableDebugLogCheck: mockHandleEnableDebugLogCheck,
};
jest.mock('./DBTCommonFields.component', () =>

View File

@ -37,6 +37,8 @@ interface Props extends DBTFormCommonProps, DbtConfigCloud {
handleDbtCloudJobId: (value: string) => void;
handleUpdateDBTClassification: (value: string) => void;
handleDbtCloudUrl: (value: string) => void;
enableDebugLog: boolean;
handleEnableDebugLogCheck: (value: boolean) => void;
}
export const DBTCloudConfig: FunctionComponent<Props> = ({
@ -58,6 +60,8 @@ export const DBTCloudConfig: FunctionComponent<Props> = ({
dbtClassificationName,
handleDbtCloudUrl,
handleUpdateDBTClassification,
enableDebugLog,
handleEnableDebugLogCheck,
}: Props) => {
const [errors, setErrors] = useState<ErrorDbtCloud>();
@ -185,6 +189,8 @@ export const DBTCloudConfig: FunctionComponent<Props> = ({
dbtClassificationName={dbtClassificationName}
dbtUpdateDescriptions={dbtUpdateDescriptions}
descriptionId="cloud-update-description"
enableDebugLog={enableDebugLog}
handleEnableDebugLogCheck={handleEnableDebugLogCheck}
handleUpdateDBTClassification={handleUpdateDBTClassification}
handleUpdateDescriptions={handleUpdateDescriptions}
/>

View File

@ -14,6 +14,7 @@
import { Input, Space, Switch, Typography } from 'antd';
import React, { Fragment } from 'react';
import { useTranslation } from 'react-i18next';
import { getSeparator } from 'utils/CommonUtils';
import { Field } from '../../Field/Field';
interface Props {
@ -22,6 +23,8 @@ interface Props {
handleUpdateDBTClassification: (value: string) => void;
dbtUpdateDescriptions: boolean;
handleUpdateDescriptions: (value: boolean) => void;
enableDebugLog: boolean;
handleEnableDebugLogCheck: (value: boolean) => void;
}
function DBTCommonFields({
@ -30,15 +33,37 @@ function DBTCommonFields({
dbtClassificationName,
handleUpdateDescriptions,
handleUpdateDBTClassification,
handleEnableDebugLogCheck,
enableDebugLog,
}: Props) {
const { t } = useTranslation();
return (
<Fragment>
<Field>
<Space align="end" className="m-b-xs">
<label className="tw-form-label m-b-0" htmlFor="enable-dbt-debug-log">
{t('label.enable-debug-log')}
</label>
<Switch
checked={enableDebugLog}
data-testid="enable-dbt-debug-log"
id="enable-dbt-debug-log"
onChange={handleEnableDebugLogCheck}
/>
</Space>
<Typography.Text
className="d-block text-grey-muted m-b-xs text-xs"
data-testid="dbt-enable-debug-logging">
{t('message.enable-debug-logging')}
</Typography.Text>
{getSeparator('')}
</Field>
<Field>
<Space align="end" className="m-b-xs">
<label
className="tw-form-label m-b-0 tw-mb-1"
className="tw-form-label m-b-0"
data-testid={descriptionId}
htmlFor={descriptionId}>
{t('label.update-description')}

View File

@ -15,12 +15,16 @@ import { getByTestId, render } from '@testing-library/react';
import React from 'react';
import DBTCommonFields from './DBTCommonFields.component';
const mockHandleEnableDebugLogCheck = jest.fn();
const mockProps = {
dbtUpdateDescriptions: false,
descriptionId: 'test-id',
dbtClassificationName: 'DBT',
handleUpdateDescriptions: jest.fn(),
handleUpdateDBTClassification: jest.fn(),
enableDebugLog: false,
handleEnableDebugLogCheck: mockHandleEnableDebugLogCheck,
};
describe('DBTCommonFields', () => {

View File

@ -81,6 +81,11 @@ const DBTConfigFormBuilder: FunctionComponent<DBTConfigFormProps> = ({
});
};
const handleEnableDebugLogCheck = (value: boolean) =>
onChange({
enableDebugLog: value,
});
const getCloudConfigFields = () => {
return (
<DBTCloudConfig
@ -92,6 +97,7 @@ const DBTConfigFormBuilder: FunctionComponent<DBTConfigFormProps> = ({
dbtCloudProjectId={dbtConfig?.dbtCloudProjectId}
dbtCloudUrl={dbtConfig.dbtCloudUrl}
dbtUpdateDescriptions={dbtConfig?.dbtUpdateDescriptions}
enableDebugLog={data.enableDebugLog}
handleCloudAccountIdChange={(val) => {
updateDbtConfig('dbtCloudAccountId', val);
}}
@ -105,6 +111,7 @@ const DBTConfigFormBuilder: FunctionComponent<DBTConfigFormProps> = ({
updateDbtConfig('dbtCloudProjectId', val);
}}
handleDbtCloudUrl={(val) => updateDbtConfig('dbtCloudUrl', val)}
handleEnableDebugLogCheck={handleEnableDebugLogCheck}
handleUpdateDBTClassification={(val) => {
updateDbtConfig('dbtClassificationName', val);
}}
@ -127,9 +134,11 @@ const DBTConfigFormBuilder: FunctionComponent<DBTConfigFormProps> = ({
dbtManifestFilePath={dbtConfig?.dbtManifestFilePath}
dbtRunResultsFilePath={dbtConfig?.dbtRunResultsFilePath}
dbtUpdateDescriptions={dbtConfig?.dbtUpdateDescriptions}
enableDebugLog={data.enableDebugLog}
handleCatalogFilePathChange={(val) => {
updateDbtConfig('dbtCatalogFilePath', val);
}}
handleEnableDebugLogCheck={handleEnableDebugLogCheck}
handleManifestFilePathChange={(val) => {
updateDbtConfig('dbtManifestFilePath', val);
}}
@ -158,9 +167,11 @@ const DBTConfigFormBuilder: FunctionComponent<DBTConfigFormProps> = ({
dbtManifestHttpPath={dbtConfig?.dbtManifestHttpPath}
dbtRunResultsHttpPath={dbtConfig?.dbtRunResultsHttpPath}
dbtUpdateDescriptions={dbtConfig?.dbtUpdateDescriptions}
enableDebugLog={data.enableDebugLog}
handleCatalogHttpPathChange={(val) => {
updateDbtConfig('dbtCatalogHttpPath', val);
}}
handleEnableDebugLogCheck={handleEnableDebugLogCheck}
handleManifestHttpPathChange={(val) => {
updateDbtConfig('dbtManifestHttpPath', val);
}}
@ -188,6 +199,8 @@ const DBTConfigFormBuilder: FunctionComponent<DBTConfigFormProps> = ({
dbtPrefixConfig={dbtConfig?.dbtPrefixConfig}
dbtSecurityConfig={dbtConfig?.dbtSecurityConfig}
dbtUpdateDescriptions={dbtConfig?.dbtUpdateDescriptions}
enableDebugLog={data.enableDebugLog}
handleEnableDebugLogCheck={handleEnableDebugLogCheck}
handlePrefixConfigChange={(val) => {
updateDbtConfig('dbtPrefixConfig', val);
}}
@ -231,7 +244,9 @@ const DBTConfigFormBuilder: FunctionComponent<DBTConfigFormProps> = ({
dbtPrefixConfig={dbtConfig?.dbtPrefixConfig}
dbtSecurityConfig={dbtConfig?.dbtSecurityConfig}
dbtUpdateDescriptions={dbtConfig?.dbtUpdateDescriptions}
enableDebugLog={data.enableDebugLog}
gcsType={gcsConfigType}
handleEnableDebugLogCheck={handleEnableDebugLogCheck}
handleGcsTypeChange={handleGcsTypeChange}
handlePrefixConfigChange={(val) => {
updateDbtConfig('dbtPrefixConfig', val);

View File

@ -12,6 +12,10 @@
*/
import { fireEvent, getByTestId, render } from '@testing-library/react';
import {
DBTBucketDetails,
SCredentials,
} from 'generated/metadataIngestion/dbtPipeline';
import React from 'react';
import { GCS_CONFIG } from './DBTFormEnum';
import { DBTGCSConfig } from './DBTGCSConfig';
@ -22,6 +26,7 @@ const mockPrefixConfigChange = jest.fn();
const mockSecurityConfigChange = jest.fn();
const mockUpdateDescriptions = jest.fn();
const mockUpdateDBTClassification = jest.fn();
const mockHandleEnableDebugLogCheck = jest.fn();
const gsConfig = {
authProviderX509CertUrl: 'url',
@ -56,6 +61,11 @@ const mockProps = {
handleSecurityConfigChange: mockSecurityConfigChange,
handleUpdateDescriptions: mockUpdateDescriptions,
handleUpdateDBTClassification: mockUpdateDBTClassification,
enableDebugLog: false,
handleEnableDebugLogCheck: mockHandleEnableDebugLogCheck,
dbtClassificationName: '',
dbtSecurityConfig: {} as SCredentials,
dbtPrefixConfig: {} as DBTBucketDetails,
};
jest.mock('./DBTCommonFields.component', () =>

View File

@ -46,6 +46,8 @@ interface Props extends DBTFormCommonProps, DbtConfigS3GCS {
handlePrefixConfigChange: (value: DBTBucketDetails) => void;
handleUpdateDescriptions: (value: boolean) => void;
handleUpdateDBTClassification: (value: string) => void;
enableDebugLog: boolean;
handleEnableDebugLogCheck: (value: boolean) => void;
}
export const DBTGCSConfig: FunctionComponent<Props> = ({
@ -63,6 +65,8 @@ export const DBTGCSConfig: FunctionComponent<Props> = ({
handleUpdateDescriptions,
dbtClassificationName,
handleUpdateDBTClassification,
enableDebugLog,
handleEnableDebugLogCheck,
}: Props) => {
const isMounted = useRef<boolean>(false);
const updateGCSCredsConfig = (
@ -439,6 +443,8 @@ export const DBTGCSConfig: FunctionComponent<Props> = ({
dbtClassificationName={dbtClassificationName}
dbtUpdateDescriptions={dbtUpdateDescriptions}
descriptionId="gcs-update-description"
enableDebugLog={enableDebugLog}
handleEnableDebugLogCheck={handleEnableDebugLogCheck}
handleUpdateDBTClassification={handleUpdateDBTClassification}
handleUpdateDescriptions={handleUpdateDescriptions}
/>

View File

@ -22,6 +22,7 @@ const mockManifestChange = jest.fn();
const mockRunResultsHttpPathChange = jest.fn();
const mockUpdateDescriptions = jest.fn();
const mockUpdateDBTClassification = jest.fn();
const mockHandleEnableDebugLogCheck = jest.fn();
jest.mock('./DBTCommonFields.component', () =>
jest.fn().mockImplementation(() => <div>DBT Common Fields</div>)
@ -41,6 +42,8 @@ const mockProps = {
handleRunResultsHttpPathChange: mockRunResultsHttpPathChange,
handleUpdateDescriptions: mockUpdateDescriptions,
handleUpdateDBTClassification: mockUpdateDBTClassification,
enableDebugLog: false,
handleEnableDebugLogCheck: mockHandleEnableDebugLogCheck,
};
describe('Test DBT Http Config Form', () => {

View File

@ -35,6 +35,8 @@ interface Props extends DBTFormCommonProps, DbtConfigHttp {
handleRunResultsHttpPathChange: (value: string) => void;
handleUpdateDescriptions: (value: boolean) => void;
handleUpdateDBTClassification: (value: string) => void;
enableDebugLog: boolean;
handleEnableDebugLogCheck: (value: boolean) => void;
}
export const DBTHttpConfig: FunctionComponent<Props> = ({
@ -52,6 +54,8 @@ export const DBTHttpConfig: FunctionComponent<Props> = ({
handleUpdateDescriptions,
dbtClassificationName,
handleUpdateDBTClassification,
enableDebugLog,
handleEnableDebugLogCheck,
}: Props) => {
const [errors, setErrors] = useState<ErrorDbtHttp>();
const { t } = useTranslation();
@ -143,6 +147,8 @@ export const DBTHttpConfig: FunctionComponent<Props> = ({
dbtClassificationName={dbtClassificationName}
dbtUpdateDescriptions={dbtUpdateDescriptions}
descriptionId="http-update-description"
enableDebugLog={enableDebugLog}
handleEnableDebugLogCheck={handleEnableDebugLogCheck}
handleUpdateDBTClassification={handleUpdateDBTClassification}
handleUpdateDescriptions={handleUpdateDescriptions}
/>

View File

@ -22,6 +22,7 @@ const mockManifestChange = jest.fn();
const mockRunResultsFilePathChange = jest.fn();
const mockUpdateDescriptions = jest.fn();
const mockUpdateDBTClassification = jest.fn();
const mockHandleEnableDebugLogCheck = jest.fn();
const mockProps = {
dbtCatalogFilePath: '',
@ -37,6 +38,8 @@ const mockProps = {
handleRunResultsFilePathChange: mockRunResultsFilePathChange,
handleUpdateDescriptions: mockUpdateDescriptions,
handleUpdateDBTClassification: mockUpdateDBTClassification,
enableDebugLog: false,
handleEnableDebugLogCheck: mockHandleEnableDebugLogCheck,
};
jest.mock('./DBTCommonFields.component', () =>

View File

@ -35,6 +35,8 @@ interface Props extends DBTFormCommonProps, DbtConfigLocal {
handleRunResultsFilePathChange: (value: string) => void;
handleUpdateDescriptions: (value: boolean) => void;
handleUpdateDBTClassification: (value: string) => void;
enableDebugLog: boolean;
handleEnableDebugLogCheck: (value: boolean) => void;
}
export const DBTLocalConfig: FunctionComponent<Props> = ({
@ -52,6 +54,8 @@ export const DBTLocalConfig: FunctionComponent<Props> = ({
handleUpdateDescriptions,
dbtClassificationName,
handleUpdateDBTClassification,
enableDebugLog,
handleEnableDebugLogCheck,
}: Props) => {
const [errors, setErrors] = useState<ErrorDbtLocal>();
@ -144,6 +148,8 @@ export const DBTLocalConfig: FunctionComponent<Props> = ({
dbtClassificationName={dbtClassificationName}
dbtUpdateDescriptions={dbtUpdateDescriptions}
descriptionId="local-update-description"
enableDebugLog={enableDebugLog}
handleEnableDebugLogCheck={handleEnableDebugLogCheck}
handleUpdateDBTClassification={handleUpdateDBTClassification}
handleUpdateDescriptions={handleUpdateDescriptions}
/>

View File

@ -21,6 +21,7 @@ const mockPrefixConfigChange = jest.fn();
const mockSecurityConfigChange = jest.fn();
const mockUpdateDescriptions = jest.fn();
const mockUpdateDBTClassification = jest.fn();
const mockHandleEnableDebugLogCheck = jest.fn();
const mockProps = {
okText: 'Next',
@ -32,6 +33,8 @@ const mockProps = {
handleSecurityConfigChange: mockSecurityConfigChange,
handleUpdateDescriptions: mockUpdateDescriptions,
handleUpdateDBTClassification: mockUpdateDBTClassification,
enableDebugLog: false,
handleEnableDebugLogCheck: mockHandleEnableDebugLogCheck,
};
jest.mock('./DBTCommonFields.component', () =>

View File

@ -41,6 +41,8 @@ interface Props extends DBTFormCommonProps, DbtConfigS3GCS {
handlePrefixConfigChange: (value: DBTBucketDetails) => void;
handleUpdateDescriptions: (value: boolean) => void;
handleUpdateDBTClassification: (value: string) => void;
enableDebugLog: boolean;
handleEnableDebugLogCheck: (value: boolean) => void;
}
export const DBTS3Config: FunctionComponent<Props> = ({
@ -56,6 +58,8 @@ export const DBTS3Config: FunctionComponent<Props> = ({
handlePrefixConfigChange,
handleUpdateDescriptions,
handleUpdateDBTClassification,
enableDebugLog,
handleEnableDebugLogCheck,
}: Props) => {
const updateS3Creds = (key: keyof SCredentials, val: string) => {
const updatedCreds: SCredentials = {
@ -239,6 +243,8 @@ export const DBTS3Config: FunctionComponent<Props> = ({
dbtClassificationName={dbtClassificationName}
dbtUpdateDescriptions={dbtUpdateDescriptions}
descriptionId="s3-update-description"
enableDebugLog={enableDebugLog}
handleEnableDebugLogCheck={handleEnableDebugLogCheck}
handleUpdateDBTClassification={handleUpdateDBTClassification}
handleUpdateDescriptions={handleUpdateDescriptions}
/>