Skip to content

Commit 533bb38

Browse files
committed
Merge remote-tracking branch 'upstream/main' into cisco_ios_hostname
2 parents 31042e9 + 9ff6aeb commit 533bb38

File tree

122 files changed

+1424
-241
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+1424
-241
lines changed

.buildkite/hooks/pre-command

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ git config --global core.pager 'cat'
1111
export UPLOAD_SAFE_LOGS=${UPLOAD_SAFE_LOGS:-"0"}
1212
export SERVERLESS=${SERVERLESS:-"false"}
1313
export STACK_VERSION=${STACK_VERSION:-""}
14+
export ELASTIC_SUBSCRIPTION=${ELASTIC_SUBSCRIPTION:-""}
15+
export STACK_LOGSDB_ENABLED=${STACK_LOGSDB_ENABLED:-"false"}
1416
export FORCE_CHECK_ALL=${FORCE_CHECK_ALL:-"false"}
1517
export PUBLISH_COVERAGE_REPORTS=${PUBLISH_COVERAGE_REPORTS:-"false"}
1618

.buildkite/scripts/common.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ API_BUILDKITE_PIPELINES_URL="https://api.buildkite.com/v2/organizations/elastic/
1818
COVERAGE_FORMAT="generic"
1919
COVERAGE_OPTIONS="--test-coverage --coverage-format=${COVERAGE_FORMAT}"
2020

