Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EDR Workflows] Verify flaky osquery tests #169749

Merged
merged 57 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
f2d6929
test flakiness
tomsonpl Oct 25, 2023
18bc8b0
test flakiness
tomsonpl Oct 25, 2023
69b847c
test flakiness
tomsonpl Oct 25, 2023
b0e4530
fix cases
tomsonpl Oct 25, 2023
bdeecef
actions_form
tomsonpl Oct 25, 2023
91ca659
check login
tomsonpl Oct 25, 2023
5853004
brokeninserverless one test
tomsonpl Oct 25, 2023
7bd8231
change login
tomsonpl Oct 26, 2023
f40ba89
Merge branch 'main' into flaky-alerts-loading
tomsonpl Oct 26, 2023
a6fa2ae
add check for agent status
tomsonpl Oct 26, 2023
4abf5d3
test
tomsonpl Oct 26, 2023
01d1c39
test
tomsonpl Oct 26, 2023
cb282ca
clickoutside and add cy.log
tomsonpl Oct 26, 2023
cc11fbc
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Oct 26, 2023
bffa366
recursively set up agent
tomsonpl Oct 26, 2023
cbf6f8f
Merge remote-tracking branch 'origin/flaky-alerts-loading' into flaky…
tomsonpl Oct 26, 2023
969d114
add more time
tomsonpl Oct 26, 2023
c313e04
more time
tomsonpl Oct 26, 2023
835e39a
test video
tomsonpl Oct 27, 2023
dcbcd05
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Oct 27, 2023
dc55d9c
test video
tomsonpl Oct 27, 2023
0d9e7d8
Merge remote-tracking branch 'origin/flaky-alerts-loading' into flaky…
tomsonpl Oct 27, 2023
e825588
fix test
tomsonpl Oct 27, 2023
68b9640
fix test
tomsonpl Oct 27, 2023
2da2515
remove global before to login
tomsonpl Oct 27, 2023
fc350db
limit specs
tomsonpl Oct 27, 2023
f719820
clean up
tomsonpl Oct 27, 2023
ef9cc6f
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Oct 27, 2023
f502a9a
specs again
tomsonpl Oct 27, 2023
e748b09
Merge remote-tracking branch 'origin/flaky-alerts-loading' into flaky…
tomsonpl Oct 27, 2023
008f001
remove redundant
tomsonpl Oct 30, 2023
0adfd83
Merge branch 'main' into flaky-alerts-loading
tomsonpl Oct 30, 2023
33eb662
unskip
tomsonpl Oct 30, 2023
70d9943
filter videos
tomsonpl Oct 30, 2023
2fb6446
fix
tomsonpl Oct 30, 2023
7a8b0e6
packs_integration.cy.ts
tomsonpl Oct 30, 2023
0578de8
fix
tomsonpl Oct 30, 2023
b7610b5
fix metrics
tomsonpl Oct 30, 2023
dc91194
fix
tomsonpl Oct 31, 2023
3d3b2e0
fix
tomsonpl Oct 31, 2023
97863fc
fix
tomsonpl Oct 31, 2023
00b3d29
clean up
tomsonpl Oct 31, 2023
b4dbac6
Merge branch 'main' into flaky-alerts-loading
tomsonpl Oct 31, 2023
5a647a3
Merge branch 'main' into flaky-alerts-loading
tomsonpl Oct 31, 2023
42bc3d0
unskip
tomsonpl Oct 31, 2023
44c74cb
Merge remote-tracking branch 'origin/flaky-alerts-loading' into flaky…
tomsonpl Oct 31, 2023
9105d07
fixes
tomsonpl Oct 31, 2023
e188c9c
pass containerName
tomsonpl Oct 31, 2023
9429418
fix
tomsonpl Oct 31, 2023
11479e3
fix
tomsonpl Oct 31, 2023
ed51ade
fix
tomsonpl Oct 31, 2023
97b8865
fix
tomsonpl Oct 31, 2023
76d1e87
fix
tomsonpl Oct 31, 2023
212cc0a
Merge branch 'main' into flaky-alerts-loading
tomsonpl Oct 31, 2023
03be3ef
remove video compressions
tomsonpl Oct 31, 2023
89c5342
Merge remote-tracking branch 'origin/flaky-alerts-loading' into flaky…
tomsonpl Oct 31, 2023
80c962b
change compression
tomsonpl Oct 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .buildkite/scripts/lifecycle/post_command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ if [[ "$IS_TEST_EXECUTION_STEP" == "true" ]]; then
buildkite-agent artifact upload 'target/kibana-*'
buildkite-agent artifact upload 'target/kibana-security-solution/**/*.png'
buildkite-agent artifact upload 'target/kibana-osquery/**/*.png'
buildkite-agent artifact upload 'target/kibana-osquery/**/*.mp4'
buildkite-agent artifact upload 'target/kibana-fleet/**/*.png'
buildkite-agent artifact upload 'target/test-metrics/*'
buildkite-agent artifact upload 'target/test-suites-ci-plan.json'
Expand Down
5 changes: 4 additions & 1 deletion x-pack/plugins/osquery/cypress/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import path from 'path';
import { safeLoad as loadYaml } from 'js-yaml';
import { readFileSync } from 'fs';

