Skip to content

Commit

Permalink
Merge branch 'main' into issue-153765
Browse files Browse the repository at this point in the history
  • Loading branch information
angorayc authored Jun 12, 2023
2 parents fcfefa0 + 70472fd commit 356ef27
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 39 deletions.
2 changes: 1 addition & 1 deletion docs/developer/plugin/plugin-tooling.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ WARNING: {kib} distributable is not shipped with `@kbn/optimizer` anymore. You n

You can leverage {kib-repo}blob/{branch}/packages/kbn-plugin-helpers[@kbn/plugin-helpers] to build a distributable archive for your plugin.
The package transpiles the plugin code, adds polyfills, and links necessary js modules in the runtime.
You don't need to install the `plugin-helpers`: the `package.json` is already pre-configured if you created your plugin with `node scripts/generate_plugin` script.
You don't need to install the `plugin-helpers` dependency. If you created the plugin using `node scripts/generate_plugin` script, `package.json` is already pre-configured.
To build your plugin run within your plugin folder:
["source","shell"]
-----------
Expand Down
6 changes: 6 additions & 0 deletions x-pack/plugins/apm/dev_docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ node x-pack/plugins/apm/scripts/test/e2e --server
node x-pack/plugins/apm/scripts/test/e2e --runner --open
```

### Rum tests multiple times to check for flakiness

```
node x-pack/plugins/apm/scripts/test/e2e --runner --times <NUMBER> [--spec <FILE_NAME>]
```

### A11y checks

Accessibility tests are added on the e2e with `checkA11y()`, they will run together with cypress.
Expand Down
41 changes: 41 additions & 0 deletions x-pack/plugins/apm/dev_docs/testing_apm_server.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Testing APM Server changes with Tilt

This document provides instructions on how to use Tilt to start a local Kubernetes (k8s) cluster for APM Server development that communicates with a local Kibana instance. This is useful when you want to test recent changes in APM Server, as the bundled or published package might not be available yet.

## Prerequisites

- Docker must be installed and running on your local system.
- You should have the APM Server repo checked out which contains the Tiltfile.

## Setup

There are two methods to start your Kubernetes cluster using Tilt:

- With a Kibana Docker container started as part of the Kubernetes cluster.
- Connecting to a locally running Kibana instance.

### Starting Kibana as a Docker container

By default, when running `tilt up` without any additional configuration, Tilt will start a Kibana Docker container as part of the Kubernetes cluster:

`$ tilt up`

### Connecting to a locally running Kibana instance

If you want to run Kibana locally and connect it with the Kubernetes cluster, follow these steps:

- Start your local Kibana instance (`yarn start`)
- Navigate to the APM Server Repo and start Tilt with the '--local-kibana' flag: `$ tilt up -- --local-kibana`

**Note**: You should start the local Kibana instance before or immediately after running the Tilt command.

As part of the Tilt setup, a `kibana_system_user` is created with the password `changeme`. You can use this user and password for your `kibana.yml` file:

```
elasticsearch.username: kibana_system_user
elasticsearch.password: changeme
```

### Building and Uploading APM Server Package

When you start Tilt, the APM Server package is built from the source and uploaded to Kibana automatically. This allows you to test recent changes in your APM Server.
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@ import {
type ControlGroupInput,
} from '@kbn/controls-plugin/public';
import { ViewMode } from '@kbn/embeddable-plugin/public';
import { compareFilters, COMPARE_ALL_OPTIONS, Filter, Query, TimeRange } from '@kbn/es-query';
import type { Filter, Query, TimeRange } from '@kbn/es-query';
import { DataView } from '@kbn/data-views-plugin/public';
import { skipWhile, Subscription } from 'rxjs';
import { Subscription } from 'rxjs';
import { useControlPanels } from '../../hooks/use_control_panels_url_state';

interface Props {
dataView: DataView | undefined;
timeRange: TimeRange;
filters: Filter[];
selectedOptions: Filter[];
query: Query;
onFiltersChange: (filters: Filter[]) => void;
}
Expand All @@ -30,13 +29,11 @@ export const ControlsContent: React.FC<Props> = ({
dataView,
filters,
query,
selectedOptions,
timeRange,
onFiltersChange,
}) => {
const [controlPanels, setControlPanels] = useControlPanels(dataView);
const inputSubscription = useRef<Subscription>();
const filterSubscription = useRef<Subscription>();
const subscriptions = useRef<Subscription>(new Subscription());

const getInitialInput = useCallback(async () => {
const initialInput: Partial<ControlGroupInput> = {
Expand All @@ -57,27 +54,24 @@ export const ControlsContent: React.FC<Props> = ({
const loadCompleteHandler = useCallback(
(controlGroup: ControlGroupAPI) => {
if (!controlGroup) return;
inputSubscription.current = controlGroup.onFiltersPublished$
.pipe(
skipWhile((newFilters) =>
compareFilters(selectedOptions, newFilters, COMPARE_ALL_OPTIONS)
)
)
.subscribe((newFilters) => {

subscriptions.current.add(
controlGroup.onFiltersPublished$.subscribe((newFilters) => {
onFiltersChange(newFilters);
});
})
);

filterSubscription.current = controlGroup
.getInput$()
.subscribe(({ panels }) => setControlPanels(panels));
subscriptions.current.add(
controlGroup.getInput$().subscribe(({ panels }) => setControlPanels(panels))
);
},
[onFiltersChange, setControlPanels, selectedOptions]
[onFiltersChange, setControlPanels]
);

useEffect(() => {
const currentSubscriptions = subscriptions.current;
return () => {
filterSubscription.current?.unsubscribe();
inputSubscription.current?.unsubscribe();
currentSubscriptions.unsubscribe();
};
}, []);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ interface Props {

export const LimitOptions = ({ limit, onChange }: Props) => {
const [idSelected, setIdSelected] = useState(limit as number);
const onSelected = (value: number) => {
const onSelected = (_id: string, value: number) => {
setIdSelected(value);
onChange(value);
};
Expand Down Expand Up @@ -70,7 +70,7 @@ export const LimitOptions = ({ limit, onChange }: Props) => {
})}
idSelected={buildId(idSelected)}
options={options}
onChange={(_, value: number) => onSelected(value)}
onChange={onSelected}
/>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,8 @@
* 2.0.
*/

import React, { useMemo } from 'react';
import {
compareFilters,
COMPARE_ALL_OPTIONS,
type Query,
type TimeRange,
type Filter,
} from '@kbn/es-query';
import React, { useCallback, useMemo } from 'react';
import type { Query, TimeRange, Filter } from '@kbn/es-query';
import { i18n } from '@kbn/i18n';
import {
EuiFlexGrid,
Expand Down Expand Up @@ -42,11 +36,12 @@ export const UnifiedSearchBar = () => {
onSubmit({ limit });
};

const onPanelFiltersChange = (panelFilters: Filter[]) => {
if (!compareFilters(searchCriteria.panelFilters, panelFilters, COMPARE_ALL_OPTIONS)) {
const onPanelFiltersChange = useCallback(
(panelFilters: Filter[]) => {
onSubmit({ panelFilters });
}
};
},
[onSubmit]
);

const handleRefresh = (payload: { query?: Query; dateRange: TimeRange }, isUpdate?: boolean) => {
// This makes sure `onQueryChange` is only called when the submit button is clicked
Expand Down Expand Up @@ -83,7 +78,6 @@ export const UnifiedSearchBar = () => {
dataView={dataView}
query={searchCriteria.query}
filters={searchCriteria.filters}
selectedOptions={searchCriteria.panelFilters}
onFiltersChange={onPanelFiltersChange}
/>
</EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import {
export default function (providerContext: FtrProviderContext) {
const { loadTestFile, getService } = providerContext;

describe('endpoint', function () {
// FAILING: https://github.com/elastic/kibana/issues/72874
describe.skip('endpoint', function () {
const ingestManager = getService('ingestManager');
const log = getService('log');
const endpointTestResources = getService('endpointTestResources');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import {
export default function (providerContext: FtrProviderContext) {
const { loadTestFile, getService } = providerContext;

describe('endpoint', function () {
// FAILING: https://github.com/elastic/kibana/issues/159450
describe.skip('endpoint', function () {
const ingestManager = getService('ingestManager');
const log = getService('log');
const endpointTestResources = getService('endpointTestResources');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ export default function ({ getService }: FtrProviderContext) {
body: Record<string, unknown> | undefined;
}

describe('When attempting to call an endpoint api', () => {
// Failing: See https://github.com/elastic/kibana/issues/147640
describe.skip('When attempting to call an endpoint api', () => {
let indexedData: IndexedHostsAndAlertsResponse;
let actionId = '';
let agentId = '';
Expand Down

0 comments on commit 356ef27

Please sign in to comment.