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

feat: add a new step to run the e2e tests for certain parts of Beats #21100

Merged
merged 21 commits into from
Oct 6, 2020
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
50 changes: 49 additions & 1 deletion .ci/packaging.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
pipeline {
agent none
environment {
BASE_DIR = 'src/github.com/elastic/beats'
REPO = 'beats'
mdelapenya marked this conversation as resolved.
Show resolved Hide resolved
BASE_DIR = "src/github.com/elastic/${env.REPO}"
JOB_GCS_BUCKET = 'beats-ci-artifacts'
JOB_GCS_BUCKET_STASH = 'beats-ci-temp'
JOB_GCS_CREDENTIALS = 'beats-ci-gcs-plugin'
DOCKERELASTIC_SECRET = 'secret/observability-team/ci/docker-registry/prod'
DOCKER_REGISTRY = 'docker.elastic.co'
GITHUB_CHECK_E2E_TESTS_NAME = 'E2E Tests'
SNAPSHOT = "true"
PIPELINE_LOG_LEVEL = "INFO"
}
Expand Down Expand Up @@ -119,6 +121,7 @@ pipeline {
release()
pushCIDockerImages()
}
runE2ETestForPackages()
}
}
stage('Package Mac OS'){
Expand Down Expand Up @@ -209,6 +212,25 @@ def tagAndPush(name){
}
}

def runE2ETestForPackages(){
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we are running the tests too early. Let me explain: as we are building different projects in parallel (i.e. metricbeat and filebeat) it could be possible that if the filebeat build is faster, then it reaches the e2e tests stage when the filebeat one has not created its artifacts. Therefore the e2e tests could potentially fail.

I could see it valid to run the e2e tests right after the release stage, so we ensure all artifacts are there. On the other hand, the tests won't be run until the slowest build hadn't finished.

As we discussed, it could be great to decide what to build in an earlier stage, something like prepareBuildContext or similar, where we calculate what to build to be tested.

Copy link
Contributor

Choose a reason for hiding this comment

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

if the step pushCIDockerImages() is finish the packages are generated and deployed, I not get your concern.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, the pushCIDockerImages method is executed per BEATS_FOLDER, so in the context of BEATS_FOLDER=filebeat it will push the images for filebeat, only. And maybe we want to test the metricbeat ones too (i.e. elastic-agent starting both processes)

Copy link
Contributor

Choose a reason for hiding this comment

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

this is part of the dependencies of the elastic agent, What are the conditions that define if we have to test Filebeat, Metricbeat, or both?

  • If there are changes in Metricbeat Should we test the Elastic Agent? Should we test Elastic Agent+Filebeat?
  • If there are changes in Filebeat Should we test the Elastic Agent? Should we test Elastic Agent+Metricbeat?
  • If there are changes in Elastic Agent Should we test the Elastic Agent+Filebeat+Metricbeat?

Copy link
Member

Choose a reason for hiding this comment

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

If those are direct dependencies then

beats/Jenkinsfile

Lines 1364 to 1381 in d2a8922

def getProjectDependencies(beatName){
def os = goos()
def goRoot = "${env.WORKSPACE}/.gvm/versions/go${GO_VERSION}.${os}.amd64"
def output = ""
withEnv([
"HOME=${env.WORKSPACE}/${env.BASE_DIR}",
"PATH=${env.WORKSPACE}/bin:${goRoot}/bin:${env.PATH}",
]) {
output = sh(label: 'Get vendor dependency patterns', returnStdout: true, script: """
go list -deps ./${beatName} \
| grep 'elastic/beats' \
| sed -e "s#github.com/elastic/beats/v7/##g" \
| awk '{print "^" \$1 "/.*"}'
""")
}
return output?.split('\n').collect{ item -> item as String }
}
could be the one to define that particular workflow for the packaging.

Otherwise, where those dependencies are defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do not think they are defined yet. I did a best effort here: elastic/e2e-testing#309 (comment)

def suite = ''

catchError(buildResult: 'UNSTABLE', message: 'Unable to run e2e tests', stageResult: 'FAILURE') {
if ("${env.BEATS_FOLDER}" == "filebeat" || "${env.BEATS_FOLDER}" == "x-pack/filebeat") {
suite = 'helm,ingest-manager'
} else if ("${env.BEATS_FOLDER}" == "metricbeat" || "${env.BEATS_FOLDER}" == "x-pack/metricbeat") {
suite = ''
} else if ("${env.BEATS_FOLDER}" == "x-pack/elastic-agent") {
suite = 'ingest-manager'
} else {
echo("Skipping E2E tests for ${env.BEATS_FOLDER}.")
return
}

triggerE2ETests(suite)
}
}

def release(){
withBeatsEnv(){
dir("${env.BEATS_FOLDER}") {
Expand All @@ -218,6 +240,32 @@ def release(){
}
}

def triggerE2ETests(String suite) {
echo("Triggering E2E tests for ${env.BEATS_FOLDER}. Test suite: ${suite}.")

def branchName = isPR() ? "${env.CHANGE_TARGET}" : "${env.JOB_BASE_NAME}"
def e2eTestsPipeline = "e2e-tests/e2e-testing-mbp/${branchName}"
build(job: "${e2eTestsPipeline}",
parameters: [
booleanParam(name: 'forceSkipGitChecks', value: true),
booleanParam(name: 'forceSkipPresubmit', value: true),
booleanParam(name: 'notifyOnGreenBuilds', value: !isPR()),
booleanParam(name: 'USE_CI_SNAPSHOTS', value: true),
string(name: 'ELASTIC_AGENT_VERSION', value: "pr-${env.CHANGE_ID}"),
string(name: 'METRICBEAT_VERSION', value: "pr-${env.CHANGE_ID}"),
string(name: 'runTestsSuites', value: suite),
string(name: 'GITHUB_CHECK_NAME', value: env.GITHUB_CHECK_E2E_TESTS_NAME),
string(name: 'GITHUB_CHECK_REPO', value: env.REPO),
string(name: 'GITHUB_CHECK_SHA1', value: env.GIT_BASE_COMMIT),
Comment on lines +257 to +259
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will add a github check in thee Beats PR for the e2e

],
propagate: false,
wait: false
)

def notifyContext = "${env.GITHUB_CHECK_E2E_TESTS_NAME} for ${env.BEATS_FOLDER}"
githubNotify(context: "${notifyContext}", description: "${notifyContext} ...", status: 'PENDING', targetUrl: "${env.JENKINS_URL}search/?q=${e2eTestsPipeline.replaceAll('/','+')}")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will start a GH check for the e2e tests in the PENDING status

}

def withMacOSEnv(Closure body){
withEnvMask( vars: [
[var: "KEYCHAIN_PASS", password: getVaultSecret(secret: "secret/jenkins-ci/macos-codesign-keychain").data.password],
Expand Down