From c6620b56b77025a28109ed9db957319a9362c49e Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Tue, 27 Jun 2023 16:30:04 +0200 Subject: [PATCH 01/40] Remove progress information from docker-compose pull --- internal/compose/compose.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/compose/compose.go b/internal/compose/compose.go index 035b98b60..df2ea7836 100644 --- a/internal/compose/compose.go +++ b/internal/compose/compose.go @@ -277,6 +277,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.disableANSI { + args = append(args, "--quiet") + } args = append(args, opts.ExtraArgs...) args = append(args, opts.Services...) From 075b05e7f555ec8bfaabee52ad5910b2150ebb53 Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Tue, 27 Jun 2023 16:43:36 +0200 Subject: [PATCH 02/40] Add new variable for pull progress information --- .buildkite/pipeline.yml | 1 + internal/compose/compose.go | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 68ab2aa4e..b75d568fd 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -2,6 +2,7 @@ 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_PROGRESS_INFORMATION: "true" KIND_VERSION: 'v0.17.0' K8S_VERSION: 'v1.26.0' diff --git a/internal/compose/compose.go b/internal/compose/compose.go index df2ea7836..2d6ba3744 100644 --- a/internal/compose/compose.go +++ b/internal/compose/compose.go @@ -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. @@ -192,6 +196,11 @@ 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 } @@ -199,7 +208,7 @@ func NewProject(name string, paths ...string) (*Project, error) { 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...) @@ -277,7 +286,7 @@ func (p *Project) Config(opts CommandOptions) (*Config, error) { func (p *Project) Pull(opts CommandOptions) error { args := p.baseArgs() args = append(args, "pull") - if p.disableANSI { + if p.disablePullProgressInformation { args = append(args, "--quiet") } args = append(args, opts.ExtraArgs...) From c73ea1799ec4cccc3032c98031a3c429e9c5bc70 Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Tue, 27 Jun 2023 17:00:43 +0200 Subject: [PATCH 03/40] Rename env var in buildkite --- .buildkite/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index b75d568fd..3a4d61986 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -2,7 +2,7 @@ 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_PROGRESS_INFORMATION: "true" + ELASTIC_PACKAGE_COMPOSE_DISABLE_PULL_PROGRESS_INFORMATION: "true" KIND_VERSION: 'v0.17.0' K8S_VERSION: 'v1.26.0' From ceb7b21c10623ad944990aa519e086c32d99286f Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Tue, 27 Jun 2023 17:31:59 +0200 Subject: [PATCH 04/40] Remove unnecesary debug log message --- internal/stack/compose.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/internal/stack/compose.go b/internal/stack/compose.go index a1e0bb00e..8948f4d9b 100644 --- a/internal/stack/compose.go +++ b/internal/stack/compose.go @@ -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 { @@ -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) } From d1f5b2082ad69735a31829a146ac5a843eaab59d Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Wed, 28 Jun 2023 09:55:46 +0200 Subject: [PATCH 05/40] Move service container status to a file --- .../pipeline.trigger.integration.tests.sh | 2 ++ .../runners/system/servicedeployer/compose.go | 35 +++++++++++++++++-- internal/compose/compose.go | 17 ++++----- .../runners/system/servicedeployer/compose.go | 33 ++++++++++++++++- .../system/servicedeployer/custom_agent.go | 5 ++- .../system/servicedeployer/terraform.go | 5 ++- 6 files changed, 84 insertions(+), 13 deletions(-) diff --git a/.buildkite/pipeline.trigger.integration.tests.sh b/.buildkite/pipeline.trigger.integration.tests.sh index c232b6616..2c0f267bb 100755 --- a/.buildkite/pipeline.trigger.integration.tests.sh +++ b/.buildkite/pipeline.trigger.integration.tests.sh @@ -44,6 +44,7 @@ for test in ${CHECK_PACKAGES_TESTS[@]}; do echo " - build/test-results/*.xml" echo " - build/elastic-stack-dump/check-*/logs/*.log" echo " - build/elastic-stack-dump/check-*/logs/fleet-server-internal/**/*" + echo " - build/container-status/*.log" if [[ $test =~ with-kind$ ]]; then echo " - build/kubectl-dump.txt" fi @@ -61,6 +62,7 @@ for package in $(find . -maxdepth 1 -mindepth 1 -type d) ; do echo " provider: \"gcp\"" echo " artifact_paths:" echo " - build/test-results/*.xml" + echo " - build/container-status/*.log" done popd > /dev/null diff --git a/internal/benchrunner/runners/system/servicedeployer/compose.go b/internal/benchrunner/runners/system/servicedeployer/compose.go index 0b3dd5e2c..941c376c6 100644 --- a/internal/benchrunner/runners/system/servicedeployer/compose.go +++ b/internal/benchrunner/runners/system/servicedeployer/compose.go @@ -5,6 +5,7 @@ package servicedeployer import ( + "bytes" "fmt" "os" "path/filepath" @@ -73,7 +74,10 @@ func (d *DockerComposeServiceDeployer) SetUp(inCtxt ServiceContext) (DeployedSer if err != nil { return nil, fmt.Errorf("could not boot up service using Docker Compose: %w", err) } - err = p.WaitForHealthy(opts) + statuses, err := p.WaitForHealthy(opts) + if statusErr := writeServiceContainerStatus(outCtxt.Name, statuses); statusErr != nil { + logger.Errorf("failed to create container status file: %v", statusErr) + } if err != nil { processServiceContainerLogs(p, compose.CommandOptions{ Env: opts.Env, @@ -205,7 +209,7 @@ func writeServiceContainerLogs(serviceName string, content []byte) error { return fmt.Errorf("can't create directory for service container logs (path: %s): %w", containerLogsDir, err) } - containerLogsFilepath := filepath.Join(containerLogsDir, fmt.Sprintf("%s-%d.log", serviceName, time.Now().UnixNano())) + containerLogsFilepath := filepath.Join(containerLogsDir, fmt.Sprintf("benchmark-%s-%d.log", serviceName, time.Now().UnixNano())) logger.Infof("Write container logs to file: %s", containerLogsFilepath) err = os.WriteFile(containerLogsFilepath, content, 0644) if err != nil { @@ -213,3 +217,30 @@ func writeServiceContainerLogs(serviceName string, content []byte) error { } return nil } + +func writeServiceContainerStatus(serviceName string, content [][]byte) error { + if len(content) == 0 { + return nil + } + + buildDir, err := builder.BuildDirectory() + if err != nil { + return fmt.Errorf("locating build directory failed: %w", err) + } + + containerStatusDir := filepath.Join(buildDir, "container-status") + err = os.MkdirAll(containerStatusDir, 0755) + if err != nil { + return fmt.Errorf("can't create directory for service container status (path: %s): %w", containerStatusDir, err) + } + + containerStatusFilepath := filepath.Join(containerStatusDir, fmt.Sprintf("benchmark-%s-%d.log", serviceName, time.Now().UnixNano())) + logger.Infof("Write container status to file: %s", containerStatusFilepath) + + contentFile := bytes.Join(content, []byte("\n")) + err = os.WriteFile(containerStatusFilepath, contentFile, 0644) + if err != nil { + return fmt.Errorf("can't write container status to file (path: %s): %w", containerStatusFilepath, err) + } + return nil +} diff --git a/internal/compose/compose.go b/internal/compose/compose.go index 2d6ba3744..56f9348eb 100644 --- a/internal/compose/compose.go +++ b/internal/compose/compose.go @@ -314,7 +314,7 @@ func (p *Project) Logs(opts CommandOptions) ([]byte, error) { } // WaitForHealthy method waits until all containers are healthy. -func (p *Project) WaitForHealthy(opts CommandOptions) error { +func (p *Project) WaitForHealthy(opts CommandOptions) ([][]byte, error) { // Read container IDs args := p.baseArgs() args = append(args, "ps") @@ -322,20 +322,21 @@ func (p *Project) WaitForHealthy(opts CommandOptions) error { var b bytes.Buffer if err := p.runDockerComposeCmd(dockerComposeOptions{args: args, env: opts.Env, stdout: &b}); err != nil { - return err + return nil, err } startTime := time.Now() timeout := startTime.Add(waitForHealthyTimeout) containerIDs := strings.Fields(b.String()) + containerStatuses := [][]byte{} for { if time.Now().After(timeout) { - return errors.New("timeout waiting for healthy container") + return containerStatuses, errors.New("timeout waiting for healthy container") } if signal.SIGINT() { - return errors.New("SIGINT: cancel waiting for policy assigned") + return containerStatuses, errors.New("SIGINT: cancel waiting for policy assigned") } // NOTE: healthy must be reinitialized at each iteration @@ -344,11 +345,11 @@ func (p *Project) WaitForHealthy(opts CommandOptions) error { logger.Debugf("Wait for healthy containers: %s", strings.Join(containerIDs, ",")) descriptions, err := docker.InspectContainers(containerIDs...) if err != nil { - return err + return containerStatuses, err } for _, containerDescription := range descriptions { - logger.Debugf("Container status: %s", containerDescription.String()) + containerStatuses = append(containerStatuses, []byte(containerDescription.String())) // No healthcheck defined for service if containerDescription.State.Status == "running" && containerDescription.State.Health == nil { @@ -367,7 +368,7 @@ func (p *Project) WaitForHealthy(opts CommandOptions) error { // Container exited with code > 0 if containerDescription.State.Status == "exited" && containerDescription.State.ExitCode > 0 { - return fmt.Errorf("container (ID: %s) exited with code %d", containerDescription.ID, containerDescription.State.ExitCode) + return containerStatuses, fmt.Errorf("container (ID: %s) exited with code %d", containerDescription.ID, containerDescription.State.ExitCode) } // Any different status is considered unhealthy @@ -383,7 +384,7 @@ func (p *Project) WaitForHealthy(opts CommandOptions) error { time.Sleep(waitForHealthyInterval) } - return nil + return containerStatuses, nil } func (p *Project) baseArgs() []string { diff --git a/internal/testrunner/runners/system/servicedeployer/compose.go b/internal/testrunner/runners/system/servicedeployer/compose.go index 69c10fb36..d259a2223 100644 --- a/internal/testrunner/runners/system/servicedeployer/compose.go +++ b/internal/testrunner/runners/system/servicedeployer/compose.go @@ -5,6 +5,7 @@ package servicedeployer import ( + "bytes" "fmt" "os" "path/filepath" @@ -89,7 +90,10 @@ func (d *DockerComposeServiceDeployer) SetUp(inCtxt ServiceContext) (DeployedSer return nil, errors.Wrap(err, "could not boot up service using Docker Compose") } - err = p.WaitForHealthy(opts) + statuses, err := p.WaitForHealthy(opts) + if statusErr := writeServiceContainerStatus(outCtxt.Name, statuses); statusErr != nil { + logger.Errorf("failed to create container status file: %v", statusErr) + } if err != nil { processServiceContainerLogs(p, compose.CommandOptions{ Env: opts.Env, @@ -234,3 +238,30 @@ func writeServiceContainerLogs(serviceName string, content []byte) error { } return nil } + +func writeServiceContainerStatus(serviceName string, content [][]byte) error { + if len(content) == 0 { + return nil + } + + buildDir, err := builder.BuildDirectory() + if err != nil { + return fmt.Errorf("locating build directory failed: %w", err) + } + + containerStatusDir := filepath.Join(buildDir, "container-status") + err = os.MkdirAll(containerStatusDir, 0755) + if err != nil { + return fmt.Errorf("can't create directory for service container status (path: %s): %w", containerStatusDir, err) + } + + containerStatusFilepath := filepath.Join(containerStatusDir, fmt.Sprintf("%s-%d.log", serviceName, time.Now().UnixNano())) + logger.Infof("Write container status to file: %s", containerStatusFilepath) + + contentFile := bytes.Join(content, []byte("\n")) + err = os.WriteFile(containerStatusFilepath, contentFile, 0644) + if err != nil { + return fmt.Errorf("can't write container status to file (path: %s): %w", containerStatusFilepath, err) + } + return nil +} diff --git a/internal/testrunner/runners/system/servicedeployer/custom_agent.go b/internal/testrunner/runners/system/servicedeployer/custom_agent.go index 02165d0e0..93ba2bc39 100644 --- a/internal/testrunner/runners/system/servicedeployer/custom_agent.go +++ b/internal/testrunner/runners/system/servicedeployer/custom_agent.go @@ -129,7 +129,10 @@ func (d *CustomAgentDeployer) SetUp(inCtxt ServiceContext) (DeployedService, err return nil, errors.Wrapf(err, "can't attach service container to the stack network") } - err = p.WaitForHealthy(opts) + statuses, err := p.WaitForHealthy(opts) + if statusErr := writeServiceContainerStatus(outCtxt.Name, statuses); statusErr != nil { + logger.Errorf("failed to create container status file: %v", statusErr) + } if err != nil { processServiceContainerLogs(p, compose.CommandOptions{ Env: opts.Env, diff --git a/internal/testrunner/runners/system/servicedeployer/terraform.go b/internal/testrunner/runners/system/servicedeployer/terraform.go index d64d40e45..55443de5d 100644 --- a/internal/testrunner/runners/system/servicedeployer/terraform.go +++ b/internal/testrunner/runners/system/servicedeployer/terraform.go @@ -148,7 +148,10 @@ func (tsd TerraformServiceDeployer) SetUp(inCtxt ServiceContext) (DeployedServic return nil, errors.Wrap(err, "could not boot up service using Docker Compose") } - err = p.WaitForHealthy(opts) + statuses, err := p.WaitForHealthy(opts) + if statusErr := writeServiceContainerStatus(outCtxt.Name, statuses); statusErr != nil { + logger.Errorf("failed to create container status file: %v", statusErr) + } if err != nil { processServiceContainerLogs(p, compose.CommandOptions{ Env: opts.Env, From 182d988ba742fbe1275e3c39707f5f5447377c2b Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Wed, 28 Jun 2023 10:38:24 +0200 Subject: [PATCH 06/40] Add PACKAGE_UNDER_TEST for benchmark tests --- .buildkite/pipeline.trigger.integration.tests.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.buildkite/pipeline.trigger.integration.tests.sh b/.buildkite/pipeline.trigger.integration.tests.sh index 2c0f267bb..5f52fe7df 100755 --- a/.buildkite/pipeline.trigger.integration.tests.sh +++ b/.buildkite/pipeline.trigger.integration.tests.sh @@ -36,8 +36,13 @@ CHECK_PACKAGES_TESTS=( test-check-packages-benchmarks ) for test in ${CHECK_PACKAGES_TESTS[@]}; do + options="" + if [ "${test}" == "test-check-packages-benchmarks" ]; then + package_name=$(basename ${package}) + options="-p ${package_name}" + fi echo " - label: \":go: Running integration test: ${test}\"" - echo " command: ./.buildkite/scripts/integration_tests.sh -t ${test}" + echo " command: ./.buildkite/scripts/integration_tests.sh -t ${test} ${options}" echo " agents:" echo " provider: \"gcp\"" echo " artifact_paths:" From 4514587d5e57640d24f43cb98980c037f45a0da8 Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Wed, 28 Jun 2023 11:02:56 +0200 Subject: [PATCH 07/40] Check package to test in benchmark in every loop Check which package is being tested in case of benchmark suite, but keeping all these test packages in the same step. --- .buildkite/pipeline.trigger.integration.tests.sh | 7 +------ scripts/test-check-packages.sh | 12 +++++++----- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/.buildkite/pipeline.trigger.integration.tests.sh b/.buildkite/pipeline.trigger.integration.tests.sh index 5f52fe7df..2c0f267bb 100755 --- a/.buildkite/pipeline.trigger.integration.tests.sh +++ b/.buildkite/pipeline.trigger.integration.tests.sh @@ -36,13 +36,8 @@ CHECK_PACKAGES_TESTS=( test-check-packages-benchmarks ) for test in ${CHECK_PACKAGES_TESTS[@]}; do - options="" - if [ "${test}" == "test-check-packages-benchmarks" ]; then - package_name=$(basename ${package}) - options="-p ${package_name}" - fi echo " - label: \":go: Running integration test: ${test}\"" - echo " command: ./.buildkite/scripts/integration_tests.sh -t ${test} ${options}" + echo " command: ./.buildkite/scripts/integration_tests.sh -t ${test}" echo " agents:" echo " provider: \"gcp\"" echo " artifact_paths:" diff --git a/scripts/test-check-packages.sh b/scripts/test-check-packages.sh index 2978bf213..c62c8593d 100755 --- a/scripts/test-check-packages.sh +++ b/scripts/test-check-packages.sh @@ -69,21 +69,23 @@ for d in test/packages/${PACKAGE_TEST_TYPE:-other}/${PACKAGE_UNDER_TEST:-*}/; do elastic-package install -v if [ "${PACKAGE_TEST_TYPE:-other}" == "benchmarks" ]; then - if [ "${PACKAGE_UNDER_TEST:-*}" == "pipeline_benchmark" ]; then + # It is not used PACKAGE_UNDER_TEST, so all benchmark packages are run in the same loop + package_to_test=$(basename ${d}) + if [ "${package_to_test}" == "pipeline_benchmark" ]; then rm -rf "${OLDPWD}/build/benchmark-results" elastic-package 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 \ --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 + if [ "${package_to_test}" == "system_benchmark" ]; then elastic-package benchmark system --benchmark logs-benchmark -v --defer-cleanup 1s fi else From 0aa32b2044ca63f9291db32869243e4d81eb57b0 Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Wed, 28 Jun 2023 11:59:08 +0200 Subject: [PATCH 08/40] Disable debug level logger for some actions --- internal/logger/logger.go | 5 +++++ internal/packages/installer/factory.go | 2 ++ internal/testrunner/runners/system/runner.go | 2 ++ 3 files changed, 9 insertions(+) diff --git a/internal/logger/logger.go b/internal/logger/logger.go index c1199ca2f..033531683 100644 --- a/internal/logger/logger.go +++ b/internal/logger/logger.go @@ -18,6 +18,11 @@ func EnableDebugMode() { Debug("Enable verbose logging") } +// DisableDebugMode method disables verbose logging. +func DisableDebugMode() { + isDebugMode = false +} + // Debug method logs message with "debug" level. func Debug(a ...interface{}) { if !IsDebugMode() { diff --git a/internal/packages/installer/factory.go b/internal/packages/installer/factory.go index 85d33a7c2..7e379151d 100644 --- a/internal/packages/installer/factory.go +++ b/internal/packages/installer/factory.go @@ -70,6 +70,7 @@ func NewForPackage(options Options) (Installer, error) { return CreateForZip(options.Kibana, options.ZipPath) } + logger.DisableDebugMode() target, err := builder.BuildPackage(builder.BuildOptions{ PackageRoot: options.RootPath, CreateZip: supportsZip, @@ -79,6 +80,7 @@ func NewForPackage(options Options) (Installer, error) { if err != nil { return nil, fmt.Errorf("failed to build package: %v", err) } + logger.EnableDebugMode() if supportsZip { return CreateForZip(options.Kibana, target) diff --git a/internal/testrunner/runners/system/runner.go b/internal/testrunner/runners/system/runner.go index eb3692499..1b34cc703 100644 --- a/internal/testrunner/runners/system/runner.go +++ b/internal/testrunner/runners/system/runner.go @@ -232,11 +232,13 @@ func (r *runner) run() (results []testrunner.TestResult, err error) { } defer os.RemoveAll(tempDir) + logger.DisableDebugMode() dumpOptions := stack.DumpOptions{Output: tempDir, Profile: r.options.Profile} _, err = stack.Dump(dumpOptions) if err != nil { return nil, fmt.Errorf("dump failed: %w", err) } + logger.EnableDebugMode() logResults, err := r.checkAgentLogs(dumpOptions, startTesting, errorPatterns) if err != nil { From 27b37dd9dac6869f5b9300f12a7bfc71e67f4210 Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Wed, 28 Jun 2023 12:32:04 +0200 Subject: [PATCH 09/40] Revert "Disable debug level logger for some actions" This reverts commit 0aa32b2044ca63f9291db32869243e4d81eb57b0. --- internal/logger/logger.go | 5 ----- internal/packages/installer/factory.go | 2 -- internal/testrunner/runners/system/runner.go | 2 -- 3 files changed, 9 deletions(-) diff --git a/internal/logger/logger.go b/internal/logger/logger.go index 033531683..c1199ca2f 100644 --- a/internal/logger/logger.go +++ b/internal/logger/logger.go @@ -18,11 +18,6 @@ func EnableDebugMode() { Debug("Enable verbose logging") } -// DisableDebugMode method disables verbose logging. -func DisableDebugMode() { - isDebugMode = false -} - // Debug method logs message with "debug" level. func Debug(a ...interface{}) { if !IsDebugMode() { diff --git a/internal/packages/installer/factory.go b/internal/packages/installer/factory.go index 7e379151d..85d33a7c2 100644 --- a/internal/packages/installer/factory.go +++ b/internal/packages/installer/factory.go @@ -70,7 +70,6 @@ func NewForPackage(options Options) (Installer, error) { return CreateForZip(options.Kibana, options.ZipPath) } - logger.DisableDebugMode() target, err := builder.BuildPackage(builder.BuildOptions{ PackageRoot: options.RootPath, CreateZip: supportsZip, @@ -80,7 +79,6 @@ func NewForPackage(options Options) (Installer, error) { if err != nil { return nil, fmt.Errorf("failed to build package: %v", err) } - logger.EnableDebugMode() if supportsZip { return CreateForZip(options.Kibana, target) diff --git a/internal/testrunner/runners/system/runner.go b/internal/testrunner/runners/system/runner.go index 1b34cc703..eb3692499 100644 --- a/internal/testrunner/runners/system/runner.go +++ b/internal/testrunner/runners/system/runner.go @@ -232,13 +232,11 @@ func (r *runner) run() (results []testrunner.TestResult, err error) { } defer os.RemoveAll(tempDir) - logger.DisableDebugMode() dumpOptions := stack.DumpOptions{Output: tempDir, Profile: r.options.Profile} _, err = stack.Dump(dumpOptions) if err != nil { return nil, fmt.Errorf("dump failed: %w", err) } - logger.EnableDebugMode() logResults, err := r.checkAgentLogs(dumpOptions, startTesting, errorPatterns) if err != nil { From 7defe80c013b1a50aab53e5fa016e2367aa3be00 Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Wed, 28 Jun 2023 13:36:50 +0200 Subject: [PATCH 10/40] Redirect debug messages to a file (set as artifact) --- .../pipeline.trigger.integration.tests.sh | 21 ++++++++++ .buildkite/pipeline.yml | 2 + scripts/test-check-packages.sh | 42 ++++++++++++------- 3 files changed, 51 insertions(+), 14 deletions(-) diff --git a/.buildkite/pipeline.trigger.integration.tests.sh b/.buildkite/pipeline.trigger.integration.tests.sh index 2c0f267bb..b76088cdf 100755 --- a/.buildkite/pipeline.trigger.integration.tests.sh +++ b/.buildkite/pipeline.trigger.integration.tests.sh @@ -27,6 +27,9 @@ for test in ${STACK_COMMAND_TESTS[@]}; do 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_FILE_PATH}" != "x" ]; then + echo " - ${CI_DEBUG_LOG_FILE_PATH}" + fi done CHECK_PACKAGES_TESTS=( @@ -45,6 +48,9 @@ for test in ${CHECK_PACKAGES_TESTS[@]}; do echo " - build/elastic-stack-dump/check-*/logs/*.log" echo " - build/elastic-stack-dump/check-*/logs/fleet-server-internal/**/*" echo " - build/container-status/*.log" + if [ "x${CI_DEBUG_LOG_FILE_PATH}" != "x" ]; then + echo " - ${CI_DEBUG_LOG_FILE_PATH}" + fi if [[ $test =~ with-kind$ ]]; then echo " - build/kubectl-dump.txt" fi @@ -63,6 +69,9 @@ for package in $(find . -maxdepth 1 -mindepth 1 -type d) ; do echo " artifact_paths:" echo " - build/test-results/*.xml" echo " - build/container-status/*.log" + if [ "x${CI_DEBUG_LOG_FILE_PATH}" != "x" ]; then + echo " - ${CI_DEBUG_LOG_FILE_PATH}" + fi done popd > /dev/null @@ -74,6 +83,9 @@ echo " provider: \"gcp\"" echo " artifact_paths:" echo " - build/elastic-stack-dump/build-zip/logs/*.log" echo " - build/packages/*.sig" +if [ "x${CI_DEBUG_LOG_FILE_PATH}" != "x" ]; then + echo " - ${CI_DEBUG_LOG_FILE_PATH}" +fi echo " - label: \":go: Running integration test: test-install-zip\"" echo " command: ./.buildkite/scripts/integration_tests.sh -t test-install-zip" @@ -81,6 +93,9 @@ echo " agents:" echo " provider: \"gcp\"" echo " artifact_paths:" echo " - build/elastic-stack-dump/install-zip/logs/*.log" +if [ "x${CI_DEBUG_LOG_FILE_PATH}" != "x" ]; then + echo " - ${CI_DEBUG_LOG_FILE_PATH}" +fi echo " - label: \":go: Running integration test: test-install-zip-shellinit\"" echo " command: ./.buildkite/scripts/integration_tests.sh -t test-install-zip-shellinit" @@ -88,8 +103,14 @@ echo " agents:" echo " provider: \"gcp\"" echo " artifact_paths:" echo " - build/elastic-stack-dump/install-zip-shellinit/logs/*.log" +if [ "x${CI_DEBUG_LOG_FILE_PATH}" != "x" ]; then + echo " - ${CI_DEBUG_LOG_FILE_PATH}" +fi echo " - label: \":go: Running integration test: test-profiles-command\"" echo " command: ./.buildkite/scripts/integration_tests.sh -t test-profiles-command" echo " agents:" echo " provider: \"gcp\"" +if [ "x${CI_DEBUG_LOG_FILE_PATH}" != "x" ]; then + echo " - ${CI_DEBUG_LOG_FILE_PATH}" +fi diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 3a4d61986..4e95dd869 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -5,6 +5,8 @@ env: ELASTIC_PACKAGE_COMPOSE_DISABLE_PULL_PROGRESS_INFORMATION: "true" KIND_VERSION: 'v0.17.0' K8S_VERSION: 'v1.26.0' + CI_DEBUG_LOG_TO_FILE: 'true' + CI_DEBUG_LOG_FILE_PATH: 'build/elastic-package-debug-output.log' steps: - label: ":go: Run check-static" diff --git a/scripts/test-check-packages.sh b/scripts/test-check-packages.sh index c62c8593d..e0e1662c9 100755 --- a/scripts/test-check-packages.sh +++ b/scripts/test-check-packages.sh @@ -2,11 +2,25 @@ set -euxo pipefail + +run_elastic_package_command() { + local folder=$(dirname ${CI_DEBUG_LOG_FILE_PATH}) + if [ "${folder}" != "." ]; then + mkdir -p ${folder} + fi + + if [ "${CI_DEBUG_LOG_TO_FILE:-false}" == "true" ]; then + elastic-package $@ 2>&1 /dev/stdout | grep " DEBUG " > ${CI_DEBUG_LOG_FILE_PATH} + exit 0 + fi + elastic-package $@ +} + 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 @@ -20,13 +34,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_commandclean -v ) done @@ -42,18 +56,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 @@ -61,36 +75,36 @@ if [ "${PACKAGE_TEST_TYPE:-other}" == "with-kind" ]; then fi # Run package tests -eval "$(elastic-package stack shellinit)" +eval "$(run_elastic_package_command 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 package_to_test=$(basename ${d}) if [ "${package_to_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 + run_elastic_package_command benchmark pipeline -v --report-format json --report-output file --fail-on-missing - elastic-package report --fail-on-missing benchmark \ + 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_to_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 --defer-cleanup 1s 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 - From 82d7d210596ca951dd049e2127efa2a14c90834c Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Wed, 28 Jun 2023 13:41:40 +0200 Subject: [PATCH 11/40] Ensure full path --- scripts/test-check-packages.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts/test-check-packages.sh b/scripts/test-check-packages.sh index e0e1662c9..d90757f8a 100755 --- a/scripts/test-check-packages.sh +++ b/scripts/test-check-packages.sh @@ -4,13 +4,11 @@ set -euxo pipefail run_elastic_package_command() { - local folder=$(dirname ${CI_DEBUG_LOG_FILE_PATH}) - if [ "${folder}" != "." ]; then - mkdir -p ${folder} - fi + local full_path="${OLDPWD}/${CI_DEBUG_LOG_FILE_PATH}" + local folder=$(dirname ${full_path}) if [ "${CI_DEBUG_LOG_TO_FILE:-false}" == "true" ]; then - elastic-package $@ 2>&1 /dev/stdout | grep " DEBUG " > ${CI_DEBUG_LOG_FILE_PATH} + elastic-package $@ 2>&1 /dev/stdout | grep " DEBUG " > ${full_path} exit 0 fi elastic-package $@ From 7652a2df2fc6f1fda60110f717d1442ea2b448e7 Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Wed, 28 Jun 2023 13:42:09 +0200 Subject: [PATCH 12/40] Skip system benchmark test package --- scripts/test-check-packages.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/test-check-packages.sh b/scripts/test-check-packages.sh index d90757f8a..357f23ace 100755 --- a/scripts/test-check-packages.sh +++ b/scripts/test-check-packages.sh @@ -97,9 +97,9 @@ for d in test/packages/${PACKAGE_TEST_TYPE:-other}/${PACKAGE_UNDER_TEST:-*}/; do --old ${OLDPWD}/build/benchmark-results-old \ --threshold 1 --report-output-path="${OLDPWD}/build/benchreport" fi - if [ "${package_to_test}" == "system_benchmark" ]; then - run_elastic_package_command benchmark system --benchmark logs-benchmark -v --defer-cleanup 1s - fi + # if [ "${package_to_test}" == "system_benchmark" ]; then + # 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 run_elastic_package_command test -v --report-format xUnit --report-output file --defer-cleanup 1s --test-coverage From adae62f6d68d52b4bb65584ee9f94ec4b09a8e0c Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Wed, 28 Jun 2023 13:59:26 +0200 Subject: [PATCH 13/40] Fix pipeline yml --- .buildkite/pipeline.trigger.integration.tests.sh | 1 + .buildkite/pipeline.yml | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/pipeline.trigger.integration.tests.sh b/.buildkite/pipeline.trigger.integration.tests.sh index b76088cdf..798a3674b 100755 --- a/.buildkite/pipeline.trigger.integration.tests.sh +++ b/.buildkite/pipeline.trigger.integration.tests.sh @@ -112,5 +112,6 @@ echo " command: ./.buildkite/scripts/integration_tests.sh -t test-profile echo " agents:" echo " provider: \"gcp\"" if [ "x${CI_DEBUG_LOG_FILE_PATH}" != "x" ]; then + echo " artifact_paths:" echo " - ${CI_DEBUG_LOG_FILE_PATH}" fi diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 4e95dd869..e30dc4ce8 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -5,7 +5,6 @@ env: ELASTIC_PACKAGE_COMPOSE_DISABLE_PULL_PROGRESS_INFORMATION: "true" KIND_VERSION: 'v0.17.0' K8S_VERSION: 'v1.26.0' - CI_DEBUG_LOG_TO_FILE: 'true' CI_DEBUG_LOG_FILE_PATH: 'build/elastic-package-debug-output.log' steps: From 333edd98c1fa1924b1d1ddc0c4afb11953531ebe Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Wed, 28 Jun 2023 14:20:21 +0200 Subject: [PATCH 14/40] Fix call to elastic_package --- scripts/test-check-packages.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/test-check-packages.sh b/scripts/test-check-packages.sh index 357f23ace..a7c41755e 100755 --- a/scripts/test-check-packages.sh +++ b/scripts/test-check-packages.sh @@ -4,10 +4,10 @@ set -euxo pipefail run_elastic_package_command() { - local full_path="${OLDPWD}/${CI_DEBUG_LOG_FILE_PATH}" - local folder=$(dirname ${full_path}) + if [ "x${CI_DEBUG_LOG_FILE_PATH:-}" == "x" ]; then + local full_path="${OLDPWD}/${CI_DEBUG_LOG_FILE_PATH}" + local folder=$(dirname ${full_path}) - if [ "${CI_DEBUG_LOG_TO_FILE:-false}" == "true" ]; then elastic-package $@ 2>&1 /dev/stdout | grep " DEBUG " > ${full_path} exit 0 fi @@ -38,7 +38,7 @@ cleanup() { for d in test/packages/${PACKAGE_TEST_TYPE:-other}/${PACKAGE_UNDER_TEST:-*}/; do ( cd $d - run_elastic_package_commandclean -v + run_elastic_package_command clean -v ) done From b99efec1e0a3da1ecefa695e4f3dc235e3e6bd99 Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Wed, 28 Jun 2023 14:39:58 +0200 Subject: [PATCH 15/40] Use tee command --- scripts/test-check-packages.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/test-check-packages.sh b/scripts/test-check-packages.sh index a7c41755e..af7323987 100755 --- a/scripts/test-check-packages.sh +++ b/scripts/test-check-packages.sh @@ -8,7 +8,7 @@ run_elastic_package_command() { local full_path="${OLDPWD}/${CI_DEBUG_LOG_FILE_PATH}" local folder=$(dirname ${full_path}) - elastic-package $@ 2>&1 /dev/stdout | grep " DEBUG " > ${full_path} + elastic-package $@ 2>&1 /dev/stdout | tee ${full_path} | grep -v " DEBUG " exit 0 fi elastic-package $@ From 0fbd21e6d5028c9825c1391f2ce3abb68bb4b225 Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Wed, 28 Jun 2023 15:03:53 +0200 Subject: [PATCH 16/40] Fix condition to redirect logs to file --- scripts/test-check-packages.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/test-check-packages.sh b/scripts/test-check-packages.sh index af7323987..364ac6d06 100755 --- a/scripts/test-check-packages.sh +++ b/scripts/test-check-packages.sh @@ -4,7 +4,7 @@ set -euxo pipefail run_elastic_package_command() { - if [ "x${CI_DEBUG_LOG_FILE_PATH:-}" == "x" ]; then + if [ "x${CI_DEBUG_LOG_FILE_PATH:-}" != "x" ]; then local full_path="${OLDPWD}/${CI_DEBUG_LOG_FILE_PATH}" local folder=$(dirname ${full_path}) From b4bd5a14d439d73111938ebee066544548c72b5a Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Wed, 28 Jun 2023 15:31:34 +0200 Subject: [PATCH 17/40] Ensure folder exists --- scripts/test-check-packages.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/test-check-packages.sh b/scripts/test-check-packages.sh index 364ac6d06..ab678f403 100755 --- a/scripts/test-check-packages.sh +++ b/scripts/test-check-packages.sh @@ -7,6 +7,7 @@ run_elastic_package_command() { if [ "x${CI_DEBUG_LOG_FILE_PATH:-}" != "x" ]; then local full_path="${OLDPWD}/${CI_DEBUG_LOG_FILE_PATH}" local folder=$(dirname ${full_path}) + mkdir -p ${folder} elastic-package $@ 2>&1 /dev/stdout | tee ${full_path} | grep -v " DEBUG " exit 0 From 24317c917014103133a44db7e643b27bcba41f39 Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Wed, 28 Jun 2023 15:37:52 +0200 Subject: [PATCH 18/40] Revert "Move service container status to a file" This reverts commit d1f5b2082ad69735a31829a146ac5a843eaab59d. --- .../pipeline.trigger.integration.tests.sh | 2 -- .../runners/system/servicedeployer/compose.go | 35 ++----------------- internal/compose/compose.go | 17 +++++---- .../runners/system/servicedeployer/compose.go | 33 +---------------- .../system/servicedeployer/custom_agent.go | 5 +-- .../system/servicedeployer/terraform.go | 5 +-- 6 files changed, 13 insertions(+), 84 deletions(-) diff --git a/.buildkite/pipeline.trigger.integration.tests.sh b/.buildkite/pipeline.trigger.integration.tests.sh index 798a3674b..4daa9dc9b 100755 --- a/.buildkite/pipeline.trigger.integration.tests.sh +++ b/.buildkite/pipeline.trigger.integration.tests.sh @@ -47,7 +47,6 @@ for test in ${CHECK_PACKAGES_TESTS[@]}; do echo " - build/test-results/*.xml" echo " - build/elastic-stack-dump/check-*/logs/*.log" echo " - build/elastic-stack-dump/check-*/logs/fleet-server-internal/**/*" - echo " - build/container-status/*.log" if [ "x${CI_DEBUG_LOG_FILE_PATH}" != "x" ]; then echo " - ${CI_DEBUG_LOG_FILE_PATH}" fi @@ -68,7 +67,6 @@ for package in $(find . -maxdepth 1 -mindepth 1 -type d) ; do echo " provider: \"gcp\"" echo " artifact_paths:" echo " - build/test-results/*.xml" - echo " - build/container-status/*.log" if [ "x${CI_DEBUG_LOG_FILE_PATH}" != "x" ]; then echo " - ${CI_DEBUG_LOG_FILE_PATH}" fi diff --git a/internal/benchrunner/runners/system/servicedeployer/compose.go b/internal/benchrunner/runners/system/servicedeployer/compose.go index 941c376c6..0b3dd5e2c 100644 --- a/internal/benchrunner/runners/system/servicedeployer/compose.go +++ b/internal/benchrunner/runners/system/servicedeployer/compose.go @@ -5,7 +5,6 @@ package servicedeployer import ( - "bytes" "fmt" "os" "path/filepath" @@ -74,10 +73,7 @@ func (d *DockerComposeServiceDeployer) SetUp(inCtxt ServiceContext) (DeployedSer if err != nil { return nil, fmt.Errorf("could not boot up service using Docker Compose: %w", err) } - statuses, err := p.WaitForHealthy(opts) - if statusErr := writeServiceContainerStatus(outCtxt.Name, statuses); statusErr != nil { - logger.Errorf("failed to create container status file: %v", statusErr) - } + err = p.WaitForHealthy(opts) if err != nil { processServiceContainerLogs(p, compose.CommandOptions{ Env: opts.Env, @@ -209,7 +205,7 @@ func writeServiceContainerLogs(serviceName string, content []byte) error { return fmt.Errorf("can't create directory for service container logs (path: %s): %w", containerLogsDir, err) } - containerLogsFilepath := filepath.Join(containerLogsDir, fmt.Sprintf("benchmark-%s-%d.log", serviceName, time.Now().UnixNano())) + containerLogsFilepath := filepath.Join(containerLogsDir, fmt.Sprintf("%s-%d.log", serviceName, time.Now().UnixNano())) logger.Infof("Write container logs to file: %s", containerLogsFilepath) err = os.WriteFile(containerLogsFilepath, content, 0644) if err != nil { @@ -217,30 +213,3 @@ func writeServiceContainerLogs(serviceName string, content []byte) error { } return nil } - -func writeServiceContainerStatus(serviceName string, content [][]byte) error { - if len(content) == 0 { - return nil - } - - buildDir, err := builder.BuildDirectory() - if err != nil { - return fmt.Errorf("locating build directory failed: %w", err) - } - - containerStatusDir := filepath.Join(buildDir, "container-status") - err = os.MkdirAll(containerStatusDir, 0755) - if err != nil { - return fmt.Errorf("can't create directory for service container status (path: %s): %w", containerStatusDir, err) - } - - containerStatusFilepath := filepath.Join(containerStatusDir, fmt.Sprintf("benchmark-%s-%d.log", serviceName, time.Now().UnixNano())) - logger.Infof("Write container status to file: %s", containerStatusFilepath) - - contentFile := bytes.Join(content, []byte("\n")) - err = os.WriteFile(containerStatusFilepath, contentFile, 0644) - if err != nil { - return fmt.Errorf("can't write container status to file (path: %s): %w", containerStatusFilepath, err) - } - return nil -} diff --git a/internal/compose/compose.go b/internal/compose/compose.go index 56f9348eb..2d6ba3744 100644 --- a/internal/compose/compose.go +++ b/internal/compose/compose.go @@ -314,7 +314,7 @@ func (p *Project) Logs(opts CommandOptions) ([]byte, error) { } // WaitForHealthy method waits until all containers are healthy. -func (p *Project) WaitForHealthy(opts CommandOptions) ([][]byte, error) { +func (p *Project) WaitForHealthy(opts CommandOptions) error { // Read container IDs args := p.baseArgs() args = append(args, "ps") @@ -322,21 +322,20 @@ func (p *Project) WaitForHealthy(opts CommandOptions) ([][]byte, error) { var b bytes.Buffer if err := p.runDockerComposeCmd(dockerComposeOptions{args: args, env: opts.Env, stdout: &b}); err != nil { - return nil, err + return err } startTime := time.Now() timeout := startTime.Add(waitForHealthyTimeout) containerIDs := strings.Fields(b.String()) - containerStatuses := [][]byte{} for { if time.Now().After(timeout) { - return containerStatuses, errors.New("timeout waiting for healthy container") + return errors.New("timeout waiting for healthy container") } if signal.SIGINT() { - return containerStatuses, errors.New("SIGINT: cancel waiting for policy assigned") + return errors.New("SIGINT: cancel waiting for policy assigned") } // NOTE: healthy must be reinitialized at each iteration @@ -345,11 +344,11 @@ func (p *Project) WaitForHealthy(opts CommandOptions) ([][]byte, error) { logger.Debugf("Wait for healthy containers: %s", strings.Join(containerIDs, ",")) descriptions, err := docker.InspectContainers(containerIDs...) if err != nil { - return containerStatuses, err + return err } for _, containerDescription := range descriptions { - containerStatuses = append(containerStatuses, []byte(containerDescription.String())) + logger.Debugf("Container status: %s", containerDescription.String()) // No healthcheck defined for service if containerDescription.State.Status == "running" && containerDescription.State.Health == nil { @@ -368,7 +367,7 @@ func (p *Project) WaitForHealthy(opts CommandOptions) ([][]byte, error) { // Container exited with code > 0 if containerDescription.State.Status == "exited" && containerDescription.State.ExitCode > 0 { - return containerStatuses, fmt.Errorf("container (ID: %s) exited with code %d", containerDescription.ID, containerDescription.State.ExitCode) + return fmt.Errorf("container (ID: %s) exited with code %d", containerDescription.ID, containerDescription.State.ExitCode) } // Any different status is considered unhealthy @@ -384,7 +383,7 @@ func (p *Project) WaitForHealthy(opts CommandOptions) ([][]byte, error) { time.Sleep(waitForHealthyInterval) } - return containerStatuses, nil + return nil } func (p *Project) baseArgs() []string { diff --git a/internal/testrunner/runners/system/servicedeployer/compose.go b/internal/testrunner/runners/system/servicedeployer/compose.go index d259a2223..69c10fb36 100644 --- a/internal/testrunner/runners/system/servicedeployer/compose.go +++ b/internal/testrunner/runners/system/servicedeployer/compose.go @@ -5,7 +5,6 @@ package servicedeployer import ( - "bytes" "fmt" "os" "path/filepath" @@ -90,10 +89,7 @@ func (d *DockerComposeServiceDeployer) SetUp(inCtxt ServiceContext) (DeployedSer return nil, errors.Wrap(err, "could not boot up service using Docker Compose") } - statuses, err := p.WaitForHealthy(opts) - if statusErr := writeServiceContainerStatus(outCtxt.Name, statuses); statusErr != nil { - logger.Errorf("failed to create container status file: %v", statusErr) - } + err = p.WaitForHealthy(opts) if err != nil { processServiceContainerLogs(p, compose.CommandOptions{ Env: opts.Env, @@ -238,30 +234,3 @@ func writeServiceContainerLogs(serviceName string, content []byte) error { } return nil } - -func writeServiceContainerStatus(serviceName string, content [][]byte) error { - if len(content) == 0 { - return nil - } - - buildDir, err := builder.BuildDirectory() - if err != nil { - return fmt.Errorf("locating build directory failed: %w", err) - } - - containerStatusDir := filepath.Join(buildDir, "container-status") - err = os.MkdirAll(containerStatusDir, 0755) - if err != nil { - return fmt.Errorf("can't create directory for service container status (path: %s): %w", containerStatusDir, err) - } - - containerStatusFilepath := filepath.Join(containerStatusDir, fmt.Sprintf("%s-%d.log", serviceName, time.Now().UnixNano())) - logger.Infof("Write container status to file: %s", containerStatusFilepath) - - contentFile := bytes.Join(content, []byte("\n")) - err = os.WriteFile(containerStatusFilepath, contentFile, 0644) - if err != nil { - return fmt.Errorf("can't write container status to file (path: %s): %w", containerStatusFilepath, err) - } - return nil -} diff --git a/internal/testrunner/runners/system/servicedeployer/custom_agent.go b/internal/testrunner/runners/system/servicedeployer/custom_agent.go index 93ba2bc39..02165d0e0 100644 --- a/internal/testrunner/runners/system/servicedeployer/custom_agent.go +++ b/internal/testrunner/runners/system/servicedeployer/custom_agent.go @@ -129,10 +129,7 @@ func (d *CustomAgentDeployer) SetUp(inCtxt ServiceContext) (DeployedService, err return nil, errors.Wrapf(err, "can't attach service container to the stack network") } - statuses, err := p.WaitForHealthy(opts) - if statusErr := writeServiceContainerStatus(outCtxt.Name, statuses); statusErr != nil { - logger.Errorf("failed to create container status file: %v", statusErr) - } + err = p.WaitForHealthy(opts) if err != nil { processServiceContainerLogs(p, compose.CommandOptions{ Env: opts.Env, diff --git a/internal/testrunner/runners/system/servicedeployer/terraform.go b/internal/testrunner/runners/system/servicedeployer/terraform.go index 55443de5d..d64d40e45 100644 --- a/internal/testrunner/runners/system/servicedeployer/terraform.go +++ b/internal/testrunner/runners/system/servicedeployer/terraform.go @@ -148,10 +148,7 @@ func (tsd TerraformServiceDeployer) SetUp(inCtxt ServiceContext) (DeployedServic return nil, errors.Wrap(err, "could not boot up service using Docker Compose") } - statuses, err := p.WaitForHealthy(opts) - if statusErr := writeServiceContainerStatus(outCtxt.Name, statuses); statusErr != nil { - logger.Errorf("failed to create container status file: %v", statusErr) - } + err = p.WaitForHealthy(opts) if err != nil { processServiceContainerLogs(p, compose.CommandOptions{ Env: opts.Env, From 564278719606ad2f18953294a231c1106b740d7a Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Wed, 28 Jun 2023 15:44:48 +0200 Subject: [PATCH 19/40] Set tee to append content to files --- scripts/test-check-packages.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/test-check-packages.sh b/scripts/test-check-packages.sh index ab678f403..f5c12027d 100755 --- a/scripts/test-check-packages.sh +++ b/scripts/test-check-packages.sh @@ -9,7 +9,7 @@ run_elastic_package_command() { local folder=$(dirname ${full_path}) mkdir -p ${folder} - elastic-package $@ 2>&1 /dev/stdout | tee ${full_path} | grep -v " DEBUG " + elastic-package $@ 2>&1 /dev/stdout | tee -a ${full_path} | grep -v " DEBUG " exit 0 fi elastic-package $@ From 555d68ce858383a48ec85548e20463b7014b9e20 Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Wed, 28 Jun 2023 15:59:34 +0200 Subject: [PATCH 20/40] Remove exit --- scripts/test-check-packages.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/test-check-packages.sh b/scripts/test-check-packages.sh index f5c12027d..2902e2a2b 100755 --- a/scripts/test-check-packages.sh +++ b/scripts/test-check-packages.sh @@ -10,9 +10,9 @@ run_elastic_package_command() { mkdir -p ${folder} elastic-package $@ 2>&1 /dev/stdout | tee -a ${full_path} | grep -v " DEBUG " - exit 0 + else + elastic-package $@ fi - elastic-package $@ } cleanup() { From 43eb0d7a9b6c1fab9c02c7d0c348590a6577f36b Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Wed, 28 Jun 2023 16:10:16 +0200 Subject: [PATCH 21/40] Separate logs per package --- .../pipeline.trigger.integration.tests.sh | 28 +++++++++---------- .buildkite/pipeline.yml | 2 +- scripts/test-check-packages.sh | 9 ++++-- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/.buildkite/pipeline.trigger.integration.tests.sh b/.buildkite/pipeline.trigger.integration.tests.sh index 4daa9dc9b..38b959c7b 100755 --- a/.buildkite/pipeline.trigger.integration.tests.sh +++ b/.buildkite/pipeline.trigger.integration.tests.sh @@ -27,8 +27,8 @@ for test in ${STACK_COMMAND_TESTS[@]}; do 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_FILE_PATH}" != "x" ]; then - echo " - ${CI_DEBUG_LOG_FILE_PATH}" + if [ "x${CI_DEBUG_LOG_FOLDER_PATH}" != "x" ]; then + echo " - ${CI_DEBUG_LOG_FOLDER_PATH}" fi done @@ -47,8 +47,8 @@ for test in ${CHECK_PACKAGES_TESTS[@]}; do 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_FILE_PATH}" != "x" ]; then - echo " - ${CI_DEBUG_LOG_FILE_PATH}" + if [ "x${CI_DEBUG_LOG_FOLDER_PATH}" != "x" ]; then + echo " - ${CI_DEBUG_LOG_FOLDER_PATH}" fi if [[ $test =~ with-kind$ ]]; then echo " - build/kubectl-dump.txt" @@ -67,8 +67,8 @@ for package in $(find . -maxdepth 1 -mindepth 1 -type d) ; do echo " provider: \"gcp\"" echo " artifact_paths:" echo " - build/test-results/*.xml" - if [ "x${CI_DEBUG_LOG_FILE_PATH}" != "x" ]; then - echo " - ${CI_DEBUG_LOG_FILE_PATH}" + if [ "x${CI_DEBUG_LOG_FOLDER_PATH}" != "x" ]; then + echo " - ${CI_DEBUG_LOG_FOLDER_PATH}" fi done @@ -81,8 +81,8 @@ echo " provider: \"gcp\"" echo " artifact_paths:" echo " - build/elastic-stack-dump/build-zip/logs/*.log" echo " - build/packages/*.sig" -if [ "x${CI_DEBUG_LOG_FILE_PATH}" != "x" ]; then - echo " - ${CI_DEBUG_LOG_FILE_PATH}" +if [ "x${CI_DEBUG_LOG_FOLDER_PATH}" != "x" ]; then + echo " - ${CI_DEBUG_LOG_FOLDER_PATH}" fi echo " - label: \":go: Running integration test: test-install-zip\"" @@ -91,8 +91,8 @@ echo " agents:" echo " provider: \"gcp\"" echo " artifact_paths:" echo " - build/elastic-stack-dump/install-zip/logs/*.log" -if [ "x${CI_DEBUG_LOG_FILE_PATH}" != "x" ]; then - echo " - ${CI_DEBUG_LOG_FILE_PATH}" +if [ "x${CI_DEBUG_LOG_FOLDER_PATH}" != "x" ]; then + echo " - ${CI_DEBUG_LOG_FOLDER_PATH}" fi echo " - label: \":go: Running integration test: test-install-zip-shellinit\"" @@ -101,15 +101,15 @@ echo " agents:" echo " provider: \"gcp\"" echo " artifact_paths:" echo " - build/elastic-stack-dump/install-zip-shellinit/logs/*.log" -if [ "x${CI_DEBUG_LOG_FILE_PATH}" != "x" ]; then - echo " - ${CI_DEBUG_LOG_FILE_PATH}" +if [ "x${CI_DEBUG_LOG_FOLDER_PATH}" != "x" ]; then + echo " - ${CI_DEBUG_LOG_FOLDER_PATH}" fi echo " - label: \":go: Running integration test: test-profiles-command\"" echo " command: ./.buildkite/scripts/integration_tests.sh -t test-profiles-command" echo " agents:" echo " provider: \"gcp\"" -if [ "x${CI_DEBUG_LOG_FILE_PATH}" != "x" ]; then +if [ "x${CI_DEBUG_LOG_FOLDER_PATH}" != "x" ]; then echo " artifact_paths:" - echo " - ${CI_DEBUG_LOG_FILE_PATH}" + echo " - ${CI_DEBUG_LOG_FOLDER_PATH}" fi diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index e30dc4ce8..672bbbe6b 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -5,7 +5,7 @@ env: ELASTIC_PACKAGE_COMPOSE_DISABLE_PULL_PROGRESS_INFORMATION: "true" KIND_VERSION: 'v0.17.0' K8S_VERSION: 'v1.26.0' - CI_DEBUG_LOG_FILE_PATH: 'build/elastic-package-debug-output.log' + CI_DEBUG_LOG_FOLDER_PATH: 'build/' steps: - label: ":go: Run check-static" diff --git a/scripts/test-check-packages.sh b/scripts/test-check-packages.sh index 2902e2a2b..33cfc9d56 100755 --- a/scripts/test-check-packages.sh +++ b/scripts/test-check-packages.sh @@ -2,10 +2,11 @@ set -euxo pipefail +DEFAULT_DEBUG_LOG_FILE=elastic-package-debug-output-main.log run_elastic_package_command() { - if [ "x${CI_DEBUG_LOG_FILE_PATH:-}" != "x" ]; then - local full_path="${OLDPWD}/${CI_DEBUG_LOG_FILE_PATH}" + if [ "x${CI_DEBUG_LOG_FOLDER_PATH:-}" != "x" ]; then + local full_path="${OLDPWD}/${CI_DEBUG_LOG_FOLDER_PATH}/${CI_DEBUG_LOG_FILE_PATH:-$DEFAULT_DEBUG_LOG_FILE}" local folder=$(dirname ${full_path}) mkdir -p ${folder} @@ -80,10 +81,12 @@ for d in test/packages/${PACKAGE_TEST_TYPE:-other}/${PACKAGE_UNDER_TEST:-*}/; do ( cd $d run_elastic_package_command install -v + package_to_test=$(basename ${d}) + + CI_DEBUG_LOG_FILE_PATH="${CI_DEBUG_LOG_FOLDER_PATH}/elastic-package-debug-output-${package_to_test}.log" if [ "${PACKAGE_TEST_TYPE:-other}" == "benchmarks" ]; then # It is not used PACKAGE_UNDER_TEST, so all benchmark packages are run in the same loop - package_to_test=$(basename ${d}) if [ "${package_to_test}" == "pipeline_benchmark" ]; then rm -rf "${OLDPWD}/build/benchmark-results" run_elastic_package_command benchmark pipeline -v --report-format xUnit --report-output file --fail-on-missing From f104aef20e6ad99f84823a9f775e87bab989a58f Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Wed, 28 Jun 2023 16:14:25 +0200 Subject: [PATCH 22/40] Add glob pattern --- .buildkite/pipeline.trigger.integration.tests.sh | 14 +++++++------- .buildkite/pipeline.yml | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.buildkite/pipeline.trigger.integration.tests.sh b/.buildkite/pipeline.trigger.integration.tests.sh index 38b959c7b..65591c36d 100755 --- a/.buildkite/pipeline.trigger.integration.tests.sh +++ b/.buildkite/pipeline.trigger.integration.tests.sh @@ -28,7 +28,7 @@ for test in ${STACK_COMMAND_TESTS[@]}; do 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}" + echo " - ${CI_DEBUG_LOG_FOLDER_PATH}/*" fi done @@ -48,7 +48,7 @@ for test in ${CHECK_PACKAGES_TESTS[@]}; do 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}" + echo " - ${CI_DEBUG_LOG_FOLDER_PATH}/*" fi if [[ $test =~ with-kind$ ]]; then echo " - build/kubectl-dump.txt" @@ -68,7 +68,7 @@ for package in $(find . -maxdepth 1 -mindepth 1 -type d) ; do echo " artifact_paths:" echo " - build/test-results/*.xml" if [ "x${CI_DEBUG_LOG_FOLDER_PATH}" != "x" ]; then - echo " - ${CI_DEBUG_LOG_FOLDER_PATH}" + echo " - ${CI_DEBUG_LOG_FOLDER_PATH}/*" fi done @@ -82,7 +82,7 @@ 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}" + echo " - ${CI_DEBUG_LOG_FOLDER_PATH}/*" fi echo " - label: \":go: Running integration test: test-install-zip\"" @@ -92,7 +92,7 @@ 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}" + echo " - ${CI_DEBUG_LOG_FOLDER_PATH}/*" fi echo " - label: \":go: Running integration test: test-install-zip-shellinit\"" @@ -102,7 +102,7 @@ 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}" + echo " - ${CI_DEBUG_LOG_FOLDER_PATH}/*" fi echo " - label: \":go: Running integration test: test-profiles-command\"" @@ -111,5 +111,5 @@ echo " agents:" echo " provider: \"gcp\"" if [ "x${CI_DEBUG_LOG_FOLDER_PATH}" != "x" ]; then echo " artifact_paths:" - echo " - ${CI_DEBUG_LOG_FOLDER_PATH}" + echo " - ${CI_DEBUG_LOG_FOLDER_PATH}/*" fi diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 672bbbe6b..317cf7099 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -5,7 +5,7 @@ env: 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_FOLDER_PATH: './build' steps: - label: ":go: Run check-static" From aeaec982ca2f3d508833d2df38e2b253471bd19a Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Wed, 28 Jun 2023 16:33:12 +0200 Subject: [PATCH 23/40] Add prefix var --- .buildkite/pipeline.trigger.integration.tests.sh | 16 +++++++++------- .buildkite/pipeline.yml | 1 + 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.buildkite/pipeline.trigger.integration.tests.sh b/.buildkite/pipeline.trigger.integration.tests.sh index 65591c36d..79e3f12ed 100755 --- a/.buildkite/pipeline.trigger.integration.tests.sh +++ b/.buildkite/pipeline.trigger.integration.tests.sh @@ -9,6 +9,8 @@ echo " - group: \":terminal: Integration test suite\"" echo " key: \"integration-tests\"" echo " steps:" +CI_DEBUG_LOG_PREFIX=${CI_DEBUG_LOG_PREFIX:-elastic-package-debug-output} + # Integration tests related stack command STACK_COMMAND_TESTS=( test-stack-command-default @@ -28,7 +30,7 @@ for test in ${STACK_COMMAND_TESTS[@]}; do 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}/*" + echo " - ${CI_DEBUG_LOG_FOLDER_PATH}/${CI_DEBUG_LOG_PREFIX}*.log" fi done @@ -48,7 +50,7 @@ for test in ${CHECK_PACKAGES_TESTS[@]}; do 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}/*" + echo " - ${CI_DEBUG_LOG_FOLDER_PATH}/${CI_DEBUG_LOG_PREFIX}*.log" fi if [[ $test =~ with-kind$ ]]; then echo " - build/kubectl-dump.txt" @@ -68,7 +70,7 @@ for package in $(find . -maxdepth 1 -mindepth 1 -type d) ; do echo " artifact_paths:" echo " - build/test-results/*.xml" if [ "x${CI_DEBUG_LOG_FOLDER_PATH}" != "x" ]; then - echo " - ${CI_DEBUG_LOG_FOLDER_PATH}/*" + echo " - ${CI_DEBUG_LOG_FOLDER_PATH}/${CI_DEBUG_LOG_PREFIX}*.log" fi done @@ -82,7 +84,7 @@ 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}/*" + echo " - ${CI_DEBUG_LOG_FOLDER_PATH}/${CI_DEBUG_LOG_PREFIX}*.log" fi echo " - label: \":go: Running integration test: test-install-zip\"" @@ -92,7 +94,7 @@ 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}/*" + echo " - ${CI_DEBUG_LOG_FOLDER_PATH}/${CI_DEBUG_LOG_PREFIX}*.log" fi echo " - label: \":go: Running integration test: test-install-zip-shellinit\"" @@ -102,7 +104,7 @@ 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}/*" + echo " - ${CI_DEBUG_LOG_FOLDER_PATH}/${CI_DEBUG_LOG_PREFIX}*.log" fi echo " - label: \":go: Running integration test: test-profiles-command\"" @@ -111,5 +113,5 @@ echo " agents:" echo " provider: \"gcp\"" if [ "x${CI_DEBUG_LOG_FOLDER_PATH}" != "x" ]; then echo " artifact_paths:" - echo " - ${CI_DEBUG_LOG_FOLDER_PATH}/*" + echo " - ${CI_DEBUG_LOG_FOLDER_PATH}/${CI_DEBUG_LOG_PREFIX}*.log" fi diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 317cf7099..2029bd828 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -6,6 +6,7 @@ env: 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" From 609a2704d6b4f2e88de75af219c99f35f5605de0 Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Wed, 28 Jun 2023 16:33:58 +0200 Subject: [PATCH 24/40] Skip shellinit --- scripts/test-check-packages.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/test-check-packages.sh b/scripts/test-check-packages.sh index 33cfc9d56..a8cf1ac45 100755 --- a/scripts/test-check-packages.sh +++ b/scripts/test-check-packages.sh @@ -75,7 +75,7 @@ if [ "${PACKAGE_TEST_TYPE:-other}" == "with-kind" ]; then fi # Run package tests -eval "$(run_elastic_package_command stack shellinit)" +eval "$(elastic-package stack shellinit)" for d in test/packages/${PACKAGE_TEST_TYPE:-other}/${PACKAGE_UNDER_TEST:-*}/; do ( From 1231cb23641c681c6e4bf61e0875c6f4b9fc9ff9 Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Wed, 28 Jun 2023 16:54:15 +0200 Subject: [PATCH 25/40] test with local variable --- scripts/test-check-packages.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/test-check-packages.sh b/scripts/test-check-packages.sh index a8cf1ac45..5b625fa3f 100755 --- a/scripts/test-check-packages.sh +++ b/scripts/test-check-packages.sh @@ -5,14 +5,15 @@ set -euxo pipefail DEFAULT_DEBUG_LOG_FILE=elastic-package-debug-output-main.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}/${CI_DEBUG_LOG_FILE_PATH:-$DEFAULT_DEBUG_LOG_FILE}" local folder=$(dirname ${full_path}) mkdir -p ${folder} - elastic-package $@ 2>&1 /dev/stdout | tee -a ${full_path} | grep -v " DEBUG " + ${command} 2>&1 /dev/stdout | tee -a ${full_path} | grep -v " DEBUG " else - elastic-package $@ + ${command} fi } From a8d0a5e00196c9a20293d6c96ed32563e3e90717 Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Wed, 28 Jun 2023 17:11:20 +0200 Subject: [PATCH 26/40] Execute with bash --- .buildkite/pipeline.trigger.integration.tests.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.buildkite/pipeline.trigger.integration.tests.sh b/.buildkite/pipeline.trigger.integration.tests.sh index 79e3f12ed..3fd07acf8 100755 --- a/.buildkite/pipeline.trigger.integration.tests.sh +++ b/.buildkite/pipeline.trigger.integration.tests.sh @@ -22,7 +22,7 @@ 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:" @@ -42,7 +42,7 @@ 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:" @@ -62,7 +62,7 @@ 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:" @@ -77,7 +77,7 @@ 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:" @@ -88,7 +88,7 @@ if [ "x${CI_DEBUG_LOG_FOLDER_PATH}" != "x" ]; then 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:" @@ -98,7 +98,7 @@ if [ "x${CI_DEBUG_LOG_FOLDER_PATH}" != "x" ]; then 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:" @@ -108,7 +108,7 @@ if [ "x${CI_DEBUG_LOG_FOLDER_PATH}" != "x" ]; then 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 From 69f9808d72bf6b3110275a8a1b1cec64af720ab2 Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Thu, 29 Jun 2023 01:00:46 +0200 Subject: [PATCH 27/40] Test annotations --- .buildkite/pipeline.yml | 5 +++++ .buildkite/scripts/check_for_errors.sh | 25 +++++++++++++++++++++++++ scripts/test-check-packages.sh | 15 +++++++++------ 3 files changed, 39 insertions(+), 6 deletions(-) create mode 100755 .buildkite/scripts/check_for_errors.sh diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 2029bd828..cfafeab9e 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -58,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: | diff --git a/.buildkite/scripts/check_for_errors.sh b/.buildkite/scripts/check_for_errors.sh new file mode 100755 index 000000000..6d100f2f0 --- /dev/null +++ b/.buildkite/scripts/check_for_errors.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -euo pipefail + + +buildkite-agent artifact download "build/output-logs/*" . + + +for package_type in $(ls build/output-logs/); do + for output_file in $(ls build/output-logs/${package_type}); do + elastic-package-demo-output*.log ; do + errors=$(grep -E "^Error:" $file) + + if [ -n "${errors}" ]; then + cat <> 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 diff --git a/scripts/test-check-packages.sh b/scripts/test-check-packages.sh index 5b625fa3f..1151576b6 100755 --- a/scripts/test-check-packages.sh +++ b/scripts/test-check-packages.sh @@ -2,16 +2,16 @@ set -euxo pipefail -DEFAULT_DEBUG_LOG_FILE=elastic-package-debug-output-main.log +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}/${CI_DEBUG_LOG_FILE_PATH:-$DEFAULT_DEBUG_LOG_FILE}" + local full_path="${OLDPWD}/${CI_DEBUG_LOG_FOLDER_PATH}/output-logs/${PACKAGE_TEST_TYPE:-other}/${CI_DEBUG_LOG_FILE_PATH:-$DEFAULT_DEBUG_LOG_FILE}" local folder=$(dirname ${full_path}) mkdir -p ${folder} - ${command} 2>&1 /dev/stdout | tee -a ${full_path} | grep -v " DEBUG " + ${command} 2>&1 | tee -a ${full_path} else ${command} fi @@ -78,13 +78,15 @@ fi # Run package tests eval "$(elastic-package stack shellinit)" +elastic-package stack status -v -d --version 8.9.9 + for d in test/packages/${PACKAGE_TEST_TYPE:-other}/${PACKAGE_UNDER_TEST:-*}/; do ( cd $d - run_elastic_package_command install -v - package_to_test=$(basename ${d}) + # package_to_test=$(basename ${d}) + package_to_test=${PACKAGE_UNDER_TEST:-*} - CI_DEBUG_LOG_FILE_PATH="${CI_DEBUG_LOG_FOLDER_PATH}/elastic-package-debug-output-${package_to_test}.log" + 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 @@ -112,3 +114,4 @@ for d in test/packages/${PACKAGE_TEST_TYPE:-other}/${PACKAGE_UNDER_TEST:-*}/; do ) cd - done + From 329d8a114c13d5959bea48cbd0915b6ba783d75d Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Thu, 29 Jun 2023 01:13:52 +0200 Subject: [PATCH 28/40] Set artifact_paths --- .buildkite/pipeline.trigger.integration.tests.sh | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.buildkite/pipeline.trigger.integration.tests.sh b/.buildkite/pipeline.trigger.integration.tests.sh index 3fd07acf8..ce9570b99 100755 --- a/.buildkite/pipeline.trigger.integration.tests.sh +++ b/.buildkite/pipeline.trigger.integration.tests.sh @@ -9,7 +9,6 @@ echo " - group: \":terminal: Integration test suite\"" echo " key: \"integration-tests\"" echo " steps:" -CI_DEBUG_LOG_PREFIX=${CI_DEBUG_LOG_PREFIX:-elastic-package-debug-output} # Integration tests related stack command STACK_COMMAND_TESTS=( @@ -30,7 +29,7 @@ for test in ${STACK_COMMAND_TESTS[@]}; do 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}/${CI_DEBUG_LOG_PREFIX}*.log" + echo " - ${CI_DEBUG_LOG_FOLDER_PATH}/output-logs/**/*.log" fi done @@ -50,7 +49,7 @@ for test in ${CHECK_PACKAGES_TESTS[@]}; do 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}/${CI_DEBUG_LOG_PREFIX}*.log" + echo " - ${CI_DEBUG_LOG_FOLDER_PATH}/output-logs/**/*.log" fi if [[ $test =~ with-kind$ ]]; then echo " - build/kubectl-dump.txt" @@ -70,7 +69,7 @@ for package in $(find . -maxdepth 1 -mindepth 1 -type d) ; do echo " artifact_paths:" echo " - build/test-results/*.xml" if [ "x${CI_DEBUG_LOG_FOLDER_PATH}" != "x" ]; then - echo " - ${CI_DEBUG_LOG_FOLDER_PATH}/${CI_DEBUG_LOG_PREFIX}*.log" + echo " - ${CI_DEBUG_LOG_FOLDER_PATH}/output-logs/**/*.log" fi done @@ -84,7 +83,7 @@ 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}/${CI_DEBUG_LOG_PREFIX}*.log" + echo " - ${CI_DEBUG_LOG_FOLDER_PATH}/output-logs/**/*.log" fi echo " - label: \":go: Running integration test: test-install-zip\"" @@ -94,7 +93,7 @@ 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}/${CI_DEBUG_LOG_PREFIX}*.log" + echo " - ${CI_DEBUG_LOG_FOLDER_PATH}/output-logs/**/*.log" fi echo " - label: \":go: Running integration test: test-install-zip-shellinit\"" @@ -104,7 +103,7 @@ 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}/${CI_DEBUG_LOG_PREFIX}*.log" + echo " - ${CI_DEBUG_LOG_FOLDER_PATH}/output-logs/**/*.log" fi echo " - label: \":go: Running integration test: test-profiles-command\"" @@ -113,5 +112,5 @@ echo " agents:" echo " provider: \"gcp\"" if [ "x${CI_DEBUG_LOG_FOLDER_PATH}" != "x" ]; then echo " artifact_paths:" - echo " - ${CI_DEBUG_LOG_FOLDER_PATH}/${CI_DEBUG_LOG_PREFIX}*.log" + echo " - ${CI_DEBUG_LOG_FOLDER_PATH}/output-logs/**/*.log" fi From d128c6016380c68f1f1378c24d832ae59a9e8506 Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Thu, 29 Jun 2023 01:31:47 +0200 Subject: [PATCH 29/40] Fix check_for_errors.sh --- .buildkite/scripts/check_for_errors.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.buildkite/scripts/check_for_errors.sh b/.buildkite/scripts/check_for_errors.sh index 6d100f2f0..4e90d8933 100755 --- a/.buildkite/scripts/check_for_errors.sh +++ b/.buildkite/scripts/check_for_errors.sh @@ -8,8 +8,7 @@ buildkite-agent artifact download "build/output-logs/*" . for package_type in $(ls build/output-logs/); do for output_file in $(ls build/output-logs/${package_type}); do - elastic-package-demo-output*.log ; do - errors=$(grep -E "^Error:" $file) + errors=$(grep -E "^Error:" build/ouput-logs/${package_type}/${output_file}) if [ -n "${errors}" ]; then cat <> markdown.md From f099323ef5e07f2a66debb65e9d002c1311c291a Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Thu, 29 Jun 2023 09:09:57 +0200 Subject: [PATCH 30/40] download all artifacts to a folder --- .buildkite/scripts/check_for_errors.sh | 4 +++- scripts/test-check-packages.sh | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.buildkite/scripts/check_for_errors.sh b/.buildkite/scripts/check_for_errors.sh index 4e90d8933..2402b701a 100755 --- a/.buildkite/scripts/check_for_errors.sh +++ b/.buildkite/scripts/check_for_errors.sh @@ -3,7 +3,9 @@ set -euo pipefail -buildkite-agent artifact download "build/output-logs/*" . +buildkite-agent artifact download "build/output-logs/*" build/ + +ls -l build for package_type in $(ls build/output-logs/); do diff --git a/scripts/test-check-packages.sh b/scripts/test-check-packages.sh index 1151576b6..7b805dffa 100755 --- a/scripts/test-check-packages.sh +++ b/scripts/test-check-packages.sh @@ -7,7 +7,12 @@ 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}/${CI_DEBUG_LOG_FILE_PATH:-$DEFAULT_DEBUG_LOG_FILE}" + 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} From 118ecd3abe3035060f843e4a51cb46e6779f7fb3 Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Thu, 29 Jun 2023 09:32:03 +0200 Subject: [PATCH 31/40] Create folder --- .buildkite/scripts/check_for_errors.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.buildkite/scripts/check_for_errors.sh b/.buildkite/scripts/check_for_errors.sh index 2402b701a..2cd794b43 100755 --- a/.buildkite/scripts/check_for_errors.sh +++ b/.buildkite/scripts/check_for_errors.sh @@ -3,6 +3,7 @@ set -euo pipefail +mkdir -p build buildkite-agent artifact download "build/output-logs/*" build/ ls -l build From ae0f119b67262583bdca6488676d21499c80846c Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Thu, 29 Jun 2023 09:54:26 +0200 Subject: [PATCH 32/40] Fix path --- .buildkite/scripts/check_for_errors.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.buildkite/scripts/check_for_errors.sh b/.buildkite/scripts/check_for_errors.sh index 2cd794b43..7b2fa13f8 100755 --- a/.buildkite/scripts/check_for_errors.sh +++ b/.buildkite/scripts/check_for_errors.sh @@ -6,12 +6,13 @@ set -euo pipefail mkdir -p build buildkite-agent artifact download "build/output-logs/*" build/ -ls -l build - +echo ---- +ls -lR build +echo ---- for package_type in $(ls build/output-logs/); do for output_file in $(ls build/output-logs/${package_type}); do - errors=$(grep -E "^Error:" build/ouput-logs/${package_type}/${output_file}) + errors=$(grep -E "^Error:" build/output-logs/${package_type}/${output_file}) if [ -n "${errors}" ]; then cat <> markdown.md From 40b023d982d8922958d1fade2498796722d0bb87 Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Thu, 29 Jun 2023 10:25:58 +0200 Subject: [PATCH 33/40] Show errors --- .buildkite/scripts/check_for_errors.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.buildkite/scripts/check_for_errors.sh b/.buildkite/scripts/check_for_errors.sh index 7b2fa13f8..edfd85169 100755 --- a/.buildkite/scripts/check_for_errors.sh +++ b/.buildkite/scripts/check_for_errors.sh @@ -12,7 +12,12 @@ echo ---- for package_type in $(ls build/output-logs/); do for output_file in $(ls build/output-logs/${package_type}); do - errors=$(grep -E "^Error:" build/output-logs/${package_type}/${output_file}) + output="build/output-logs/${package_type}/${output_file}" + echo "Any error on ${output}?" + errors=$(grep -E "^Error:" ${output}) + + echo "Found errors": + echo "${errors}" if [ -n "${errors}" ]; then cat <> markdown.md @@ -20,7 +25,7 @@ for package_type in $(ls build/output-logs/); do > ${errors} EOF fi -done + done done if [ -f markdown.md ]; then From ad6f50191e90d16d1e8cc45ca601c96e9f1cd784 Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Thu, 29 Jun 2023 10:59:57 +0200 Subject: [PATCH 34/40] Avoid exiting script --- .buildkite/scripts/check_for_errors.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.buildkite/scripts/check_for_errors.sh b/.buildkite/scripts/check_for_errors.sh index edfd85169..8c57ddfc2 100755 --- a/.buildkite/scripts/check_for_errors.sh +++ b/.buildkite/scripts/check_for_errors.sh @@ -14,12 +14,13 @@ 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}?" - errors=$(grep -E "^Error:" ${output}) - echo "Found errors": - echo "${errors}" + if grep -E "^Error:" ${output}; then + echo "Found errors": + + errors=$(grep -E "^Error:" ${output}) + echo "${errors}" - if [ -n "${errors}" ]; then cat <> markdown.md - Error found in ${package_type} > ${errors} From fb10ba4f4e21927a604cd31fe1d4d234234ca574 Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Thu, 29 Jun 2023 11:35:45 +0200 Subject: [PATCH 35/40] Change regex --- .buildkite/scripts/check_for_errors.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.buildkite/scripts/check_for_errors.sh b/.buildkite/scripts/check_for_errors.sh index 8c57ddfc2..8aa161c42 100755 --- a/.buildkite/scripts/check_for_errors.sh +++ b/.buildkite/scripts/check_for_errors.sh @@ -15,10 +15,10 @@ for package_type in $(ls build/output-logs/); do output="build/output-logs/${package_type}/${output_file}" echo "Any error on ${output}?" - if grep -E "^Error:" ${output}; then + if grep -E "Error:" ${output}; then echo "Found errors": - errors=$(grep -E "^Error:" ${output}) + errors=$(grep -E "Error:" ${output}) echo "${errors}" cat <> markdown.md From 7d007d06d6e0a8baf982ffa87436f6cb9fed066b Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Thu, 29 Jun 2023 13:19:21 +0200 Subject: [PATCH 36/40] Add test --- scripts/test-check-packages.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/test-check-packages.sh b/scripts/test-check-packages.sh index 7b805dffa..c1c9961ca 100755 --- a/scripts/test-check-packages.sh +++ b/scripts/test-check-packages.sh @@ -83,7 +83,7 @@ fi # Run package tests eval "$(elastic-package stack shellinit)" -elastic-package stack status -v -d --version 8.9.9 +run_elastic_package_command package stack status -v -d --version 8.9.9 for d in test/packages/${PACKAGE_TEST_TYPE:-other}/${PACKAGE_UNDER_TEST:-*}/; do ( From c3840d4bd0fee5af7a79343299c5110794416ce0 Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Thu, 29 Jun 2023 13:50:25 +0200 Subject: [PATCH 37/40] Test format --- .buildkite/scripts/check_for_errors.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.buildkite/scripts/check_for_errors.sh b/.buildkite/scripts/check_for_errors.sh index 8aa161c42..9e7e5213f 100755 --- a/.buildkite/scripts/check_for_errors.sh +++ b/.buildkite/scripts/check_for_errors.sh @@ -21,9 +21,9 @@ for package_type in $(ls build/output-logs/); do errors=$(grep -E "Error:" ${output}) echo "${errors}" - cat <> markdown.md - - Error found in ${package_type} - > ${errors} + cat <> markdown. +- Error found in ${package_type} + > ${errors} EOF fi done From fecfcf88c3d6041e09bacf67dd4c5db9179c6056 Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Thu, 29 Jun 2023 14:10:05 +0200 Subject: [PATCH 38/40] Fix file name --- .buildkite/scripts/check_for_errors.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.buildkite/scripts/check_for_errors.sh b/.buildkite/scripts/check_for_errors.sh index 9e7e5213f..8199da0d4 100755 --- a/.buildkite/scripts/check_for_errors.sh +++ b/.buildkite/scripts/check_for_errors.sh @@ -6,10 +6,6 @@ set -euo pipefail mkdir -p build buildkite-agent artifact download "build/output-logs/*" build/ -echo ---- -ls -lR build -echo ---- - 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}" @@ -21,7 +17,7 @@ for package_type in $(ls build/output-logs/); do errors=$(grep -E "Error:" ${output}) echo "${errors}" - cat <> markdown. + cat <> markdown.md - Error found in ${package_type} > ${errors} EOF From 022af1fa7f916d6c368e51ba63c54da9e04556dd Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Thu, 29 Jun 2023 14:36:27 +0200 Subject: [PATCH 39/40] Revert changes related to benchmark packages --- scripts/test-check-packages.sh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/scripts/test-check-packages.sh b/scripts/test-check-packages.sh index c1c9961ca..4b052b9b1 100755 --- a/scripts/test-check-packages.sh +++ b/scripts/test-check-packages.sh @@ -83,19 +83,17 @@ fi # Run package tests eval "$(elastic-package stack shellinit)" -run_elastic_package_command package stack status -v -d --version 8.9.9 +run_elastic_package_command stack status -v -d --version 8.9.9 for d in test/packages/${PACKAGE_TEST_TYPE:-other}/${PACKAGE_UNDER_TEST:-*}/; do ( cd $d - # package_to_test=$(basename ${d}) - package_to_test=${PACKAGE_UNDER_TEST:-*} 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_to_test}" == "pipeline_benchmark" ]; then + if [ "${PACKAGE_UNDER_TEST:-*}" == "pipeline_benchmark" ]; then rm -rf "${OLDPWD}/build/benchmark-results" run_elastic_package_command benchmark pipeline -v --report-format xUnit --report-output file --fail-on-missing @@ -109,9 +107,9 @@ for d in test/packages/${PACKAGE_TEST_TYPE:-other}/${PACKAGE_UNDER_TEST:-*}/; do --old ${OLDPWD}/build/benchmark-results-old \ --threshold 1 --report-output-path="${OLDPWD}/build/benchreport" fi - # if [ "${package_to_test}" == "system_benchmark" ]; then - # run_elastic_package_command benchmark system --benchmark logs-benchmark -v - # fi + if [ "${PACKAGE_UNDER_TEST:-*}" == "system_benchmark" ]; then + 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 run_elastic_package_command test -v --report-format xUnit --report-output file --defer-cleanup 1s --test-coverage From 0bdf2e47f82661c02eef6e1504865bbe591392f0 Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Thu, 29 Jun 2023 14:37:10 +0200 Subject: [PATCH 40/40] Remove debug command --- scripts/test-check-packages.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/test-check-packages.sh b/scripts/test-check-packages.sh index 4b052b9b1..42a3e74f0 100755 --- a/scripts/test-check-packages.sh +++ b/scripts/test-check-packages.sh @@ -83,8 +83,6 @@ fi # Run package tests eval "$(elastic-package stack shellinit)" -run_elastic_package_command stack status -v -d --version 8.9.9 - for d in test/packages/${PACKAGE_TEST_TYPE:-other}/${PACKAGE_UNDER_TEST:-*}/; do ( cd $d