This repository has been archived by the owner on Sep 10, 2024. It is now read-only.
forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Uptime] UI Monitor Management/Synthetics Service e2e tests - add env…
…ironment variables for service (elastic#122552) * add environment variables for service * add SYNTHETICS_SERVICE_MANIFEST and basic tests * Update x-pack/plugins/uptime/e2e/playwright_run.ts Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
fc64d17
commit 5789546
Showing
9 changed files
with
413 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
136 changes: 136 additions & 0 deletions
136
x-pack/plugins/uptime/e2e/journeys/monitor_management.journey.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { journey, step, expect, before, Page } from '@elastic/synthetics'; | ||
import { monitorManagementPageProvider } from '../page_objects/monitor_management'; | ||
|
||
journey('Monitor Management', async ({ page, params }: { page: Page; params: any }) => { | ||
const uptime = monitorManagementPageProvider({ page, kibanaUrl: params.kibanaUrl }); | ||
const basicMonitorDetails = { | ||
name: 'Sample monitor', | ||
location: 'US Central', | ||
schedule: '@every 3m', | ||
apmServiceName: 'service', | ||
}; | ||
|
||
const deleteMonitor = async () => { | ||
const isSuccessful = await uptime.deleteMonitor(); | ||
expect(isSuccessful).toBeTruthy(); | ||
}; | ||
|
||
before(async () => { | ||
await uptime.waitForLoadingToFinish(); | ||
}); | ||
|
||
step('Go to monitor-management', async () => { | ||
await uptime.navigateToMonitorManagement(); | ||
}); | ||
|
||
step('login to Kibana', async () => { | ||
await uptime.loginToKibana(); | ||
}); | ||
|
||
step('create monitor http monitor', async () => { | ||
const monitorDetails = { | ||
...basicMonitorDetails, | ||
url: 'https://elastic.co', | ||
locations: [basicMonitorDetails.location], | ||
}; | ||
await uptime.clickAddMonitor(); | ||
await uptime.createBasicHTTPMonitorDetails(monitorDetails); | ||
const isSuccessful = await uptime.confirmAndSave(); | ||
expect(isSuccessful).toBeTruthy(); | ||
}); | ||
|
||
step('view HTTP details in monitor management UI', async () => { | ||
const monitorDetails = { | ||
...basicMonitorDetails, | ||
url: 'https://elastic.co', | ||
}; | ||
await uptime.clickAddMonitor(); | ||
await uptime.findMonitorConfiguration(monitorDetails); | ||
}); | ||
|
||
step('delete http monitor', async () => { | ||
await deleteMonitor(); | ||
}); | ||
|
||
step('create monitor tcp monitor', async () => { | ||
const monitorDetails = { | ||
...basicMonitorDetails, | ||
host: 'smtp.gmail.com:587', | ||
locations: [basicMonitorDetails.location], | ||
}; | ||
await uptime.clickAddMonitor(); | ||
await uptime.createBasicTCPMonitorDetails(monitorDetails); | ||
const isSuccessful = await uptime.confirmAndSave(); | ||
expect(isSuccessful).toBeTruthy(); | ||
}); | ||
|
||
step('view TCP details in monitor management UI', async () => { | ||
const monitorDetails = { | ||
...basicMonitorDetails, | ||
host: 'smtp.gmail.com:587', | ||
}; | ||
await uptime.clickAddMonitor(); | ||
await uptime.findMonitorConfiguration(monitorDetails); | ||
}); | ||
|
||
step('delete tcp monitor', async () => { | ||
await deleteMonitor(); | ||
}); | ||
|
||
step('create basic ICMP monitor', async () => { | ||
const monitorDetails = { | ||
...basicMonitorDetails, | ||
host: '1.1.1.1', | ||
locations: [basicMonitorDetails.location], | ||
}; | ||
await uptime.clickAddMonitor(); | ||
await uptime.createBasicICMPMonitorDetails(monitorDetails); | ||
const isSuccessful = await uptime.confirmAndSave(); | ||
expect(isSuccessful).toBeTruthy(); | ||
}); | ||
|
||
step('view ICMP details in monitor management UI', async () => { | ||
const monitorDetails = { | ||
...basicMonitorDetails, | ||
host: '1.1.1.1', | ||
}; | ||
await uptime.clickAddMonitor(); | ||
await uptime.findMonitorConfiguration(monitorDetails); | ||
}); | ||
|
||
step('delete ICMP monitor', async () => { | ||
await deleteMonitor(); | ||
}); | ||
|
||
step('create basic Browser monitor', async () => { | ||
const monitorDetails = { | ||
...basicMonitorDetails, | ||
inlineScript: 'step("test step", () => {})', | ||
locations: [basicMonitorDetails.location], | ||
}; | ||
await uptime.clickAddMonitor(); | ||
await uptime.createBasicBrowserMonitorDetails(monitorDetails, true); | ||
const isSuccessful = await uptime.confirmAndSave(); | ||
expect(isSuccessful).toBeTruthy(); | ||
}); | ||
|
||
step('view ICMP details in monitor management UI', async () => { | ||
const monitorDetails = { | ||
...basicMonitorDetails, | ||
host: '1.1.1.1', | ||
}; | ||
await uptime.clickAddMonitor(); | ||
await uptime.findMonitorConfiguration(monitorDetails); | ||
}); | ||
|
||
step('delete ICMP monitor', async () => { | ||
await deleteMonitor(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import { Page } from '@elastic/synthetics'; | ||
|
||
export function loginPageProvider({ page }: { page: Page; kibanaUrl: string }) { | ||
return { | ||
async waitForLoadingToFinish() { | ||
while (true) { | ||
if ((await page.$('[data-test-subj=kbnLoadingMessage]')) === null) break; | ||
await page.waitForTimeout(5 * 1000); | ||
} | ||
}, | ||
async loginToKibana() { | ||
await page.fill('[data-test-subj=loginUsername]', 'elastic', { | ||
timeout: 60 * 1000, | ||
}); | ||
await page.fill('[data-test-subj=loginPassword]', 'changeme'); | ||
|
||
await page.click('[data-test-subj=loginSubmit]'); | ||
|
||
await this.waitForLoadingToFinish(); | ||
}, | ||
}; | ||
} |
183 changes: 183 additions & 0 deletions
183
x-pack/plugins/uptime/e2e/page_objects/monitor_management.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { Page } from '@elastic/synthetics'; | ||
import { loginPageProvider } from './login'; | ||
import { utilsPageProvider } from './utils'; | ||
|
||
export function monitorManagementPageProvider({ | ||
page, | ||
kibanaUrl, | ||
}: { | ||
page: Page; | ||
kibanaUrl: string; | ||
}) { | ||
const monitorManagement = `${kibanaUrl}/app/uptime/manage-monitors`; | ||
const addMonitor = `${kibanaUrl}/app/uptime/add-monitor`; | ||
|
||
return { | ||
...loginPageProvider({ page, kibanaUrl }), | ||
...utilsPageProvider({ page }), | ||
|
||
async navigateToMonitorManagement() { | ||
await page.goto(monitorManagement, { | ||
waitUntil: 'networkidle', | ||
}); | ||
}, | ||
|
||
async navigateToAddMonitor() { | ||
await page.goto(addMonitor, { | ||
waitUntil: 'networkidle', | ||
}); | ||
}, | ||
|
||
async clickAddMonitor() { | ||
await page.click('text=Add monitor'); | ||
}, | ||
|
||
async deleteMonitor() { | ||
await this.clickByTestSubj('monitorManagementDeleteMonitor'); | ||
return await this.findByTestSubj('uptimeDeleteMonitorSuccess'); | ||
}, | ||
|
||
async findMonitorConfiguration(monitorConfig: Record<string, string>) { | ||
const values = Object.values(monitorConfig); | ||
|
||
for (let i = 0; i < values.length; i++) { | ||
await this.findByText(values[i]); | ||
} | ||
}, | ||
|
||
async selectMonitorType(monitorType: string) { | ||
await this.selectByTestSubj('syntheticsMonitorTypeField', monitorType); | ||
}, | ||
|
||
async ensureIsOnMonitorConfigPage() { | ||
await page.isVisible('[data-test-subj=monitorSettingsSection]'); | ||
}, | ||
|
||
async confirmAndSave(isEditPage?: boolean) { | ||
await this.ensureIsOnMonitorConfigPage(); | ||
if (isEditPage) { | ||
await page.click('text=Update monitor'); | ||
} else { | ||
await page.click('text=Save monitor'); | ||
} | ||
return await this.findByTestSubj('uptimeAddMonitorSuccess'); | ||
}, | ||
|
||
async fillCodeEditor(value: string) { | ||
await page.fill('[data-test-subj=codeEditorContainer] textarea', value); | ||
}, | ||
|
||
async selectLocations({ locations }: { locations: string[] }) { | ||
await this.clickByTestSubj('syntheticsServiceLocationsComboBox'); | ||
for (let i = 0; i < locations.length; i++) { | ||
await page.click(`text=${locations[i]}`); | ||
} | ||
}, | ||
|
||
async createBasicMonitorDetails({ | ||
name, | ||
apmServiceName, | ||
locations, | ||
}: { | ||
name: string; | ||
apmServiceName: string; | ||
locations: string[]; | ||
}) { | ||
await this.fillByTestSubj('monitorManagementMonitorName', name); | ||
await this.fillByTestSubj('syntheticsAPMServiceName', apmServiceName); | ||
await this.selectLocations({ locations }); | ||
}, | ||
|
||
async createBasicHTTPMonitorDetails({ | ||
name, | ||
url, | ||
apmServiceName, | ||
locations, | ||
}: { | ||
name: string; | ||
url: string; | ||
apmServiceName: string; | ||
locations: string[]; | ||
}) { | ||
await this.createBasicMonitorDetails({ name, apmServiceName, locations }); | ||
await this.fillByTestSubj('syntheticsUrlField', url); | ||
}, | ||
|
||
async createBasicTCPMonitorDetails({ | ||
name, | ||
host, | ||
apmServiceName, | ||
locations, | ||
}: { | ||
name: string; | ||
host: string; | ||
apmServiceName: string; | ||
locations: string[]; | ||
}) { | ||
await this.selectMonitorType('tcp'); | ||
await this.createBasicMonitorDetails({ name, apmServiceName, locations }); | ||
await this.fillByTestSubj('syntheticsTCPHostField', host); | ||
}, | ||
|
||
async createBasicICMPMonitorDetails({ | ||
name, | ||
host, | ||
apmServiceName, | ||
locations, | ||
}: { | ||
name: string; | ||
host: string; | ||
apmServiceName: string; | ||
locations: string[]; | ||
}) { | ||
await this.selectMonitorType('icmp'); | ||
await this.createBasicMonitorDetails({ name, apmServiceName, locations }); | ||
await this.fillByTestSubj('syntheticsICMPHostField', host); | ||
}, | ||
|
||
async createBasicBrowserMonitorDetails( | ||
{ | ||
name, | ||
inlineScript, | ||
zipUrl, | ||
folder, | ||
params, | ||
username, | ||
password, | ||
apmServiceName, | ||
locations, | ||
}: { | ||
name: string; | ||
inlineScript?: string; | ||
zipUrl?: string; | ||
folder?: string; | ||
params?: string; | ||
username?: string; | ||
password?: string; | ||
apmServiceName: string; | ||
locations: string[]; | ||
}, | ||
isInline: boolean = false | ||
) { | ||
await this.selectMonitorType('browser'); | ||
await this.createBasicMonitorDetails({ name, apmServiceName, locations }); | ||
if (isInline && inlineScript) { | ||
await this.clickByTestSubj('syntheticsSourceTab__inline'); | ||
await this.fillCodeEditor(inlineScript); | ||
return; | ||
} | ||
await this.fillByTestSubj('syntheticsBrowserZipUrl', zipUrl || ''); | ||
await this.fillByTestSubj('syntheticsBrowserZipUrlFolder', folder || ''); | ||
await this.fillByTestSubj('syntheticsBrowserZipUrlUsername', username || ''); | ||
await this.fillByTestSubj('syntheticsBrowserZipUrlPassword', password || ''); | ||
await this.fillCodeEditor(params || ''); | ||
}, | ||
}; | ||
} |
Oops, something went wrong.