Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
9679c7c
Add support to run Elastic stack with other licenses
mrodm Apr 1, 2025
6e586b7
Add support to report issues related to subscription
mrodm Apr 1, 2025
495da16
Refactor to build common summary and string from dataError
mrodm Apr 1, 2025
e74ae7e
Refactor to buld common error links data from its object
mrodm Apr 1, 2025
081ffd3
Add option to enable verbose mode
mrodm Apr 1, 2025
969e38b
Test setting subscription basic - to be removed
mrodm Apr 1, 2025
cf0da7b
Rename function
mrodm Apr 1, 2025
099dea6
Check first if owners is not nil in summary template
mrodm Apr 2, 2025
2247914
Test with trial subscription
mrodm Apr 2, 2025
d7e479c
Test with other packages with other scenarios
mrodm Apr 2, 2025
b37ac87
Test again with basic subscription
mrodm Apr 2, 2025
3c114bd
Add target mage for subscription validation
mrodm Apr 2, 2025
0ee660e
Add some more packages to test
mrodm Apr 2, 2025
51bbb78
Test with bash functions
mrodm Apr 2, 2025
5d03168
Try with mage targets - added missing installation
mrodm Apr 2, 2025
1dc0401
Test all packages with basic license
mrodm Apr 2, 2025
69edc0a
Not shown files from git-diff checks
mrodm Apr 2, 2025
bee404b
Show annotation with skipped files
mrodm Apr 2, 2025
7252015
Fix collapsed annotation
mrodm Apr 2, 2025
571eca9
Test annotation
mrodm Apr 3, 2025
ce0b4a7
Just show skipped packages
mrodm Apr 3, 2025
d1a7db4
Test elastic-package PR 2511 - 62704d87
mrodm Apr 3, 2025
5522c3d
Update version in .go-version file
mrodm Apr 3, 2025
28e6578
Revert changes moved to other PRs
mrodm Apr 4, 2025
067f900
Test all packages with basic license
mrodm Apr 4, 2025
139851c
Merge upstream/main into test_packages_basic_subscription
mrodm Apr 7, 2025
f3fee7c
Include summary data into description data too
mrodm Apr 7, 2025
0a2b778
Add stack version entry if it has empty string
mrodm Apr 7, 2025
6805016
Test updating just one package
mrodm Apr 7, 2025
999aa58
Add collapsed blocks in trigger step
mrodm Apr 7, 2025
b9173ae
Remove one collapsed block
mrodm Apr 7, 2025
eaed4c4
Remove comments and changes for debugging
mrodm Apr 7, 2025
63fcf64
Test creation of GH issues
mrodm Apr 7, 2025
87e64da
Add default values
mrodm Apr 8, 2025
ef66216
Remove step to test with LogsDB and basic subscription
mrodm Apr 8, 2025
3f606bb
Add comment
mrodm Apr 8, 2025
4b5a98d
Remove kibana from test packages
mrodm Apr 8, 2025
51e2db1
Rename function
mrodm Apr 8, 2025
592acb2
Remove changes for debugging
mrodm Apr 8, 2025
8934110
Remove show skipped packages as annotation
mrodm Apr 8, 2025
8461649
Revert changes in go.mod go.sum
mrodm Apr 8, 2025
fcfc90a
Remove whitespace
mrodm Apr 8, 2025
2dd8413
Update go.mod
mrodm Apr 8, 2025
3c93e90
Revert .go-version file
mrodm Apr 8, 2025
fe32361
Use stdout to indicate whether or not it is supported
mrodm Apr 8, 2025
7560c46
Test some packages
mrodm Apr 8, 2025
ae345bb
Update error management
mrodm Apr 8, 2025
5f301e4
Add debug messages
mrodm Apr 8, 2025
4eea916
Test with elastic-pacakge v0.111.0
mrodm Apr 8, 2025
d32eb44
Add collapsed block
mrodm Apr 8, 2025
092b361
Revert "Test with elastic-pacakge v0.111.0"
mrodm Apr 9, 2025
1e3ee5c
Revert "Test some packages"
mrodm Apr 9, 2025
9986985
Test with LogsDB enabled
mrodm Apr 8, 2025
de21096
Test some packages
mrodm Apr 8, 2025
01fb08c
Add error messages
mrodm Apr 8, 2025
94076ff
Test with logsdb
mrodm Apr 8, 2025
ec53b60
Add tests
mrodm Apr 8, 2025
df15ef0
Update values returned
mrodm Apr 9, 2025
ddb0641
Update summary to include reference for LogsDB without STACK_VERSION
mrodm Apr 9, 2025
48f3e7d
Show stack version to be used for testing
mrodm Apr 9, 2025
db4431e
Add another test package
mrodm Apr 9, 2025
f1b9f41
Test reporting issues DRY_RUN mode
mrodm Apr 9, 2025
7605ef2
Remove step from daily job
mrodm Apr 9, 2025
4d358a4
Update variables for stack versions
mrodm Apr 9, 2025
e1134b7
Remove changes for debugging
mrodm Apr 9, 2025
fb1b48e
Merge upstream/main into test_packages_basic_subscription_and_logsdb
mrodm Apr 9, 2025
1f0a1a8
Added comments
mrodm Apr 9, 2025
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
52 changes: 49 additions & 3 deletions .buildkite/scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -499,25 +499,44 @@ create_elastic_package_profile() {
prepare_stack() {
echo "--- Prepare stack"

local requiredSubscription="${ELASTIC_SUBSCRIPTION:-""}"
local requiredLogsDB="${STACK_LOGSDB_ENABLED:-"false"}"

local args="-v"
local version_set=""
if [ -n "${STACK_VERSION}" ]; then
args="${args} --version ${STACK_VERSION}"
version_set="${STACK_VERSION}"
else
local version
version=$(oldest_supported_version)
if [[ "${requiredLogsDB}" == "true" ]]; then
# If LogsDB index mode is enabled, the required Elastic stack should be at least 8.17.0
# In 8.17.0 LogsDB index mode was made GA.
local less_than=""
if ! less_than=$(mage -d "${WORKSPACE}" -w . isVersionLessThanLogsDBGA "${version}") ; then
echo "${FATAL_ERROR}"
return 1
fi
if [[ "${less_than}" == "true" ]]; then
version="8.17.0"
fi
fi
if [[ "${version}" != "null" ]]; then
args="${args} --version ${version}"
version_set="${version}"
fi
fi
echoerr "- Stack Version: \"${version_set}\""

if [ "${STACK_LOGSDB_ENABLED:-false}" == "true" ]; then
if [ "${requiredLogsDB:-false}" == "true" ]; then
echoerr "- Enable LogsDB"
args="${args} -U stack.logsdb_enabled=true"
fi

if [ "${ELASTIC_SUBSCRIPTION:-""}" != "" ]; then
if [ "${requiredSubscription}" != "" ]; then
echoerr "- Set Subscription ${ELASTIC_SUBSCRIPTION}"
args="${args} -U stack.elastic_subscription=${ELASTIC_SUBSCRIPTION}"
args="${args} -U stack.elastic_subscription=${requiredSubscription}"
fi

if [[ "${STACK_VERSION}" =~ ^7\.17 ]]; then
Expand Down Expand Up @@ -686,6 +705,20 @@ is_subscription_compatible() {
return 0
}

is_logsdb_compatible() {
if [[ "${STACK_VERSION:-""}" != "" ]]; then
# Assumption that if this variable is set, it is supported
echo "true"
return 0
fi

if ! reason=$(mage -d "${WORKSPACE}" -w . isLogsDBSupportedInPackage); then
return 1
fi
echo "${reason}"
return 0
}

is_pr_affected() {
local package="${1}"
local from="${2}"
Expand All @@ -696,6 +729,19 @@ is_pr_affected() {
return 1
fi

if [[ "${STACK_LOGSDB_ENABLED:-"false"}" == "true" ]]; then
# Packages require to support 8.17.0 or higher as part of their Kibana constraints (manifest)
local logsdb_compatible=""
if ! logsdb_compatible=$(is_logsdb_compatible); then
echo "${FATAL_ERROR}"
return 1
fi
if [[ "${logsdb_compatible}" == "false" ]]; then
echo "[${package}] PR is not affected: not supported LogsDB (${STACK_VERSION})"
return 1
fi
fi

if is_serverless; then
if is_package_excluded_in_config "${package}" "${WORKSPACE}/kibana.serverless.config.yml"; then
echo "[${package}] PR is not affected: package ${package} excluded in Kibana config for ${SERVERLESS_PROJECT}"
Expand Down
59 changes: 59 additions & 0 deletions dev/citools/logsdb.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

package citools

import (
"fmt"

"github.com/Masterminds/semver/v3"
)

var (
semver8_17_0 = semver.MustParse("8.17.0")
semver8_19_99 = semver.MustParse("8.19.99")
semver9_99_99 = semver.MustParse("9.99.99")
)

func IsVersionLessThanLogsDBGA(version *semver.Version) bool {
return version.LessThan(semver8_17_0)
}

func packageKibanaConstraint(path string) (*semver.Constraints, error) {
manifest, err := readPackageManifest(path)
if err != nil {
return nil, err
}

kibanaConstraint := manifest.Conditions.Kibana.Version
if kibanaConstraint == "" {
return nil, nil
}

constraints, err := semver.NewConstraint(kibanaConstraint)
if err != nil {
return nil, err
}

return constraints, nil
}

func IsLogsDBSupportedInPackage(path string) (bool, error) {
constraint, err := packageKibanaConstraint(path)
if err != nil {
return false, fmt.Errorf("failed to read kibana.constraint fro mmanifest: %w", err)
}

if constraint == nil {
// Package does not contain any kibana.version
return true, nil
}

// Ensure that the package supports LogsDB mode
// It is not used here "semver8_17_0" since a constraint like "^8.18.0 || ^9.0.0" would return false
if constraint.Check(semver8_19_99) || constraint.Check(semver9_99_99) {
return true, nil
}
return false, nil
}
104 changes: 104 additions & 0 deletions dev/citools/logsdb_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

package citools

import (
"os"
"path/filepath"
"testing"

"github.com/Masterminds/semver/v3"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestIsVersionLessThanLogsDBGA(t *testing.T) {
cases := []struct {
title string
version *semver.Version
expected bool
}{
{
title: "less than LogsDB GA",
version: semver.MustParse("8.12.0"),
expected: true,
},
{
title: "greater or equal than LogsSB GA",
version: semver.MustParse("8.17.0"),
expected: false,
},
}

for _, c := range cases {
t.Run(c.title, func(t *testing.T) {
value := IsVersionLessThanLogsDBGA(c.version)
assert.Equal(t, c.expected, value)
})
}

}

func TestIsLogsDBSupportedInPackage(t *testing.T) {
cases := []struct {
title string
contents string
expectedError bool
supported bool
}{
{
title: "Supported LogsDB field",
contents: `name: "logsdb"
conditions:
kibana:
version: "^7.16.0 || ^8.0.0 || ^9.0.0"
`,
expectedError: false,
supported: true,
},
{
title: "Kibana constraint dotted field",
contents: `name: "subscription"
conditions:
kibana.version: "^7.16.0 || ^8.0.0 || ^9.0.0"
`,
expectedError: false,
supported: true,
},
{
title: "LogsDB not supported",
contents: `name: "subscription"
conditions:
kibana.version: "^7.16.0"
`,
expectedError: false,
supported: false,
},
{
title: "No Kibana constraint",
contents: `name: "subscription"
`,
expectedError: false,
supported: true,
},
}

for _, c := range cases {
t.Run(c.title, func(t *testing.T) {
directory := t.TempDir()
pkgManifestPath := filepath.Join(directory, "manifest.yml")
err := os.WriteFile(pkgManifestPath, []byte(c.contents), 0o644)
require.NoError(t, err)
supported, err := IsLogsDBSupportedInPackage(pkgManifestPath)
if c.expectedError {
assert.Error(t, err)
} else {
assert.NoError(t, err)
assert.Equal(t, c.supported, supported)
}
})
}

}
4 changes: 4 additions & 0 deletions dev/testsreporter/_static/summary.tmpl
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{{ if ne .stackVersion "" -}}
- Stack version: {{ .stackVersion }}
{{ else -}}
{{ if .logsDB -}}
- Stack version: maximum of either the version used in PR builds or 8.17.0 (GA version for LogsDB index mode)
{{ else -}}
- Stack version: Same as in Pull Request builds
{{ end -}}
{{ end -}}
{{ if .serverless -}}
- Serverless: {{ .serverlessProject}}
{{ end -}}
Expand Down
4 changes: 2 additions & 2 deletions dev/testsreporter/format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func TestSummary(t *testing.T) {
`,
},
{
title: "summary logsdb",
title: "summary logsdb without stack version defined",
resultError: &packageError{
dataError: dataError{
logsDB: true,
Expand All @@ -135,7 +135,7 @@ func TestSummary(t *testing.T) {
},
teams: []string{"team1", "team2"},
},
expected: `- Stack version: Same as in Pull Request builds
expected: `- Stack version: maximum of either the version used in PR builds or 8.17.0 (GA version for LogsDB index mode)
- LogsDB: enabled
- Package: foo
- Failing test: mytest
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/elastic/integrations
go 1.24.2

require (
github.com/Masterminds/semver/v3 v3.3.1
github.com/blang/semver v3.5.1+incompatible
github.com/cli/go-gh/v2 v2.12.0
github.com/elastic/elastic-package v0.111.0
Expand Down Expand Up @@ -34,7 +35,6 @@ require (
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.49.0 // indirect
github.com/MakeNowJust/heredoc v1.0.0 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.3.1 // indirect
github.com/Masterminds/sprig/v3 v3.3.0 // indirect
github.com/PaesslerAG/gval v1.2.2 // indirect
github.com/PaesslerAG/jsonpath v0.1.1 // indirect
Expand Down
30 changes: 30 additions & 0 deletions magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"path/filepath"
"strconv"

"github.com/Masterminds/semver/v3"
"github.com/magefile/mage/mg"
"github.com/magefile/mage/sh"
"github.com/pkg/errors"
Expand Down Expand Up @@ -233,3 +234,32 @@ func IsSubscriptionCompatible() error {
fmt.Println("false")
return nil
}

// IsLogsDBSupportedInPackage checks wheter or not the package in the current directory supports LogsDB
func IsLogsDBSupportedInPackage() error {
supported, err := citools.IsLogsDBSupportedInPackage("manifest.yml")
if err != nil {
return err
}
if !supported {
fmt.Println("false")
return nil
}
fmt.Println("true")
return nil
}

// IsVersionLessThanLogsDBGA checks wheter or not the given version supports LogsDB. Minimum version that supports LogsDB as GA 8.17.0.
func IsVersionLessThanLogsDBGA(version string) error {
stackVersion, err := semver.NewVersion(version)
if err != nil {
return fmt.Errorf("failed to parse version %q: %w", version, err)
}
lessThan := citools.IsVersionLessThanLogsDBGA(stackVersion)
if lessThan {
fmt.Println("true")
return nil
}
fmt.Println("false")
return nil
}