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

tests/resource/aws_elastic_beanstalk_environment: Refactoring and modernization #11702

Merged
merged 1 commit into from
Feb 3, 2020

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Jan 22, 2020

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Release note for CHANGELOG:

NONE

Previously in the acceptance testing (across entire resource):

--- FAIL: TestAccAWSBeanstalkEnv_basic (20.78s)
    testing.go:640: Step 0 error: errors during apply:

        Error: Error waiting for Elastic Beanstalk Environment (e-mua2t3mjij) to become ready: 2 errors occurred:
        	* 2020-01-21 07:33:24.327 +0000 UTC (e-mua2t3mjij) : Service:AmazonCloudFormation, Message:Parameter InstanceType failed to satisfy constraint: must be a valid EC2 instance type.
        	* 2020-01-21 07:33:24.426 +0000 UTC (e-mua2t3mjij) : Failed to launch environment.

--- FAIL: TestAccAWSBeanstalkEnv_settingWithJsonValue (0.73s)
    testing.go:640: Step 0 error: /opt/teamcity-agent/temp/buildTmp/tf-test536039886/main.tf:74,3-10: Attribute redefined; The argument "setting" was already set at /opt/teamcity-agent/temp/buildTmp/tf-test536039886/main.tf:68,3-10. Each argument may be set only once., and 19 other diagnostic(s)

The test configurations were previously written to expect either a Elastic Beanstalk compatible Default VPC (IGW, map public IPs on launch Subnets, and permissive ingress/egress NACL) or EC2-Classic. We have moved away from these expectations and the majority of this refactor is centered on supplying self-contained VPC configurations to each test.

Other changes include:

  • Blocking usw2-az4 as the default instance type for EB is t2.micro and that instance type is not available in that Availability Zone, always (when that subnet is selected) triggering a launch error
  • Migrating to import testing in most tests
  • Migrating to resources named "test" in configurations and single resourceName variable in functions
  • Migrating to single rName variable for randomization
  • Using helper TestCheckFunc for ARNs
  • Removing duplicate test functions and configurations

Especially given the new import testing, there are potential further fixes that could be done to this resource including properly setting the setting and template_name attributes into the Terraform state during refresh, however those changes to the resource logic are out of scope for these test fixes.

Output from acceptance testing:

--- PASS: TestAccAWSBeanstalkEnv_platformArn (410.22s)
--- PASS: TestAccAWSBeanstalkEnv_resource (439.66s)
--- PASS: TestAccAWSBeanstalkEnv_basic (489.82s)
--- PASS: TestAccAWSBeanstalkEnv_settingWithJsonValue (558.85s)
--- PASS: TestAccAWSBeanstalkEnv_cname_prefix (577.42s)
--- PASS: TestAccAWSBeanstalkEnv_version_label (618.65s)
--- PASS: TestAccAWSBeanstalkEnv_config (628.04s)
--- PASS: TestAccAWSBeanstalkEnv_tier (630.63s)
--- PASS: TestAccAWSBeanstalkEnv_tags (667.96s)
--- PASS: TestAccAWSBeanstalkEnv_settings_update (744.56s)
--- PASS: TestAccAWSBeanstalkEnv_template_change (768.69s)

…ernization

Previously in the acceptance testing (across entire resource):

```
--- FAIL: TestAccAWSBeanstalkEnv_basic (20.78s)
    testing.go:640: Step 0 error: errors during apply:

        Error: Error waiting for Elastic Beanstalk Environment (e-mua2t3mjij) to become ready: 2 errors occurred:
        	* 2020-01-21 07:33:24.327 +0000 UTC (e-mua2t3mjij) : Service:AmazonCloudFormation, Message:Parameter InstanceType failed to satisfy constraint: must be a valid EC2 instance type.
        	* 2020-01-21 07:33:24.426 +0000 UTC (e-mua2t3mjij) : Failed to launch environment.

--- FAIL: TestAccAWSBeanstalkEnv_settingWithJsonValue (0.73s)
    testing.go:640: Step 0 error: /opt/teamcity-agent/temp/buildTmp/tf-test536039886/main.tf:74,3-10: Attribute redefined; The argument "setting" was already set at /opt/teamcity-agent/temp/buildTmp/tf-test536039886/main.tf:68,3-10. Each argument may be set only once., and 19 other diagnostic(s)
```

The test configurations were previously written to expect either a Elastic Beanstalk compatible Default VPC (IGW, map public IPs on launch Subnets, and permissive ingress/egress NACL) or EC2-Classic. We have moved away from these expectations and the majority of this refactor is centered on supplying self-contained VPC configurations to each test.

Other changes include:

