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

fix: use the status of the agent by hostname #181

Merged
merged 5 commits into from
Jul 20, 2020

Conversation

mdelapenya
Copy link
Contributor

What is this PR doing?

It uses the hostname to get the status of the agent, because the hostname value is used as agentID. That way we are able to look up the status of the agent in the response of the API call, which returns a JSON with the list of agents including their active status.

We also revoke/remove the token that is created for the enrollment process (we create it on each scenario)

Why is it important?

It moves from a testing approach that is based in the existence of only one agent, to an approach that is based in the status of a specific agent (identified by hostname). We need this change because the API should be able to unenroll/remove an agent whenever the container representing it is removed (docker-compose down), and this is not currently happening.

Related issues

@mdelapenya mdelapenya self-assigned this Jul 20, 2020
@mdelapenya mdelapenya requested review from a team, EricDavisX and michalpristas July 20, 2020 21:49
@elasticmachine
Copy link
Contributor

elasticmachine commented Jul 20, 2020

💔 Tests Failed

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #181 updated]

  • Start Time: 2020-07-20T21:55:01.455+0000

  • Duration: 21 min 49 sec

Test stats 🧪

Test Results
Failed 1
Passed 55
Skipped 10
Total 66

Test errors

Expand to view the tests failures

  • Name: Initializing / Tests / Sanity checks / golangcilint – pre_commit.lint

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

Log output

Expand to view the last 100 lines of log output

[2020-07-20T22:13:35.216Z] time="2020-07-20T22:13:35Z" level=error msg="Could not enroll the agent with the token" command="[elastic-agent enroll http://kibana:5601 RS1KSmJuTUJaNU52d1NmY3RUZFY6ampxRTBjRGZSLTJwNGpGWV9GN3hKQQ== -f --insecure]" error="Could not run compose file: [/var/lib/jenkins/workspace/e2e-tests_e2e-testing-mbp_PR-181/.op/compose/profiles/ingest-manager/docker-compose.yml /var/lib/jenkins/workspace/e2e-tests_e2e-testing-mbp_PR-181/.op/compose/services/centos/docker-compose.yml] - Local Docker compose exited abnormally whilst running docker-compose: [exec -T centos elastic-agent enroll http://kibana:5601 RS1KSmJuTUJaNU52d1NmY3RUZFY6ampxRTBjRGZSLTJwNGpGWV9GN3hKQQ== -f --insecure]. exit status 2" service=centos tag=7 token="RS1KSmJuTUJaNU52d1NmY3RUZFY6ampxRTBjRGZSLTJwNGpGWV9GN3hKQQ=="
[2020-07-20T22:13:35.761Z] time="2020-07-20T22:13:33Z" level=warning msg="Waiting for more hits in the index" currentHits=2 desiredHits=5 elapsedTime=8.110432ms index=metricbeat-7.8.0-mysql-percona-5.7.24-wec28p2w retry=1
[2020-07-20T22:13:35.762Z] time="2020-07-20T22:13:33Z" level=warning msg="Waiting for more hits in the index" currentHits=2 desiredHits=5 elapsedTime=714.032733ms index=metricbeat-7.8.0-mysql-percona-5.7.24-wec28p2w retry=2
[2020-07-20T22:13:35.762Z] time="2020-07-20T22:13:34Z" level=warning msg="Waiting for more hits in the index" currentHits=2 desiredHits=5 elapsedTime=1.317265234s index=metricbeat-7.8.0-mysql-percona-5.7.24-wec28p2w retry=3
[2020-07-20T22:13:36.157Z] Stopping ingest-manager_centos_2 ... 
[2020-07-20T22:13:37.671Z] time="2020-07-20T22:13:37Z" level=warning msg="Waiting for more hits in the index" currentHits=2 desiredHits=5 elapsedTime=4.277512053s index=metricbeat-7.8.0-mysql-percona-5.7.24-wec28p2w retry=4
[2020-07-20T22:13:40.215Z] time="2020-07-20T22:13:39Z" level=warning msg="Waiting for more hits in the index" currentHits=2 desiredHits=5 elapsedTime=6.580551994s index=metricbeat-7.8.0-mysql-percona-5.7.24-wec28p2w retry=5
[2020-07-20T22:13:43.513Z] time="2020-07-20T22:13:43Z" level=warning msg="Waiting for more hits in the index" currentHits=3 desiredHits=5 elapsedTime=10.203647865s index=metricbeat-7.8.0-mysql-percona-5.7.24-wec28p2w retry=6
[2020-07-20T22:13:48.394Z] 
Stopping ingest-manager_centos_2 ... done
Removing ingest-manager_centos_2 ... 
[2020-07-20T22:13:48.394Z] 
Removing ingest-manager_centos_2 ... done
Going to remove ingest-manager_centos_2
[2020-07-20T22:13:49.338Z] Stopping ingest-manager_kibana_1           ... 
[2020-07-20T22:13:49.338Z] Stopping ingest-manager_elasticsearch_1    ... 
[2020-07-20T22:13:49.338Z] Stopping ingest-manager_package-registry_1 ... 
[2020-07-20T22:13:50.091Z] time="2020-07-20T22:13:49Z" level=warning msg="Waiting for more hits in the index" currentHits=3 desiredHits=5 elapsedTime=16.115488552s index=metricbeat-7.8.0-mysql-percona-5.7.24-wec28p2w retry=7
[2020-07-20T22:13:53.386Z] time="2020-07-20T22:13:53Z" level=warning msg="Waiting for more hits in the index" currentHits=4 desiredHits=5 elapsedTime=19.829731843s index=metricbeat-7.8.0-mysql-percona-5.7.24-wec28p2w retry=8
[2020-07-20T22:13:54.387Z] 
Stopping ingest-manager_kibana_1           ... done

