generated from cloudposse-terraform-components/template
-
-
Notifications
You must be signed in to change notification settings - Fork 2
chore: add tests #31
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
Merged
chore: add tests #31
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
d440784
chore: add tests
RoseSecurity 8e308d2
fix: remove dns-primary
RoseSecurity 461cc27
Delete test/run.sh
goruha 0ad39ec
Delete test/test_suite.yaml
goruha 2518e61
fix: add gitignore
RoseSecurity a9a83a6
Merge branch 'main' into add-tests
goruha 4f7aa9b
fix: use redis family instead of valkey
RoseSecurity 5042eb4
fix: adjust redis version to 6.2
RoseSecurity fae3a03
fix: update redis engine version
RoseSecurity b6a59eb
fix: add parameter cluster-allow-pubsubshard-when-down
RoseSecurity e3457b5
fix: destroy with inputs
RoseSecurity a27eddf
fix: update redis family for disabled
RoseSecurity c71b87d
fix: add required fields to disabled
RoseSecurity 49fc537
fix: update deprecated egress arguments
RoseSecurity 12f0bf4
Merge branch 'main' into add-tests
RoseSecurity File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
state/ | ||
.cache | ||
test/test-suite.json | ||
.atmos | ||
test_suite.yaml |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package test | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"testing" | ||
|
||
helper "github.com/cloudposse/test-helpers/pkg/atmos/component-helper" | ||
"github.com/gruntwork-io/terratest/modules/random" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
type ComponentSuite struct { | ||
helper.TestSuite | ||
} | ||
|
||
func (s *ComponentSuite) TestBasic() { | ||
const component = "elasticache-redis/basic" | ||
const stack = "default-test" | ||
const awsRegion = "us-east-2" | ||
|
||
engineName := "redis" | ||
uniqueSuffix := strings.ToLower(random.UniqueId()) | ||
|
||
inputs := map[string]any{ | ||
"name": fmt.Sprintf("%s-%s", engineName, uniqueSuffix), | ||
"redis_clusters": map[string]any{ | ||
"redis-test": map[string]any{ | ||
"num_shards": 0, | ||
"replicas_per_shard": 1, | ||
"num_replicas": 1, | ||
"engine": engineName, | ||
"engine_version": "7.0", | ||
"instance_type": "cache.t4g.small", | ||
"parameters": []map[string]any{ | ||
{ | ||
"name": "cluster-allow-pubsubshard-when-down", | ||
"value": "yes", | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
defer s.DestroyAtmosComponent(s.T(), component, stack, &inputs) | ||
options, _ := s.DeployAtmosComponent(s.T(), component, stack, &inputs) | ||
assert.NotNil(s.T(), options) | ||
|
||
s.DriftTest(component, stack, &inputs) | ||
} | ||
|
||
func (s *ComponentSuite) TestEnabledFlag() { | ||
const component = "elasticache-redis/disabled" | ||
const stack = "default-test" | ||
s.VerifyEnabledFlag(component, stack, nil) | ||
} | ||
|
||
func TestRunSuite(t *testing.T) { | ||
suite := new(ComponentSuite) | ||
|
||
suite.AddDependency(t, "vpc", "default-test", nil) | ||
|
||
subdomain := strings.ToLower(random.UniqueId()) | ||
inputs := map[string]any{ | ||
"zone_config": []map[string]any{ | ||
{ | ||
"subdomain": subdomain, | ||
"zone_name": "components.cptest.test-automation.app", | ||
}, | ||
}, | ||
} | ||
|
||
suite.AddDependency(t, "dns-delegated", "default-test", &inputs) | ||
|
||
helper.Run(t, suite) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# CLI config is loaded from the following locations (from lowest to highest priority): | ||
# system dir (`/usr/local/etc/atmos` on Linux, `%LOCALAPPDATA%/atmos` on Windows) | ||
# home dir (~/.atmos) | ||
# current directory | ||
# ENV vars | ||
# Command-line arguments | ||
# | ||
# It supports POSIX-style Globs for file names/paths (double-star `**` is supported) | ||
# https://en.wikipedia.org/wiki/Glob_(programming) | ||
|
||
# Base path for components, stacks and workflows configurations. | ||
# Can also be set using `ATMOS_BASE_PATH` ENV var, or `--base-path` command-line argument. | ||
# Supports both absolute and relative paths. | ||
# If not provided or is an empty string, `components.terraform.base_path`, `components.helmfile.base_path`, `stacks.base_path` and `workflows.base_path` | ||
# are independent settings (supporting both absolute and relative paths). | ||
# If `base_path` is provided, `components.terraform.base_path`, `components.helmfile.base_path`, `stacks.base_path` and `workflows.base_path` | ||
# are considered paths relative to `base_path`. | ||
base_path: "" | ||
|
||
components: | ||
terraform: | ||
# Can also be set using `ATMOS_COMPONENTS_TERRAFORM_BASE_PATH` ENV var, or `--terraform-dir` command-line argument | ||
# Supports both absolute and relative paths | ||
base_path: "components/terraform" | ||
# Can also be set using `ATMOS_COMPONENTS_TERRAFORM_APPLY_AUTO_APPROVE` ENV var | ||
apply_auto_approve: true | ||
# Can also be set using `ATMOS_COMPONENTS_TERRAFORM_DEPLOY_RUN_INIT` ENV var, or `--deploy-run-init` command-line argument | ||
deploy_run_init: true | ||
# Can also be set using `ATMOS_COMPONENTS_TERRAFORM_INIT_RUN_RECONFIGURE` ENV var, or `--init-run-reconfigure` command-line argument | ||
init_run_reconfigure: true | ||
# Can also be set using `ATMOS_COMPONENTS_TERRAFORM_AUTO_GENERATE_BACKEND_FILE` ENV var, or `--auto-generate-backend-file` command-line argument | ||
auto_generate_backend_file: true | ||
|
||
stacks: | ||
# Can also be set using `ATMOS_STACKS_BASE_PATH` ENV var, or `--config-dir` and `--stacks-dir` command-line arguments | ||
# Supports both absolute and relative paths | ||
base_path: "stacks" | ||
# Can also be set using `ATMOS_STACKS_INCLUDED_PATHS` ENV var (comma-separated values string) | ||
# Since we are distinguishing stacks based on namespace, and namespace is not part | ||
# of the stack name, we have to set `included_paths` via the ENV var in the Dockerfile | ||
included_paths: | ||
- "orgs/**/*" | ||
|
||
# Can also be set using `ATMOS_STACKS_EXCLUDED_PATHS` ENV var (comma-separated values string) | ||
excluded_paths: | ||
- "**/_defaults.yaml" | ||
|
||
# Can also be set using `ATMOS_STACKS_NAME_PATTERN` ENV var | ||
name_pattern: "{tenant}-{stage}" | ||
|
||
workflows: | ||
# Can also be set using `ATMOS_WORKFLOWS_BASE_PATH` ENV var, or `--workflows-dir` command-line arguments | ||
# Supports both absolute and relative paths | ||
base_path: "stacks/workflows" | ||
|
||
# https://github.com/cloudposse/atmos/releases/tag/v1.33.0 | ||
logs: | ||
file: "/dev/stdout" | ||
# Supported log levels: Trace, Debug, Info, Warning, Off | ||
level: Info | ||
|
||
settings: | ||
# Can also be set using 'ATMOS_SETTINGS_LIST_MERGE_STRATEGY' environment variable, or '--settings-list-merge-strategy' command-line argument | ||
list_merge_strategy: replace | ||
|
||
# `Go` templates in Atmos manifests | ||
# https://atmos.tools/core-concepts/stacks/templating | ||
# https://pkg.go.dev/text/template | ||
templates: | ||
settings: | ||
enabled: true | ||
# https://masterminds.github.io/sprig | ||
sprig: | ||
enabled: true | ||
# https://docs.gomplate.ca | ||
gomplate: | ||
enabled: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
components: | ||
terraform: | ||
account-map: | ||
metadata: | ||
terraform_workspace: core-gbl-root | ||
vars: | ||
tenant: core | ||
environment: gbl | ||
stage: root | ||
|
||
# This remote state is only for Cloud Posse internal use. | ||
# It references the Cloud Posse test organizations actual infrastructure. | ||
# remote_state_backend: | ||
# s3: | ||
# bucket: cptest-core-ue2-root-tfstate-core | ||
# dynamodb_table: cptest-core-ue2-root-tfstate-core-lock | ||
# role_arn: arn:aws:iam::822777368227:role/cptest-core-gbl-root-tfstate-core-ro | ||
# encrypt: true | ||
# key: terraform.tfstate | ||
# acl: bucket-owner-full-control | ||
# region: us-east-2 | ||
|
||
remote_state_backend_type: static | ||
remote_state_backend: | ||
# This static backend is used for tests that only need to use the account map iam-roles module | ||
# to find the role to assume for Terraform operations. It is configured to use whatever | ||
# the current user's role is, but the environment variable `TEST_ACCOUNT_ID` must be set to | ||
# the account ID of the account that the user is currently assuming a role in. | ||
# | ||
# For some components, this backend is missing important data, and those components | ||
# will need that data added to the backend configuration in order to work properly. | ||
static: | ||
account_info_map: {} | ||
all_accounts: [] | ||
aws_partition: aws | ||
full_account_map: {} | ||
iam_role_arn_templates: {} | ||
non_eks_accounts: [] | ||
profiles_enabled: false | ||
root_account_aws_name: root | ||
terraform_access_map: {} | ||
terraform_dynamic_role_enabled: false | ||
terraform_role_name_map: | ||
apply: terraform | ||
plan: planner | ||
terraform_roles: {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
components: | ||
terraform: | ||
dns-delegated: | ||
metadata: | ||
component: dns-delegated | ||
vars: | ||
zone_config: | ||
- subdomain: test | ||
zone_name: example.net | ||
request_acm_certificate: false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
components: | ||
terraform: | ||
dns-primary: | ||
metadata: | ||
component: dns-primary | ||
vars: | ||
domain_names: | ||
- example.net | ||
record_config: [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
components: | ||
terraform: | ||
elasticache-redis/basic: | ||
metadata: | ||
component: target | ||
vars: | ||
enabled: true | ||
family: redis7 | ||
allow_ingress_from_this_vpc: true | ||
allow_all_egress: true | ||
port: 6379 | ||
at_rest_encryption_enabled: true | ||
transit_encryption_enabled: true | ||
apply_immediately: true | ||
auto_minor_version_upgrade: true | ||
cloudwatch_metric_alarms_enabled: true | ||
snapshot_retention_limit: 7 | ||
automatic_failover_enabled: false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
components: | ||
terraform: | ||
elasticache-redis/disabled: | ||
metadata: | ||
component: target | ||
vars: | ||
enabled: false | ||
family: redis7 | ||
allow_ingress_from_this_vpc: true | ||
allow_all_egress: true | ||
port: 6379 | ||
at_rest_encryption_enabled: true | ||
transit_encryption_enabled: true | ||
apply_immediately: true | ||
auto_minor_version_upgrade: true | ||
cloudwatch_metric_alarms_enabled: true | ||
snapshot_retention_limit: 7 | ||
automatic_failover_enabled: false | ||
redis_clusters: | ||
redis-test: | ||
num_shards: 0 | ||
replicas_per_shard: 1 | ||
num_replicas: 1 | ||
engine: "redis" | ||
engine_version: "7.0" | ||
instance_type: "cache.t4g.small" | ||
parameters: | ||
- name: cluster-allow-pubsubshard-when-down | ||
value: "yes" | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
components: | ||
terraform: | ||
vpc: | ||
metadata: | ||
component: vpc | ||
vars: | ||
name: "vpc" | ||
availability_zones: | ||
- "b" | ||
- "c" | ||
public_subnets_enabled: true | ||
max_nats: 1 | ||
# Private subnets do not need internet access | ||
nat_gateway_enabled: false | ||
nat_instance_enabled: false | ||
subnet_type_tag_key: "eg.cptest.co/subnet/type" | ||
max_subnet_count: 3 | ||
vpc_flow_logs_enabled: false | ||
ipv4_primary_cidr_block: "172.16.0.0/16" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import: | ||
- catalog/account-map | ||
|
||
terraform: | ||
backend_type: local | ||
backend: | ||
local: | ||
path: '{{ getenv "COMPONENT_HELPER_STATE_DIR" | default "../../../state" }}/{{ .component }}/terraform.tfstate' | ||
workspace_dir: '{{ getenv "COMPONENT_HELPER_STATE_DIR" | default "../../../state" }}/{{ .component }}/' | ||
vars: | ||
namespace: eg | ||
tenant: default | ||
environment: ue2 | ||
region: us-east-2 | ||
stage: test | ||
label_order: | ||
- namespace | ||
- tenant | ||
- environment | ||
- stage | ||
- name | ||
- attributes | ||
descriptor_formats: | ||
account_name: | ||
format: "%v-%v" | ||
labels: | ||
- tenant | ||
- stage | ||
stack: | ||
format: "%v-%v-%v" | ||
labels: | ||
- tenant | ||
- environment | ||
- stage | ||
|
||
components: | ||
terraform: | ||
account-map: | ||
remote_state_backend: | ||
static: | ||
account_info_map: | ||
default-test: | ||
account_email_format: aws+cptest-%[email protected] | ||
eks: true | ||
id: '{{ getenv "TEST_ACCOUNT_ID" | default "<TEST_ACCOUNT_ID>" }}' | ||
ou: default | ||
parent_ou: none | ||
stage: test | ||
tags: | ||
eks: false | ||
tenant: default | ||
all_accounts: | ||
- default-test | ||
artifacts_account_account_name: default-test | ||
audit_account_account_name: default-test | ||
dns_account_account_name: default-test | ||
eks_accounts: | ||
- default-test | ||
full_account_map: | ||
default-test: '{{ getenv "TEST_ACCOUNT_ID" | default "<TEST_ACCOUNT_ID>" }}' | ||
iam_role_arn_templates: | ||
default-test: 'arn:aws:iam::{{ getenv "TEST_ACCOUNT_ID" | default "<TEST_ACCOUNT_ID>" }}:role/tester-%s' | ||
identity_account_account_name: default-test | ||
root_account_account_name: default-test | ||
terraform_roles: | ||
default-test: '' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import: | ||
- orgs/default/test/_defaults | ||
- catalog/vpc | ||
- catalog/dns-delegated | ||
- catalog/usecase/basic | ||
- catalog/usecase/disabled |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.