Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

feat: support using Beats CI snapshots #205

Merged
merged 17 commits into from
Jul 30, 2020

Conversation

mdelapenya
Copy link
Contributor

@mdelapenya mdelapenya commented Jul 28, 2020

What does this PR do?

It supports downloading the elastic-agent binaries from the Google Cloud Storage bucket used by Beats CI on every merge-to-master. For that, as the objects in the bucket are not public, we are listing bucket's contents, looking for a match for the agent we want to use in tests.

To enable this feature, set the ELASTIC_AGENT_USE_CI_SNAPSHOTS environment variable to true, and the tests will not fetch the binaries from the default location.

Besides, we are using the Docker image for all Elastic components from Elastic's docker registry, using the observability-ci namespace. This namespace contains snapshots from each merge-to-master, and all PRs for Beats.

To enable this feature, set the ELASTIC_AGENT_STAND_ALONE_VERSION environment variable to a valid and puushed tag i.e. 78a762c76080aafa34c52386341b590dac24e2df or eventually pr-20323, and the tests will not fetch the default image (8.0.0-SNAPSHOT).

Finally, we are arranging the existing env vars into a different name convention, prefixing them with the test suite that the var belongs to, removing the OP_ prefix when needed.

Why is it important?

The release process for the binaries is not as reliable as we need, as it could take days until we have a new snapshot, blocking this test suite. For that reason we want to support a way to switch to another location if the official binaries are not working or does not contain latest code or fixes.

About the small refactors, consistent names that are easy to read are names easy to understand, that's the motivation for that change.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have run the Unit tests for the CLI, and they are passing locally
  • I have run the End-2-End tests for the suite I'm working on, and they are passing locally
  • I have noticed new Go dependencies (run make notice in the proper directory)

Author's Checklist

  • Executed e2e tests with and without the new variable
  • Verified that refactored code keeps existing behavior

How to test this PR locally

Using the latest snapshot

$ cd e2e/_suites/ingest-manager
$ OP_LOG_LEVEL=DEBUG ELASTIC_AGENT_USE_CI_SNAPSHOTS=true godog -t "fleet_mode && unenroll"

You should see something similar to these log entries, related to Google Cloud Storage APIs:

DEBU[0088] Google Cloud Storage API is available bucket=beats-ci-artifacts elapsedTime=1.529925991s object=elastic-agent-8.0.0-SNAPSHOT-linux-x86_64.tar.gz retries=1 statusEndpoint="https://storage.googleapis.com/storage/v1/b/beats-ci-artifacts/o"
DEBU[0088] Downloading file path="/var/folders/wn/zl67dnhn27s0jkdlgw4bbts40000gn/T/snapshots%2Felastic-agent-8.0.0-SNAPSHOT-linux-x86_64.tar.gz?generation=1594737904872374&alt=media569500323" url="https://storage.googleapis.com/download/storage/v1/b/beats-ci-artifacts/o/snapshots%2Felastic-agent-8.0.0-SNAPSHOT-linux-x86_64.tar.gz?generation=1594737904872374&alt=media"
DEBU[0088] File downloaded elapsedTime=752.260024ms path="/var/folders/wn/zl67dnhn27s0jkdlgw4bbts40000gn/T/snapshots%2Felastic-agent-8.0.0-SNAPSHOT-linux-x86_64.tar.gz?generation=1594737904872374&alt=media569500323" retries=1 url="https://storage.googleapis.com/download/storage/v1/b/beats-ci-artifacts/o/snapshots%2Felastic-agent-8.0.0-SNAPSHOT-linux-x86_64.tar.gz?generation=1594737904872374&alt=media"

On the other hand, if not setting that variable, or setting to something not true:

$ cd e2e/_suites/ingest-manager
$ OP_LOG_LEVEL=DEBUG godog -t "fleet_mode && unenroll"

You should see something similar to these logs entries, related to the official artifacts endpoint:

DEBU[0088] The Elastic artifacts API is available elapsedTime=784.608597ms retries=1 statusEndpoint="https://artifacts-api.elastic.co/v1/search/8.0.0-SNAPSHOT/elastic-agent"
DEBU[0088] Downloading file path=/var/folders/wn/zl67dnhn27s0jkdlgw4bbts40000gn/T/elastic-agent-8.0.0-SNAPSHOT-linux-x86_64.tar.gz697951930 url="https://snapshots.elastic.co/8.0.0-f762d16e/downloads/beats/elastic-agent/elastic-agent-8.0.0-SNAPSHOT-linux-x86_64.tar.gz"

