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 4 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
42 changes: 42 additions & 0 deletions .ci/packaging.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ pipeline {
deleteDir()
release()
pushCIDockerImages()
runE2ETestForPackages()
}
}
}
Expand Down Expand Up @@ -209,6 +210,31 @@ 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 slackChannel = 'ingest-management'

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

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

def triggerE2ETests(String suite, String channel) {
build(job: "../../e2e-tests/e2e-testing-mbp/${env.JOB_BASE_NAME}",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@elastic/observablt-robots how do we build the relative path here? I tried with and without the dots, without success. See error here: https://beats-ci.elastic.co/job/Beats/job/packaging/job/PR-21100/6/console

Copy link
Member

@v1v v1v Sep 17, 2020

Choose a reason for hiding this comment

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

I guess thee JOB_BASE_NAME does not match any of the jobs in the MBP:

It might work for branches but for testing this PR it might not work since they are different git projects.

Maybe you would like to use the target branch env variable (see CHANGE_TARGET in here).

You can use e2e-tests/e2e-testing-mbp/.. instead ../../..

mdelapenya marked this conversation as resolved.
Show resolved Hide resolved
parameters: [
booleanParam(name: 'forceSkipGitChecks', value: true),
booleanParam(name: 'forceSkipPresubmit', value: true),
booleanParam(name: 'notifyOnGreenBuilds', value: !isPR()),
booleanParam(name: 'ELASTIC_AGENT_USE_CI_SNAPSHOTS', value: true),
string(name: 'ELASTIC_AGENT_VERSION', value: "pr-${env.CHANGE_ID}"),
string(name: 'runTestsSuite', value: suite),
string(name: 'SLACK_CHANNEL', value: channel),
],
propagate: false,
wait: false
)
}

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