- Blocking usw2-az4 as the default instance type for EB is t2.micro and that instance type is not available in that Availability Zone, always (when that subnet is selected) triggering a launch error
- Migrating to import testing in most tests
- Migrating to resources named "test" in configurations and single resourceName variable in functions
- Migrating to single rName variable for randomization
- Using helper TestCheckFunc for ARNs
- Removing duplicate test functions and configurations

Especially given the new import testing, there are potential further fixes that could be done to this resource including properly setting the `setting` and `template_name` attributes into the Terraform state during refresh, however those changes to the resource logic are out of scope for these test fixes.

Output from acceptance testing:

```
--- PASS: TestAccAWSBeanstalkEnv_platformArn (410.22s)
--- PASS: TestAccAWSBeanstalkEnv_resource (439.66s)
--- PASS: TestAccAWSBeanstalkEnv_basic (489.82s)
--- PASS: TestAccAWSBeanstalkEnv_settingWithJsonValue (558.85s)
--- PASS: TestAccAWSBeanstalkEnv_cname_prefix (577.42s)
--- PASS: TestAccAWSBeanstalkEnv_version_label (618.65s)
--- PASS: TestAccAWSBeanstalkEnv_config (628.04s)
--- PASS: TestAccAWSBeanstalkEnv_tier (630.63s)
--- PASS: TestAccAWSBeanstalkEnv_tags (667.96s)
--- PASS: TestAccAWSBeanstalkEnv_settings_update (744.56s)
--- PASS: TestAccAWSBeanstalkEnv_template_change (768.69s)
```
@bflad bflad added the technical-debt Addresses areas of the codebase that need refactoring or redesign. label Jan 22, 2020
@bflad bflad requested a review from a team January 22, 2020 02:53
@ghost ghost added needs-triage Waiting for first response or review from a maintainer. size/XXL Managed by automation to categorize the size of a PR. service/elasticbeanstalk Issues and PRs that pertain to the elasticbeanstalk service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Jan 22, 2020
@bflad bflad removed the needs-triage Waiting for first response or review from a maintainer. label Jan 22, 2020
Copy link
Contributor

@gdavison gdavison left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

--- PASS: TestProvider_impl (0.10s)
--- PASS: TestProvider (0.90s)
--- PASS: TestAccAWSProvider_Region_AwsGovCloudUs (15.35s)
--- PASS: TestAccAWSProvider_Region_AwsCommercial (15.79s)
--- PASS: TestAccAWSProvider_Region_AwsChina (15.55s)
--- PASS: TestAccAWSProvider_IgnoreTagPrefixes_One (16.51s)
--- PASS: TestAccAWSProvider_IgnoreTagPrefixes_Multiple (16.55s)
--- PASS: TestAccAWSProvider_IgnoreTags_Multiple (16.53s)
--- PASS: TestAccAWSProvider_IgnoreTagPrefixes_None (16.96s)
--- PASS: TestAccAWSProvider_IgnoreTags_None (16.92s)
--- PASS: TestAccAWSProvider_IgnoreTags_One (17.18s)
--- PASS: TestAccAWSProvider_Endpoints_Deprecated (17.43s)
--- PASS: TestAccAWSProvider_Endpoints (17.50s)
--- PASS: TestAccAWSBeanstalkEnv_cname_prefix (339.88s)
--- PASS: TestAccAWSBeanstalkEnv_basic (390.06s)
--- PASS: TestAccAWSBeanstalkEnv_settingWithJsonValue (461.63s)
--- PASS: TestAccAWSBeanstalkEnv_resource (570.10s)
--- PASS: TestAccAWSBeanstalkEnv_tier (616.26s)
--- PASS: TestAccAWSBeanstalkEnv_version_label (616.69s)
--- PASS: TestAccAWSBeanstalkEnv_tags (624.32s)
--- PASS: TestAccAWSBeanstalkEnv_config (650.68s)
--- PASS: TestAccAWSBeanstalkEnv_template_change (660.97s)
--- PASS: TestAccAWSBeanstalkEnv_platformArn (790.99s)
--- PASS: TestAccAWSBeanstalkEnv_settings_update (870.54s)

@bflad bflad added this to the v2.48.0 milestone Feb 3, 2020
@bflad bflad merged commit e8a3576 into master Feb 3, 2020
@bflad bflad deleted the t-aws_elastic_beanstalk_environment-test-refactoring branch February 3, 2020 22:02
@ghost
Copy link

ghost commented Feb 7, 2020

This has been released in version 2.48.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented Mar 27, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
service/elasticbeanstalk Issues and PRs that pertain to the elasticbeanstalk service. size/XXL Managed by automation to categorize the size of a PR. technical-debt Addresses areas of the codebase that need refactoring or redesign. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants