Skip to content

Commit

Permalink
Merge branch '7.7' into backport/7.7/pr-62364
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Apr 4, 2020
2 parents 4c4f27b + 3aea932 commit 412ffcb
Show file tree
Hide file tree
Showing 21 changed files with 123 additions and 166 deletions.
2 changes: 1 addition & 1 deletion .ci/Jenkinsfile_coverage
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ kibanaPipeline(timeoutMinutes: 180) {
'xpack-ciGroup10': kibanaPipeline.xpackCiGroupProcess(10),
]),
])
workers.base(name: 'coverage-worker', label: 'tests-l', ramDisk: false, bootstrapped: false) {
workers.base(name: 'coverage-worker', size: 'l', ramDisk: false, bootstrapped: false) {
kibanaPipeline.downloadCoverageArtifacts()
kibanaPipeline.bash(
'''
Expand Down
4 changes: 2 additions & 2 deletions .ci/Jenkinsfile_visual_baseline
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ kibanaPipeline(timeoutMinutes: 120) {
catchError {
parallel([
'oss-visualRegression': {
workers.ci(name: 'oss-visualRegression', label: 'linux && immutable', ramDisk: false) {
workers.ci(name: 'oss-visualRegression', size: 's', ramDisk: false) {
kibanaPipeline.functionalTestProcess('oss-visualRegression', './test/scripts/jenkins_visual_regression.sh')(1)
}
},
'xpack-visualRegression': {
workers.ci(name: 'xpack-visualRegression', label: 'linux && immutable', ramDisk: false) {
workers.ci(name: 'xpack-visualRegression', size: 's', ramDisk: false) {
kibanaPipeline.functionalTestProcess('xpack-visualRegression', './test/scripts/jenkins_xpack_visual_regression.sh')(1)
}
},
Expand Down
2 changes: 1 addition & 1 deletion .ci/es-snapshots/Jenkinsfile_build_es
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def PROMOTE_WITHOUT_VERIFY = !!params.PROMOTE_WITHOUT_VERIFICATION
timeout(time: 120, unit: 'MINUTES') {
timestamps {
ansiColor('xterm') {
node('linux && immutable') {
node(workers.label('s')) {
catchErrors {
def VERSION
def SNAPSHOT_ID
Expand Down
2 changes: 1 addition & 1 deletion .ci/es-snapshots/Jenkinsfile_verify_es
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ kibanaPipeline(timeoutMinutes: 120) {
}

def promoteSnapshot(snapshotVersion, snapshotId) {
node('linux && immutable') {
node(workers.label('s')) {
esSnapshots.promote(snapshotVersion, snapshotId)
}
}
35 changes: 25 additions & 10 deletions vars/workers.groovy
Original file line number Diff line number Diff line change
@@ -1,23 +1,38 @@
// "Workers" in this file will spin up an instance, do some setup etc depending on the configuration, and then execute some work that you define
// e.g. workers.base(name: 'my-worker') { sh "echo 'ready to execute some kibana scripts'" }

def label(size) {
switch(size) {
case 's':
return 'linux && immutable'
case 'l':
return 'tests-l'
case 'xl':
return 'tests-xl'
case 'xxl':
return 'tests-xxl'
}

error "unknown size '${size}'"
}

/*
The base worker that all of the others use. Will clone the scm (assumed to be kibana), and run kibana bootstrap processes by default.
Parameters:
label - gobld/agent label to use, e.g. 'linux && immutable'
size - size of worker label to use, e.g. 's' or 'xl'
ramDisk - Should the workspace be mounted in memory? Default: true
bootstrapped - If true, download kibana dependencies, run kbn bootstrap, etc. Default: true
name - Name of the worker for display purposes, filenames, etc.
scm - Jenkins scm configuration for checking out code. Use `null` to disable checkout. Default: inherited from job
*/
def base(Map params, Closure closure) {
def config = [label: '', ramDisk: true, bootstrapped: true, name: 'unnamed-worker', scm: scm] + params
if (!config.label) {
error "You must specify an agent label, such as 'tests-xl' or 'linux && immutable', when using workers.base()"
def config = [size: '', ramDisk: true, bootstrapped: true, name: 'unnamed-worker', scm: scm] + params
if (!config.size) {
error "You must specify an agent size, such as 'xl' or 's', when using workers.base()"
}

node(config.label) {
node(label(config.size)) {
agentInfo.print()

if (config.ramDisk) {
Expand Down Expand Up @@ -88,7 +103,7 @@ def ci(Map params, Closure closure) {
// Worker for running the current intake jobs. Just runs a single script after bootstrap.
def intake(jobName, String script) {
return {
ci(name: jobName, label: 'linux && immutable', ramDisk: false) {
ci(name: jobName, size: 's', ramDisk: false) {
withEnv(["JOB=${jobName}"]) {
runbld(script, "Execute ${jobName}")
}
Expand All @@ -99,7 +114,7 @@ def intake(jobName, String script) {
// Worker for running functional tests. Runs a setup process (e.g. the kibana build) then executes a map of closures in parallel (e.g. one for each ciGroup)
def functional(name, Closure setup, Map processes) {
return {
parallelProcesses(name: name, setup: setup, processes: processes, delayBetweenProcesses: 20, label: 'tests-xl')
parallelProcesses(name: name, setup: setup, processes: processes, delayBetweenProcesses: 20, size: 'xl')
}
}

Expand All @@ -111,12 +126,12 @@ def functional(name, Closure setup, Map processes) {
setup: Closure to execute after the agent is bootstrapped, before starting the parallel work
processes: Map of closures that will execute in parallel after setup. Each closure is passed a unique number.
delayBetweenProcesses: Number of seconds to wait between starting the parallel processes. Useful to spread the load of heavy init processes, e.g. Elasticsearch starting up. Default: 0
label: gobld/agent label to use, e.g. 'linux && immutable'. Default: 'tests-xl', a 32 CPU machine used for running many functional test suites in parallel
size: size of worker label to use, e.g. 's' or 'xl'
*/
def parallelProcesses(Map params) {
def config = [name: 'parallel-worker', setup: {}, processes: [:], delayBetweenProcesses: 0, label: 'tests-xl'] + params
def config = [name: 'parallel-worker', setup: {}, processes: [:], delayBetweenProcesses: 0, size: 'xl'] + params

ci(label: config.label, name: config.name) {
ci(size: config.size, name: config.name) {
config.setup()

def nextProcessNumber = 1
Expand Down
77 changes: 40 additions & 37 deletions x-pack/legacy/plugins/siem/cypress/integration/detections.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,47 +42,49 @@ describe('Detections', () => {
cy.get(NUMBER_OF_SIGNALS)
.invoke('text')
.then(numberOfSignals => {
cy.get(SHOWING_SIGNALS)
.invoke('text')
.should('eql', `Showing ${numberOfSignals} signals`);
cy.get(SHOWING_SIGNALS).should('have.text', `Showing ${numberOfSignals} signals`);

const numberOfSignalsToBeClosed = 3;
selectNumberOfSignals(numberOfSignalsToBeClosed);

cy.get(SELECTED_SIGNALS)
.invoke('text')
.should('eql', `Selected ${numberOfSignalsToBeClosed} signals`);
cy.get(SELECTED_SIGNALS).should(
'have.text',
`Selected ${numberOfSignalsToBeClosed} signals`
);

closeSignals();
waitForSignals();
cy.reload();
waitForSignals();

const expectedNumberOfSignalsAfterClosing = +numberOfSignals - numberOfSignalsToBeClosed;
cy.get(NUMBER_OF_SIGNALS)
.invoke('text')
.should('eq', expectedNumberOfSignalsAfterClosing.toString());
cy.get(SHOWING_SIGNALS)
.invoke('text')
.should('eql', `Showing ${expectedNumberOfSignalsAfterClosing.toString()} signals`);
cy.get(NUMBER_OF_SIGNALS).should(
'have.text',
expectedNumberOfSignalsAfterClosing.toString()
);

cy.get(SHOWING_SIGNALS).should(
'have.text',
`Showing ${expectedNumberOfSignalsAfterClosing.toString()} signals`
);

goToClosedSignals();
waitForSignals();

cy.get(NUMBER_OF_SIGNALS)
.invoke('text')
.should('eql', numberOfSignalsToBeClosed.toString());
cy.get(SHOWING_SIGNALS)
.invoke('text')
.should('eql', `Showing ${numberOfSignalsToBeClosed.toString()} signals`);
cy.get(NUMBER_OF_SIGNALS).should('have.text', numberOfSignalsToBeClosed.toString());
cy.get(SHOWING_SIGNALS).should(
'have.text',
`Showing ${numberOfSignalsToBeClosed.toString()} signals`
);
cy.get(SIGNALS).should('have.length', numberOfSignalsToBeClosed);

const numberOfSignalsToBeOpened = 1;
selectNumberOfSignals(numberOfSignalsToBeOpened);

cy.get(SELECTED_SIGNALS)
.invoke('text')
.should('eql', `Selected ${numberOfSignalsToBeOpened} signal`);
cy.get(SELECTED_SIGNALS).should(
'have.text',
`Selected ${numberOfSignalsToBeOpened} signal`
);

openSignals();
waitForSignals();
Expand All @@ -93,29 +95,30 @@ describe('Detections', () => {
waitForSignals();

const expectedNumberOfClosedSignalsAfterOpened = 2;
cy.get(NUMBER_OF_SIGNALS)
.invoke('text')
.should('eql', expectedNumberOfClosedSignalsAfterOpened.toString());
cy.get(SHOWING_SIGNALS)
.invoke('text')
.should(
'eql',
`Showing ${expectedNumberOfClosedSignalsAfterOpened.toString()} signals`
);
cy.get(NUMBER_OF_SIGNALS).should(
'have.text',
expectedNumberOfClosedSignalsAfterOpened.toString()
);
cy.get(SHOWING_SIGNALS).should(
'have.text',
`Showing ${expectedNumberOfClosedSignalsAfterOpened.toString()} signals`
);
cy.get(SIGNALS).should('have.length', expectedNumberOfClosedSignalsAfterOpened);

goToOpenedSignals();
waitForSignals();

const expectedNumberOfOpenedSignals =
+numberOfSignals - expectedNumberOfClosedSignalsAfterOpened;
cy.get(SHOWING_SIGNALS)
.invoke('text')
.should('eql', `Showing ${expectedNumberOfOpenedSignals.toString()} signals`);

cy.get('[data-test-subj="server-side-event-count"]')
.invoke('text')
.should('eql', expectedNumberOfOpenedSignals.toString());
cy.get(SHOWING_SIGNALS).should(
'have.text',
`Showing ${expectedNumberOfOpenedSignals.toString()} signals`
);

cy.get('[data-test-subj="server-side-event-count"]').should(
'have.text',
expectedNumberOfOpenedSignals.toString()
);
});
});

Expand Down
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/siem/cypress/screens/detections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const LOADING_SIGNALS_PANEL = '[data-test-subj="loading-signals-panel"]';

export const MANAGE_SIGNAL_DETECTION_RULES_BTN = '[data-test-subj="manage-signal-detection-rules"]';

export const NUMBER_OF_SIGNALS = '[data-test-subj="server-side-event-count"]';
export const NUMBER_OF_SIGNALS = '[data-test-subj="server-side-event-count"] .euiBadge__text';

export const OPEN_CLOSE_SIGNAL_BTN = '[data-test-subj="update-signal-status-button"]';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ describe('usePersistRule', () => {
usePrePackagedRules({
canUserCRUD: null,
hasIndexWrite: null,
hasManageApiKey: null,
isAuthenticated: null,
hasEncryptionKey: null,
isSignalIndexExists: null,
Expand Down Expand Up @@ -50,7 +49,6 @@ describe('usePersistRule', () => {
usePrePackagedRules({
canUserCRUD: null,
hasIndexWrite: null,
hasManageApiKey: null,
isAuthenticated: null,
hasEncryptionKey: null,
isSignalIndexExists: null,
Expand Down Expand Up @@ -79,7 +77,6 @@ describe('usePersistRule', () => {
usePrePackagedRules({
canUserCRUD: true,
hasIndexWrite: true,
hasManageApiKey: true,
isAuthenticated: true,
hasEncryptionKey: true,
isSignalIndexExists: true,
Expand Down Expand Up @@ -116,7 +113,6 @@ describe('usePersistRule', () => {
usePrePackagedRules({
canUserCRUD: true,
hasIndexWrite: true,
hasManageApiKey: true,
isAuthenticated: true,
hasEncryptionKey: true,
isSignalIndexExists: true,
Expand All @@ -139,7 +135,6 @@ describe('usePersistRule', () => {
usePrePackagedRules({
canUserCRUD: false,
hasIndexWrite: true,
hasManageApiKey: true,
isAuthenticated: true,
hasEncryptionKey: true,
isSignalIndexExists: true,
Expand All @@ -161,29 +156,6 @@ describe('usePersistRule', () => {
usePrePackagedRules({
canUserCRUD: true,
hasIndexWrite: false,
hasManageApiKey: true,
isAuthenticated: true,
hasEncryptionKey: true,
isSignalIndexExists: true,
})
);
await waitForNextUpdate();
await waitForNextUpdate();
let resp = null;
if (result.current.createPrePackagedRules) {
resp = await result.current.createPrePackagedRules();
}
expect(resp).toEqual(false);
});
});

test('can NOT createPrePackagedRules because hasManageApiKey === false', async () => {
await act(async () => {
const { result, waitForNextUpdate } = renderHook<unknown, ReturnPrePackagedRules>(() =>
usePrePackagedRules({
canUserCRUD: true,
hasIndexWrite: true,
hasManageApiKey: false,
isAuthenticated: true,
hasEncryptionKey: true,
isSignalIndexExists: true,
Expand All @@ -205,7 +177,6 @@ describe('usePersistRule', () => {
usePrePackagedRules({
canUserCRUD: true,
hasIndexWrite: true,
hasManageApiKey: true,
isAuthenticated: false,
hasEncryptionKey: true,
isSignalIndexExists: true,
Expand All @@ -227,7 +198,6 @@ describe('usePersistRule', () => {
usePrePackagedRules({
canUserCRUD: true,
hasIndexWrite: true,
hasManageApiKey: true,
isAuthenticated: true,
hasEncryptionKey: false,
isSignalIndexExists: true,
Expand All @@ -249,7 +219,6 @@ describe('usePersistRule', () => {
usePrePackagedRules({
canUserCRUD: true,
hasIndexWrite: true,
hasManageApiKey: true,
isAuthenticated: true,
hasEncryptionKey: true,
isSignalIndexExists: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export interface ReturnPrePackagedRules {
interface UsePrePackagedRuleProps {
canUserCRUD: boolean | null;
hasIndexWrite: boolean | null;
hasManageApiKey: boolean | null;
isAuthenticated: boolean | null;
hasEncryptionKey: boolean | null;
isSignalIndexExists: boolean | null;
Expand All @@ -36,7 +35,6 @@ interface UsePrePackagedRuleProps {
* Hook for using to get status about pre-packaged Rules from the Detection Engine API
*
* @param hasIndexWrite boolean
* @param hasManageApiKey boolean
* @param isAuthenticated boolean
* @param hasEncryptionKey boolean
* @param isSignalIndexExists boolean
Expand All @@ -45,7 +43,6 @@ interface UsePrePackagedRuleProps {
export const usePrePackagedRules = ({
canUserCRUD,
hasIndexWrite,
hasManageApiKey,
isAuthenticated,
hasEncryptionKey,
isSignalIndexExists,
Expand Down Expand Up @@ -117,7 +114,6 @@ export const usePrePackagedRules = ({
if (
canUserCRUD &&
hasIndexWrite &&
hasManageApiKey &&
isAuthenticated &&
hasEncryptionKey &&
isSignalIndexExists
Expand Down Expand Up @@ -185,14 +181,7 @@ export const usePrePackagedRules = ({
isSubscribed = false;
abortCtrl.abort();
};
}, [
canUserCRUD,
hasIndexWrite,
hasManageApiKey,
isAuthenticated,
hasEncryptionKey,
isSignalIndexExists,
]);
}, [canUserCRUD, hasIndexWrite, isAuthenticated, hasEncryptionKey, isSignalIndexExists]);

return {
loading,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,6 @@ export const mockUserPrivilege: Privilege = {
monitor_watcher: true,
monitor_transform: true,
read_ilm: true,
manage_api_key: true,
manage_security: true,
manage_own_api_key: false,
manage_saml: true,
Expand Down
Loading

0 comments on commit 412ffcb

Please sign in to comment.