Stand-alone mode: using another Docker tag

$ cd e2e/_suites/ingest-manager
$ OP_LOG_LEVEL=DEBUG ELASTIC_AGENT_STAND_ALONE_VERSION=78a762c76080aafa34c52386341b590dac24e2df godog -t "deploy-stand-alone"

You should see something similar to these logs entries, related to the docker-compose pull command fetching the tag you selected:

Pulling elastic-agent (docker.elastic.co/observability-ci/elastic-agent:78a762c76080aafa34c52386341b590dac24e2df)...

Related issues

Follow-ups

An interesting follow-up will be consuming the snapshot for a PR, instead of the merge-to-master snapshot. See elastic/beats#20274 and elastic/beats#20323 for related work on Beats side.

@mdelapenya mdelapenya self-assigned this Jul 28, 2020
@mdelapenya mdelapenya requested review from a team and EricDavisX July 28, 2020 22:34
@elasticmachine
Copy link
Contributor

elasticmachine commented Jul 28, 2020

💔 Tests Failed

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #205 updated]

  • Start Time: 2020-07-29T19:31:39.233+0000

  • Duration: 19 min 23 sec

Test stats 🧪

Test Results
Failed 1
Passed 56
Skipped 10
Total 67

Test errors

Expand to view the tests failures

  • Name: Initializing / Pre-Submit / Sanity checks / golangcilint – pre_commit.lint

    • Age: 1
    • Duration: 0
    • Error Details: error

Steps errors

Expand to view the steps failures

  • Name: Docker login

    • Description:

    • Duration: 0 min 27 sec

    • Start Time: 2020-07-29T19:37:06.253+0000

    • log

  • Name: Docker login

    • Description:

    • Duration: 0 min 27 sec

    • Start Time: 2020-07-29T19:37:06.105+0000

    • log

  • Name: Docker login

    • Description:

    • Duration: 0 min 22 sec

    • Start Time: 2020-07-29T19:37:09.929+0000

    • log

Log output

Expand to view the last 100 lines of log output

