Open YakDriver opened 7 months ago
Voting for Prioritization
Volunteering to Work on This Issue
@YakDriver - I'm curious if there's been any development on this topic. I was just updating some acceptance tests for Neptune this week and noticed the few places were we hard coded engine versions and instance types.
As it pertains to our needs, we have some tests that validate in-place upgrades for both minor engine version upgrades and major engine version upgrades. While there's an API to get currently available engine versions (), there's not an API for getting a list of major or minor engine versions. And some of the tests we need to execute need to provide engine versions that are sequential (going from major engine version 1.2 to 1.3, as an example). So I'm trying to think through the best way to dynamically address those particular tests. I can certainly create a data source that pulls all available versions and perhaps returns a latest_major_version
parameter. But wondering if this has been implemented elsewhere before proceeding.
Description
Collaborate on this initiative and contribute any insights or suggestions for refinement!
TL;DR: Tests using hardcoded values like engine versions, AMIs, and compute types break with AWS updates, demanding maintenance and concealing genuine issues. To mitigate this, adopting dynamic lookup via data sources is crucial to minimize reliance on hardcoded values.
Our acceptance tests have become a source of ongoing maintenance challenges and obscure underlying issues. At present, numerous tests depend on hardcoded, yet variable AWS-defined parameters, including versions and instance classes. These hardcoded values frequently define arguments such as
engine_type
,host_type
,instance_class
,instance_type
,node_type
,ami
, andengine_version
.We need to mitigate these challenges by implementing dynamic lookup mechanisms using data sources within our tests. By dynamically retrieving information, such as versions and instance classes, during test execution, we can ensure that our tests remain resilient to changes in the environment and are not reliant on hardcoded dependencies.
This approach offers several benefits:
Incorporating dynamic lookup mechanisms into our testing procedures will require initial investment and adjustments to our existing workflows. However, the long-term benefits in terms of improved test reliability and reduced maintenance overhead far outweigh the initial effort.
Fixing
Follow these general steps to fix hardcoded values in acceptance tests that are based on AWS-changeable information, such as compute, version, or AMI values. Some commonly hardcoded arguments are
engine_type
,host_type
,instance_class
,instance_type
,node_type
,ami
, andengine_version
but there may be others.aws_rds_engine_version
andaws_rds_orderable_db_instance
, which facilitate searching for versions and classes. If a suitable data source is found, proceed to step 4. If not, proceed to step 2. If a data source exists but lacks the necessary information or search customization, proceed to step 3.DescribeOrderableDBInstanceOptions
, which furnishes dynamic and current information about RDS instances. If the AWS API doesn't provide the dynamic information we need, escalate the matter by opening an AWS support ticket and engaging with AWS engineers to incorporate the required functionality.aws_rds_orderable_db_instance
data source within the Terraform AWS provider, which leverages theDescribeOrderableDBInstanceOptions
SDK function. While AWS offers certain filtering options like restricting results to a specific database engine, additional filtering requirements, such as identifying instances supporting RDS clusters, necessitates implementation on the provider side.For example, this data source configuration finds an RDS DB instance that has
io1
storage, supports IOPS, and supports clusters.NOTE: This configuration would be even better if it didn't have a hardcoded lists of preferred instance classes. Since instance classes vary significantly in price, we don't want to let the data source choose one at random since that could cause huge bills for running tests. An ideal solution would be another data source that would provide a list of instance class options, sorted by price.
Then we use the information from the data source to inform the creation of resources:
Potentially affected services
Based on a quick look in the provider, here is a starting point for services with potential problems. (Some of the services are using resources from other services in their tests.) AWS updates some services, such as changing version and compute options, more than others. Regardless, we should attempt to avoid all AWS-mutable hardcoded values.
References
35698