Stopping ingest-manager_package-registry_1 ... done

Stopping ingest-manager_elasticsearch_1    ... done
Removing ingest-manager_kibana_1           ... 
[2020-07-20T22:13:54.387Z] Removing ingest-manager_elasticsearch_1    ... 
[2020-07-20T22:13:54.387Z] Removing ingest-manager_package-registry_1 ... 
[2020-07-20T22:13:54.648Z] 
Removing ingest-manager_package-registry_1 ... done

Removing ingest-manager_elasticsearch_1    ... done

Removing ingest-manager_kibana_1           ... done
Removing network ingest-manager_default
[2020-07-20T22:13:54.648Z] <?xml version="1.0" encoding="UTF-8"?>
[2020-07-20T22:13:54.648Z] <testsuites name="main" tests="6" skipped="0" failures="0" errors="0" time="583.361227273">
[2020-07-20T22:13:54.648Z]   <testsuite name="Fleet Mode Agent" tests="6" skipped="0" failures="0" errors="0" time="207.499757176">
[2020-07-20T22:13:54.648Z]     <testcase name="Deploying an agent" status="passed" time="36.779747154"></testcase>
[2020-07-20T22:13:54.648Z]     <testcase name="Starting the agent starts backend processes" status="passed" time="21.975291351"></testcase>
[2020-07-20T22:13:54.648Z]     <testcase name="Stopping the agent stops backend processes" status="passed" time="13.716011857"></testcase>
[2020-07-20T22:13:54.648Z]     <testcase name="Un-enrolling an agent" status="passed" time="14.631812758"></testcase>
[2020-07-20T22:13:54.648Z]     <testcase name="Re-enrolling an agent" status="passed" time="19.090152287"></testcase>
[2020-07-20T22:13:54.648Z]     <testcase name="Revoking the enrollment token for an agent" status="passed" time="30.21653515"></testcase>
[2020-07-20T22:13:54.648Z]   </testsuite>
[2020-07-20T22:13:54.648Z]   <testsuite name="Stand-alone Agent Mode" tests="0" skipped="0" failures="0" errors="0" time="0"></testsuite>
[2020-07-20T22:13:54.648Z] </testsuites>+ grep -E '^<.*>$'
[2020-07-20T22:13:54.648Z] + sed -e 's/^[ \t]*//; s#>.*failed$#>#g' outputs/TEST-ingest-manager-fleet_mode
[2020-07-20T22:13:54.648Z] + exit 0
[2020-07-20T22:13:54.682Z] Recording test results
[2020-07-20T22:13:55.151Z] Archiving artifacts
[2020-07-20T22:13:57.587Z] time="2020-07-20T22:13:57Z" level=warning msg="Waiting for more hits in the index" currentHits=4 desiredHits=5 elapsedTime=23.895961362s index=metricbeat-7.8.0-mysql-percona-5.7.24-wec28p2w retry=9
[2020-07-20T22:14:05.717Z] time="2020-07-20T22:14:04Z" level=info msg="Hits number satisfied" currentHits=5 desiredHits=5 elapsedTime=31.068441287s retries=10
[2020-07-20T22:14:05.718Z] time="2020-07-20T22:14:04Z" level=info msg="Hits number satisfied" currentHits=5 desiredHits=5 elapsedTime=5.000578ms retries=1
[2020-07-20T22:14:05.718Z] Stopping metricbeat_metricbeat_1 ... 
[2020-07-20T22:14:05.718Z] 
Stopping metricbeat_metricbeat_1 ... done
Removing metricbeat_metricbeat_1 ... 
[2020-07-20T22:14:05.718Z] 
Removing metricbeat_metricbeat_1 ... done
Going to remove metricbeat_metricbeat_1
[2020-07-20T22:14:05.977Z] Stopping metricbeat_mysql_1 ... 
[2020-07-20T22:14:09.278Z] 
Stopping metricbeat_mysql_1 ... done
Removing metricbeat_mysql_1 ... 
[2020-07-20T22:14:09.278Z] 
Removing metricbeat_mysql_1 ... done
Going to remove metricbeat_mysql_1
[2020-07-20T22:14:09.278Z] Pulling mysql (docker.elastic.co/integrations-ci/beats-mysql:percona-8.0.13-4-1)...
[2020-07-20T22:14:09.849Z] percona-8.0.13-4-1: Pulling from integrations-ci/beats-mysql
[2020-07-20T22:14:24.761Z] metricbeat_elasticsearch_1 is up-to-date
[2020-07-20T22:14:24.761Z] Creating metricbeat_mysql_1 ... 
[2020-07-20T22:14:50.034Z] 
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-20T22:14:50.034Z] metricbeat_elasticsearch_1 is up-to-date
[2020-07-20T22:14:50.034Z] Creating metricbeat_metricbeat_1 ... 
[2020-07-20T22:14:50.034Z] 
Creating metricbeat_metricbeat_1 ... done
time="2020-07-20T22:14:49Z" 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-20T22:15:11.994Z] time="2020-07-20T22:15:09Z" level=warning msg="Waiting for more hits in the index" currentHits=2 desiredHits=5 elapsedTime=8.681607ms index=metricbeat-7.8.0-mysql-percona-8.0.13-4-d1datfzy retry=1
[2020-07-20T22:15:11.994Z] time="2020-07-20T22:15:10Z" level=warning msg="Waiting for more hits in the index" currentHits=2 desiredHits=5 elapsedTime=635.276603ms index=metricbeat-7.8.0-mysql-percona-8.0.13-4-d1datfzy retry=2
[2020-07-20T22:15:11.994Z] time="2020-07-20T22:15:11Z" level=warning msg="Waiting for more hits in the index" currentHits=2 desiredHits=5 elapsedTime=1.942174447s index=metricbeat-7.8.0-mysql-percona-8.0.13-4-d1datfzy retry=3
[2020-07-20T22:15:13.909Z] time="2020-07-20T22:15:13Z" level=warning msg="Waiting for more hits in the index" currentHits=2 desiredHits=5 elapsedTime=4.408320805s index=metricbeat-7.8.0-mysql-percona-8.0.13-4-d1datfzy retry=4
[2020-07-20T22:15:17.217Z] time="2020-07-20T22:15:16Z" level=warning msg="Waiting for more hits in the index" currentHits=2 desiredHits=5 elapsedTime=7.146638291s index=metricbeat-7.8.0-mysql-percona-8.0.13-4-d1datfzy retry=5
[2020-07-20T22:15:21.428Z] time="2020-07-20T22:15:21Z" level=warning msg="Waiting for more hits in the index" currentHits=3 desiredHits=5 elapsedTime=11.798333401s index=metricbeat-7.8.0-mysql-percona-8.0.13-4-d1datfzy retry=6
[2020-07-20T22:15:29.561Z] time="2020-07-20T22:15:28Z" level=warning msg="Waiting for more hits in the index" currentHits=3 desiredHits=5 elapsedTime=18.789536313s index=metricbeat-7.8.0-mysql-percona-8.0.13-4-d1datfzy retry=7
[2020-07-20T22:15:34.845Z] time="2020-07-20T22:15:34Z" level=warning msg="Waiting for more hits in the index" currentHits=4 desiredHits=5 elapsedTime=24.709774631s index=metricbeat-7.8.0-mysql-percona-8.0.13-4-d1datfzy retry=8
[2020-07-20T22:15:42.987Z] time="2020-07-20T22:15:41Z" level=info msg="Hits number satisfied" currentHits=5 desiredHits=5 elapsedTime=32.111777931s retries=9
[2020-07-20T22:15:42.987Z] time="2020-07-20T22:15:41Z" level=info msg="Hits number satisfied" currentHits=5 desiredHits=5 elapsedTime=5.375276ms retries=1
[2020-07-20T22:15:42.987Z] Stopping metricbeat_metricbeat_1 ... 
[2020-07-20T22:15:42.987Z] 
Stopping metricbeat_metricbeat_1 ... done
Removing metricbeat_metricbeat_1 ... 
[2020-07-20T22:15:42.987Z] 
Removing metricbeat_metricbeat_1 ... done
Going to remove metricbeat_metricbeat_1
[2020-07-20T22:15:43.249Z] Stopping metricbeat_mysql_1 ... 
[2020-07-20T22:15:46.549Z] 
Stopping metricbeat_mysql_1 ... done
Removing metricbeat_mysql_1 ... 
[2020-07-20T22:15:46.549Z] 
Removing metricbeat_mysql_1 ... done
Going to remove metricbeat_mysql_1
[2020-07-20T22:15:47.121Z] Stopping metricbeat_elasticsearch_1 ... 
[2020-07-20T22:15:48.064Z] 
Stopping metricbeat_elasticsearch_1 ... done
Removing metricbeat_elasticsearch_1 ... 
[2020-07-20T22:15:48.064Z] 
Removing metricbeat_elasticsearch_1 ... done
Removing network metricbeat_default
[2020-07-20T22:15:48.064Z] <?xml version="1.0" encoding="UTF-8"?>
[2020-07-20T22:15:48.064Z] <testsuites name="main" tests="7" skipped="0" failures="0" errors="0" time="693.453222897">
[2020-07-20T22:15:48.064Z]   <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-20T22:15:48.064Z]   <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-20T22:15:48.064Z]   <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="646.89348055">
[2020-07-20T22:15:48.064Z]     <testcase name="Check MariaDB-10.2.23 is sending metrics to Elasticsearch without errors" status="passed" time="109.446395033"></testcase>
[2020-07-20T22:15:48.064Z]     <testcase name="Check MariaDB-10.3.14 is sending metrics to Elasticsearch without errors" status="passed" time="75.457167213"></testcase>
[2020-07-20T22:15:48.064Z]     <testcase name="Check MariaDB-10.4.4 is sending metrics to Elasticsearch without errors" status="passed" time="91.367261169"></testcase>
[2020-07-20T22:15:48.064Z]     <testcase name="Check MySQL-5.7.12 is sending metrics to Elasticsearch without errors" status="passed" time="83.702965054"></testcase>
[2020-07-20T22:15:48.064Z]     <testcase name="Check MySQL-8.0.13 is sending metrics to Elasticsearch without errors" status="passed" time="84.612660026"></testcase>
[2020-07-20T22:15:48.064Z]     <testcase name="Check Percona-5.7.24 is sending metrics to Elasticsearch without errors" status="passed" time="86.312134206"></testcase>
[2020-07-20T22:15:48.064Z]     <testcase name="Check Percona-8.0.13-4 is sending metrics to Elasticsearch without errors" status="passed" time="92.909452839"></testcase>
[2020-07-20T22:15:48.064Z]   </testsuite>
[2020-07-20T22:15:48.064Z]   <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-20T22:15:48.064Z]   <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-20T22:15:48.064Z] </testsuites>+ sed -e 's/^[ \t]*//; s#>.*failed$#>#g' outputs/TEST-metricbeat-mysql
[2020-07-20T22:15:48.064Z] + grep -E '^<.*>$'
[2020-07-20T22:15:48.064Z] + exit 0
[2020-07-20T22:15:48.095Z] Recording test results
[2020-07-20T22:15:48.555Z] Archiving artifacts
[2020-07-20T22:15:49.661Z] Stage "Release" skipped due to when conditional
[2020-07-20T22:15:50.189Z] Running on worker-395930 in /var/lib/jenkins/workspace/e2e-tests_e2e-testing-mbp_PR-181
[2020-07-20T22:15:50.220Z] [INFO] getVaultSecret: Getting secrets
[2020-07-20T22:15:50.282Z] Masking supported pattern matches of $VAULT_ADDR or $VAULT_ROLE_ID or $VAULT_SECRET_ID
[2020-07-20T22:15:52.549Z] + chmod 755 generate-build-data.sh
[2020-07-20T22:15:52.549Z] + ./generate-build-data.sh https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/e2e-tests/e2e-testing-mbp/PR-181/ https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/e2e-tests/e2e-testing-mbp/PR-181/runs/2 UNSTABLE 1249262
[2020-07-20T22:15:52.549Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/e2e-tests/e2e-testing-mbp/PR-181/runs/2/steps/?limit=10000 -o steps-info.json
[2020-07-20T22:15:53.260Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/e2e-tests/e2e-testing-mbp/PR-181/runs/2/tests/?status=FAILED -o tests-errors.json
[2020-07-20T22:15:53.969Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/e2e-tests/e2e-testing-mbp/PR-181/runs/2/log/ -o pipeline-log.txt

@mdelapenya mdelapenya marked this pull request as ready for review July 20, 2020 22:18
@mdelapenya
Copy link
Contributor Author

mdelapenya commented Jul 20, 2020

The failed tests complains about Go lint in a multi module project, so it's not related:

golangci-lint run e2e/_suites/ingest-manager/fleet.go
_suites/ingest-manager/fleet.go:22:24: undeclared name: `kibanaBaseURL` (typecheck)
const fleetAgentsURL = kibanaBaseURL + "/api/ingest_manager/fleet/agents"
                       ^
_suites/ingest-manager/fleet.go:593:9: undeclared name: `execCommandInService` (typecheck)
	err := execCommandInService(profile, serviceName, cmd, false)
	       ^
_suites/ingest-manager/fleet.go:535:2: undeclared name: `profileEnv` (typecheck)
	profileEnv[service+"Tag"] = serviceTag
	^
/var/lib/jenkins/workspace/e2e-tests_e2e-testing-mbp_PR-181/src/github.com/elastic/e2e-testing
golangci-lint run e2e/_suites/ingest-manager/ingest-manager_test.go
_suites/ingest-manager/ingest-manager_test.go:189:14: undeclared name: `FleetTestSuite` (typecheck)
	Fleet      *FleetTestSuite
	            ^
_suites/ingest-manager/ingest-manager_test.go:190:14: undeclared name: `StandAloneTestSuite` (typecheck)
	StandAlone *StandAloneTestSuite
	            ^
/var/lib/jenkins/workspace/e2e-tests_e2e-testing-mbp_PR-181/src/github.com/elastic/e2e-testing
Lint failed!golangci-lint run e2e/_suites/ingest-manager/fleet.go
_suites/ingest-manager/fleet.go:22:24: undeclared name: `kibanaBaseURL` (typecheck)
const fleetAgentsURL = kibanaBaseURL + "/api/ingest_manager/fleet/agents"
                       ^
_suites/ingest-manager/fleet.go:593:9: undeclared name: `execCommandInService` (typecheck)
	err := execCommandInService(profile, serviceName, cmd, false)
	       ^
_suites/ingest-manager/fleet.go:535:2: undeclared name: `profileEnv` (typecheck)
	profileEnv[service+"Tag"] = serviceTag
	^
/var/lib/jenkins/workspace/e2e-tests_e2e-testing-mbp_PR-181/src/github.com/elastic/e2e-testing
golangci-lint run e2e/_suites/ingest-manager/ingest-manager_test.go
_suites/ingest-manager/ingest-manager_test.go:189:14: undeclared name: `FleetTestSuite` (typecheck)
	Fleet      *FleetTestSuite
	            ^
_suites/ingest-manager/ingest-manager_test.go:190:14: undeclared name: `StandAloneTestSuite` (typecheck)
	StandAlone *StandAloneTestSuite
	            ^
/var/lib/jenkins/workspace/e2e-tests_e2e-testing-mbp_PR-181/src/github.com/elastic/e2e-testing
Lint failed!

@mdelapenya
Copy link
Contributor Author

Merging, as the tests for fleet are now green!

image

@mdelapenya mdelapenya merged commit a457007 into elastic:master Jul 20, 2020
@mdelapenya mdelapenya deleted the remove-token branch July 20, 2020 22:34
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.

2 participants