Skip to content

Commit

Permalink
Merge branch 'main' into path-rn-8-11-2
Browse files Browse the repository at this point in the history
  • Loading branch information
lcawl authored Dec 12, 2023
2 parents 29b2fdc + fe0ad5a commit 30445d1
Show file tree
Hide file tree
Showing 69 changed files with 1,061 additions and 276 deletions.
5 changes: 5 additions & 0 deletions .buildkite/pipelines/quality-gates/pipeline.kibana-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
#
# Docs: https://docs.elastic.dev/serverless/qualitygates

agents:
cpu: 2
ephemeralStorage: "20G"
memory: "8G"

env:
TEAM_CHANNEL: "#kibana-mission-control"
ENVIRONMENT: ${ENVIRONMENT?}
Expand Down
2 changes: 1 addition & 1 deletion examples/README.asciidoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[[example-plugins]]
== Example plugins

This folder contains example plugins. To run the plugins in this folder, use the `--run-examples` flag, via
This folder contains example plugins. To run the plugins in this folder, use the `--run-examples` flag (without a basepath), via

[source,bash]
----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ export function ProfilingOverview() {
environment={environment}
dataSource={preferred?.source}
kuery={kuery}
rangeFrom={rangeFrom}
rangeTo={rangeTo}
/>
</>
),
Expand All @@ -99,12 +101,23 @@ export function ProfilingOverview() {
endIndex={10}
dataSource={preferred?.source}
kuery={kuery}
rangeFrom={rangeFrom}
rangeTo={rangeTo}
/>
</>
),
},
];
}, [end, environment, kuery, preferred?.source, serviceName, start]);
}, [
end,
environment,
kuery,
preferred?.source,
rangeFrom,
rangeTo,
serviceName,
start,
]);

