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

[CI] Add support to test packages with basic subscription #13377

Merged
merged 54 commits into from
Apr 9, 2025
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
54 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
383240f
Fix typo
mrodm Apr 9, 2025
44080a4
Remove daily step
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
2 changes: 2 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ env:
ELASTIC_PACKAGE_DISABLE_ELASTIC_AGENT_WOLFI: "${ELASTIC_PACKAGE_DISABLE_ELASTIC_AGENT_WOLFI:-false}"
# Disable checking for newer versions
ELASTIC_PACKAGE_CHECK_UPDATE_DISABLED: "true"
# Set Elastic subscription basic
ELASTIC_SUBSCRIPTION: "basic"

steps:
- label: "Get reference from target branch"
Expand Down
58 changes: 55 additions & 3 deletions .buildkite/scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,10 @@ prepare_stack() {
args="${args} -U stack.logsdb_enabled=true"
fi

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

if [[ "${STACK_VERSION}" =~ ^7\.17 ]]; then
# Required starting with STACK_VERSION 7.17.21
export ELASTIC_AGENT_IMAGE_REF_OVERRIDE="docker.elastic.co/beats/elastic-agent-complete:${STACK_VERSION}-amd64"
Expand Down Expand Up @@ -570,9 +574,9 @@ prepare_serverless_stack() {
}

is_spec_3_0_0() {
local pkg_spec
local pkg_spec=""
pkg_spec=$(cat manifest.yml | yq '.format_version')
local major_version
local major_version=""
major_version=$(echo "$pkg_spec" | cut -d '.' -f 1)

if [ "${major_version}" -ge 3 ]; then
Expand Down Expand Up @@ -668,6 +672,49 @@ get_to_changeset() {
echo "${to}"
}

subscription_package() {
local default="basic"
local subscription=""
subscription="$(cat "./manifest.yml" |yq -r '.conditions.elastic.subscription')"
if [[ "${subscription}" == "null" ]]; then
subscription="$(cat "./manifest.yml" |yq -r '.conditions."elastic.subscription"')"
fi
# Is it using the deprecated setting license ?
if [[ "${subscription}" == "null" ]]; then
subscription="$(cat "./manifest.yml" |yq -r '.license')"
fi
# if there is no value
if [[ "${subscription}" == "null" ]]; then
subscription="${default}"
fi
echo "${subscription}"
}

is_compatible_subscription() {
if [[ "${ELASTIC_SUBSCRIPTION:-""}" == "" ]]; then
return 0
fi

local subscription=""
subscription="$(subscription_package)"
echo "Subscription package=$subscription"

if [[ "${ELASTIC_SUBSCRIPTION}" == "trial" ]]; then
# All subscriptions are supported
return 0
fi

if [[ "${ELASTIC_SUBSCRIPTION}" == "basic" ]]; then
if [[ "${subscription}" != "basic" ]]; then
return 1
fi
return 0
fi

# Unknown subscription
return 1
}

is_pr_affected() {
local package="${1}"
local from=${2:-""}
Expand All @@ -691,6 +738,11 @@ is_pr_affected() {
fi
fi

if ! is_compatible_subscription; then
echo "[${package}] PR is not affected: subscription not compatible with ${ELASTIC_SUBSCRIPTION}"
return 1
fi

if [[ "${FORCE_CHECK_ALL}" == "true" ]];then
echo "[${package}] PR is affected: \"force_check_all\" parameter enabled"
return 0
Expand Down Expand Up @@ -757,7 +809,7 @@ teardown_test_package() {
}

list_all_directories() {
find . -maxdepth 1 -mindepth 1 -type d | xargs -I {} basename {} | sort
find . -maxdepth 1 -mindepth 1 -type d | xargs -I {} basename {} | sort |grep -E '^elastic_package_registry|cloud_defend|beaconing$'
}

check_package() {
Expand Down
3 changes: 3 additions & 0 deletions dev/testsreporter/_static/summary.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
{{ if .logsDB -}}
- LogsDB: enabled
{{ end -}}
{{ if ne .subscription "" -}}
- Subscription: {{ .subscription }}
{{ end -}}
{{ if and (ne .packageName "") (ne .packageName nil) -}}
- Package: {{ .packageName }}
- Failing test: {{ .testName }}
Expand Down
59 changes: 17 additions & 42 deletions dev/testsreporter/builderror.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package testsreporter

import (
"fmt"
"strings"
)

Expand All @@ -14,14 +13,6 @@ const (
buildReportingTeamLabel = "Team:Ecosystem"
)

type dataError struct {
errorLinks
serverless bool
serverlessProject string
logsDB bool
stackVersion string
}

type buildError struct {
dataError
teams []string
Expand All @@ -33,6 +24,7 @@ type buildErrorOptions struct {
ServerlessProject string
LogsDB bool
StackVersion string
Subscription string
Packages []string
BuildURL string
PreviousBuilds []string
Expand All @@ -49,6 +41,7 @@ func newBuildError(options buildErrorOptions) (*buildError, error) {
serverlessProject: options.ServerlessProject,
logsDB: options.LogsDB,
stackVersion: options.StackVersion,
subscription: options.Subscription,
errorLinks: errorLinks{
firstBuild: options.BuildURL,
closedIssueURL: options.ClosedIssueURL,
Expand All @@ -65,53 +58,35 @@ func newBuildError(options buildErrorOptions) (*buildError, error) {
func (b *buildError) String() string {
var sb strings.Builder

if b.logsDB {
sb.WriteString("[LogsDB] ")
}
if b.serverless {
sb.WriteString(fmt.Sprintf("[Serverless %s] ", b.serverlessProject))
}
if b.stackVersion != "" {
sb.WriteString("[Stack ")
sb.WriteString(b.stackVersion)
sb.WriteString("] ")
}
sb.WriteString(b.dataError.String())
sb.WriteString("Too many packages failing in daily job")

return sb.String()
}

func (p *buildError) FirstBuild() string {
return p.errorLinks.firstBuild
func (b *buildError) FirstBuild() string {
return b.errorLinks.firstBuild
}

func (p *buildError) UpdateLinks(links errorLinks) {
p.errorLinks = links
func (b *buildError) UpdateLinks(links errorLinks) {
b.errorLinks = links
}

func (p *buildError) Teams() []string {
return p.teams
func (b *buildError) Teams() []string {
return b.teams
}

func (p *buildError) SummaryData() map[string]any {
return map[string]any{
"stackVersion": p.stackVersion,
"serverless": p.serverless,
"serverlessProject": p.serverlessProject,
"logsDB": p.logsDB,
"packages": p.packages,
"owners": p.teams,
}
func (b *buildError) SummaryData() map[string]any {
data := b.dataError.SummaryData()
data["packages"] = b.packages
data["owners"] = b.teams
return data
}

func (p *buildError) DescriptionData() map[string]any {
return map[string]any{
"firstBuild": p.errorLinks.firstBuild,
"closedIssueURL": p.errorLinks.closedIssueURL,
"previousBuilds": p.errorLinks.previousBuilds,
}
func (b *buildError) DescriptionData() map[string]any {
return b.errorLinks.Data()
}

func (p *buildError) Labels() []string {
func (b *buildError) Labels() []string {
return []string{buildReportingTeamLabel}
}
51 changes: 51 additions & 0 deletions dev/testsreporter/dataerror.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// 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 testsreporter

import (
"fmt"
"strings"
)

type dataError struct {
errorLinks
serverless bool
serverlessProject string
logsDB bool
stackVersion string
subscription string
}

func (d *dataError) String() string {
var sb strings.Builder

if d.logsDB {
sb.WriteString("[LogsDB] ")
}
if d.serverless {
sb.WriteString(fmt.Sprintf("[Serverless %s] ", d.serverlessProject))
}
if d.stackVersion != "" {
sb.WriteString("[Stack ")
sb.WriteString(d.stackVersion)
sb.WriteString("] ")
}
if d.subscription != "" {
sb.WriteString("[Subscription ")
sb.WriteString(d.subscription)
sb.WriteString("] ")
}
return sb.String()
}

func (d *dataError) SummaryData() map[string]any {
return map[string]any{
"stackVersion": d.stackVersion,
"serverless": d.serverless,
"serverlessProject": d.serverlessProject,
"logsDB": d.logsDB,
"subscription": d.subscription,
}
}
20 changes: 20 additions & 0 deletions dev/testsreporter/errorlinks.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// 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 testsreporter

type errorLinks struct {
currentIssueURL string
firstBuild string
previousBuilds []string
closedIssueURL string
}

func (e *errorLinks) Data() map[string]any {
return map[string]any{
"firstBuild": e.firstBuild,
"closedIssueURL": e.closedIssueURL,
"previousBuilds": e.previousBuilds,
}
}
37 changes: 28 additions & 9 deletions dev/testsreporter/format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestSummary(t *testing.T) {
`,
},
{
title: "summary stack version with owners wihtout data stream",
title: "summary stack version with owners without data stream",
resultError: &packageError{
dataError: dataError{
stackVersion: "8.14",
Expand Down Expand Up @@ -156,6 +156,30 @@ func TestSummary(t *testing.T) {
teams: []string{"team1"},
},
expected: `- Stack version: 8.16
- Packages:
- foo
- bar
- Owners:
- team1
`,
},
{
title: "summary with basic license",
resultError: &buildError{
dataError: dataError{
logsDB: false,
serverless: false,
subscription: "basic",
stackVersion: "8.16",
},
packages: []string{
"foo",
"bar",
},
teams: []string{"team1"},
},
expected: `- Stack version: 8.16
- Subscription: basic
- Packages:
- foo
- bar
Expand All @@ -181,14 +205,12 @@ func TestSummary(t *testing.T) {
func TestDescription(t *testing.T) {
cases := []struct {
title string
summary string
resultError failureObserver
maxLinks int
expected string
}{
{
title: "description error all fields",
summary: "summary",
title: "description error all fields",
resultError: &packageError{
dataError: dataError{
stackVersion: "8.14",
Expand Down Expand Up @@ -226,8 +248,7 @@ Latest failed builds:
`,
},
{
title: "description failure all fields",
summary: "summary",
title: "description failure all fields",
resultError: &packageError{
dataError: dataError{
stackVersion: "8.14",
Expand Down Expand Up @@ -265,8 +286,7 @@ Latest failed builds:
`,
},
{
title: "description no closed issue",
summary: "summary",
title: "description no closed issue",
resultError: &packageError{
dataError: dataError{
stackVersion: "8.14",
Expand Down Expand Up @@ -302,7 +322,6 @@ Latest failed builds:
},
{
title: "description max links",
summary: "summary",
maxLinks: 2,
resultError: &packageError{
dataError: dataError{
Expand Down
Loading