import { getFailedSpecVideos } from './support/filter_videos';
import type { YamlRoleDefinitions } from '../../../test_serverless/shared/lib';
import { setupUserDataLoader } from '../../../test_serverless/functional/test_suites/security/cypress/support/setup_data_loader_tasks';
const ROLES_YAML_FILE_PATH = path.join(
Expand All @@ -36,8 +37,9 @@ export default defineCypressConfig({

screenshotsFolder: '../../../target/kibana-osquery/cypress/screenshots',
trashAssetsBeforeRuns: false,
video: false,
video: true,
videosFolder: '../../../target/kibana-osquery/cypress/videos',
videoCompression: 15,
viewportHeight: 900,
viewportWidth: 1440,
experimentalStudio: true,
Expand All @@ -59,6 +61,7 @@ export default defineCypressConfig({
numTestsKeptInMemory: 3,
setupNodeEvents(on, config) {
setupUserDataLoader(on, config, { roleDefinitions, additionalRoleName: 'viewer' });
on('after:spec', getFailedSpecVideos);

return config;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ describe('ALL - Add Integration', { tags: ['@ess', '@serverless'] }, () => {
}
);

// FLAKY: https://github.com/elastic/kibana/issues/169702
describe.skip('Add and upgrade integration', { tags: ['@ess', '@serverless'] }, () => {
describe('Add and upgrade integration', { tags: ['@ess', '@serverless'] }, () => {
const oldVersion = '0.7.4';
const [integrationName, policyName] = generateRandomStringName(2);
let policyId: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@
* 2.0.
*/

import { initializeDataViews } from '../../tasks/login';
import { cleanupRule, loadRule } from '../../tasks/api_fixtures';
import { checkActionItemsInResults, loadRuleAlerts } from '../../tasks/live_query';

const UUID_REGEX = '[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}';

// FLAKY: https://github.com/elastic/kibana/issues/169727
describe.skip('Alert Flyout Automated Action Results', () => {
describe('Alert Flyout Automated Action Results', () => {
let ruleId: string;

before(() => {
initializeDataViews();
});

beforeEach(() => {
loadRule(true).then((data) => {
ruleId = data.id;
Expand Down
4 changes: 4 additions & 0 deletions x-pack/plugins/osquery/cypress/e2e/all/alerts_cases.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* 2.0.
*/

import { initializeDataViews } from '../../tasks/login';
import { OSQUERY_FLYOUT_BODY_EDITOR } from '../../screens/live_query';
import {
cleanupCase,
Expand All @@ -29,6 +30,9 @@ describe('Alert Event Details - Cases', { tags: ['@ess', '@serverless'] }, () =>
let packId: string;
let packName: string;
const packData = packFixture();
before(() => {
initializeDataViews();
});

beforeEach(() => {
loadPack(packData).then((data) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* 2.0.
*/

import { initializeDataViews } from '../../tasks/login';
import { cleanupRule, loadRule } from '../../tasks/api_fixtures';
import { RESPONSE_ACTIONS_ITEM_0, RESPONSE_ACTIONS_ITEM_1 } from '../../tasks/response_actions';
import {
Expand All @@ -25,7 +26,9 @@ describe(
() => {
let ruleId: string;
let ruleName: string;

before(() => {
initializeDataViews();
});
beforeEach(() => {
loadRule().then((data) => {
ruleId = data.id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* 2.0.
*/

import { initializeDataViews } from '../../tasks/login';
import { cleanupRule, loadRule } from '../../tasks/api_fixtures';
import {
inputQuery,
Expand All @@ -14,8 +15,7 @@ import {
} from '../../tasks/live_query';
import { OSQUERY_FLYOUT_BODY_EDITOR } from '../../screens/live_query';

// FLAKY: https://github.com/elastic/kibana/issues/170157
describe.skip(
describe(
'Alert Event Details - dynamic params',
{
tags: ['@ess', '@serverless'],
Expand All @@ -25,6 +25,7 @@ describe.skip(
let ruleName: string;

before(() => {
initializeDataViews();
loadRule(true).then((data) => {
ruleId = data.id;
ruleName = data.name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* 2.0.
*/

import { initializeDataViews } from '../../tasks/login';
import {
cleanupPack,
cleanupRule,
Expand All @@ -31,7 +32,9 @@ describe('Alert Event Details - Response Actions Form', { tags: ['@ess', '@serve
let packName: string;
const packData = packFixture();
const multiQueryPackData = multiQueryPackFixture();

before(() => {
initializeDataViews();
});
beforeEach(() => {
loadPack(packData).then((data) => {
packId = data.saved_object_id;
Expand All @@ -55,6 +58,7 @@ describe('Alert Event Details - Response Actions Form', { tags: ['@ess', '@serve
it('adds response actions with osquery with proper validation and form values', () => {
cy.visit('/app/security/rules');
clickRuleName(ruleName);
cy.getBySel('globalLoadingIndicator').should('not.exist');
cy.getBySel('editRuleSettingsLink').click();
cy.getBySel('globalLoadingIndicator').should('not.exist');
closeDateTabIfVisible();
Expand All @@ -81,20 +85,22 @@ describe('Alert Event Details - Response Actions Form', { tags: ['@ess', '@serve

cy.getBySel(OSQUERY_RESPONSE_ACTION_ADD_BUTTON).click();

cy.getBySel(RESPONSE_ACTIONS_ITEM_2).within(() => {
cy.contains('Query is a required field');
inputQuery('select * from uptime');
cy.contains('Query is a required field').should('not.exist');
cy.contains('Advanced').click();
typeInECSFieldInput('{downArrow}{enter}');
cy.getBySel('osqueryColumnValueSelect').type('days{downArrow}{enter}');
cy.wait(1000); // wait for the validation to trigger - cypress is way faster than users ;)
});
cy.getBySel(RESPONSE_ACTIONS_ITEM_2)
.within(() => {
cy.contains('Query is a required field');
inputQuery('select * from uptime');
cy.contains('Query is a required field').should('not.exist');
cy.contains('Advanced').click();
typeInECSFieldInput('{downArrow}{enter}');
cy.getBySel('osqueryColumnValueSelect').type('days{downArrow}{enter}');
})
.clickOutside();

cy.getBySel('ruleEditSubmitButton').click();
cy.contains(`${ruleName} was saved`).should('exist');
closeToastIfVisible();

cy.getBySel('globalLoadingIndicator').should('not.exist');
cy.getBySel('editRuleSettingsLink').click();
cy.getBySel('globalLoadingIndicator').should('not.exist');
cy.getBySel('edit-rule-actions-tab').click();
Expand All @@ -114,18 +120,21 @@ describe('Alert Event Details - Response Actions Form', { tags: ['@ess', '@serve
cy.contains('select * from uptime1');
cy.getBySel('remove-response-action').click();
});
cy.getBySel(RESPONSE_ACTIONS_ITEM_0).within(() => {
cy.contains('Search for a pack to run');
cy.contains('Pack is a required field');
cy.getBySel('comboBoxInput').type(`${packName}{downArrow}{enter}`);
});
cy.getBySel(RESPONSE_ACTIONS_ITEM_0)
.within(() => {
cy.contains('Search for a pack to run');
cy.contains('Pack is a required field');
cy.getBySel('comboBoxInput').type(`${packName}{downArrow}{enter}`);
})
.clickOutside();
cy.getBySel(RESPONSE_ACTIONS_ITEM_1).within(() => {
cy.contains('select * from uptime');
cy.contains('Custom key/value pairs. e.g. {"application":"foo-bar","env":"production"}');
cy.contains('Days of uptime');
});

cy.intercept('PUT', '/api/detection_engine/rules').as('saveRuleSingleQuery');

cy.getBySel('ruleEditSubmitButton').click();
cy.wait('@saveRuleSingleQuery').should(({ request }) => {
const oneQuery = [
Expand All @@ -141,8 +150,10 @@ describe('Alert Event Details - Response Actions Form', { tags: ['@ess', '@serve
cy.contains(`${ruleName} was saved`).should('exist');
closeToastIfVisible();

cy.getBySel('globalLoadingIndicator').should('not.exist');
cy.getBySel('editRuleSettingsLink').click();
cy.getBySel('globalLoadingIndicator').should('not.exist');

cy.getBySel('edit-rule-actions-tab').click();
cy.getBySel(RESPONSE_ACTIONS_ITEM_0)
.within(() => {
Expand All @@ -153,12 +164,15 @@ describe('Alert Event Details - Response Actions Form', { tags: ['@ess', '@serve
})
.clickOutside();

cy.getBySel(RESPONSE_ACTIONS_ITEM_1).within(() => {
cy.contains('select * from uptime');
cy.contains('Custom key/value pairs. e.g. {"application":"foo-bar","env":"production"}');
cy.contains('Days of uptime');
});
cy.getBySel(RESPONSE_ACTIONS_ITEM_1)
.within(() => {
cy.contains('select * from uptime');
cy.contains('Custom key/value pairs. e.g. {"application":"foo-bar","env":"production"}');
cy.contains('Days of uptime');
})
.clickOutside();
cy.intercept('PUT', '/api/detection_engine/rules').as('saveRuleMultiQuery');

cy.contains('Save changes').click();
cy.wait('@saveRuleMultiQuery').should(({ request }) => {
const threeQueries = [
Expand Down
13 changes: 7 additions & 6 deletions x-pack/plugins/osquery/cypress/e2e/all/cases.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* 2.0.
*/

import { initializeDataViews } from '../../tasks/login';
import {
addLiveQueryToCase,
checkActionItemsInResults,
Expand All @@ -14,11 +15,11 @@ import { navigateTo } from '../../tasks/navigation';
import { loadLiveQuery, loadCase, cleanupCase } from '../../tasks/api_fixtures';
import { ServerlessRoleName } from '../../support/roles';

// FLAKY: https://github.com/elastic/kibana/issues/169747
describe.skip('Add to Cases', () => {
describe('Add to Cases', () => {
let liveQueryId: string;
let liveQueryQuery: string;
before(() => {
initializeDataViews();
loadLiveQuery({
agent_all: true,
query: "SELECT * FROM os_version where name='Ubuntu';",
Expand All @@ -32,7 +33,7 @@ describe.skip('Add to Cases', () => {
describe('observability', { tags: ['@ess'] }, () => {
let caseId: string;
let caseTitle: string;
before(() => {
beforeEach(() => {
loadCase('observability').then((caseInfo) => {
caseId = caseInfo.id;
caseTitle = caseInfo.title;
Expand All @@ -41,7 +42,7 @@ describe.skip('Add to Cases', () => {
navigateTo('/app/osquery');
});

after(() => {
afterEach(() => {
cleanupCase(caseId);
});

Expand All @@ -64,7 +65,7 @@ describe.skip('Add to Cases', () => {
let caseId: string;
let caseTitle: string;

before(() => {
beforeEach(() => {
loadCase('securitySolution').then((caseInfo) => {
caseId = caseInfo.id;
caseTitle = caseInfo.title;
Expand All @@ -73,7 +74,7 @@ describe.skip('Add to Cases', () => {
navigateTo('/app/osquery');
});

after(() => {
afterEach(() => {
cleanupCase(caseId);
});

Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/osquery/cypress/e2e/all/custom_space.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* 2.0.
*/

import { initializeDataViews } from '../../tasks/login';
import { navigateTo } from '../../tasks/navigation';
import {
checkActionItemsInResults,
Expand All @@ -28,6 +29,7 @@ describe('ALL - Custom space', () => {
let spaceId: string;

before(() => {
initializeDataViews();
cy.wrap(
new Promise<string>((resolve) => {
if (testSpace.name !== 'default') {
Expand Down
5 changes: 5 additions & 0 deletions x-pack/plugins/osquery/cypress/e2e/all/ecs_mappings.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* 2.0.
*/

import { initializeDataViews } from '../../tasks/login';
import { getAdvancedButton } from '../../screens/integrations';
import { navigateTo } from '../../tasks/navigation';
import {
Expand All @@ -19,6 +20,10 @@ import {
import { ServerlessRoleName } from '../../support/roles';

describe('EcsMapping', { tags: ['@ess', '@serverless'] }, () => {
before(() => {
initializeDataViews();
});

beforeEach(() => {
cy.login(ServerlessRoleName.SOC_MANAGER);
});
Expand Down
5 changes: 2 additions & 3 deletions x-pack/plugins/osquery/cypress/e2e/all/live_query.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ import { LIVE_QUERY_EDITOR } from '../../screens/live_query';
import { getAdvancedButton } from '../../screens/integrations';
import { ServerlessRoleName } from '../../support/roles';

// FLAKY: https://github.com/elastic/kibana/issues/169725
describe.skip('ALL - Live Query', { tags: ['@ess', '@serverless'] }, () => {
describe('ALL - Live Query', { tags: ['@ess', '@serverless'] }, () => {
beforeEach(() => {
cy.login(ServerlessRoleName.SOC_MANAGER);
navigateTo('/app/osquery');
Expand Down Expand Up @@ -87,6 +86,6 @@ describe.skip('ALL - Live Query', { tags: ['@ess', '@serverless'] }, () => {

inputQuery('{selectall}{backspace}{selectall}{backspace}');
// not sure if this is how it used to work when I implemented the functionality, but let's leave it like this for now
cy.get(LIVE_QUERY_EDITOR).invoke('height').should('be.gt', 200).and('be.lt', 380);
cy.get(LIVE_QUERY_EDITOR).invoke('height').should('be.gt', 200).and('be.lt', 400);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of hardcoding values, could we write it in a more dynamic way? checking if the values have changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah not sure, sometimes these numbers change, but in general it is good to know if it is in some scope, and not changed as from 300px to 3000px. I find this to be a quite easy way to get it tested, now just making the expectations more loose.

});
});
4 changes: 1 addition & 3 deletions x-pack/plugins/osquery/cypress/e2e/all/metrics.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import { loadSavedQuery, cleanupSavedQuery } from '../../tasks/api_fixtures';
import { triggerLoadData } from '../../tasks/inventory';
import { ServerlessRoleName } from '../../support/roles';

// FLAKY: https://github.com/elastic/kibana/issues/169574
// FLAKY: https://github.com/elastic/kibana/issues/169575
describe.skip('ALL - Inventory', { tags: ['@ess'] }, () => {
describe('ALL - Inventory', { tags: ['@ess'] }, () => {
let savedQueryName: string;
let savedQueryId: string;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
findFormFieldByRowsLabelAndType,
inputQuery,
} from '../../tasks/live_query';
import { activatePack, deactivatePack, preparePack } from '../../tasks/packs';
import { changePackActiveStatus, preparePack } from '../../tasks/packs';
import {
closeModalIfVisible,
closeToastIfVisible,
Expand Down Expand Up @@ -513,8 +513,8 @@ describe('Packs - Create and Edit', { tags: ['@ess', '@serverless'] }, () => {

it('', () => {
cy.contains('Packs').click();
deactivatePack(packName);
activatePack(packName);
changePackActiveStatus(packName);
changePackActiveStatus(packName);
});
});

Expand Down
Loading
Loading