[2020-07-29T19:46:55.498Z] 
Creating metricbeat_mysql_1 ... done
Found orphan containers (metricbeat_mysql_1) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
[2020-07-29T19:46:55.498Z] metricbeat_elasticsearch_1 is up-to-date
[2020-07-29T19:46:55.498Z] Creating metricbeat_metricbeat_1 ... 
[2020-07-29T19:46:55.498Z] 
Creating metricbeat_metricbeat_1 ... done
time="2020-07-29T19:46:54Z" level=info msg="Metricbeat is running configured for the service" metricbeatVersion=7.8.0 service=mysql serviceVersion=8.0.13 variant=MySQL
[2020-07-29T19:47:17.471Z] time="2020-07-29T19:47:14Z" level=warning msg="Waiting for more hits in the index" currentHits=2 desiredHits=5 elapsedTime=28.775027ms index=metricbeat-7.8.0-mysql-mysql-8.0.13-qm50hmvz retry=1
[2020-07-29T19:47:17.471Z] time="2020-07-29T19:47:15Z" level=warning msg="Waiting for more hits in the index" currentHits=2 desiredHits=5 elapsedTime=428.441425ms index=metricbeat-7.8.0-mysql-mysql-8.0.13-qm50hmvz retry=2
[2020-07-29T19:47:17.471Z] time="2020-07-29T19:47:16Z" level=warning msg="Waiting for more hits in the index" currentHits=2 desiredHits=5 elapsedTime=1.724099223s index=metricbeat-7.8.0-mysql-mysql-8.0.13-qm50hmvz retry=3
[2020-07-29T19:47:18.452Z] time="2020-07-29T19:47:18Z" level=warning msg="Waiting for more hits in the index" currentHits=3 desiredHits=5 elapsedTime=3.454581143s index=metricbeat-7.8.0-mysql-mysql-8.0.13-qm50hmvz retry=4
[2020-07-29T19:47:25.041Z] time="2020-07-29T19:47:23Z" level=warning msg="Waiting for more hits in the index" currentHits=3 desiredHits=5 elapsedTime=8.984509958s index=metricbeat-7.8.0-mysql-mysql-8.0.13-qm50hmvz retry=5
[2020-07-29T19:47:28.345Z] time="2020-07-29T19:47:27Z" level=warning msg="Waiting for more hits in the index" currentHits=3 desiredHits=5 elapsedTime=12.978145656s index=metricbeat-7.8.0-mysql-mysql-8.0.13-qm50hmvz retry=6
[2020-07-29T19:47:34.932Z] time="2020-07-29T19:47:34Z" level=warning msg="Waiting for more hits in the index" currentHits=4 desiredHits=5 elapsedTime=19.958079117s index=metricbeat-7.8.0-mysql-mysql-8.0.13-qm50hmvz retry=7
[2020-07-29T19:47:38.233Z] time="2020-07-29T19:47:37Z" level=warning msg="Waiting for more hits in the index" currentHits=4 desiredHits=5 elapsedTime=22.952850223s index=metricbeat-7.8.0-mysql-mysql-8.0.13-qm50hmvz retry=8
[2020-07-29T19:47:46.375Z] time="2020-07-29T19:47:45Z" level=info msg="Hits number satisfied" currentHits=5 desiredHits=5 elapsedTime=30.346397412s retries=9
[2020-07-29T19:47:46.375Z] time="2020-07-29T19:47:45Z" level=info msg="Hits number satisfied" currentHits=5 desiredHits=5 elapsedTime=6.22917ms retries=1
[2020-07-29T19:47:46.375Z] Stopping metricbeat_metricbeat_1 ... 
[2020-07-29T19:47:46.375Z] 
Stopping metricbeat_metricbeat_1 ... done
Removing metricbeat_metricbeat_1 ... 
[2020-07-29T19:47:46.375Z] 
Removing metricbeat_metricbeat_1 ... done
Going to remove metricbeat_metricbeat_1
[2020-07-29T19:47:46.948Z] Stopping metricbeat_mysql_1 ... 
[2020-07-29T19:47:49.492Z] 
Stopping metricbeat_mysql_1 ... done
Removing metricbeat_mysql_1 ... 
[2020-07-29T19:47:49.753Z] 
Removing metricbeat_mysql_1 ... done
Going to remove metricbeat_mysql_1
[2020-07-29T19:47:50.329Z] Pulling mysql (docker.elastic.co/integrations-ci/beats-mysql:percona-5.7.24-1)...
[2020-07-29T19:47:50.591Z] percona-5.7.24-1: Pulling from integrations-ci/beats-mysql
[2020-07-29T19:48:02.836Z] metricbeat_elasticsearch_1 is up-to-date
[2020-07-29T19:48:02.837Z] Creating metricbeat_mysql_1 ... 
[2020-07-29T19:48:25.747Z] 
Creating metricbeat_mysql_1 ... done
Found orphan containers (metricbeat_mysql_1) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
[2020-07-29T19:48:25.747Z] metricbeat_elasticsearch_1 is up-to-date
[2020-07-29T19:48:25.747Z] Creating metricbeat_metricbeat_1 ... 
[2020-07-29T19:48:25.747Z] 
Creating metricbeat_metricbeat_1 ... done
time="2020-07-29T19:48:25Z" level=info msg="Metricbeat is running configured for the service" metricbeatVersion=7.8.0 service=mysql serviceVersion=5.7.24 variant=Percona
[2020-07-29T19:48:47.733Z] time="2020-07-29T19:48:45Z" level=warning msg="Waiting for more hits in the index" currentHits=1 desiredHits=5 elapsedTime=8.793906ms index=metricbeat-7.8.0-mysql-percona-5.7.24-p4m2vzzm retry=1
[2020-07-29T19:48:47.734Z] time="2020-07-29T19:48:45Z" level=warning msg="Waiting for more hits in the index" currentHits=1 desiredHits=5 elapsedTime=301.684384ms index=metricbeat-7.8.0-mysql-percona-5.7.24-p4m2vzzm retry=2
[2020-07-29T19:48:47.734Z] time="2020-07-29T19:48:46Z" level=warning msg="Waiting for more hits in the index" currentHits=1 desiredHits=5 elapsedTime=1.030464755s index=metricbeat-7.8.0-mysql-percona-5.7.24-p4m2vzzm retry=3
[2020-07-29T19:48:48.691Z] time="2020-07-29T19:48:48Z" level=warning msg="Waiting for more hits in the index" currentHits=2 desiredHits=5 elapsedTime=3.401782868s index=metricbeat-7.8.0-mysql-percona-5.7.24-p4m2vzzm retry=4
[2020-07-29T19:48:52.032Z] time="2020-07-29T19:48:51Z" level=warning msg="Waiting for more hits in the index" currentHits=2 desiredHits=5 elapsedTime=6.375577893s index=metricbeat-7.8.0-mysql-percona-5.7.24-p4m2vzzm retry=5
[2020-07-29T19:48:56.236Z] time="2020-07-29T19:48:55Z" level=warning msg="Waiting for more hits in the index" currentHits=2 desiredHits=5 elapsedTime=10.440025581s index=metricbeat-7.8.0-mysql-percona-5.7.24-p4m2vzzm retry=6
[2020-07-29T19:49:02.827Z] time="2020-07-29T19:49:02Z" level=warning msg="Waiting for more hits in the index" currentHits=3 desiredHits=5 elapsedTime=17.613450002s index=metricbeat-7.8.0-mysql-percona-5.7.24-p4m2vzzm retry=7
[2020-07-29T19:49:09.415Z] time="2020-07-29T19:49:08Z" level=warning msg="Waiting for more hits in the index" currentHits=4 desiredHits=5 elapsedTime=23.830566633s index=metricbeat-7.8.0-mysql-percona-5.7.24-p4m2vzzm retry=8
[2020-07-29T19:49:16.016Z] time="2020-07-29T19:49:15Z" level=warning msg="Waiting for more hits in the index" currentHits=4 desiredHits=5 elapsedTime=30.344159901s index=metricbeat-7.8.0-mysql-percona-5.7.24-p4m2vzzm retry=9
[2020-07-29T19:49:22.620Z] time="2020-07-29T19:49:21Z" level=info msg="Hits number satisfied" currentHits=5 desiredHits=5 elapsedTime=36.506723103s retries=10
[2020-07-29T19:49:22.620Z] time="2020-07-29T19:49:21Z" level=info msg="Hits number satisfied" currentHits=5 desiredHits=5 elapsedTime=6.343769ms retries=1
[2020-07-29T19:49:22.620Z] Stopping metricbeat_metricbeat_1 ... 
[2020-07-29T19:49:22.620Z] 
Stopping metricbeat_metricbeat_1 ... done
Removing metricbeat_metricbeat_1 ... 
[2020-07-29T19:49:22.883Z] 
Removing metricbeat_metricbeat_1 ... done
Going to remove metricbeat_metricbeat_1
[2020-07-29T19:49:23.459Z] Stopping metricbeat_mysql_1 ... 
[2020-07-29T19:49:26.036Z] 
Stopping metricbeat_mysql_1 ... done
Removing metricbeat_mysql_1 ... 
[2020-07-29T19:49:26.308Z] 
Removing metricbeat_mysql_1 ... done
Going to remove metricbeat_mysql_1
[2020-07-29T19:49:26.885Z] Pulling mysql (docker.elastic.co/integrations-ci/beats-mysql:percona-8.0.13-4-1)...
[2020-07-29T19:49:27.202Z] percona-8.0.13-4-1: Pulling from integrations-ci/beats-mysql
[2020-07-29T19:49:42.131Z] metricbeat_elasticsearch_1 is up-to-date
[2020-07-29T19:49:42.131Z] Creating metricbeat_mysql_1 ... 
[2020-07-29T19:50:08.390Z] 
Creating metricbeat_mysql_1 ... done
Found orphan containers (metricbeat_mysql_1) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
[2020-07-29T19:50:08.390Z] metricbeat_elasticsearch_1 is up-to-date
[2020-07-29T19:50:08.390Z] Creating metricbeat_metricbeat_1 ... 
[2020-07-29T19:50:08.390Z] 
Creating metricbeat_metricbeat_1 ... done
time="2020-07-29T19:50:07Z" level=info msg="Metricbeat is running configured for the service" metricbeatVersion=7.8.0 service=mysql serviceVersion=8.0.13-4 variant=Percona
[2020-07-29T19:50:30.354Z] time="2020-07-29T19:50:27Z" level=warning msg="Waiting for more hits in the index" currentHits=2 desiredHits=5 elapsedTime=10.396951ms index=metricbeat-7.8.0-mysql-percona-8.0.13-4-8hhwyzf5 retry=1
[2020-07-29T19:50:30.354Z] time="2020-07-29T19:50:27Z" level=warning msg="Waiting for more hits in the index" currentHits=2 desiredHits=5 elapsedTime=359.050975ms index=metricbeat-7.8.0-mysql-percona-8.0.13-4-8hhwyzf5 retry=2
[2020-07-29T19:50:30.354Z] time="2020-07-29T19:50:28Z" level=warning msg="Waiting for more hits in the index" currentHits=2 desiredHits=5 elapsedTime=1.294085078s index=metricbeat-7.8.0-mysql-percona-8.0.13-4-8hhwyzf5 retry=3
[2020-07-29T19:50:31.308Z] time="2020-07-29T19:50:31Z" level=warning msg="Waiting for more hits in the index" currentHits=2 desiredHits=5 elapsedTime=4.095059545s index=metricbeat-7.8.0-mysql-percona-8.0.13-4-8hhwyzf5 retry=4
[2020-07-29T19:50:36.599Z] time="2020-07-29T19:50:36Z" level=warning msg="Waiting for more hits in the index" currentHits=3 desiredHits=5 elapsedTime=8.83256491s index=metricbeat-7.8.0-mysql-percona-8.0.13-4-8hhwyzf5 retry=5
[2020-07-29T19:50:44.736Z] time="2020-07-29T19:50:43Z" level=warning msg="Waiting for more hits in the index" currentHits=4 desiredHits=5 elapsedTime=16.23504272s index=metricbeat-7.8.0-mysql-percona-8.0.13-4-8hhwyzf5 retry=6
[2020-07-29T19:50:51.321Z] time="2020-07-29T19:50:50Z" level=warning msg="Waiting for more hits in the index" currentHits=4 desiredHits=5 elapsedTime=23.353691015s index=metricbeat-7.8.0-mysql-percona-8.0.13-4-8hhwyzf5 retry=7
[2020-07-29T19:50:53.871Z] time="2020-07-29T19:50:53Z" level=info msg="Hits number satisfied" currentHits=5 desiredHits=5 elapsedTime=26.316277161s retries=8
[2020-07-29T19:50:53.871Z] time="2020-07-29T19:50:53Z" level=info msg="Hits number satisfied" currentHits=5 desiredHits=5 elapsedTime=4.89864ms retries=1
[2020-07-29T19:50:54.132Z] Stopping metricbeat_metricbeat_1 ... 
[2020-07-29T19:50:54.705Z] 
Stopping metricbeat_metricbeat_1 ... done
Removing metricbeat_metricbeat_1 ... 
[2020-07-29T19:50:54.705Z] 
Removing metricbeat_metricbeat_1 ... done
Going to remove metricbeat_metricbeat_1
[2020-07-29T19:50:55.278Z] Stopping metricbeat_mysql_1 ... 
[2020-07-29T19:50:57.830Z] 
Stopping metricbeat_mysql_1 ... done
Removing metricbeat_mysql_1 ... 
[2020-07-29T19:50:57.830Z] 
Removing metricbeat_mysql_1 ... done
Going to remove metricbeat_mysql_1
[2020-07-29T19:50:58.092Z] Stopping metricbeat_elasticsearch_1 ... 
[2020-07-29T19:50:59.484Z] 
Stopping metricbeat_elasticsearch_1 ... done
Removing metricbeat_elasticsearch_1 ... 
[2020-07-29T19:50:59.484Z] 
Removing metricbeat_elasticsearch_1 ... done
Removing network metricbeat_default
[2020-07-29T19:50:59.484Z] <?xml version="1.0" encoding="UTF-8"?>
[2020-07-29T19:50:59.484Z] <testsuites name="main" tests="7" skipped="0" failures="0" errors="0" time="686.94283755">
[2020-07-29T19:50:59.484Z]   <testsuite name="As a Metricbeat developer I want to check that default configuration works as expected" tests="0" skipped="0" failures="0" errors="0" time="0"></testsuite>
[2020-07-29T19:50:59.484Z]   <testsuite name="As a Metricbeat developer I want to check that the Apache module works as expected" tests="0" skipped="0" failures="0" errors="0" time="0"></testsuite>
[2020-07-29T19:50:59.484Z]   <testsuite name="As a Metricbeat developer I want to check that the MySQL module works as expected" tests="7" skipped="0" failures="0" errors="0" time="637.902837796">
[2020-07-29T19:50:59.484Z]     <testcase name="Check MariaDB-10.2.23 is sending metrics to Elasticsearch without errors" status="passed" time="93.980929387"></testcase>
[2020-07-29T19:50:59.484Z]     <testcase name="Check MariaDB-10.3.14 is sending metrics to Elasticsearch without errors" status="passed" time="81.851072385"></testcase>
[2020-07-29T19:50:59.484Z]     <testcase name="Check MariaDB-10.4.4 is sending metrics to Elasticsearch without errors" status="passed" time="87.433151731"></testcase>
[2020-07-29T19:50:59.484Z]     <testcase name="Check MySQL-5.7.12 is sending metrics to Elasticsearch without errors" status="passed" time="86.972785022"></testcase>
[2020-07-29T19:50:59.484Z]     <testcase name="Check MySQL-8.0.13 is sending metrics to Elasticsearch without errors" status="passed" time="85.683739696"></testcase>
[2020-07-29T19:50:59.484Z]     <testcase name="Check Percona-5.7.24 is sending metrics to Elasticsearch without errors" status="passed" time="92.071033684"></testcase>
[2020-07-29T19:50:59.484Z]     <testcase name="Check Percona-8.0.13-4 is sending metrics to Elasticsearch without errors" status="passed" time="87.352587448"></testcase>
[2020-07-29T19:50:59.484Z]   </testsuite>
[2020-07-29T19:50:59.484Z]   <testsuite name="As a Metricbeat developer I want to check that the Redis module works as expected" tests="0" skipped="0" failures="0" errors="0" time="0"></testsuite>
[2020-07-29T19:50:59.484Z]   <testsuite name="As a Metricbeat developer I want to check that the vSphere module works as expected" tests="0" skipped="0" failures="0" errors="0" time="0"></testsuite>
[2020-07-29T19:50:59.484Z] </testsuites>+ sed -e 's/^[ \t]*//; s#>.*failed$#>#g' outputs/TEST-metricbeat-mysql
[2020-07-29T19:50:59.484Z] + grep -E '^<.*>$'
[2020-07-29T19:50:59.484Z] + exit 0
[2020-07-29T19:50:59.533Z] Recording test results
[2020-07-29T19:51:00.006Z] Archiving artifacts
[2020-07-29T19:51:01.321Z] Stage "Release" skipped due to when conditional
[2020-07-29T19:51:01.563Z] Running on worker-395930 in /var/lib/jenkins/workspace/e2e-tests_e2e-testing-mbp_PR-205
[2020-07-29T19:51:01.596Z] [INFO] getVaultSecret: Getting secrets
[2020-07-29T19:51:01.655Z] Masking supported pattern matches of $VAULT_ADDR or $VAULT_ROLE_ID or $VAULT_SECRET_ID
[2020-07-29T19:51:04.008Z] + chmod 755 generate-build-data.sh
[2020-07-29T19:51:04.009Z] + ./generate-build-data.sh https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/e2e-tests/e2e-testing-mbp/PR-205/ https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/e2e-tests/e2e-testing-mbp/PR-205/runs/13 UNSTABLE 1163020
[2020-07-29T19:51:04.009Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/e2e-tests/e2e-testing-mbp/PR-205/runs/13/steps/?limit=10000 -o steps-info.json
[2020-07-29T19:51:04.711Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/e2e-tests/e2e-testing-mbp/PR-205/runs/13/tests/?status=FAILED -o tests-errors.json
[2020-07-29T19:51:05.410Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/e2e-tests/e2e-testing-mbp/PR-205/runs/13/log/ -o pipeline-log.txt

func GetEnvBool(key string) bool {
s := os.Getenv(key)
if s == "" {
return false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kind of wonder if this should return something else here instead of false. (Perhaps nil?) It seems like this behavior might introduce hard-to-handle error conditions, where a value is incorrectly interpreted as being truly false instead of an error in processing the lookup itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmmm, I see your point: so if the env var is not present, then do not consider it as false... In this particular use case, we are going to check for true, only. If true, then execute the proper code, otherwise use default. But it could be the case that we use this function again checking for false, and if the var is not present, it will satisfy the condition

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think returning (bool, error) will do the trick, although we'll have to handle errors on the consume side.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added your suggestion in 3881a99, including unit tests for verification.

e2e/utils.go Outdated Show resolved Hide resolved
@mdelapenya mdelapenya marked this pull request as ready for review July 29, 2020 07:39
@mdelapenya
Copy link
Contributor Author

@EricDavisX with these changes now we will be able to run tests with the artifacts for a PR :)

@mdelapenya mdelapenya merged commit 64c10e0 into elastic:master Jul 30, 2020
@mdelapenya mdelapenya deleted the 204-use-beats-ci-snapshots branch July 31, 2020 11:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move from release artifacts to those generated by the packaging job in Beats
5 participants