Skip to content

Commit

Permalink
Merge branch 'main' into fix/olm-128444-fix-event-filter-creation-suc…
Browse files Browse the repository at this point in the history
…cess-toast
  • Loading branch information
ashokaditya authored Mar 29, 2022
2 parents 1339441 + 1e33587 commit d4b797f
Show file tree
Hide file tree
Showing 34 changed files with 785 additions and 435 deletions.
1 change: 1 addition & 0 deletions packages/elastic-apm-synthtrace/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ export { createLogger, LogLevel } from './lib/utils/create_logger';
export type { Fields } from './lib/entity';
export type { ApmException, ApmSynthtraceEsClient } from './lib/apm';
export type { SpanIterable } from './lib/span_iterable';
export { SpanArrayIterable } from './lib/span_iterable';
3 changes: 3 additions & 0 deletions packages/kbn-rule-data-utils/src/technical_field_names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const ALERT_RULE_CREATED_AT = `${ALERT_RULE_NAMESPACE}.created_at` as const;
const ALERT_RULE_CREATED_BY = `${ALERT_RULE_NAMESPACE}.created_by` as const;
const ALERT_RULE_DESCRIPTION = `${ALERT_RULE_NAMESPACE}.description` as const;
const ALERT_RULE_ENABLED = `${ALERT_RULE_NAMESPACE}.enabled` as const;
const ALERT_RULE_EXCEPTIONS_LIST = `${ALERT_RULE_NAMESPACE}.exceptions_list` as const;
const ALERT_RULE_EXECUTION_UUID = `${ALERT_RULE_NAMESPACE}.execution.uuid` as const;
const ALERT_RULE_FROM = `${ALERT_RULE_NAMESPACE}.from` as const;
const ALERT_RULE_INTERVAL = `${ALERT_RULE_NAMESPACE}.interval` as const;
Expand Down Expand Up @@ -104,6 +105,7 @@ const fields = {
ALERT_RULE_CREATED_BY,
ALERT_RULE_DESCRIPTION,
ALERT_RULE_ENABLED,
ALERT_RULE_EXCEPTIONS_LIST,
ALERT_RULE_EXECUTION_UUID,
ALERT_RULE_FROM,
ALERT_RULE_INTERVAL,
Expand Down Expand Up @@ -158,6 +160,7 @@ export {
ALERT_RULE_CREATED_BY,
ALERT_RULE_DESCRIPTION,
ALERT_RULE_ENABLED,
ALERT_RULE_EXCEPTIONS_LIST,
ALERT_RULE_EXECUTION_UUID,
ALERT_RULE_FROM,
ALERT_RULE_INTERVAL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export type ReturnExceptionListAndItems = [
];

/**
* Hook for using to get an ExceptionList and it's ExceptionListItems
* Hook for using to get an ExceptionList and its ExceptionListItems
*
* @param http Kibana http service
* @param lists array of ExceptionListIdentifiers for all lists to fetch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,12 @@ export const buildExceptionFilter = ({
lists,
excludeExceptions,
chunkSize,
alias = null,
}: {
lists: Array<ExceptionListItemSchema | CreateExceptionListItemSchema>;
excludeExceptions: boolean;
chunkSize: number;
alias: string | null;
}): Filter | undefined => {
// Remove exception items with large value lists. These are evaluated
// elsewhere for the moment being.
Expand All @@ -154,7 +156,7 @@ export const buildExceptionFilter = ({

const exceptionFilter: Filter = {
meta: {
alias: null,
alias,
disabled: false,
negate: excludeExceptions,
},
Expand Down Expand Up @@ -195,7 +197,7 @@ export const buildExceptionFilter = ({

return {
meta: {
alias: null,
alias,
disabled: false,
negate: excludeExceptions,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ describe('Comparison feature flag', () => {
});

describe('when comparison feature is disabled', () => {
// Reverts to default state, which is comparison enabled
after(() => {
cy.visit(settingsPath);
cy.get(comparisonToggle).click();
cy.contains('Save changes').should('not.be.disabled');
cy.contains('Save changes').click();
});

it('shows the flag as disabled in kibana advanced settings', () => {
cy.visit(settingsPath);
cy.get(comparisonToggle).click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ describe('Infrastracture feature flag', () => {

cy.get(infraToggle)
.should('have.attr', 'aria-checked')
.and('equal', 'true');
.and('equal', 'false');
});

it('shows infrastructure tab in service overview page', () => {
it('hides infrastructure tab in service overview page', () => {
cy.visit(serviceOverviewPath);
cy.contains('a[role="tab"]', 'Infrastructure').click();
cy.contains('a[role="tab"]', 'Infrastructure').should('not.exist');
});
});

Expand All @@ -59,12 +59,12 @@ describe('Infrastracture feature flag', () => {

cy.get(infraToggle)
.should('have.attr', 'aria-checked')
.and('equal', 'false');
.and('equal', 'true');
});

it('hides infrastructure tab in service overview page', () => {
it('shows infrastructure tab in service overview page', () => {
cy.visit(serviceOverviewPath);
cy.contains('a[role="tab"]', 'Infrastructure').should('not.exist');
cy.contains('a[role="tab"]', 'Infrastructure').click();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ describe('Rules', () => {
// Create a rule in APM
cy.visit('/app/apm/services');
cy.contains('Alerts and rules').click();
cy.contains('Error count').click();
cy.contains('Create threshold rule').click();
cy.contains('Create error count rule').click();

// Check for the existence of this element to make sure the form
// has loaded.
Expand All @@ -69,10 +68,6 @@ describe('Rules', () => {
before(() => {
cy.loginAsPowerUser();
deleteAllRules();
cy.intercept(
'GET',
'/api/alerting/rules/_find?page=1&per_page=10&default_search_operator=AND&sort_field=name&sort_order=asc'
).as('list rules API call');
});

after(() => {
Expand All @@ -83,11 +78,6 @@ describe('Rules', () => {
// Go to stack management
cy.visit('/app/management/insightsAndAlerting/triggersActions/rules');

// Wait for this call to finish so the create rule button does not disappear.
// The timeout is set high because at this point we're also waiting for the
// full page load.
cy.wait('@list rules API call', { timeout: 30000 });

// Create a rule
cy.contains('button', 'Create rule').click();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const start = '2021-10-10T00:00:00.000Z';
const end = '2021-10-10T00:15:00.000Z';
const errorDetailsPageHref = url.format({
pathname:
'/app/apm/services/opbeans-java/errors/0000000000000000000000000Error%201',
'/app/apm/services/opbeans-java/errors/0000000000000000000000000Error%200',
query: {
rangeFrom: start,
rangeTo: end,
Expand Down Expand Up @@ -89,7 +89,7 @@ describe('Error details', () => {
describe('when clicking on View x occurences in discover', () => {
it('should redirects the user to discover', () => {
cy.visit(errorDetailsPageHref);
cy.contains('span', 'Discover').click();
cy.contains('View 1 occurrence in Discover.').click();
cy.url().should('include', 'app/discover');
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ const apisToIntercept = [
},
];

describe('Home page', () => {
// flaky test
describe.skip('Home page', () => {
before(async () => {
await synthtrace.index(
opbeans({
Expand All @@ -46,12 +47,12 @@ describe('Home page', () => {
cy.loginAsReadOnlyUser();
});

it('Redirects to service page with rangeFrom and rangeTo added to the URL', () => {
it('Redirects to service page with environment, rangeFrom and rangeTo added to the URL', () => {
cy.visit('/app/apm');

cy.url().should(
'include',
'app/apm/services?rangeFrom=now-15m&rangeTo=now'
'app/apm/services?environment=ENVIRONMENT_ALL&rangeFrom=now-15m&rangeTo=now'
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import moment from 'moment';
import url from 'url';
import { synthtrace } from '../../../../synthtrace';
import { opbeans } from '../../../fixtures/synthtrace/opbeans';
Expand Down Expand Up @@ -104,8 +105,8 @@ describe('When navigating to the service inventory', () => {
cy.wait(aliasNames);

cy.selectAbsoluteTimeRange(
'Oct 10, 2021 @ 01:00:00.000',
'Oct 10, 2021 @ 01:30:00.000'
moment(timeRange.rangeFrom).subtract(5, 'm').toISOString(),
moment(timeRange.rangeTo).subtract(5, 'm').toISOString()
);
cy.contains('Update').click();
cy.wait(aliasNames);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ const apisToIntercept = [
'/internal/apm/services/opbeans-node/service_overview_instances/main_statistics?*',
name: 'instancesMainStatisticsRequest',
},
{
endpoint:
'/internal/apm/services/opbeans-node/errors/groups/main_statistics?*',
name: 'errorGroupsMainStatisticsRequest',
},
{
endpoint:
'/internal/apm/services/opbeans-node/transaction/charts/breakdown?*',
Expand Down Expand Up @@ -144,7 +139,7 @@ describe('Service overview - header filters', () => {
.find('li')
.first()
.click();
cy.get('[data-test-subj="suggestionContainer"]').realPress('{enter}');
cy.get('[data-test-subj="headerFilterKuerybar"]').type('{enter}');
cy.url().should('include', '&kuery=transaction.name');
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* 2.0.
*/

import moment from 'moment';
import url from 'url';
import { synthtrace } from '../../../../synthtrace';
import { opbeans } from '../../../fixtures/synthtrace/opbeans';
Expand All @@ -23,12 +24,12 @@ const apiRequestsToIntercept = [
{
endpoint:
'/internal/apm/services/opbeans-node/transactions/groups/main_statistics?*',
aliasName: 'transactionsGroupsMainStadisticsRequest',
aliasName: 'transactionsGroupsMainStatisticsRequest',
},
{
endpoint:
'/internal/apm/services/opbeans-node/errors/groups/main_statistics?*',
aliasName: 'errorsGroupsMainStadisticsRequest',
aliasName: 'errorsGroupsMainStatisticsRequest',
},
{
endpoint:
Expand Down Expand Up @@ -59,18 +60,18 @@ const apiRequestsToInterceptWithComparison = [
{
endpoint:
'/internal/apm/services/opbeans-node/transactions/groups/detailed_statistics?*',
aliasName: 'transactionsGroupsDetailedStadisticsRequest',
aliasName: 'transactionsGroupsDetailedStatisticsRequest',
},
{
endpoint:
'/internal/apm/services/opbeans-node/service_overview_instances/main_statistics?*',
aliasName: 'instancesMainStadisticsRequest',
aliasName: 'instancesMainStatisticsRequest',
},

{
endpoint:
'/internal/apm/services/opbeans-node/service_overview_instances/detailed_statistics?*',
aliasName: 'instancesDetailedStadisticsRequest',
aliasName: 'instancesDetailedStatisticsRequest',
},
];

Expand All @@ -84,7 +85,8 @@ const aliasNamesWithComparison = apiRequestsToInterceptWithComparison.map(

const aliasNames = [...aliasNamesNoComparison, ...aliasNamesWithComparison];

describe('Service Overview', () => {
// flaky test
describe.skip('Service Overview', () => {
before(async () => {
await synthtrace.index(
opbeans({
Expand All @@ -104,37 +106,16 @@ describe('Service Overview', () => {
cy.visit(baseUrl);
});

it('has no detectable a11y violations on load', () => {
it('renders all components on the page', () => {
cy.contains('opbeans-node');
// set skipFailures to true to not fail the test when there are accessibility failures
checkA11y({ skipFailures: true });
});

it('transaction latency chart', () => {
cy.get('[data-test-subj="latencyChart"]');
});

it('throughput chart', () => {
cy.get('[data-test-subj="throughput"]');
});

it('transactions group table', () => {
cy.get('[data-test-subj="transactionsGroupTable"]');
});

it('error table', () => {
cy.get('[data-test-subj="serviceOverviewErrorsTable"]');
});

it('dependencies table', () => {
cy.get('[data-test-subj="dependenciesTable"]');
});

it('instances latency distribution chart', () => {
cy.get('[data-test-subj="instancesLatencyDistribution"]');
});

it('instances table', () => {
cy.get('[data-test-subj="serviceOverviewInstancesTable"]');
});
});
Expand Down Expand Up @@ -241,16 +222,18 @@ describe('Service Overview', () => {
it('when selecting a different time range and clicking the update button', () => {
cy.wait(aliasNames, { requestTimeout: 10000 });

cy.selectAbsoluteTimeRange(
'Oct 10, 2021 @ 01:00:00.000',
'Oct 10, 2021 @ 01:30:00.000'
);
const timeStart = moment(start).subtract(5, 'm').toISOString();
const timeEnd = moment(end).subtract(5, 'm').toISOString();

cy.selectAbsoluteTimeRange(timeStart, timeEnd);

cy.contains('Update').click();

cy.expectAPIsToHaveBeenCalledWith({
apisIntercepted: aliasNames,
value:
'start=2021-10-10T00%3A00%3A00.000Z&end=2021-10-10T00%3A30%3A00.000Z',
value: `start=${encodeURIComponent(
new Date(timeStart).toISOString()
)}&end=${encodeURIComponent(new Date(timeEnd).toISOString())}`,
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ const apisToIntercept = [
},
];

describe('Service overview: Time Comparison', () => {
// Skipping tests since it's flaky.
describe.skip('Service overview: Time Comparison', () => {
before(async () => {
await synthtrace.index(
opbeans({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ describe('Transactions Overview', () => {

it('has no detectable a11y violations on load', () => {
cy.visit(serviceTransactionsHref);
cy.contains('aria-selected="true"', 'Transactions').should(
'have.class',
'euiTab-isSelected'
cy.get('a:contains(Transactions)').should(
'have.attr',
'aria-selected',
'true'
);
// set skipFailures to true to not fail the test when there are accessibility failures
checkA11y({ skipFailures: true });
Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/apm/ftr_e2e/cypress/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
apm,
createLogger,
LogLevel,
SpanIterable,
SpanArrayIterable,
} from '@elastic/apm-synthtrace';
import { createEsClientForTesting } from '@kbn/test';

Expand Down Expand Up @@ -46,8 +46,8 @@ const plugin: Cypress.PluginConfig = (on, config) => {
);

on('task', {
'synthtrace:index': async (events: SpanIterable) => {
await synthtraceEsClient.index(events);
'synthtrace:index': async (events: Array<Record<string, any>>) => {
await synthtraceEsClient.index(new SpanArrayIterable(events));
return null;
},
'synthtrace:clean': async () => {
Expand Down
Loading

0 comments on commit d4b797f

Please sign in to comment.