if (isLoading) {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ interface Props {
ApmDocumentType.TransactionMetric | ApmDocumentType.TransactionEvent
>;
kuery: string;
rangeFrom: string;
rangeTo: string;
}

export function ProfilingFlamegraph({
Expand All @@ -49,6 +51,8 @@ export function ProfilingFlamegraph({
environment,
dataSource,
kuery,
rangeFrom,
rangeTo,
}: Props) {
const { profilingLocators } = useProfilingPlugin();

Expand Down Expand Up @@ -93,6 +97,8 @@ export function ProfilingFlamegraph({
data-test-subj="apmProfilingFlamegraphGoToFlamegraphLink"
href={profilingLocators?.flamegraphLocator.getRedirectUrl({
kuery: mergeKueries([`(${hostNamesKueryFormat})`, kuery]),
rangeFrom,
rangeTo,
})}
>
{i18n.translate('xpack.apm.profiling.flamegraph.link', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ interface Props {
ApmDocumentType.TransactionMetric | ApmDocumentType.TransactionEvent
>;
kuery: string;
rangeFrom: string;
rangeTo: string;
}

export function ProfilingTopNFunctions({
Expand All @@ -42,6 +44,8 @@ export function ProfilingTopNFunctions({
endIndex,
dataSource,
kuery,
rangeFrom,
rangeTo,
}: Props) {
const { profilingLocators } = useProfilingPlugin();

Expand Down Expand Up @@ -97,6 +101,8 @@ export function ProfilingTopNFunctions({
data-test-subj="apmProfilingTopNFunctionsGoToUniversalProfilingFlamegraphLink"
href={profilingLocators?.topNFunctionsLocator.getRedirectUrl({
kuery: mergeKueries([`(${hostNamesKueryFormat})`, kuery]),
rangeFrom,
rangeTo,
})}
>
{i18n.translate('xpack.apm.profiling.topnFunctions.link', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ const AzureAccountTypeSelect = ({
updatePolicy(
getPosturePolicy(newPolicy, input.type, {
'azure.account_type': {
value: AZURE_SINGLE_ACCOUNT,
value: isAzureOrganizationDisabled ? AZURE_SINGLE_ACCOUNT : AZURE_ORGANIZATION_ACCOUNT,
type: 'text',
},
'azure.credentials.type': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
EuiTabbedContentTab,
EuiTitle,
EuiText,
EuiTextColor,
} from '@elastic/eui';

import { i18n } from '@kbn/i18n';
Expand Down Expand Up @@ -130,15 +131,27 @@ export const ConfigurePipeline: React.FC = () => {
<EuiSpacer />
</>
)}
<EuiFormRow
fullWidth
label={i18n.translate(
'xpack.enterpriseSearch.content.indices.pipelines.addInferencePipelineModal.steps.configure.titleSelectTrainedModel',
{ defaultMessage: 'Select a trained ML Model' }
)}
>
<ModelSelect />
</EuiFormRow>
<EuiSpacer size="s" />
<EuiTitle size="xxxs">
<h6>
{i18n.translate(
'xpack.enterpriseSearch.content.indices.pipelines.addInferencePipelineModal.steps.configure.titleSelectTrainedModel',
{ defaultMessage: 'Select a trained ML Model' }
)}
</h6>
</EuiTitle>
{formErrors.modelStatus !== undefined && (
<>
<EuiSpacer size="xs" />
<EuiText size="xs">
<p>
<EuiTextColor color="danger">{formErrors.modelStatus}</EuiTextColor>
</p>
</EuiText>
</>
)}
<EuiSpacer size="xs" />
<ModelSelect />
</EuiForm>
</>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,25 @@ describe('MlInferenceLogic', () => {
pipelineName: 'Name already used by another pipeline.',
});
});
it('has errors when non-deployed model is selected', () => {
MLInferenceLogic.actions.setInferencePipelineConfiguration({
...MLInferenceLogic.values.addInferencePipelineModal.configuration,
pipelineName: 'unit-test-pipeline',
modelID: 'unit-test-model',
existingPipeline: false,
fieldMappings: [
{
sourceField: 'body',
targetField: 'ml.inference.body',
},
],
isModelPlaceholderSelected: true,
});

expect(MLInferenceLogic.values.formErrors).toEqual({
modelStatus: 'Model must be deployed before use.',
});
});
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,23 @@ describe('ModelSelect', () => {
})
);
});
it('sets placeholder flag on selecting a placeholder item', () => {
setMockValues(DEFAULT_VALUES);

const wrapper = shallow(<ModelSelect />);
expect(wrapper.find(EuiSelectable)).toHaveLength(1);
const selectable = wrapper.find(EuiSelectable);
selectable.simulate('change', [
{ modelId: 'model_1' },
{ modelId: 'model_2', isPlaceholder: true, checked: 'on' },
]);
expect(MOCK_ACTIONS.setInferencePipelineConfiguration).toHaveBeenCalledWith(
expect.objectContaining({
modelID: 'model_2',
isModelPlaceholderSelected: true,
})
);
});
it('generates pipeline name on selecting an item', () => {
setMockValues(DEFAULT_VALUES);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const ModelSelect: React.FC = () => {
...configuration,
inferenceConfig: undefined,
modelID: selectedOption?.modelId ?? '',
isModelPlaceholderSelected: selectedOption?.isPlaceholder ?? false,
fieldMappings: undefined,
pipelineName: isPipelineNameUserSupplied
? pipelineName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface InferencePipelineConfiguration {
existingPipeline?: boolean;
inferenceConfig?: InferencePipelineInferenceConfig;
isPipelineNameUserSupplied?: boolean;
isModelPlaceholderSelected?: boolean;
modelID: string;
pipelineName: string;
fieldMappings?: FieldMapping[];
Expand All @@ -21,6 +22,7 @@ export interface InferencePipelineConfiguration {

export interface AddInferencePipelineFormErrors {
modelID?: string;
modelStatus?: string;
fieldMappings?: string;
pipelineName?: string;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ const PIPELINE_NAME_EXISTS_ERROR = i18n.translate(
defaultMessage: 'Name already used by another pipeline.',
}
);
const MODEL_NOT_DEPLOYED_ERROR = i18n.translate(
'xpack.enterpriseSearch.content.indices.pipelines.addInferencePipelineModal.steps.configure.modelNotDeployedError',
{
defaultMessage: 'Model must be deployed before use.',
}
);

export const validateInferencePipelineConfiguration = (
config: InferencePipelineConfiguration
Expand All @@ -55,6 +61,8 @@ export const validateInferencePipelineConfiguration = (
}
if (config.modelID.trim().length === 0) {
errors.modelID = FIELD_REQUIRED_ERROR;
} else if (config.isModelPlaceholderSelected) {
errors.modelStatus = MODEL_NOT_DEPLOYED_ERROR;
}

return errors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,20 @@ describe('SecretFormRow', () => {

expect(onUsePlainText).toHaveBeenCalled();
});

it('should not display the cancel change button when no initial value is provided', () => {
const { queryByTestId } = render(
<SecretFormRow
title={title}
clear={clear}
onUsePlainText={onUsePlainText}
cancelEdit={cancelEdit}
initialValue={''}
>
<input type="text" />
</SecretFormRow>
);

expect(queryByTestId('secretCancelChangeBtn')).not.toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const SecretFormRow: React.FC<{
onUsePlainText,
cancelEdit,
}) => {
const hasInitialValue = initialValue !== undefined;
const hasInitialValue = !!initialValue;
const [editMode, setEditMode] = useState(!initialValue);
const valueHiddenPanel = (
<EuiPanel color="subdued" borderRadius="none" hasShadow={false}>
Expand Down Expand Up @@ -98,7 +98,7 @@ export const SecretFormRow: React.FC<{
<>
{children}
{hasInitialValue && (
<EuiFlexGroup justifyContent="flexEnd">
<EuiFlexGroup justifyContent="flexEnd" data-test-subj="secretCancelChangeBtn">
<EuiFlexItem grow={false}>{cancelButton}</EuiFlexItem>
</EuiFlexGroup>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe('OutputHealth', () => {

await waitFor(async () => {
expect(utils.getByTestId('outputHealthDegradedCallout').textContent).toContain(
'Unable to connect to "Remote ES" at https://remote-es:443. Please check the details are correct.'
'Unable to connect to "Remote ES" at https://remote-es:443.Please check the details are correct.'
);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ export const OutputHealth: React.FunctionComponent<Props> = ({ output, showBadge
iconType="error"
data-test-subj="outputHealthDegradedCallout"
>
<p>
<p className="eui-textBreakWord">
{i18n.translate('xpack.fleet.output.calloutText', {
defaultMessage: 'Unable to connect to "{name}" at {host}.',
values: {
name: output.name,
host: output.hosts?.join(',') ?? '',
},
})}
</p>{' '}
</p>
<p>
{i18n.translate('xpack.fleet.output.calloutPromptText', {
defaultMessage: 'Please check the details are correct.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,30 @@
* 2.0.
*/

import { securityMock } from '@kbn/security-plugin/server/mocks';
import { loggerMock } from '@kbn/logging-mocks';

import type { Logger } from '@kbn/core/server';

import { appContextService } from '../../server/services/app_context';

import { verifyAllTestPackages } from './verify_test_packages';

jest.mock('../../server/services/app_context');

const mockedAppContextService = appContextService as jest.Mocked<typeof appContextService>;
mockedAppContextService.getSecuritySetup.mockImplementation(() => ({
...securityMock.createSetup(),
}));

let mockedLogger: jest.Mocked<Logger>;

describe('Test packages', () => {
beforeEach(() => {
mockedLogger = loggerMock.create();
mockedAppContextService.getLogger.mockReturnValue(mockedLogger);
});

test('All test packages should be valid (node scripts/verify_test_packages) ', async () => {
const { errors } = await verifyAllTestPackages();
expect(errors).toEqual([]);
Expand Down
Loading

0 comments on commit 30445d1

Please sign in to comment.