-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
chore: standardise how unit/integration tests is run on CI, adding a build command to compress the system-tests files #26209
Conversation
This command will replace the search_system_tests.py script
Filebeat and Metricbeat, including x-pack
This pull request doesn't have a |
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
Trends 🧪💚 Flaky test reportTests succeeded. Expand to view the summary
Test stats 🧪
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 added some suggestions.
Co-authored-by: Jaime Soriano Pastor <[email protected]>
def os_suffix = isArm() ? 'linux' : nodeOS() | ||
def name = folder.replaceAll('/', '-').replaceAll('\\\\', '-').replaceAll('build', '').replaceAll('^-', '') + '-' + os_suffix | ||
tarAndUploadArtifacts(file: "${name}.tgz", location: folder) | ||
withMageEnv(version: "${env.GO_VERSION}"){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can it be done this change in a different PR? Then, we can remove the scripts that configure the tools too?
def name = folder.replaceAll('/', '-').replaceAll('\\\\', '-').replaceAll('build', '').replaceAll('^-', '') + '-' + os_suffix | ||
tarAndUploadArtifacts(file: "${name}.tgz", location: folder) | ||
withMageEnv(version: "${env.GO_VERSION}"){ | ||
dir(directory){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if this is ''
as it would be if the .get()
returned its default value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are setting the variable with setEnvVar('GO_VERSION', readFile(".go-version").trim())
. Do you mean that the readFile
can return empty value? That would be the case if the .go-version
file disappears, which will represent a breaking change in how Go is installed.
We want to avoid collitions in beats overriding some commands
* master: [MetricBeat] [AWS] Fix aws metric tags with resourcegroupstaggingapi paginator (elastic#26385) (elastic#26443) Move openmetrics module to oss (elastic#26561) Skip flaky test TestFilestreamMetadataUpdatedOnRename (elastic#26609) [filebeat][fortinet] Use default add_locale for fortinet.firewall (elastic#26524) Enroll proxy settings (elastic#26514)
This pull request is now in conflicts. Could you fix it? 🙏
|
* master: (61 commits) Add disk queue unit tests based on the queuetest package [Heartbeat] redact authorization headers from logger (elastic#26892) Expose custom process metrics (elastic#26912) [gcp/billing] always quote table name identifier (elastic#26870) Add Beats central management removal to BCs (elastic#26400) Add custom suffix to identifiers in filestream input when needed (elastic#26669) Update asa-ftd-pipeline.yml (elastic#26265) Use common host parser in vsphere module (elastic#26904) [automation] Update go release version 1.16.6 (elastic#26860) Skip flaky test: filestream and harvester group (elastic#26728) [Filebeat] Remove alias fields from Suricata and Traefik module mappings (elastic#26627) docs: apm-server.auth (elastic#26831) [Automation] Update elastic stack version to 8.0.0-2f008f4a for testing (elastic#26881) Clarify the scope of start/end multiline example (elastic#26786) [Heartbeat]: update Node.js version for synthetics (elastic#26867) [fix][httpjson] Fix incorrect key for template data (elastic#26848) [httpjson] Add value_type parameter to httpjson transforms (elastic#26847) [Heartbeat]: capture error from journey/end events (elastic#26781) [Winlogbeat] Fixes for wineventlog experimental api (elastic#26826) Set agent.id to Fleet Agent ID for each metric/log monitoring input (elastic#26776) ...
This reverts commit 7aa8e53.
* master: Forward port 7.13.4 to master (elastic#26971) Use MustAddMetricSet in all metricsets (elastic#26907) add_process_metadata: enrich process info with process owner (elastic#21068) (elastic#21111) Use aws sdk paginator for FilterLogEvents and GetMetricData (elastic#26852) [Filebeat] Allow - for source IP for AWS S3 Access pipeline (elastic#26940) Increase timeout to 30secs (elastic#26841) Add Cluster filter on Kubernetes Overview ECS dashboard (elastic#26919)
jenkins run the tests please |
jenkins run the tests please |
@jsoriano I think this is ready to merge. Waiting for final 👍 to do so |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requesting changes mainly for the use of withModule
, I am not sure if this can be generaly used in other Beats beyond Metricbeat.
I am also a bit worried about the refactor of mage targets, we may be missing the execution of some tests by mistake. I think that the use of a central test
target was introduced for this. I wouldn't be in any case opposed to the use more specific targets, specially now that we have separated Jenkinsfiles, but I would like to have a second opinion by @andrewkroh about this.
// PackageSystemTests packages the python system tests results | ||
func PackageSystemTests() error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, if this target packages test results, could it be called PackageSystemTestsResults()
? :)
// PackageSystemTests packages the python system tests results | |
func PackageSystemTests() error { | |
// PackageSystemTestsResults packages the python system tests results | |
func PackageSystemTestsResults() error { |
withModule: true | ||
stage: mandatory | ||
pythonIntegTest: | ||
mage: "mage pythonIntegTest" | ||
withModule: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, not sure if we can use withModule
. Heartbeat doesn't have modules, it has monitors, but they have a different directory layout.
unitTest: | ||
mage: "mage build unitTest" | ||
stage: mandatory | ||
goIntegTest: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think heartbeat doesn't have integration tests.
tarAndUploadArtifacts(file: "${name}.tgz", location: folder) | ||
withMageEnv(version: "${env.GO_VERSION}"){ | ||
dir(directory){ | ||
cmd(label: "Archive system tests files", script: 'mage packageSystemTests') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If packageSystemTests
is only called here, are all the other changes required? I am a bit concerned that we may be missing the execution of some tests in some cases, it may be good to separate these changes to a different PR if possible, so we can merge this feature with less risks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, let me split the PR in two:
- changing test execution layout on CI
- adding the new mage command
Co-authored-by: Jaime Soriano Pastor <[email protected]>
This pull request is now in conflicts. Could you fix it? 🙏
|
What does this PR do?
This PR adds two things:
mage packageSystemTests
command, plugged into filebeat and metricbeat modules (both OSS and xpack flavours).Tar
method under thecommons.go
mage build file, so that it's possible to compress a source directory using TAR+GZIP algorithms, and writing it to the build dir in the root directory of the Beats repository.Besides that, we are removing a python script that detected the path to the Python system-tests (used in the pipeline to store the folder name in a variable), and we are updating the Jenkins pipeline to call the new build system command instead of the previous script. To keep existing behaviour, that we could consider it wrong and would possible discusse about it in a follow-up PR, we are passing a new argument to the groovy method in the pipeline, representing the directory in which the Beat live (i.e. filebeat, x-pack/filebeat), so that it's possible to run the
mage
command in the right context.Finally, we are keeping Pipeline2.0-consistency across Beats calling the Python system-tests, using OSS metricbeat's as the canonical reference: run unit tests, then Go integration tests, and finally Python integration tests when needed. This change applies to filebeat and metricbeat in both OSS and xpack flavours.
UPDATE: I finally revisited each Beat and made sure all of them run the unit, goInteg and pythonInteg tests in a consistent manner: instead of calling the obscure mage test command, we separate it in three different stages when needed:
mage unitTest
,mage goIntegTest
andmage pythonIntegTest
. I've verified one by one that each of those three commands is present in the build for the related Beat, adding or removing them from the CI descriptor (Jenkinsfile.yml
) when/if needed, creating the consistent experience of running atomic commands for each test type.Why is it important?
First one is simplicity: instead of adding code into the Jenkins pipeline that makes it almost impossible to reproduce it locally, we are moving to the build system, which will allow developers to run this target locally and verify what the CI will do.
Second is consistency: metricbeat and filebeat are running system-tests, and we want to operate them on CI in the same manner. That's why we are making the descriptors very similar.
And third, separation of concers: we want to run unit > integration > e2e tests in different stages, so that we acknowledge the power of not building/running code that could have been broken after a possible failure in a previous stage.
Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Author's Checklist
How to test this PR locally
Expected behaviour: a TAR file in the root's
build
directory named as the Beat will exist (i.e. ./build/system-tests-filebeat.tar.gz)Related issues
Follow-ups
We should consider following same separation of concerns in all Beats running
mage build test
, so that they run unitTest instead, and then having separate stages for integrations tests.