Skip to content

Commit bf4ba5b

Browse files
authored
Merge branch 'main' into hide-uptime
2 parents 1a5b56f + e5db0db commit bf4ba5b

5 files changed

Lines changed: 96 additions & 1 deletion

File tree

test/functional/services/common/find.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,16 @@ export class FindService extends FtrService {
307307
}, timeout);
308308
}
309309

310+
public async existsByXpath(
311+
selector: string,
312+
timeout: number = this.WAIT_FOR_EXISTS_TIME
313+
): Promise<boolean> {
314+
this.log.debug(`Find.existsByXpath('${selector}') with timeout=${timeout}`);
315+
return await this.exists(async (drive) => {
316+
return this.wrapAll(await drive.findElements(By.xpath(selector)));
317+
}, timeout);
318+
}
319+
310320
public async clickByCssSelectorWhenNotDisabled(selector: string, opts?: TimeoutOpt) {
311321
const timeout = opts?.timeout ?? this.defaultFindTimeout;
312322

x-pack/plugins/apm/dev_docs/testing.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ node x-pack/plugins/apm/scripts/test/e2e --server
9797
node x-pack/plugins/apm/scripts/test/e2e --runner --open
9898
```
9999

100+
### Rum tests multiple times to check for flakiness
101+
102+
```
103+
node x-pack/plugins/apm/scripts/test/e2e --runner --times <NUMBER> [--spec <FILE_NAME>]
104+
```
105+
100106
### A11y checks
101107

102108
Accessibility tests are added on the e2e with `checkA11y()`, they will run together with cypress.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Testing APM Server changes with Tilt
2+
3+
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.
4+
5+
## Prerequisites
6+
7+
- Docker must be installed and running on your local system.
8+
- You should have the APM Server repo checked out which contains the Tiltfile.
9+
10+
## Setup
11+
12+
There are two methods to start your Kubernetes cluster using Tilt:
13+
14+
- With a Kibana Docker container started as part of the Kubernetes cluster.
15+
- Connecting to a locally running Kibana instance.
16+
17+
### Starting Kibana as a Docker container
18+
19+
By default, when running `tilt up` without any additional configuration, Tilt will start a Kibana Docker container as part of the Kubernetes cluster:
20+
21+
`$ tilt up`
22+
23+
### Connecting to a locally running Kibana instance
24+
25+
If you want to run Kibana locally and connect it with the Kubernetes cluster, follow these steps:
26+
27+
- Start your local Kibana instance (`yarn start`)
28+
- Navigate to the APM Server Repo and start Tilt with the '--local-kibana' flag: `$ tilt up -- --local-kibana`
29+
30+
**Note**: You should start the local Kibana instance before or immediately after running the Tilt command.
31+
32+
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:
33+
34+
```
35+
elasticsearch.username: kibana_system_user
36+
elasticsearch.password: changeme
37+
```
38+
39+
### Building and Uploading APM Server Package
40+
41+
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.

x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
RuleActionFrequency,
2626
RuleActionParam,
2727
} from '@kbn/alerting-plugin/common';
28+
import { v4 as uuidv4 } from 'uuid';
2829
import { betaBadgeProps } from './beta_badge_props';
2930
import { loadActionTypes, loadAllActions as loadConnectors } from '../../lib/action_connector_api';
3031
import {
@@ -242,6 +243,7 @@ export const ActionForm = ({
242243
group: defaultActionGroupId,
243244
params: {},
244245
frequency: defaultRuleFrequency,
246+
uuid: uuidv4(),
245247
});
246248
setActionIdByIndex(actionTypeConnectors[0].id, actions.length - 1);
247249
} else {
@@ -255,6 +257,7 @@ export const ActionForm = ({
255257
group: defaultActionGroupId,
256258
params: {},
257259
frequency: DEFAULT_FREQUENCY,
260+
uuid: uuidv4(),
258261
});
259262
setActionIdByIndex(actionTypeConnectors[0].id, actions.length - 1);
260263
}
@@ -427,7 +430,7 @@ export const ActionForm = ({
427430
actionItem={actionItem}
428431
actionConnector={actionConnector}
429432
index={index}
430-
key={`action-form-action-at-${index}`}
433+
key={`action-form-action-at-${actionItem.uuid}`}
431434
setActionParamsProperty={setActionParamsProperty}
432435
setActionFrequencyProperty={setActionFrequencyProperty}
433436
setActionAlertsFilterProperty={setActionAlertsFilterProperty}

x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alert_create_flyout.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,41 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
8585
await testSubjects.click('rulesTab');
8686
});
8787

88+
it('should delete the right action when the same action has been added twice', async () => {
89+
// create a new rule
90+
const ruleName = generateUniqueKey();
91+
await rules.common.defineIndexThresholdAlert(ruleName);
92+
93+
// create webhook connector
94+
await testSubjects.click('.webhook-alerting-ActionTypeSelectOption');
95+
await testSubjects.click('createActionConnectorButton-0');
96+
await testSubjects.setValue('nameInput', 'webhook-test');
97+
await testSubjects.setValue('webhookUrlText', 'https://test.test');
98+
await testSubjects.setValue('webhookUserInput', 'fakeuser');
99+
await testSubjects.setValue('webhookPasswordInput', 'fakepassword');
100+
101+
// save rule
102+
await find.clickByCssSelector('[data-test-subj="saveActionButtonModal"]:not(disabled)');
103+
await find.setValueByClass('kibanaCodeEditor', 'myUniqueKey');
104+
await testSubjects.click('saveRuleButton');
105+
106+
// add new action and remove first one
107+
await testSubjects.click('ruleSidebarEditAction');
108+
await testSubjects.click('.webhook-alerting-ActionTypeSelectOption');
109+
await find.clickByCssSelector(
110+
'[data-test-subj="alertActionAccordion-0"] [aria-label="Delete"]'
111+
);
112+
113+
// check that the removed action is the right one
114+
const doesExist = await find.existsByXpath(".//*[text()='myUniqueKey']");
115+
expect(doesExist).to.eql(false);
116+
117+
// clean up created alert
118+
const alertsToDelete = await getAlertsByName(ruleName);
119+
await deleteAlerts(alertsToDelete.map((rule: { id: string }) => rule.id));
120+
expect(true).to.eql(true);
121+
});
122+
88123
it('should create an alert', async () => {
89124
const alertName = generateUniqueKey();
90125
await rules.common.defineIndexThresholdAlert(alertName);

0 commit comments

Comments
 (0)