21+
FATAL_ERROR="Fatal Error"
22+
2123
running_on_buildkite() {
2224
if [[ "${BUILDKITE:-"false"}" == "true" ]]; then
2325
return 0
@@ -509,9 +511,15 @@ prepare_stack() {
509511
fi
510512

511513
if [ "${STACK_LOGSDB_ENABLED:-false}" == "true" ]; then
514+
echoerr "- Enable LogsDB"
512515
args="${args} -U stack.logsdb_enabled=true"
513516
fi
514517

518+
if [ "${ELASTIC_SUBSCRIPTION:-""}" != "" ]; then
519+
echoerr "- Set Subscription ${ELASTIC_SUBSCRIPTION}"
520+
args="${args} -U stack.elastic_subscription=${ELASTIC_SUBSCRIPTION}"
521+
fi
522+
515523
if [[ "${STACK_VERSION}" =~ ^7\.17 ]]; then
516524
# Required starting with STACK_VERSION 7.17.21
517525
export ELASTIC_AGENT_IMAGE_REF_OVERRIDE="docker.elastic.co/beats/elastic-agent-complete:${STACK_VERSION}-amd64"
@@ -668,6 +676,16 @@ get_to_changeset() {
668676
echo "${to}"
669677
}
670678

679+
is_subscription_compatible() {
680+
local reason=""
681+
682+
if ! reason=$(mage -d "${WORKSPACE}" -w . isSubscriptionCompatible) ; then
683+
return 1
684+
fi
685+
echo "${reason}"
686+
return 0
687+
}
688+
671689
is_pr_affected() {
672690
local package="${1}"
673691
local from="${2}"
@@ -698,6 +716,15 @@ is_pr_affected() {
698716
return 1
699717
fi
700718
fi
719+
local compatible=""
720+
if ! compatible=$(is_subscription_compatible); then
721+
echo "${FATAL_ERROR}"
722+
return 1
723+
fi
724+
if [[ "${compatible}" == "false" ]]; then
725+
echo "[${package}] PR is not affected: subscription not compatible with ${ELASTIC_SUBSCRIPTION}"
726+
return 1
727+
fi
701728

702729
if [[ "${FORCE_CHECK_ALL}" == "true" ]];then
703730
echo "[${package}] PR is affected: \"force_check_all\" parameter enabled"

.buildkite/scripts/test_integrations_with_serverless.sh

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ if [ ! -d packages ]; then
4343
exit 1
4444
fi
4545

46+
echo "--- Install requirements"
4647
add_bin_path
4748

4849
with_yq
@@ -60,6 +61,7 @@ sleep 120
6061
echo "Done."
6162

6263
# setting range of changesets to check differences
64+
echo "--- Get from and to changesets"
6365
from="$(get_from_changeset)"
6466
if [[ "${from}" == "" ]]; then
6567
echo "Missing \"from\" changset".
@@ -76,15 +78,28 @@ any_package_failing=0
7678

7779
pushd packages > /dev/null
7880
for package in $(list_all_directories); do
81+
echo "--- [$package] check if it is required to be tested"
7982
pushd "${package}" > /dev/null
83+
skip_package=false
84+
failure=false
8085
if ! reason=$(is_pr_affected "${package}" "${from}" "${to}") ; then
81-
echo "${reason}"
86+
skip_package=true
87+
if [[ "${reason}" == "${FATAL_ERROR}" ]]; then
88+
failure=true
89+
fi
90+
fi
91+
popd > /dev/null
92+
if [[ "${failure}" == "true" ]]; then
93+
echo "Unexpected failure checking ${package}"
94+
exit 1
95+
fi
96+
97+
echo "${reason}"
98+
99+
if [[ "${skip_package}" == "true" ]]; then
82100
echo "- ${reason}" >> "${SKIPPED_PACKAGES_FILE_PATH}"
83-
popd > /dev/null
84101
continue
85102
fi
86-
echo "${reason}"
87-
popd > /dev/null
88103

89104
if ! process_package "${package}" "${FAILED_PACKAGES_FILE_PATH}" ; then
90105
any_package_failing=1
@@ -94,10 +109,12 @@ popd > /dev/null
94109

95110
if running_on_buildkite ; then
96111
if [ -f "${SKIPPED_PACKAGES_FILE_PATH}" ]; then
112+
echo "--- Create Skip Buildkite annotation"
97113
create_collapsed_annotation "Skipped packages in ${SERVERLESS_PROJECT}" "${SKIPPED_PACKAGES_FILE_PATH}" "info" "ctx-skipped-packages-${SERVERLESS_PROJECT}"
98114
fi
99115

100116
if [ -f "${FAILED_PACKAGES_FILE_PATH}" ]; then
117+
echo "--- Create Failed Buildkite annotation"
101118
create_collapsed_annotation "Failed packages in ${SERVERLESS_PROJECT}" "${FAILED_PACKAGES_FILE_PATH}" "error" "ctx-failed-packages-${SERVERLESS_PROJECT}"
102119
fi
103120
fi

.buildkite/scripts/trigger_integrations_in_parallel.sh

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ source .buildkite/scripts/common.sh
44

55
set -euo pipefail
66

7+
echo "--- Install requirements"
78
add_bin_path
89
with_yq
10+
with_mage
911

1012
pushd packages > /dev/null
1113
PACKAGE_LIST=$(list_all_directories)
@@ -22,8 +24,8 @@ steps:
2224
EOF
2325

2426
# Get from and to changesets to avoid repeating the same queries for each package
25-
2627
# setting range of changesets to check differences
28+
echo "--- Get from and to changesets"
2729
from="$(get_from_changeset)"
2830
if [[ "${from}" == "" ]]; then
2931
echo "Missing \"from\" changset".
@@ -51,15 +53,24 @@ packages_to_test=0
5153

5254
for package in ${PACKAGE_LIST}; do
5355
# check if needed to create an step for this package
56+
echo "--- [$package] check if it is required to be tested"
5457
pushd "packages/${package}" > /dev/null
5558
skip_package="false"
59+
failure="false"
5660
if ! reason=$(is_pr_affected "${package}" "${from}" "${to}") ; then
5761
skip_package="true"
62+
if [[ "${reason}" == "${FATAL_ERROR}" ]]; then
63+
failure=true
64+
fi
5865
fi
59-
echoerr "${reason}"
6066
popd > /dev/null
67+
if [[ "${failure}" == "true" ]]; then
68+
echo "Unexpected failure checking ${package}"
69+
exit 1
70+
fi
6171

62-
if [[ "$skip_package" == "true" ]] ; then
72+
echoerr "${reason}"
73+
if [[ "${skip_package}" == "true" ]] ; then
6374
continue
6475
fi
6576

@@ -87,8 +98,10 @@ EOF
8798
done
8899

89100
if [ ${packages_to_test} -eq 0 ]; then
101+
echo "--- Create Buildkite annotation no packages to be tested"
90102
buildkite-agent annotate "No packages to be tested" --context "ctx-no-packages" --style "warning"
91103
exit 0
92104
fi
93105

106+
echo "--- Upload Buildkite pipeline"
94107
cat ${PIPELINE_FILE} | buildkite-agent pipeline upload

.go-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.23.4
1+
1.24.2

dev/citools/packagemanifest.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
2+
// or more contributor license agreements. Licensed under the Elastic License;
3+
// you may not use this file except in compliance with the Elastic License.
4+
5+
package citools
6+
7+
import (
8+
"fmt"
9+
10+
"github.com/elastic/go-ucfg"
11+
"github.com/elastic/go-ucfg/yaml"
12+
)
13+
14+
// kibanaConditions defines conditions for Kibana (e.g. required version).
15+
type kibanaConditions struct {
16+
Version string `config:"version" json:"version" yaml:"version"`
17+
}
18+
19+
// elasticConditions defines conditions related to Elastic subscriptions or partnerships.
20+
type elasticConditions struct {
21+
Subscription string `config:"subscription" json:"subscription" yaml:"subscription"`
22+
}
23+
24+
// conditions define requirements for different parts of the Elastic stack.
25+
type conditions struct {
26+
Kibana kibanaConditions `config:"kibana" json:"kibana" yaml:"kibana"`
27+
Elastic elasticConditions `config:"elastic" json:"elastic" yaml:"elastic"`
28+
}
29+
30+
type packageManifest struct {
31+
Name string `config:"name" json:"name" yaml:"name"`
32+
License string `config:"license" json:"license" yaml:"license"`
33+
Conditions conditions `config:"conditions" json:"conditions" yaml:"conditions"`
34+
}
35+
36+
func readPackageManifest(path string) (*packageManifest, error) {
37+
cfg, err := yaml.NewConfigWithFile(path, ucfg.PathSep("."))
38+
if err != nil {
39+
return nil, fmt.Errorf("reading file failed (path: %s): %w", path, err)
40+
}
41+
42+
var manifest packageManifest
43+
err = cfg.Unpack(&manifest)
44+
if err != nil {
45+
return nil, fmt.Errorf("unpacking package manifest failed (path: %s): %w", path, err)
46+
}
47+
return &manifest, nil
48+
}

dev/citools/subscription.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
2+
// or more contributor license agreements. Licensed under the Elastic License;
3+
// you may not use this file except in compliance with the Elastic License.
4+
5+
package citools
6+
7+
import (
8+
"fmt"
9+
)
10+
11+
func packageSubscription(path string) (string, error) {
12+
manifest, err := readPackageManifest(path)
13+
if err != nil {
14+
return "", err
15+
}
16+
17+
packageSubscription := manifest.Conditions.Elastic.Subscription
18+
if packageSubscription == "" {
19+
packageSubscription = manifest.License
20+
}
21+
if packageSubscription == "" {
22+
packageSubscription = "basic"
23+
}
24+
25+
return packageSubscription, nil
26+
}
27+
28+
func IsSubscriptionCompatible(stackSubscription, path string) (bool, error) {
29+
pkgSubscription, err := packageSubscription(path)
30+
if err != nil {
31+
return false, fmt.Errorf("failed to read subscription from manifest: %w", err)
32+
}
33+
34+
if stackSubscription == "trial" {
35+
// All subscriptions supported
36+
return true, nil
37+
}
38+
39+
if stackSubscription == "basic" {
40+
if pkgSubscription != "basic" {
41+
return false, nil
42+
}
43+
return true, nil
44+
}
45+
46+
return false, fmt.Errorf("unknown subscription %s", stackSubscription)
47+
}

0 commit comments

Comments
 (0)