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

WIP: fix #6071 #6085

Merged
merged 1 commit into from
Oct 8, 2018
Merged

WIP: fix #6071 #6085

merged 1 commit into from
Oct 8, 2018

Conversation

euclideansphere
Copy link
Contributor

Fixes #6071

Changes proposed in this pull request:

  • return nil if the job queue cannot be found on read instead of erroring (which prevents a proper destroy workflow in some scenarios).

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccAWSAvailabilityZones'

...

(WIP - currently don't have access to an AWS account with billing enabled to run/fix/create acceptance tests.).

@ghost ghost added size/XS Managed by automation to categorize the size of a PR. service/batch Issues and PRs that pertain to the batch service. labels Oct 6, 2018
@bflad bflad added the bug Addresses a defect in current functionality. label Oct 8, 2018
@bflad bflad added this to the v1.40.0 milestone Oct 8, 2018
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

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

Hi @euclideansphere 👋 Glad to see you were able to submit this (even without the testing)! I was able to write up the acceptance test code below and everything looks great. 🚀

func TestAccAWSBatchJobQueue_disappears(t *testing.T) {
	var jobQueue1 batch.JobQueueDetail
	resourceName := "aws_batch_job_queue.test_queue"
	rInt := acctest.RandInt()

	resource.Test(t, resource.TestCase{
		PreCheck:     func() { testAccPreCheck(t) },
		Providers:    testAccProviders,
		CheckDestroy: testAccCheckAWSLaunchTemplateDestroy,
		Steps: []resource.TestStep{
			{
				Config: fmt.Sprintf(testAccBatchJobQueueBasic, rInt),
				Check: resource.ComposeTestCheckFunc(
					testAccCheckBatchJobQueueExists(resourceName, &jobQueue1),
					testAccCheckBatchJobQueueDisappears(&jobQueue1),
				),
				ExpectNonEmptyPlan: true,
			},
		},
	})
}

func testAccCheckBatchJobQueueDisappears(jobQueue *batch.JobQueueDetail) resource.TestCheckFunc {
	return func(s *terraform.State) error {
		conn := testAccProvider.Meta().(*AWSClient).batchconn
		name := aws.StringValue(jobQueue.JobQueueName)

		err := disableBatchJobQueue(name, 10*time.Minute, conn)
		if err != nil {
			return fmt.Errorf("error disabling Batch Job Queue (%s): %s", name, err)
		}

		return deleteBatchJobQueue(name, 10*time.Minute, conn)
	}
}

Previously:

--- FAIL: TestAccAWSBatchJobQueue_disappears (60.01s)
    testing.go:527: Step 0 error: Error on follow-up refresh: 1 error occurred:
        	* aws_batch_job_queue.test_queue: 1 error occurred:
        	* aws_batch_job_queue.test_queue: aws_batch_job_queue.test_queue: Error reading JobQueue: "%!s(<nil>)"

Output from acceptance testing:

$ make testacc TEST=./aws TESTARGS='-run=TestAccAWSBatchJobQueue_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSBatchJobQueue_ -timeout 120m
=== RUN   TestAccAWSBatchJobQueue_basic
--- PASS: TestAccAWSBatchJobQueue_basic (80.89s)
=== RUN   TestAccAWSBatchJobQueue_disappears
--- PASS: TestAccAWSBatchJobQueue_disappears (79.91s)
=== RUN   TestAccAWSBatchJobQueue_update
--- PASS: TestAccAWSBatchJobQueue_update (116.97s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	278.513s

@bflad bflad merged commit e9b828b into hashicorp:master Oct 8, 2018
bflad added a commit that referenced this pull request Oct 8, 2018
@bflad
Copy link
Contributor

bflad commented Oct 10, 2018

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

@ghost
Copy link

ghost commented Apr 2, 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 Apr 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/batch Issues and PRs that pertain to the batch service. size/XS Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error reading JobQueue: "%!s(<nil>)"
2 participants