-
Notifications
You must be signed in to change notification settings - Fork 158
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
[DO NOT MERGE] - PoC for orchestrating remote tests from inside the package using terraform #4832
Conversation
Provision a GCP ubuntu VM, install Golang, copy source code (WIP) Run from testMain as part of setup/teardown
Pinging @elastic/elastic-agent (Team:Elastic-Agent) |
Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane) |
This pull request does not have a backport label. Could you fix it @pchila? 🙏
NOTE: |
Just want to be clear that the integration testing framework already supports different providers. Like the ability to switch to multipass on macOS. Implementing a terraform provisioner, and having it output the SSH credentials would be enough to switch to using terraform. |
Closing this as it was just meant to show what has been done as a PoC |
What does this PR do?
This PR contains a simple PoC to show what a TestMain for remote tests looks like when provisioning is offloaded to a third-party tool like Terraform.
Note: the code is really rough and in no way, shape or form close to production quality. This has been tested only on Linux even if it should work with minimal changes on MacOS. Windows has not been harmed during the writing of this code but it's also not been taken into account for compatibility. This PR is there just to explore what is possible without getting distracted by something like support for all OSes
Goals:
mage
or other toolsdefine.*
constructs already used for elastic-agent integration testsgo test
can be readily executed without setup getting too much in the way of the tests to be runNon-Goals:
What has been implemented:
go test
command that supports custom command line argumentsWhat is still missing (and would probably be the next steps)
Provisioner
,Runner
via interfaces so that we can swap different implementations (the ones needed by the current code are at leastTerraformProvisioner
andSSHRunner
)elastic-package
(and others...) provisioningdlv
on the remote while port forwarding the debug port on the local machineI would also like to extend special thanks to @alexsapran and @pierrehilbert which helped me get through some of the terraform stuff
Why is it important?
Checklist
./changelog/fragments
using the changelog toolDisruptive User Impact
How to test this PR locally
To test this PR we launch tests of the
newexp
package like:go test -tags integration -test.count 1 -test.v github.com/elastic/elastic-agent/testing/newexp
The output should look like this:
Congratulations: you have just provisioned everything, ran the tests and cleaned up everything! 🎉
If you want to iterate over the code you can leave the stuff provisioned by adding some extra test parameters (note the use of
-args
before the custom flags)go test -tags integration -test.timeout 30m -test.count 1 -test.v github.com/elastic/elastic-agent/testing/newexp -args -integration.skip-destroy
To check for command line help, we are interested in the
-integration.*
flags (there is not much yet but weirdly there are some default agent CLI flags in there 🤔 )Related issues
Questions to ask yourself