Skip to content

Commit

Permalink
Merge branch 'master' into np-migration/searchprofiler
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine committed Oct 31, 2019
2 parents 3c09351 + d5831e8 commit 10b0425
Show file tree
Hide file tree
Showing 21 changed files with 343 additions and 311 deletions.
38 changes: 28 additions & 10 deletions .ci/Jenkinsfile_flaky
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,28 @@ def JOB_PARTS = params.CI_GROUP.split(':')
def IS_XPACK = JOB_PARTS[0] == 'xpack'
def JOB = JOB_PARTS[1]
def CI_GROUP = JOB_PARTS.size() > 2 ? JOB_PARTS[2] : ''
def EXECUTIONS = params.NUMBER_EXECUTIONS.toInteger()
def AGENT_COUNT = getAgentCount(EXECUTIONS)

def worker = getWorkerFromParams(IS_XPACK, JOB, CI_GROUP)

def workerFailures = []

currentBuild.displayName += trunc(" ${params.GITHUB_OWNER}:${params.branch_specifier}", 24)
currentBuild.description = "${params.CI_GROUP}<br />Executions: ${params.NUMBER_EXECUTIONS}"

// Note: If you increase agent count, it will execute NUMBER_EXECUTIONS per agent. It will not divide them up amongst the agents
// e.g. NUMBER_EXECUTIONS = 25, agentCount = 4 results in 100 total executions
def agentCount = 1
currentBuild.description = "${params.CI_GROUP}<br />Agents: ${AGENT_COUNT}<br />Executions: ${params.NUMBER_EXECUTIONS}"

stage("Kibana Pipeline") {
timeout(time: 180, unit: 'MINUTES') {
timestamps {
ansiColor('xterm') {
def agents = [:]
for(def agentNumber = 1; agentNumber <= agentCount; agentNumber++) {
for(def agentNumber = 1; agentNumber <= AGENT_COUNT; agentNumber++) {
def agentNumberInside = agentNumber
def agentExecutions = floor(EXECUTIONS/AGENT_COUNT) + (agentNumber <= EXECUTIONS%AGENT_COUNT ? 1 : 0)
agents["agent-${agentNumber}"] = {
catchError {
print "Agent ${agentNumberInside} - ${agentExecutions} executions"

kibanaPipeline.withWorkers('flaky-test-runner', {
if (!IS_XPACK) {
kibanaPipeline.buildOss()
Expand All @@ -37,7 +39,7 @@ stage("Kibana Pipeline") {
} else {
kibanaPipeline.buildXpack()
}
}, getWorkerMap(agentNumber, params.NUMBER_EXECUTIONS.toInteger(), worker, workerFailures))()
}, getWorkerMap(agentNumberInside, agentExecutions, worker, workerFailures))()
}
}
}
Expand Down Expand Up @@ -77,17 +79,20 @@ def getWorkerFromParams(isXpack, job, ciGroup) {
}
}

def getWorkerMap(agentNumber, numberOfExecutions, worker, workerFailures, maxWorkers = 14) {
def getWorkerMap(agentNumber, numberOfExecutions, worker, workerFailures, maxWorkerProcesses = 12) {
def workerMap = [:]
def numberOfWorkers = Math.min(numberOfExecutions, maxWorkers)
def numberOfWorkers = Math.min(numberOfExecutions, maxWorkerProcesses)

for(def i = 1; i <= numberOfWorkers; i++) {
def workerExecutions = numberOfExecutions/numberOfWorkers + (i <= numberOfExecutions%numberOfWorkers ? 1 : 0)

workerMap["agent-${agentNumber}-worker-${i}"] = { workerNumber ->
for(def j = 0; j < workerExecutions; j++) {
print "Execute agent-${agentNumber} worker-${workerNumber}: ${j}"
withEnv(["JOB=agent-${agentNumber}-worker-${workerNumber}-${j}"]) {
withEnv([
"JOB=agent-${agentNumber}-worker-${workerNumber}-${j}",
"REMOVE_KIBANA_INSTALL_DIR=1",
]) {
catchError {
try {
worker(workerNumber)
Expand All @@ -104,10 +109,23 @@ def getWorkerMap(agentNumber, numberOfExecutions, worker, workerFailures, maxWor
return workerMap
}

def getAgentCount(executions) {
// Increase agent count every 24 worker processess, up to 3 agents maximum
return Math.min(3, 1 + floor(executions/24))
}

def trunc(str, length) {
if (str.size() >= length) {
return str.take(length) + "..."
}

return str;
}

// All of the real rounding/truncating methods are sandboxed
def floor(num) {
return num
.toString()
.split('\\.')[0]
.toInteger()
}
14 changes: 12 additions & 2 deletions test/functional/services/remote/webdriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,23 @@ async function attemptToCreateCommand(
case 'chrome': {
const chromeCapabilities = Capabilities.chrome();
const chromeOptions = [
'disable-translate',
'new-window',
// Disables the sandbox for all process types that are normally sandboxed.
'no-sandbox',
// Launches URL in new browser window.
'new-window',
// By default, file:// URIs cannot read other file:// URIs. This is an override for developers who need the old behavior for testing.
'allow-file-access-from-files',
// Use fake device for Media Stream to replace actual camera and microphone.
'use-fake-device-for-media-stream',
// Bypass the media stream infobar by selecting the default device for media streams (e.g. WebRTC). Works with --use-fake-device-for-media-stream.
'use-fake-ui-for-media-stream',
];
if (process.platform === 'linux') {
// The /dev/shm partition is too small in certain VM environments, causing
// Chrome to fail or crash. Use this flag to work-around this issue
// (a temporary directory will always be used to create anonymous shared memory files).
chromeOptions.push('disable-dev-shm-usage');
}
if (headlessBrowser === '1') {
// Use --disable-gpu to avoid an error from a missing Mesa library, as per
// See: https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
Expand Down
8 changes: 1 addition & 7 deletions test/scripts/jenkins_ci_group.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
#!/usr/bin/env bash

set -e

if [[ -n "$IS_PIPELINE_JOB" ]] ; then
source src/dev/ci_setup/setup_env.sh
fi

export TEST_BROWSER_HEADLESS=1
source test/scripts/jenkins_test_setup.sh

if [[ -z "$IS_PIPELINE_JOB" ]] ; then
yarn run grunt functionalTests:ensureAllTestsInCiGroup;
Expand Down
6 changes: 1 addition & 5 deletions test/scripts/jenkins_firefox_smoke.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#!/usr/bin/env bash

set -e

if [[ -n "$IS_PIPELINE_JOB" ]] ; then
source src/dev/ci_setup/setup_env.sh
fi
source test/scripts/jenkins_test_setup.sh

if [[ -z "$IS_PIPELINE_JOB" ]] ; then
node scripts/build --debug --oss;
Expand Down
20 changes: 20 additions & 0 deletions test/scripts/jenkins_test_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
set -e

function post_work() {
set +e
if [[ -z "$IS_PIPELINE_JOB" ]] ; then
node "$KIBANA_DIR/scripts/report_failed_tests"
fi

if [[ -z "$REMOVE_KIBANA_INSTALL_DIR" && -z "$KIBANA_INSTALL_DIR" && -d "$KIBANA_INSTALL_DIR" ]]; then
rm -rf "$REMOVE_KIBANA_INSTALL_DIR"
fi
}

trap 'post_work' EXIT

export TEST_BROWSER_HEADLESS=1

if [[ -n "$IS_PIPELINE_JOB" ]] ; then
source src/dev/ci_setup/setup_env.sh
fi
9 changes: 1 addition & 8 deletions test/scripts/jenkins_visual_regression.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
#!/usr/bin/env bash

set -e

if [[ -n "$IS_PIPELINE_JOB" ]] ; then
source src/dev/ci_setup/setup_env.sh
fi

source test/scripts/jenkins_test_setup.sh
source "$KIBANA_DIR/src/dev/ci_setup/setup_percy.sh"

if [[ -z "$IS_PIPELINE_JOB" ]] ; then
Expand All @@ -22,8 +17,6 @@ else
export KIBANA_INSTALL_DIR="$destDir"
fi

export TEST_BROWSER_HEADLESS=1

checks-reporter-with-killswitch "Kibana visual regression tests" \
yarn run percy exec -t 500 \
node scripts/functional_tests \
Expand Down
8 changes: 1 addition & 7 deletions test/scripts/jenkins_xpack_ci_group.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
#!/usr/bin/env bash

set -e

if [[ -n "$IS_PIPELINE_JOB" ]] ; then
source src/dev/ci_setup/setup_env.sh
fi

export TEST_BROWSER_HEADLESS=1
source test/scripts/jenkins_test_setup.sh

if [[ -z "$IS_PIPELINE_JOB" ]] ; then
echo " -> Ensuring all functional tests are in a ciGroup"
Expand Down
8 changes: 1 addition & 7 deletions test/scripts/jenkins_xpack_firefox_smoke.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#!/usr/bin/env bash

set -e

if [[ -n "$IS_PIPELINE_JOB" ]] ; then
source src/dev/ci_setup/setup_env.sh
fi
source test/scripts/jenkins_test_setup.sh

if [[ -z "$IS_PIPELINE_JOB" ]] ; then
node scripts/build --debug --no-oss;
Expand All @@ -21,8 +17,6 @@ else
export KIBANA_INSTALL_DIR="$destDir"
fi

export TEST_BROWSER_HEADLESS=1

cd "$XPACK_DIR"

checks-reporter-with-killswitch "X-Pack firefox smoke test" \
Expand Down
9 changes: 1 addition & 8 deletions test/scripts/jenkins_xpack_visual_regression.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
#!/usr/bin/env bash

set -e

if [[ -n "$IS_PIPELINE_JOB" ]] ; then
source src/dev/ci_setup/setup_env.sh
fi

source test/scripts/jenkins_test_setup.sh
source "$KIBANA_DIR/src/dev/ci_setup/setup_percy.sh"

if [[ -z "$IS_PIPELINE_JOB" ]] ; then
Expand All @@ -23,8 +18,6 @@ else
export KIBANA_INSTALL_DIR="$destDir"
fi

export TEST_BROWSER_HEADLESS=1

cd "$XPACK_DIR"

checks-reporter-with-killswitch "X-Pack visual regression tests" \
Expand Down
18 changes: 14 additions & 4 deletions x-pack/legacy/plugins/canvas/scripts/shareable_runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,20 @@ run(

clean();
log.info('Building Canvas Shareable Workpad Runtime...');
execa.sync('yarn', ['webpack', '--config', webpackConfig, '--hide-modules', '--progress'], {
...options,
env,
});
execa.sync(
'yarn',
[
'webpack',
'--config',
webpackConfig,
'--hide-modules',
...(process.stdout.isTTY ? ['--progress'] : []),
],
{
...options,
env,
}
);
log.success('...runtime built!');
},
{
Expand Down
Loading

0 comments on commit 10b0425

Please sign in to comment.