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

[E2E Testing] mage targets to interact with VMs and cloud stack #3887

Merged
merged 6 commits into from
Feb 1, 2024

Conversation

belimawr
Copy link
Contributor

@belimawr belimawr commented Dec 8, 2023

The Goal

That's my OnWeek project, I focused on getting something simple that works, so I ended up not using most of the runner package/features because they're looked too coupled with running a test/set of tests and I was looking for easy and simple ways to interact directly with the VMs and Cloud Stacks.

The part installs tools on a VM is not very smart, it focus on not breaking if called multiple times rather than being super efficient.

What does this PR do?

This commit adds a number of mage targets to improve developer experience when using the integration test framework. Those targets aim to easy how to login into VMs and run tests from there as well as how to access the Cloud Stacks.

The targets added are:

  • integration:deployDebugTools
  • integration:deployEnvFile
  • integration:generateEnvFile
  • integration:listInstances
  • integration:printState
  • integration:ssh
  • integration:stacks

Why is it important?

It improves developer experience

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 added an entry in ./changelog/fragments using the changelog tool
    - [ ] I have added an integration test or an E2E test

## Author's Checklist

How to test this PR locally

Just run any of the new mage targets.

Related issues

Logs

Some example output from the new targets

mage integration:Stacks
+-------------------+------------------------------------------------------------------------------+ 
| #                 | 0                                                                            |
| Type              | stateful                                                                     |
| Deployment ID     | e73ae5d3fffff74aa436bbbbb8992342                                             |
| Elasticsearch URL | https://a-deployment.elastic-cloud.com                                       |
| Kibana            | https://a-deployment.elastic-cloud.com:9243                                  |
| Username          | elastic                                                                      |
| Password          | very-secret-password                                                         |
+-------------------+------------------------------------------------------------------------------+
+-------------------+--------------------------------------------------------+
| #                 | 1                                                      |
| Type              | serverless                                             |
| Project ID        | f2eddddd8d994aaa442677dc426cab235                      |
| Elasticsearch URL | https://a-serverless.es.elastic.cloud                  |
| Kibana            | https://a-serverless.kb.elastic.cloud                  |
| Username          | elastic                                                |
| Password          | very-secret-password                                   |
+-------------------+--------------------------------------------------------+

mage integration:ListInstances
+----------------+------------------------------------------------------------------------------------------------------------+
| #              | 0                                                                                                          |
| Provisioner    | ogc                                                                                                        |
| Name           | ogc-linux-amd64-ubuntu-2204-fleet-cac0                                                                     |
| ID             | linux-amd64-ubuntu-2204-fleet                                                                              |
| Instance ID    | 123458374283                                                                                               |
| IP             | 35.1.2.3                                                                                                   |
| Private Key    | /home/user/dev/elastic-agent/.integration-cache/id_rsa                                                     |
| Public Key     | /home/user/dev/elastic-agent/.integration-cache/id_rsa.pub                                                 |
| SSH connection | ssh -i /home/user/dev/elastic-agent/.integration-cache/id_rsa ubuntu@35.1.2.3                              |
| GCP Link       | https://console.cloud.google.com/compute/instancesDetail/zones/us-central1-a/instances/123458374283        |
+----------------+------------------------------------------------------------------------------------------------------------+
+----------------+-------------------------------------------------------------------------------------+
| #              | 1                                                                                   |
| Provisioner    | multipass                                                                           |
| Name           | linux-amd64-ubuntu-2204-fleet                                                       |
| ID             | linux-amd64-ubuntu-2204-fleet                                                       |
| IP             | 10.23.24.15                                                                         |
| Private Key    | /home/user/dev/elastic-agent/.integration-cache/id_rsa                              |
| Public Key     | /home/user/dev/elastic-agent/.integration-cache/id_rsa.pub                          |
| SSH connection | ssh -i /home/user/dev/elastic-agent/.integration-cache/id_rsa ubuntu@10.23.24.15    |
+----------------+-------------------------------------------------------------------------------------+

Questions to ask yourself

  • How are we going to support this in production?
  • How are we going to measure its adoption?
  • How are we going to debug this?
  • What are the metrics I should take care of?
  • ...

@belimawr belimawr added enhancement New feature or request Team:Elastic-Agent Label for the Agent team labels Dec 8, 2023
Copy link
Contributor

mergify bot commented Dec 8, 2023

This pull request does not have a backport label. Could you fix it @belimawr? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v./d./d./d is the label to automatically backport to the 8./d branch. /d is the digit

NOTE: backport-skip has been added to this pull request.

@mergify mergify bot added the backport-skip label Dec 8, 2023
@belimawr belimawr force-pushed the integ-test-framework-devex branch 4 times, most recently from 1d8d82e to 4a09ffb Compare December 8, 2023 14:21
@belimawr belimawr requested a review from pchila December 8, 2023 14:28
@belimawr belimawr force-pushed the integ-test-framework-devex branch 2 times, most recently from cbe8051 to c006ea8 Compare December 8, 2023 15:44
@belimawr belimawr marked this pull request as ready for review December 8, 2023 15:44
@belimawr belimawr requested a review from a team as a code owner December 8, 2023 15:44
@belimawr belimawr requested a review from blakerouse December 8, 2023 15:44
@elasticmachine
Copy link
Contributor

Pinging @elastic/elastic-agent (Team:Elastic-Agent)

Copy link
Contributor

@blakerouse blakerouse left a comment

Choose a reason for hiding this comment

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

Overall these targets look very useful and could be very helpful for debugging. I gave some suggestions on the naming of the targets.

In general I think these items would be better inside of the pkg/testing/runner directly. Would be much cleaner then being into the mage file.

magefile.go Outdated Show resolved Hide resolved
magefile.go Outdated Show resolved Hide resolved
magefile.go Outdated Show resolved Hide resolved
@belimawr
Copy link
Contributor Author

Thanks for the suggestions @blakerouse! I implemented them on 8c06e69.

This commit adds a number of mage targets to improve developer
experience when using the integration test framework. Those targets
aim to easy how to login into VMs and run tests from there as well as
how to access the Cloud Stacks.

The targets added are:
- integration:deployDebugTools
- integration:deployEnvFile
- integration:generateEnvFile
- integration:listStacks
- integration:listVMs
- integration:printState
- integration:sshvm
@belimawr belimawr force-pushed the integ-test-framework-devex branch from 8c06e69 to fd6cc21 Compare December 21, 2023 07:35
@belimawr
Copy link
Contributor Author

In general I think these items would be better inside of the pkg/testing/runner directly. Would be much cleaner then being into the mage file.

I agree. I kept it in the magefile because it was a OnWeek project and I didn't have much time. I agree we should move it there later.

@belimawr belimawr requested a review from blakerouse December 21, 2023 16:56
@pierrehilbert
Copy link
Contributor

Setting back to draft for now.

@pierrehilbert pierrehilbert marked this pull request as draft January 9, 2024 13:39
@belimawr belimawr marked this pull request as ready for review January 17, 2024 15:41
Copy link

Quality Gate passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No Coverage information No data about Coverage
No Duplication information No data about Duplication

See analysis details on SonarQube

@belimawr belimawr merged commit ece91fe into elastic:main Feb 1, 2024
9 checks passed
@belimawr belimawr deleted the integ-test-framework-devex branch February 1, 2024 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-skip enhancement New feature or request skip-changelog Team:Elastic-Agent Label for the Agent team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants