-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
resource/aws_batch_job_queue: Prevent panic when ComputeEnvironmentOrder is updated outside Terraform #12632
Conversation
…der is updated outside Terraform Reference: #8083 Also modernizes the testing. Previously: ``` === CONT TestAccAWSBatchJobQueue_ComputeEnvironments_ExternalOrderUpdate panic: runtime error: index out of range [1] with length 1 goroutine 1306 [running]: github.com/terraform-providers/terraform-provider-aws/aws.resourceAwsBatchJobQueueRead(0xc001117c70, 0x62e4cc0, 0xc0003bcf00, 0xc001117c70, 0x0) /Users/bflad/src/github.com/terraform-providers/terraform-provider-aws-deux/aws/resource_aws_batch_job_queue.go:110 +0x55a github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc0005df580, 0xc00104ae60, 0x62e4cc0, 0xc0003bcf00, 0xc000c7ec30, 0x0, 0x0) /Users/bflad/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.8.0/helper/schema/resource.go:455 +0x119 ``` Output from acceptance testing: ``` --- PASS: TestAccAWSBatchJobQueue_basic (85.28s) --- PASS: TestAccAWSBatchJobQueue_disappears (87.06s) --- PASS: TestAccAWSBatchJobQueue_ComputeEnvironments_ExternalOrderUpdate (98.67s) --- PASS: TestAccAWSBatchJobQueue_Priority (120.72s) --- PASS: TestAccAWSBatchJobQueue_State (127.15s) ```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
--- PASS: TestAccAWSBatchJobQueue_ComputeEnvironments_ExternalOrderUpdate (79.65s)
--- PASS: TestAccAWSBatchJobQueue_disappears (79.84s)
--- PASS: TestAccAWSBatchJobQueue_basic (82.40s)
--- PASS: TestAccAWSBatchJobQueue_Priority (96.07s)
--- PASS: TestAccAWSBatchJobQueue_State (96.14s)
resourceName := "aws_batch_job_queue.test_queue" | ||
// Reference: https://github.com/terraform-providers/terraform-provider-aws/issues/8083 | ||
func TestAccAWSBatchJobQueue_ComputeEnvironments_ExternalOrderUpdate(t *testing.T) { | ||
var jobQueue1 batch.JobQueueDetail |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there's only one job queue involved in this test, does it need the 1
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I find appending the number from the start helps reduce code churn should the test be extended to need multiple later on, but we'll want to setup something to enforce the naming of these if its a concern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also do something like always require it to be a slice, e.g. var jobQueues []*batch.JobQueueDetail
, then adjust ...Exists
functions to append and ones reading the information like ...Recreated
functions to require a two index parameters, e.g. ...Recreated(jobQueues, 0, 1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even better, honestly, would be not handling the API object at all in most cases. Its typically added now to avoid the churn in case its needed later on, but we could switch up the testing a little to enable generic versions of the various functions like ...Recreated
/...NotRecreated
that use state attributes across TestStep
or more generically understands the apply difference (update vs destroy/create). It'd be best if the SDK provided that functionality though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for all the comments here. 😄 Here's a reference implementation to my previous comment: hashicorp/terraform-plugin-sdk#329
This has been released in version 2.60.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! |
…der is updated outside Terraform (hashicorp#12632) Reference: hashicorp#8083 Also modernizes the testing. Previously: ``` === CONT TestAccAWSBatchJobQueue_ComputeEnvironments_ExternalOrderUpdate panic: runtime error: index out of range [1] with length 1 goroutine 1306 [running]: github.com/terraform-providers/terraform-provider-aws/aws.resourceAwsBatchJobQueueRead(0xc001117c70, 0x62e4cc0, 0xc0003bcf00, 0xc001117c70, 0x0) /Users/bflad/src/github.com/terraform-providers/terraform-provider-aws-deux/aws/resource_aws_batch_job_queue.go:110 +0x55a github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc0005df580, 0xc00104ae60, 0x62e4cc0, 0xc0003bcf00, 0xc000c7ec30, 0x0, 0x0) /Users/bflad/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.8.0/helper/schema/resource.go:455 +0x119 ``` Output from acceptance testing: ``` --- PASS: TestAccAWSBatchJobQueue_basic (85.28s) --- PASS: TestAccAWSBatchJobQueue_disappears (87.06s) --- PASS: TestAccAWSBatchJobQueue_ComputeEnvironments_ExternalOrderUpdate (98.67s) --- PASS: TestAccAWSBatchJobQueue_Priority (120.72s) --- PASS: TestAccAWSBatchJobQueue_State (127.15s) ```
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! |
Community Note
Closes #8083
Release note for CHANGELOG:
Also modernizes the testing.
Previously:
Output from acceptance testing: