Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

systemtest: test apm-server in Fleet mode #4650

Merged
merged 15 commits into from
Feb 3, 2021

Conversation

axw
Copy link
Member

@axw axw commented Jan 25, 2021

Motivation/summary

Add a system test that runs Elastic Agent in Fleet mode, with a locally built APM Server binary injected into the container. The test adds the "apm" integration package to a new agent policy, waits for elastic-agent to start apm-server, and verifies it is functional.

We run a custom package registry into which the "apm" integration package is bind-mounted from the tree, enabling us to test with unreleased package changes.

For the time being we must also inject a custom built elastic-agent binary to disable PGP verification of the apm-server artifact. Once we bundle the apm-server artifact with Elastic Agent we can stop doing this.

How to test these changes

cd systemtest && go test -run Fleet

Related issues

None.

@apmmachine
Copy link
Contributor

apmmachine commented Jan 25, 2021

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: Pull request #4650 updated

    • Start Time: 2021-02-03T05:03:31.616+0000
  • Duration: 36 min 35 sec

  • Commit: 638dddd

Test stats 🧪

Test Results
Failed 0
Passed 4361
Skipped 123
Total 4484

Steps errors 4

Expand to view the steps failures

Run Window tests
  • Took 11 min 7 sec . View more details on here
Compress
  • Took 0 min 0 sec . View more details on here
  • Description: tar --exclude=coverage-files.tgz -czf coverage-files.tgz coverage
Compress
  • Took 0 min 0 sec . View more details on here
  • Description: tar --exclude=system-tests-linux-files.tgz -czf system-tests-linux-files.tgz system-tests
Test Sync
  • Took 4 min 46 sec . View more details on here
  • Description: ./.ci/scripts/sync.sh

@codecov-io
Copy link

codecov-io commented Jan 25, 2021

Codecov Report

Merging #4650 (07512e3) into master (62f3ed6) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master    #4650   +/-   ##
=======================================
  Coverage   76.16%   76.16%           
=======================================
  Files         161      161           
  Lines        9873     9873           
=======================================
  Hits         7520     7520           
  Misses       2353     2353           

axw added 2 commits January 27, 2021 12:12
We run a custom package registry into which
the "apm" integration package is bind-mounted
from the tree, enabling us to test with
unreleased package changes.

Add a system test that runs Elastic Agent in
Fleet mode, with a locally built APM Server
binary injected into the container. The test
adds the "apm" integration package to a new
agent policy, waits for elastic-agent to start
apm-server, and verifies it is functional.

For the time being we must also inject a custom
built elastic-agent binary to disable PGP verification
of the apm-server artifact. Once we bundle the
apm-server artifact with Elastic Agent we can
stop doing this.
@axw axw force-pushed the systemtest-elasticagent branch from 33b10ac to 82f9b31 Compare January 27, 2021 04:12
@axw axw marked this pull request as ready for review January 27, 2021 05:17
@axw axw requested a review from a team January 27, 2021 05:17
Copy link
Contributor

@jalvz jalvz left a comment

Choose a reason for hiding this comment

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

Tests are failing for me, any idea?

Waiting for container id 133773e9632f image: docker.elastic.co/beats/elastic-agent:8.0.0-SNAPSHOT
--- FAIL: TestFleetIntegration (80.85s)
    fleet_test.go:133:
        	Error Trace:	fleet_test.go:133
        	Error:      	Received unexpected error:
        	            	context deadline exceeded
        	            	failed to start container
        	            	github.com/testcontainers/testcontainers-go.GenericContainer
        	            		~/.gvm/pkgsets/go1.15/global/pkg/mod/github.com/testcontainers/[email protected]/generic.go:50
        	            	github.com/elastic/apm-server/systemtest.(*ElasticAgentContainer).Start
        	            		~/apm-server/systemtest/containers.go:407
        	            	github.com/elastic/apm-server/systemtest_test.TestFleetIntegration
        	            		~/apm-server/systemtest/fleet_test.go:133
        	            	testing.tRunner
        	            		~/.gvm/gos/go1.15/src/testing/testing.go:1108
        	            	runtime.goexit
        	            		~/.gvm/gos/go1.15/src/runtime/asm_amd64.s:1374
        	Test:       	TestFleetIntegration
FAIL
exit status 1
FAIL	github.com/elastic/apm-server/systemtest	82.224s

systemtest/containers.go Outdated Show resolved Hide resolved
systemtest/apmservertest/config.go Outdated Show resolved Hide resolved
- Don't create archive in downloads (APM Server is bundled)
- DefaultKibanaPort -> KibanaPort
@axw
Copy link
Member Author

axw commented Feb 1, 2021

Tests are failing for me, any idea?

Nope, I'm not seeing any errors here. Pull latest Docker images? Otherwise check the agent logs in the ephemeral Docker container.

Close Tracer when test ends
@axw
Copy link
Member Author

axw commented Feb 2, 2021

CI is seeing that error now though 🤔
I'll keep trying to reproduce it here.

Specify the API Key that the agent should use
to enroll with Fleet, rather than supplying the
Kibana username and password for it to query for
a token. Using the latter approach, the agent
could end up enrolling with an unrelated policy.
@axw
Copy link
Member Author

axw commented Feb 2, 2021

