Skip to content

Commit

Permalink
ci: update RM and screenshots (#128)
Browse files Browse the repository at this point in the history
### Description

Update readme for integration tests
  • Loading branch information
obs-gh-nikhildua authored Nov 8, 2024
1 parent f47a891 commit 7d0f169
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 3 deletions.
105 changes: 102 additions & 3 deletions integration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,74 @@ Generally a test will do the following for any given EC2 Machine:
- Create a machine using the variables provided below in `us-west-1`
- Run a test using `observeinc/collection/aws//modules/testing/exec` module to accept python scripts located at `integration/tests/scripts`

### Pre-requisites

### Variables
Ensure you have the following:
- Built version of the agent ( in `observe-repos/observe-agent/dist`) using `go-releaser`
- Blunderdome Admin Access in AWS (used to assume the `gh-observe_agent-repo` role for testing )
- Observe Collection URL & Datastream Token to test with
- Generated Private & public key pair ( name to `test_key.pub` & `test_key.pem`)
- Terraform provider overide and terraform variables (see below section on how to do this)


**Building the agent**:

```
observe-agent git:(nikhil/update-RM) ✗ goreleaser release --snapshot --clean --verbose
```

If agent distributable is not built, you may get the following message:

```
│ Error: Test assertion failed
│ on tests/integration.tftest.hcl line 65, in run "test_install":
│ 65: condition = output.error == ""
│ ├────────────────
│ │ output.error is "FileNotFoundError: [Errno 2] No such file or directory: '/Users/nikhil.dua/Documents/observe-repos/observe-agent/dist'"
│ Error in Installation Test
```


**SSH Key Pairs**:

Generate in PEM format for the OpenSSH Key that will be used by Terraform EC2 Modules:

```
ssh-keygen -m PEM
```

For more info on generating SSH keys, see [here](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/create-key-pairs.html#how-to-generate-your-own-key-and-import-it-to-aws)

Ensure you have `./test_key.pub` and `./test_key.pem` in the `integration` directory. This can also be changed and specifed in the `integration/tests.auto.tfvars` file.

Ensure the extensions are correct!


**AWS UI Access (optional)**:

For AWS UI access for viewing machines:
1. Login to Britive Blunderdome

2. Navigate to AWS Console

<p align="left">
<img src="screenshots/aws-console.png" alt="AWS Console" width="300"/>
</p>

3. Click Switch role and input details for `nikhil-ps-account` which is the member account for integration testing within Blunderdome. Details are the following:
<p align="left">
<img src="screenshots/member-account.png" alt="Member Account" width="500"/>
</p>

4. You can now access EC2 machines and download key pairs (same as what Github Actions workflow uses)

5. Ensure you're in `us-west-1`



### Terraform Variables

The tests are run using the following variables. These can be set in the `integration/tests.auto.tfvars` file for local testing.

Expand All @@ -25,6 +91,17 @@ OBSERVE_URL = "https://<TENANT_ID.collect.observe-staging.com>" #Observe URL to
OBSERVE_TOKEN ="<DATASTREAM_TOKEN_TO_TEST_OBSERVE_AGENT_WITH">
```

The PUBLIC & PRIVATE key pair can be generated by following the instructions in the "SSH Key Pairs" section above

Example of what the `integrations` folder contains after creating `.*tfvars` file and SSH Key Pair:


<p align="left">
<img src="screenshots/ssh-example.png" alt="SSH Example" width="200"/>
</p>


### Terraform Provider

Note: You must also set the provider correctly. We use the following settings:
- Region: `us-west-1`
Expand All @@ -47,8 +124,30 @@ provider "aws" {

or through a `provider_override.tf` placed in `modules/create_ec2` directory.

Example of this:

<p align="left">
<img src="screenshots/provider-example.png" alt="SSH Example" width="200"/>
</p>




> [!NOTE]
> For Terraform to access and assume the role properly, you MUST be logged into Blunderdome Admin in console and have the correct permissions!
Example of this:

```
observe git:(master) ✗ s/aws-creds checkout blunderdome
Checked out 'AWS Blunderdome Organization/460044344528 (observe-blunderdome)/BritiveBlunderdome-FullAWSAdmin' into awscli profile 'blunderdome'
observe git:(master) ✗ export AWS_PROFILE=blunderdome
```


### Local Testing
### Local Testing (without terraform test)

Any of the python scripts in the `/scripts` directory can be tested by running them directly, granted an EC2 Machine exists. As the scripts rely on the outputs of `create_ec2` and `setup_observe_variables` modules to be passed in as environment variables, these environment variables can be manually set if the set up modules are not ran.

Expand Down Expand Up @@ -88,7 +187,7 @@ Testing SSH connection to host 54.177.26.178 with timeout 120s

### Architecture

The architecture diagram can be found ![here](Observe-Agent.png)
The architecture diagram can be found ![here](screenshots/Observe-Agent.png)



File renamed without changes
Binary file added integration/screenshots/aws-console.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added integration/screenshots/member-account.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added integration/screenshots/provider-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added integration/screenshots/ssh-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7d0f169

Please sign in to comment.