[Observability Onboarding] Integration tests for auto-detect happy path (#189335)

Resolves #186652

- Integration tests for auto-detect happy path
- Adds docker metrics detection
This commit is contained in:
Thom Heymann 2024-07-29 18:30:35 +01:00 committed by GitHub
parent e523debb2c
commit ffa3843464
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 121 additions and 2 deletions

View file

@ -113,6 +113,7 @@ export const AutoDetectPanel: FunctionComponent = () => {
{ defaultMessage: 'Your data is ready to explore!' }
)}
isLoading={false}
data-test-subj="observabilityOnboardingAutoDetectPanelDataReceivedProgressIndicator"
/>
) : status === 'awaitingData' ? (
<ProgressIndicator
@ -120,6 +121,7 @@ export const AutoDetectPanel: FunctionComponent = () => {
'xpack.observability_onboarding.autoDetectPanel.installingElasticAgentFlexItemLabel',
{ defaultMessage: 'Waiting for data to arrive...' }
)}
data-test-subj="observabilityOnboardingAutoDetectPanelAwaitingDataProgressIndicator"
/>
) : status === 'inProgress' ? (
<ProgressIndicator
@ -127,6 +129,7 @@ export const AutoDetectPanel: FunctionComponent = () => {
'xpack.observability_onboarding.autoDetectPanel.lookingForLogFilesFlexItemLabel',
{ defaultMessage: 'Waiting for installation to complete...' }
)}
data-test-subj="observabilityOnboardingAutoDetectPanelInProgressProgressIndicator"
/>
) : null}
{(status === 'awaitingData' || status === 'dataReceived') &&

View file

@ -62,7 +62,7 @@ export function GetStartedPanel({
<EuiFlexItem>
<EuiFlexGroup direction="column" gutterSize="s">
{dashboardLinks.map(({ id, label, title }) => (
<EuiFlexItem>
<EuiFlexItem key={id}>
<EuiFlexGroup direction="column" gutterSize="xs" alignItems="flexStart">
<EuiText key={id} size="s">
<p>{title}</p>

View file

@ -348,7 +348,9 @@ detect_known_integrations() {
fi
done
if compgen -G "/var/lib/docker/containers/*/*-json.log" > /dev/null; then
if [ -S /var/run/docker.sock ]; then
known_integrations_list_string+="docker"$'\n'
elif compgen -G "/var/lib/docker/containers/*/*-json.log" > /dev/null; then
known_integrations_list_string+="docker"$'\n'
fi

View file

@ -62,6 +62,9 @@ export function createTestConfig(options: CreateTestConfigOptions) {
observabilityLogsExplorer: {
pathname: '/app/observability-logs-explorer',
},
observabilityOnboarding: {
pathname: '/app/observabilityOnboarding',
},
management: {
pathname: '/app/management',
},

View file

@ -15,6 +15,7 @@ export default function ({ loadTestFile }: FtrProviderContext) {
loadTestFile(require.resolve('./navigation'));
loadTestFile(require.resolve('./observability_logs_explorer'));
loadTestFile(require.resolve('./dataset_quality'));
loadTestFile(require.resolve('./onboarding'));
loadTestFile(require.resolve('./rules/rules_list'));
loadTestFile(require.resolve('./cases'));
loadTestFile(require.resolve('./advanced_settings'));

View file

@ -0,0 +1,96 @@
/*
* 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 expect from 'expect';
import { generateLongId, log, timerange } from '@kbn/apm-synthtrace-client';
import moment from 'moment';
import { FtrProviderContext } from '../../../ftr_provider_context';
export default function ({ getPageObjects, getService }: FtrProviderContext) {
const PageObjects = getPageObjects([
'datasetQuality',
'observabilityLogsExplorer',
'common',
'svlCommonNavigation',
'svlCommonPage',
]);
const browser = getService('browser');
const testSubjects = getService('testSubjects');
const supertest = getService('supertest');
const synthtrace = getService('svlLogsSynthtraceClient');
describe('Onboarding Auto-Detect', () => {
before(async () => {
await PageObjects.svlCommonPage.loginAsAdmin(); // Onboarding requires admin role
await PageObjects.common.navigateToUrlWithBrowserHistory(
'observabilityOnboarding',
'/auto-detect/',
'?category=logs',
{
ensureCurrentUrl: false, // the check sometimes is too slow for the page so it misses the point in time before the app rewrites the URL
}
);
});
after(async () => {
await synthtrace.clean();
});
it('guides user through data onboarding', async () => {
await testSubjects.clickWhenNotDisabled('observabilityOnboardingCopyToClipboardButton');
const copiedCommand = await browser.getClipboardValue();
const commandRegex =
/sudo bash auto_detect\.sh --id=(\S+) --kibana-url=(\S+) --install-key=(\S+) --ingest-key=(\S+) --ea-version=(\S+)/;
expect(copiedCommand).toMatch(commandRegex);
const [, onboardingId, _kibanaUrl, installKey, _ingestKey, _eaVersion] =
copiedCommand.match(commandRegex)!;
// Simulate bash script installing detected integrations
await supertest
.post(`/internal/observability_onboarding/flow/${onboardingId}/integrations/install`)
.set('Authorization', `ApiKey ${installKey}`)
.set('Content-Type', 'text/tab-separated-values')
.set('x-elastic-internal-origin', 'Kibana')
.set('kbn-xsrf', 'true')
.send('system\tregistry\n')
.expect(200);
// Simulate bash script installing Elastic Agent
const agentId = generateLongId();
await supertest
.post(`/internal/observability_onboarding/flow/${onboardingId}/step/ea-status`)
.set('Authorization', `ApiKey ${installKey}`)
.set('x-elastic-internal-origin', 'Kibana')
.set('kbn-xsrf', 'true')
.send({ status: 'complete', message: '', payload: { agentId } })
.expect(200);
// Simulate Elastic Agent ingesting log files
const to = new Date().toISOString();
const count = 1;
await synthtrace.index(
timerange(moment(to).subtract(count, 'minute'), moment(to))
.interval('1m')
.rate(1)
.generator((timestamp) => {
return log.create().dataset('system.syslog').timestamp(timestamp).defaults({
'agent.id': agentId,
});
})
);
// Wait for logs to be ingested
await testSubjects.existOrFail(
'observabilityOnboardingAutoDetectPanelDataReceivedProgressIndicator'
);
});
});
}

View file

@ -0,0 +1,14 @@
/*
* 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 { FtrProviderContext } from '../../../ftr_provider_context';
export default function ({ loadTestFile }: FtrProviderContext) {
describe('Onboarding', function () {
loadTestFile(require.resolve('./auto_detect'));
});
}