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

Clean elastic-package output #1324

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
c6620b5
Remove progress information from docker-compose pull
mrodm Jun 27, 2023
075b05e
Add new variable for pull progress information
mrodm Jun 27, 2023
c73ea17
Rename env var in buildkite
mrodm Jun 27, 2023
ceb7b21
Remove unnecesary debug log message
mrodm Jun 27, 2023
d1f5b20
Move service container status to a file
mrodm Jun 28, 2023
182d988
Add PACKAGE_UNDER_TEST for benchmark tests
mrodm Jun 28, 2023
4514587
Check package to test in benchmark in every loop
mrodm Jun 28, 2023
0aa32b2
Disable debug level logger for some actions
mrodm Jun 28, 2023
27b37dd
Revert "Disable debug level logger for some actions"
mrodm Jun 28, 2023
7defe80
Redirect debug messages to a file (set as artifact)
mrodm Jun 28, 2023
82d7d21
Ensure full path
mrodm Jun 28, 2023
7652a2d
Skip system benchmark test package
mrodm Jun 28, 2023
adae62f
Fix pipeline yml
mrodm Jun 28, 2023
333edd9
Fix call to elastic_package
mrodm Jun 28, 2023
b99efec
Use tee command
mrodm Jun 28, 2023
0fbd21e
Fix condition to redirect logs to file
mrodm Jun 28, 2023
b4bd5a1
Ensure folder exists
mrodm Jun 28, 2023
24317c9
Revert "Move service container status to a file"
mrodm Jun 28, 2023
5642787
Set tee to append content to files
mrodm Jun 28, 2023
555d68c
Remove exit
mrodm Jun 28, 2023
43eb0d7
Separate logs per package
mrodm Jun 28, 2023
f104aef
Add glob pattern
mrodm Jun 28, 2023
aeaec98
Add prefix var
mrodm Jun 28, 2023
609a270
Skip shellinit
mrodm Jun 28, 2023
1231cb2
test with local variable
mrodm Jun 28, 2023
a8d0a5e
Execute with bash
mrodm Jun 28, 2023
69f9808
Test annotations
mrodm Jun 28, 2023
329d8a1
Set artifact_paths
mrodm Jun 28, 2023
d128c60
Fix check_for_errors.sh
mrodm Jun 28, 2023
f099323
download all artifacts to a folder
mrodm Jun 29, 2023
118ecd3
Create folder
mrodm Jun 29, 2023
ae0f119
Fix path
mrodm Jun 29, 2023
40b023d
Show errors
mrodm Jun 29, 2023
ad6f501
Avoid exiting script
mrodm Jun 29, 2023
fb10ba4
Change regex
mrodm Jun 29, 2023
7d007d0
Add test
mrodm Jun 29, 2023
c3840d4
Test format
mrodm Jun 29, 2023
fecfcf8
Fix file name
mrodm Jun 29, 2023
022af1f
Revert changes related to benchmark packages
mrodm Jun 29, 2023
0bdf2e4
Remove debug command
mrodm Jun 29, 2023
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
37 changes: 30 additions & 7 deletions .buildkite/pipeline.trigger.integration.tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ echo " - group: \":terminal: Integration test suite\""
echo " key: \"integration-tests\""
echo " steps:"


# Integration tests related stack command
STACK_COMMAND_TESTS=(
test-stack-command-default
Expand All @@ -20,13 +21,16 @@ STACK_COMMAND_TESTS=(

for test in ${STACK_COMMAND_TESTS[@]}; do
echo " - label: \":go: Running integration test: ${test}\""
echo " command: ./.buildkite/scripts/integration_tests.sh -t ${test}"
echo " command: bash ./.buildkite/scripts/integration_tests.sh -t ${test}"
echo " agents:"
echo " provider: \"gcp\""
echo " artifact_paths:"
echo " - build/elastic-stack-dump/stack/*/logs/*.log"
echo " - build/elastic-stack-dump/stack/*/logs/fleet-server-internal/**/*"
echo " - build/elastic-stack-status/*/*"
if [ "x${CI_DEBUG_LOG_FOLDER_PATH}" != "x" ]; then
echo " - ${CI_DEBUG_LOG_FOLDER_PATH}/output-logs/**/*.log"
fi
done

CHECK_PACKAGES_TESTS=(
Expand All @@ -37,13 +41,16 @@ CHECK_PACKAGES_TESTS=(
)
for test in ${CHECK_PACKAGES_TESTS[@]}; do
echo " - label: \":go: Running integration test: ${test}\""
echo " command: ./.buildkite/scripts/integration_tests.sh -t ${test}"
echo " command: bash ./.buildkite/scripts/integration_tests.sh -t ${test}"
echo " agents:"
echo " provider: \"gcp\""
echo " artifact_paths:"
echo " - build/test-results/*.xml"
echo " - build/elastic-stack-dump/check-*/logs/*.log"
echo " - build/elastic-stack-dump/check-*/logs/fleet-server-internal/**/*"
if [ "x${CI_DEBUG_LOG_FOLDER_PATH}" != "x" ]; then
echo " - ${CI_DEBUG_LOG_FOLDER_PATH}/output-logs/**/*.log"
fi
if [[ $test =~ with-kind$ ]]; then
echo " - build/kubectl-dump.txt"
fi
Expand All @@ -54,40 +61,56 @@ for package in $(find . -maxdepth 1 -mindepth 1 -type d) ; do
package_name=$(basename ${package})
echo " - label: \":go: Running integration test: ${package_name}\""
echo " key: \"integration-parallel-${package_name}\""
echo " command: ./.buildkite/scripts/integration_tests.sh -t test-check-packages-parallel -p ${package_name}"
echo " command: bash ./.buildkite/scripts/integration_tests.sh -t test-check-packages-parallel -p ${package_name}"
echo " env:"
echo " UPLOAD_SAFE_LOGS: 1"
echo " agents:"
echo " provider: \"gcp\""
echo " artifact_paths:"
echo " - build/test-results/*.xml"
if [ "x${CI_DEBUG_LOG_FOLDER_PATH}" != "x" ]; then
echo " - ${CI_DEBUG_LOG_FOLDER_PATH}/output-logs/**/*.log"
fi
done

popd > /dev/null

echo " - label: \":go: Running integration test: test-build-zip\""
echo " command: ./.buildkite/scripts/integration_tests.sh -t test-build-zip"
echo " command: bash ./.buildkite/scripts/integration_tests.sh -t test-build-zip"
echo " agents:"
echo " provider: \"gcp\""
echo " artifact_paths:"
echo " - build/elastic-stack-dump/build-zip/logs/*.log"
echo " - build/packages/*.sig"
if [ "x${CI_DEBUG_LOG_FOLDER_PATH}" != "x" ]; then
echo " - ${CI_DEBUG_LOG_FOLDER_PATH}/output-logs/**/*.log"
fi

echo " - label: \":go: Running integration test: test-install-zip\""
echo " command: ./.buildkite/scripts/integration_tests.sh -t test-install-zip"
echo " command: bash ./.buildkite/scripts/integration_tests.sh -t test-install-zip"
echo " agents:"
echo " provider: \"gcp\""
echo " artifact_paths:"
echo " - build/elastic-stack-dump/install-zip/logs/*.log"
if [ "x${CI_DEBUG_LOG_FOLDER_PATH}" != "x" ]; then
echo " - ${CI_DEBUG_LOG_FOLDER_PATH}/output-logs/**/*.log"
fi

echo " - label: \":go: Running integration test: test-install-zip-shellinit\""
echo " command: ./.buildkite/scripts/integration_tests.sh -t test-install-zip-shellinit"
echo " command: bash ./.buildkite/scripts/integration_tests.sh -t test-install-zip-shellinit"
echo " agents:"
echo " provider: \"gcp\""
echo " artifact_paths:"
echo " - build/elastic-stack-dump/install-zip-shellinit/logs/*.log"
if [ "x${CI_DEBUG_LOG_FOLDER_PATH}" != "x" ]; then
echo " - ${CI_DEBUG_LOG_FOLDER_PATH}/output-logs/**/*.log"
fi

echo " - label: \":go: Running integration test: test-profiles-command\""
echo " command: ./.buildkite/scripts/integration_tests.sh -t test-profiles-command"
echo " command: bash ./.buildkite/scripts/integration_tests.sh -t test-profiles-command"
echo " agents:"
echo " provider: \"gcp\""
if [ "x${CI_DEBUG_LOG_FOLDER_PATH}" != "x" ]; then
echo " artifact_paths:"
echo " - ${CI_DEBUG_LOG_FOLDER_PATH}/output-logs/**/*.log"
fi
8 changes: 8 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ env:
SETUP_GVM_VERSION: 'v0.5.0' # https://github.com/andrewkroh/gvm/issues/44#issuecomment-1013231151
DOCKER_COMPOSE_VERSION: "v2.17.2"
ELASTIC_PACKAGE_COMPOSE_DISABLE_ANSI: "true"
ELASTIC_PACKAGE_COMPOSE_DISABLE_PULL_PROGRESS_INFORMATION: "true"
KIND_VERSION: 'v0.17.0'
K8S_VERSION: 'v1.26.0'
CI_DEBUG_LOG_FOLDER_PATH: './build'
CI_DEBUG_LOG_PREFIX: 'elastic-package-debug-output'

steps:
- label: ":go: Run check-static"
Expand Down Expand Up @@ -55,6 +58,11 @@ steps:
agents:
provider: "gcp" # junit plugin requires docker

- label: ":mag_right: Check for errors"
command: "bash .buildkite/scripts/check_for_errors.sh"
agents:
provider: "gcp"

- label: ":github: Release"
key: "release"
if: |
Expand Down
30 changes: 30 additions & 0 deletions .buildkite/scripts/check_for_errors.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

set -euo pipefail


mkdir -p build
buildkite-agent artifact download "build/output-logs/*" build/

for package_type in $(ls build/output-logs/); do
for output_file in $(ls build/output-logs/${package_type}); do
output="build/output-logs/${package_type}/${output_file}"
echo "Any error on ${output}?"

if grep -E "Error:" ${output}; then
echo "Found errors":

errors=$(grep -E "Error:" ${output})
echo "${errors}"

cat <<EOF >> markdown.md
- Error found in ${package_type}
> ${errors}
EOF
fi
done
done

if [ -f markdown.md ]; then
cat markdown.md | buildkite-agent annotate --style error
fi
20 changes: 16 additions & 4 deletions internal/compose/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,19 @@ const (
waitForHealthyInterval = 1 * time.Second
)

var DisableANSIComposeEnv = environment.WithElasticPackagePrefix("COMPOSE_DISABLE_ANSI")
var (
DisableANSIComposeEnv = environment.WithElasticPackagePrefix("COMPOSE_DISABLE_ANSI")
DisablePullProgressInformationEnv = environment.WithElasticPackagePrefix("COMPOSE_DISABLE_PULL_PROGRESS_INFORMATION")
)

// Project represents a Docker Compose project.
type Project struct {
name string
composeFilePaths []string

dockerComposeV1 bool
disableANSI bool
dockerComposeV1 bool
disableANSI bool
disablePullProgressInformation bool
}

// Config represents a Docker Compose configuration file.
Expand Down Expand Up @@ -192,14 +196,19 @@ func NewProject(name string, paths ...string) (*Project, error) {
c.disableANSI = true
}

v, ok = os.LookupEnv(DisablePullProgressInformationEnv)
if ok && strings.ToLower(v) != "false" {
c.disablePullProgressInformation = true
}

return &c, nil
}

// Up brings up a Docker Compose project.
func (p *Project) Up(opts CommandOptions) error {
args := p.baseArgs()
args = append(args, "up")
if p.disableANSI {
if p.disablePullProgressInformation {
args = append(args, "--quiet-pull")
}
args = append(args, opts.ExtraArgs...)
Expand Down Expand Up @@ -277,6 +286,9 @@ func (p *Project) Config(opts CommandOptions) (*Config, error) {
func (p *Project) Pull(opts CommandOptions) error {
args := p.baseArgs()
args = append(args, "pull")
if p.disablePullProgressInformation {
args = append(args, "--quiet")
}
args = append(args, opts.ExtraArgs...)
args = append(args, opts.Services...)

Expand Down
2 changes: 0 additions & 2 deletions internal/stack/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/elastic/elastic-package/internal/compose"
"github.com/elastic/elastic-package/internal/docker"
"github.com/elastic/elastic-package/internal/install"
"github.com/elastic/elastic-package/internal/logger"
)

type ServiceStatus struct {
Expand Down Expand Up @@ -207,7 +206,6 @@ func dockerComposeStatus() ([]ServiceStatus, error) {
if err != nil {
return nil, err
}
logger.Debugf("Adding Service: \"%v\"", service.Name)
services = append(services, *service)
}

Expand Down
55 changes: 39 additions & 16 deletions scripts/test-check-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,31 @@

set -euxo pipefail

DEFAULT_DEBUG_LOG_FILE=elastic-package-debug-output.log

run_elastic_package_command() {
local command="elastic-package $@"
if [ "x${CI_DEBUG_LOG_FOLDER_PATH:-}" != "x" ]; then
local full_path="${OLDPWD}/${CI_DEBUG_LOG_FOLDER_PATH}/output-logs/${PACKAGE_TEST_TYPE:-other}"
if [ -n "${PACKAGE_UNDER_TEST:-}" ]; then
full_path="${full_path}-${PACKAGE_UNDER_TEST}"
fi
full_path="${full_path}/${CI_DEBUG_LOG_FILE_PATH:-$DEFAULT_DEBUG_LOG_FILE}"

local folder=$(dirname ${full_path})
mkdir -p ${folder}

${command} 2>&1 | tee -a ${full_path}
else
${command}
fi
}

cleanup() {
r=$?

# Dump stack logs
elastic-package stack dump -v --output "build/elastic-stack-dump/check-${PACKAGE_UNDER_TEST:-${PACKAGE_TEST_TYPE:-any}}"
run_elastic_package_command stack dump -v --output "build/elastic-stack-dump/check-${PACKAGE_UNDER_TEST:-${PACKAGE_TEST_TYPE:-any}}"

if [ "${PACKAGE_TEST_TYPE:-other}" == "with-kind" ]; then
# Dump kubectl details
Expand All @@ -20,13 +40,13 @@ cleanup() {
fi

# Take down the stack
elastic-package stack down -v
run_elastic_package_command stack down -v

# Clean used resources
for d in test/packages/${PACKAGE_TEST_TYPE:-other}/${PACKAGE_UNDER_TEST:-*}/; do
(
cd $d
elastic-package clean -v
run_elastic_package_command clean -v
)
done

Expand All @@ -42,18 +62,18 @@ OLDPWD=$PWD
for d in test/packages/${PACKAGE_TEST_TYPE:-other}/${PACKAGE_UNDER_TEST:-*}/; do
(
cd $d
elastic-package check -v
run_elastic_package_command check -v
)
done
cd -

# Update the stack
elastic-package stack update -v
run_elastic_package_command stack update -v

# Boot up the stack
elastic-package stack up -d -v
run_elastic_package_command stack up -d -v

elastic-package stack status
run_elastic_package_command stack status

if [ "${PACKAGE_TEST_TYPE:-other}" == "with-kind" ]; then
# Boot up the kind cluster
Expand All @@ -66,30 +86,33 @@ eval "$(elastic-package stack shellinit)"
for d in test/packages/${PACKAGE_TEST_TYPE:-other}/${PACKAGE_UNDER_TEST:-*}/; do
(
cd $d
elastic-package install -v

run_elastic_package_command install -v

if [ "${PACKAGE_TEST_TYPE:-other}" == "benchmarks" ]; then
# It is not used PACKAGE_UNDER_TEST, so all benchmark packages are run in the same loop
if [ "${PACKAGE_UNDER_TEST:-*}" == "pipeline_benchmark" ]; then
rm -rf "${OLDPWD}/build/benchmark-results"
elastic-package benchmark pipeline -v --report-format xUnit --report-output file --fail-on-missing
run_elastic_package_command benchmark pipeline -v --report-format xUnit --report-output file --fail-on-missing

rm -rf "${OLDPWD}/build/benchmark-results-old"
mv "${OLDPWD}/build/benchmark-results" "${OLDPWD}/build/benchmark-results-old"
elastic-package benchmark pipeline -v --report-format json --report-output file --fail-on-missing
elastic-package report --fail-on-missing benchmark \

run_elastic_package_command benchmark pipeline -v --report-format json --report-output file --fail-on-missing

run_elastic_package_command report --fail-on-missing benchmark \
--new ${OLDPWD}/build/benchmark-results \
--old ${OLDPWD}/build/benchmark-results-old \
--threshold 1 --report-output-path="${OLDPWD}/build/benchreport"
fi
if [ "${PACKAGE_UNDER_TEST:-*}" == "system_benchmark" ]; then
elastic-package benchmark system --benchmark logs-benchmark -v --defer-cleanup 1s
run_elastic_package_command benchmark system --benchmark logs-benchmark -v
fi
else
# defer-cleanup is set to a short period to verify that the option is available
elastic-package test -v --report-format xUnit --report-output file --defer-cleanup 1s --test-coverage
run_elastic_package_command test -v --report-format xUnit --report-output file --defer-cleanup 1s --test-coverage
fi
)
cd -
done