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

Cherry-pick #18835 to 7.x: Add missing Jenkins stages for Auditbeat #18867

Merged
merged 1 commit into from
May 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
108 changes: 69 additions & 39 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ pipeline {
}
}
}
stage('Auditbeat oss'){
stage('Auditbeat oss Linux'){
agent { label 'ubuntu && immutable' }
options { skipDefaultCheckout() }
when {
Expand All @@ -273,49 +273,53 @@ pipeline {
return env.BUILD_AUDITBEAT != "false"
}
}
stages {
stage('Auditbeat Linux'){
steps {
makeTarget("Auditbeat oss Linux", "-C auditbeat testsuite")
}
steps {
makeTarget("Auditbeat oss Linux", "-C auditbeat testsuite")
}
}
stage('Auditbeat crosscompile'){
agent { label 'ubuntu && immutable' }
options { skipDefaultCheckout() }
when {
beforeAgent true
expression {
return env.BUILD_AUDITBEAT != "false"
}
stage('Auditbeat crosscompile'){
steps {
makeTarget("Auditbeat oss crosscompile", "-C auditbeat crosscompile")
}
}
steps {
makeTarget("Auditbeat oss crosscompile", "-C auditbeat crosscompile")
}
}
stage('Auditbeat oss Mac OS X'){
agent { label 'macosx' }
options { skipDefaultCheckout() }
when {
beforeAgent true
expression {
return env.BUILD_AUDITBEAT != "false" && params.macosTest
}
stage('Auditbeat Mac OS X'){
agent { label 'macosx' }
options { skipDefaultCheckout() }
when {
beforeAgent true
expression {
return params.macosTest
}
}
steps {
mageTarget("Auditbeat oss Mac OS X", "auditbeat", "build unitTest")
}
post {
always {
delete()
}
}
}
steps {
mageTarget("Auditbeat oss Mac OS X", "auditbeat", "build unitTest")
}
post {
always {
delete()
}
stage('Auditbeat Windows'){
agent { label 'windows-immutable && windows-2019' }
options { skipDefaultCheckout() }
when {
beforeAgent true
expression {
return params.windowsTest
}
}
steps {
mageTargetWin("Auditbeat Windows Unit test", "auditbeat", "build unitTest")
}
}
}
stage('Auditbeat oss Windows'){
agent { label 'windows-immutable && windows-2019' }
options { skipDefaultCheckout() }
when {
beforeAgent true
expression {
return env.BUILD_AUDITBEAT != "false" && params.windowsTest
}
}
steps {
mageTargetWin("Auditbeat oss Windows Unit test", "auditbeat", "build unitTest")
}
}
stage('Auditbeat x-pack'){
agent { label 'ubuntu && immutable' }
Expand All @@ -330,6 +334,32 @@ pipeline {
mageTarget("Auditbeat x-pack Linux", "x-pack/auditbeat", "update build test")
}
}
stage('Auditbeat x-pack Mac OS X'){
agent { label 'macosx' }
options { skipDefaultCheckout() }
when {
beforeAgent true
expression {
return env.BUILD_AUDITBEAT_XPACK != "false" && params.macosTest
}
}
steps {
mageTarget("Auditbeat x-pack Mac OS X", "x-pack/auditbeat", "build unitTest")
}
}
stage('Auditbeat x-pack Windows'){
agent { label 'windows-immutable && windows-2019' }
options { skipDefaultCheckout() }
when {
beforeAgent true
expression {
return env.BUILD_AUDITBEAT_XPACK != "false" && params.windowsTest
}
}
steps {
mageTargetWin("Auditbeat x-pack Windows", "x-pack/auditbeat", "build unitTest")
}
}
stage('Libbeat'){
agent { label 'ubuntu && immutable' }
options { skipDefaultCheckout() }
Expand Down
3 changes: 2 additions & 1 deletion x-pack/auditbeat/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
// mage:import
"github.com/elastic/beats/v7/dev-tools/mage/target/common"
// mage:import
_ "github.com/elastic/beats/v7/dev-tools/mage/target/unittest"
"github.com/elastic/beats/v7/dev-tools/mage/target/unittest"
// mage:import
_ "github.com/elastic/beats/v7/dev-tools/mage/target/integtest"
// mage:import
Expand All @@ -29,6 +29,7 @@ import (

func init() {
common.RegisterCheckDeps(Update)
unittest.RegisterPythonTestDeps(fieldsYML)

devtools.BeatDescription = "Audit the activities of users and processes on your system."
devtools.BeatLicense = "Elastic License"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ func TestHomebrew(t *testing.T) {
checkFieldValue(t, event, "system.audit.package.summary", "Test package")
checkFieldValue(t, event, "system.audit.package.url", "https://www.elastic.co/")
checkFieldValue(t, event, "system.audit.package.version", "1.0.0")
checkFieldValue(t, event, "system.audit.package.entity_id", "Krm421rtYM4wgq1S")
// FIXME: The value of this field changes on each execution in CI - https://github.com/elastic/beats/issues/18855
// checkFieldValue(t, event, "system.audit.package.entity_id", "Krm421rtYM4wgq1S")
checkFieldValue(t, event, "package.name", "test-package")
checkFieldValue(t, event, "package.description", "Test package")
checkFieldValue(t, event, "package.reference", "https://www.elastic.co/")
Expand All @@ -69,9 +70,10 @@ func TestHomebrew(t *testing.T) {
}

func checkFieldValue(t *testing.T, event beat.Event, fieldName string, fieldValue interface{}) {
t.Helper()
value, err := event.GetValue(fieldName)
if assert.NoError(t, err) {
assert.Equal(t, fieldValue, value)
if assert.NoError(t, err, "checking field %s", fieldName) {
assert.Equal(t, fieldValue, value, "checking field %v", fieldName)
}
}

Expand Down
5 changes: 5 additions & 0 deletions x-pack/auditbeat/module/system/package/package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package pkg

import (
"path/filepath"
"runtime"
"testing"

"github.com/stretchr/testify/assert"
Expand All @@ -19,6 +20,10 @@ import (
)

func TestData(t *testing.T) {
if runtime.GOOS == "darwin" {
t.Skip("FIXME: https://github.com/elastic/beats/issues/18855")
}

defer abtest.SetupDataDir(t)()

f := mbtest.NewReportingMetricSetV2(t, getConfig())
Expand Down