@jalvz I can't be sure that it's the same issue that tripped you and CI up, but I realised that the test never explicitly told the agent to run the policy created. It just worked by accident, when the agent started up and found the right enrollment token. I've reworked the test to specify the enrollment token to use. PTAL

@axw axw requested a review from jalvz February 2, 2021 04:15
systemtest/fleet_test.go Outdated Show resolved Hide resolved
@axw axw merged commit 77c43d6 into elastic:master Feb 3, 2021
@axw axw deleted the systemtest-elasticagent branch February 3, 2021 05:47
axw added a commit to axw/apm-server that referenced this pull request Feb 18, 2021
* systemtest: test apm-server in Fleet mode

We run a custom package registry into which
the "apm" integration package is bind-mounted
from the tree, enabling us to test with
unreleased package changes.

Add a system test that runs Elastic Agent in
Fleet mode, with a locally built APM Server
binary injected into the container. The test
adds the "apm" integration package to a new
agent policy, waits for elastic-agent to start
apm-server, and verifies it is functional.
axw added a commit to axw/apm-server that referenced this pull request Feb 19, 2021
* systemtest: test apm-server in Fleet mode

We run a custom package registry into which
the "apm" integration package is bind-mounted
from the tree, enabling us to test with
unreleased package changes.

Add a system test that runs Elastic Agent in
Fleet mode, with a locally built APM Server
binary injected into the container. The test
adds the "apm" integration package to a new
agent policy, waits for elastic-agent to start
apm-server, and verifies it is functional.
axw added a commit to axw/apm-server that referenced this pull request Feb 19, 2021
* systemtest: test apm-server in Fleet mode

We run a custom package registry into which
the "apm" integration package is bind-mounted
from the tree, enabling us to test with
unreleased package changes.

Add a system test that runs Elastic Agent in
Fleet mode, with a locally built APM Server
binary injected into the container. The test
adds the "apm" integration package to a new
agent policy, waits for elastic-agent to start
apm-server, and verifies it is functional.
axw added a commit to axw/apm-server that referenced this pull request Feb 19, 2021
* systemtest: test apm-server in Fleet mode

We run a custom package registry into which
the "apm" integration package is bind-mounted
from the tree, enabling us to test with
unreleased package changes.

Add a system test that runs Elastic Agent in
Fleet mode, with a locally built APM Server
binary injected into the container. The test
adds the "apm" integration package to a new
agent policy, waits for elastic-agent to start
apm-server, and verifies it is functional.
# Conflicts:
#	systemtest/elasticsearch.go
axw added a commit to axw/apm-server that referenced this pull request Feb 19, 2021
* systemtest: test apm-server in Fleet mode

We run a custom package registry into which
the "apm" integration package is bind-mounted
from the tree, enabling us to test with
unreleased package changes.

Add a system test that runs Elastic Agent in
Fleet mode, with a locally built APM Server
binary injected into the container. The test
adds the "apm" integration package to a new
agent policy, waits for elastic-agent to start
apm-server, and verifies it is functional.
# Conflicts:
#	systemtest/elasticsearch.go
axw added a commit that referenced this pull request Feb 19, 2021
…: fix missing error check (#4683) | systemtest: compensate for Fleet API bug (#4693) (#4832)

* systemtest: test apm-server in Fleet mode (#4650)

* systemtest: test apm-server in Fleet mode

We run a custom package registry into which
the "apm" integration package is bind-mounted
from the tree, enabling us to test with
unreleased package changes.

Add a system test that runs Elastic Agent in
Fleet mode, with a locally built APM Server
binary injected into the container. The test
adds the "apm" integration package to a new
agent policy, waits for elastic-agent to start
apm-server, and verifies it is functional.
# Conflicts:
#	systemtest/elasticsearch.go

* systemtest: fix missing error check (#4683)

* systemtest: compensate for Fleet API bug (#4693)

* systemtest: compensate for Fleet API bug

elastic/kibana#90544 is
causing the system test to respond with 404 Not Found,
despite the policy existing and being successfully
deleted.

Update the test to temporarily expect a 404 response to
avoid failing all our builds. Once the Kibana bug is
resolved this will start failing, and we can again check
that no error is returned.
axw added a commit that referenced this pull request Feb 20, 2021
… fix missing error check (#4683) | systemtest: compensate for Fleet API bug (#4693) (#4831)

* systemtest: test apm-server in Fleet mode (#4650)

* systemtest: test apm-server in Fleet mode

We run a custom package registry into which
the "apm" integration package is bind-mounted
from the tree, enabling us to test with
unreleased package changes.

Add a system test that runs Elastic Agent in
Fleet mode, with a locally built APM Server
binary injected into the container. The test
adds the "apm" integration package to a new
agent policy, waits for elastic-agent to start
apm-server, and verifies it is functional.
# Conflicts:
#	systemtest/elasticsearch.go

* systemtest: fix missing error check (#4683)

* systemtest: compensate for Fleet API bug (#4693)

* systemtest: compensate for Fleet API bug

elastic/kibana#90544 is
causing the system test to respond with 404 Not Found,
despite the policy existing and being successfully
deleted.

Update the test to temporarily expect a 404 response to
avoid failing all our builds. Once the Kibana bug is
resolved this will start failing, and we can again check
that no error is returned.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants