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

Implement terraform based system tests #227

Merged
merged 66 commits into from
Jan 29, 2021

Conversation

mtojek
Copy link
Contributor

@mtojek mtojek commented Jan 19, 2021

I'm opening this as draft to present the progress on the TF-based system tests.

Please do not consider this as final form, as I will modify it soon.

Issue: #89

How to test this:

export AWS_ACCESS_KEY_ID="secret"
export AWS_SECRET_ACCESS_KEY="secret"

cd test/packages/aws
elastic-package test system --data-streams ec2_metrics -v

Tf definitions in: data_stream/ec2_metrics/_dev/deploy/tf/main.tf (or other .tf files)

EDIT:

I switched from SNS to EC2 metrics during tests as metrics tend to appear quicker.

@elasticmachine
Copy link
Collaborator

elasticmachine commented Jan 19, 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 #227 updated

    • Start Time: 2021-01-29T17:05:56.456+0000
  • Duration: 15 min 39 sec

  • Commit: e7e8764

Test stats 🧪

Test Results
Failed 0
Passed 291
Skipped 0
Total 291

@mtojek
Copy link
Contributor Author

mtojek commented Jan 21, 2021

Status update:

I managed to write the TF service deployer, but it needs to nice Terraform definition, which will actually perform something useful. A test scenario consist of two parts:

  1. Test configuration (mainly vars): https://github.com/mtojek/elastic-package/blob/89-terraform-definitions/test/packages/aws/data_stream/sns/_dev/test/system/test-default-config.yml
  2. Terraform definition which will bring up required AWS resources: https://github.com/mtojek/elastic-package/blob/89-terraform-definitions/test/packages/aws/data_stream/sns/_dev/deploy/tf/main.tf

@kaiyan-sheng I was wondering if you wouldn't like to play with it (git checkout), share some feedback and write some Terraform files which can usually do sth useful (most wanted). I wrote a sample which creates SNS topic, but due to lack of messages, I don't see any CloudWatch metrics :(

FYI I haven't enabled the AWS account in the CI due to security reasons and cost-savings. Let's first check it on our workstations.

@mtojek mtojek requested a review from ycombinator January 21, 2021 15:17
@mtojek
Copy link
Contributor Author

mtojek commented Jan 28, 2021

@ycombinator Thanks a lot for the review! I addressed your comments and introduced small changes in README. Please take a look and re-review whenever you've time.

@mtojek mtojek requested a review from ycombinator January 28, 2021 15:44

`<service deployer>` - a name of the supported service deployer: `docker` or `tf` (terraform).

### Docker Compose service deployer

The `docker-compose.yml` file defines the integration service(s) for the package. If your package has a logs data stream, the log files from your package's integration service must be written to a volume. For example, the `apache` package has the following definition in it's integration service's `docker-compose.yml` file.
Copy link
Contributor

Choose a reason for hiding this comment

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

This sentence made sense earlier because the sample file structure above showed a docker-compose.yml file. Now the sample file structure above just says <service deployer files> so this sentence doesn't make as much sense.

I would add another introductory sentence to bridge this gap, something like:

When using the Docker Compose service deployer, the <service deployer files> must include a docker-compose.yml file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added here and for the TF service deployer

<service deployer files>
```

`<service deployer>` - a name of the supported service deployer: `docker` or `tf` (terraform).
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be worth clarifying that the docker name is for the Docker Compose service deployer and the tf name is for the Terraform service deployer. It's pretty obvious but it doesn't hurt to be explicit and tie these names to the sections that follow.

Copy link
Contributor Author

@mtojek mtojek Jan 29, 2021

Choose a reason for hiding this comment

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

Good point, docker and docker compose are different products. Fixed

### Data stream-level configuration
### Terraform service deployer

The `*.tf` files define the infrastructure using the Terraform syntax. The terraform based service can be handy to boot up
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to my comment on the Docker Composer service deployer, I would add an introductory sentence to bridge the gap between what's shown in the sample file structure and this sentence here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

### Terraform service deployer

The `*.tf` files define the infrastructure using the Terraform syntax. The terraform based service can be handy to boot up
resources on AWS and use them for testing (e.g. spawn EC2 instance and collect its metrics).
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we specifically mention AWS here? Or can we be more generic and say resources supported by Terraform or something like that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed


// Build Terraform executor container name
serviceContainer := fmt.Sprintf("%s_terraform_1", service.project)
outCtxt.Hostname = serviceContainer
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to set outCtxt.Hostname here? AFAICT it's not useful because the Agent configuration will never really need to talk to the Terraform executor container. Instead it will need to use the outCtxt.CustomProperties to talk to the service that is deployed by the Terraform executor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can try this, I hope everything will still work (it's not expected value somewhere). Fixed.

@mtojek mtojek requested a review from ycombinator January 29, 2021 11:55
Copy link
Contributor

@ycombinator ycombinator left a comment

Choose a reason for hiding this comment

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

LGTM. Very nice work on this!

@mtojek mtojek requested a review from ycombinator January 29, 2021 17:22
Copy link
Contributor

@ycombinator ycombinator left a comment

Choose a reason for hiding this comment

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

LGTM.

@mtojek mtojek merged commit dcebdb3 into elastic:master Jan 29, 2021
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