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

resource/aws_dx_private_virtual_interface: Update resource to support MTU param #6141

Merged
merged 18 commits into from
Oct 30, 2018

Conversation

slapula
Copy link
Contributor

@slapula slapula commented Oct 13, 2018

Fixes #6136

Changes proposed in this pull request:

  • Updated aws_dx_private_virtual_interface resource to support new MTU parameter

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccAwsDxPrivateVirtualInterface_basic'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -run=TestAccAwsDxPrivateVirtualInterface_basic -timeout 120m
?   	github.com/terraform-providers/terraform-provider-aws	[no test files]
=== RUN   TestAccAwsDxPrivateVirtualInterface_basic
--- SKIP: TestAccAwsDxPrivateVirtualInterface_basic (0.00s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	0.029s

@ghost ghost added size/XS Managed by automation to categorize the size of a PR. documentation Introduces or discusses updates to documentation. service/directconnect Issues and PRs that pertain to the directconnect service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Oct 13, 2018
@ewbankkit
Copy link
Contributor

Please add verification of the mtu and jumbo_frame_enabled attributes to the acceptance tests; something like:

resource.TestCheckResourceAttr("aws_dx_private_virtual_interface.foo", "mtu", "9001"),
resource.TestCheckResourceAttr("aws_dx_private_virtual_interface.foo", "jumbo_frame_enabled", "1"),

Computed: true,
ForceNew: true,
},
"jumbo_frame_enabled": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick - In the documentation the feature is called Jumbo Frames. For consistency I suggest naming the attribute jumbo_frames_enabled or jumbo_frame_capable (to match the API).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, I meant to have this match the API but I just spaced on it. This will be corrected in my next commit.

@ghost ghost added size/S Managed by automation to categorize the size of a PR. and removed size/XS Managed by automation to categorize the size of a PR. labels Oct 13, 2018
@@ -84,6 +84,16 @@ func resourceAwsDxPrivateVirtualInterface() *schema.Resource {
Computed: true,
ForceNew: true,
},
"mtu": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Type: schema.TypeInt,
Default: 1500,
Optional: true,
ForceNew: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

@ghost ghost added size/M Managed by automation to categorize the size of a PR. and removed size/S Managed by automation to categorize the size of a PR. labels Oct 15, 2018
@slapula
Copy link
Contributor Author

slapula commented Oct 15, 2018

@ewbankkit I believe I have addressed your comments with this latest commit. I ran out of time today to test and write tests so I will likely circle back to that tomorrow or Tuesday. It looks to me that my changes "should work" so if you have spare cycles to test before I get to it please feel free.

@@ -219,3 +235,22 @@ func dxPrivateVirtualInterfaceWaitUntilAvailable(d *schema.ResourceData, conn *d
directconnect.VirtualInterfaceStateDown,
})
}

func IntInSlice(valid []int) schema.SchemaValidateFunc {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Again, haven't fully tested this yet but would this be a good candidate to move to the core validation library?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I think it would but given the churn in the codebase with v0.12 it is probably best to wait until that settles down.

Copy link
Contributor

@ewbankkit ewbankkit Oct 19, 2018

Choose a reason for hiding this comment

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

Probably better to move this to validators.go and rename it to something like validateIntInSlice and add a unit test to validators_test.go.

@ewbankkit
Copy link
Contributor

OK, I'll look at testing this week.

@ewbankkit
Copy link
Contributor

ewbankkit commented Oct 21, 2018

@slapula I made a couple of mainly cosmetic changes and pushed to my slapula-dx-private-virtual-interface-mtu branch:

  • According to the documentation, after an update is made to the virtual interface its state will be pending until the update is complete so I added an Update value to the schema's Timeouts and added a call to dxPrivateVirtualInterfaceWaitUntilAvailable after calling the update API (this changed the signature to a function shared by all the VIF attributes so there was some cascading call site changes)
  • Simplified your acceptance tests - No need to do the MTU update in TestAccAwsDxPrivateVirtualInterface_basic, just do it in TestAccAwsDxPrivateVirtualInterface_mtuUpdate
  • Minor documentation tweaks

I should be able to run the acceptance tests in the next couple of days - I'll make any modifications on that branch and you can then merge back.

@ewbankkit
Copy link
Contributor

@slapula I took your latest code (fixed a merge error) and ran acceptance tests for the new test case.
With one minor change

resource.TestCheckResourceAttr("aws_dx_private_virtual_interface.foo", "jumbo_frame_capable", "true")
->
resource.TestCheckResourceAttr("aws_dx_private_virtual_interface.foo", "jumbo_frame_capable", "1")

the test passes:

$ DX_CONNECTION_ID=dxcon-xxxxxxxx AWS_DEFAULT_REGION=us-east-1 make testacc TESTARGS='-run=TestAccAwsDxPrivateVirtualInterface_mtuUpdate'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -parallel 20 -run=TestAccAwsDxPrivateVirtualInterface_mtuUpdate -timeout 120m
?   	github.com/terraform-providers/terraform-provider-aws	[no test files]
=== RUN   TestAccAwsDxPrivateVirtualInterface_mtuUpdate
--- PASS: TestAccAwsDxPrivateVirtualInterface_mtuUpdate (1252.51s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	1270.641s

If you merge the latest changes from https://github.com/ewbankkit/terraform-provider-aws/tree/slapula-dx-private-virtual-interface-mtu I can the run all the aws_dx_private_virtual_interface acceptance tests on the complete code.

@ghost ghost added size/L Managed by automation to categorize the size of a PR. and removed size/M Managed by automation to categorize the size of a PR. labels Oct 22, 2018
@slapula
Copy link
Contributor Author

slapula commented Oct 22, 2018

@ewbankkit Thanks for the help on this! I totally spaced on the Update and WaitUntilAvailable calls so good catch. Anyway, I have your changes pulled in and Travis is green. If we're good here, I can start porting these changes over to #6142.

testAccCheckAwsDxPrivateVirtualInterfaceExists("aws_dx_private_virtual_interface.foo"),
resource.TestCheckResourceAttr("aws_dx_private_virtual_interface.foo", "name", vifName),
resource.TestCheckResourceAttr("aws_dx_private_virtual_interface.foo", "mtu", "1500"),
resource.TestCheckResourceAttr("aws_dx_private_virtual_interface.foo", "jumbo_frame_capable", "1"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to change this to

resource.TestCheckResourceAttr("aws_dx_private_virtual_interface.foo", "jumbo_frame_capable", "true"),

or else will get errors like

$ DX_CONNECTION_ID=dxcon-xxxxxxxx AWS_DEFAULT_REGION=us-east-1 make testacc TESTARGS='-run=TestAccAwsDxPrivateVirtualInterface_mtuUpdate'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -parallel 20 -run=TestAccAwsDxPrivateVirtualInterface_mtuUpdate -timeout 120m
?   	github.com/terraform-providers/terraform-provider-aws	[no test files]
=== RUN   TestAccAwsDxPrivateVirtualInterface_mtuUpdate
--- FAIL: TestAccAwsDxPrivateVirtualInterface_mtuUpdate (667.21s)
    testing.go:538: Step 0 error: Check failed: Check 4/4 error: aws_dx_private_virtual_interface.foo: Attribute 'jumbo_frame_capable' expected "1", got "true"
FAIL
FAIL	github.com/terraform-providers/terraform-provider-aws/aws	668.068s
make: *** [testacc] Error 1

@ewbankkit
Copy link
Contributor

@slapula Left a comment on changing 1 to true in the new acceptance test, once that's committed I can run the full acceptance tests. Yes, makes sense to merge the changes into the other PR.

@slapula
Copy link
Contributor Author

slapula commented Oct 23, 2018

Oh ok, I misread your previous comment. I'll update that in a moment.

@ewbankkit
Copy link
Contributor

OK, tested the code (serially as there is a problem with running the acceptance tests in parallel, #6244, which shouldn't block this PR).

$ git rev-parse HEAD
da69517c8d918611b8ab9599b7e82ee1445c8be4
$ DX_CONNECTION_ID=dxcon-xxxxxxxx AWS_DEFAULT_REGION=us-east-1 make testacc TESTARGS='-run=TestAccAwsDxPrivateVirtualInterface_mtuUpdate'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -parallel 20 -run=TestAccAwsDxPrivateVirtualInterface_mtuUpdate -timeout 120m
?   	github.com/terraform-providers/terraform-provider-aws	[no test files]
=== RUN   TestAccAwsDxPrivateVirtualInterface_mtuUpdate
--- PASS: TestAccAwsDxPrivateVirtualInterface_mtuUpdate (1252.51s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	(cached)
$ DX_CONNECTION_ID=dxcon-xxxxxxxx AWS_DEFAULT_REGION=us-east-1 make testacc TESTARGS='-run=TestAccAwsDxPrivateVirtualInterface_basic'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -parallel 20 -run=TestAccAwsDxPrivateVirtualInterface_basic -timeout 120m
?   	github.com/terraform-providers/terraform-provider-aws	[no test files]
=== RUN   TestAccAwsDxPrivateVirtualInterface_basic
=== PAUSE TestAccAwsDxPrivateVirtualInterface_basic
=== CONT  TestAccAwsDxPrivateVirtualInterface_basic
--- PASS: TestAccAwsDxPrivateVirtualInterface_basic (409.98s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	410.875s
$ DX_CONNECTION_ID=dxcon-xxxxxxxx AWS_DEFAULT_REGION=us-east-1 make testacc TESTARGS='-run=TestAccAwsDxPrivateVirtualInterface_dxGateway'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -parallel 20 -run=TestAccAwsDxPrivateVirtualInterface_dxGateway -timeout 120m
?   	github.com/terraform-providers/terraform-provider-aws	[no test files]
=== RUN   TestAccAwsDxPrivateVirtualInterface_dxGateway
=== PAUSE TestAccAwsDxPrivateVirtualInterface_dxGateway
=== CONT  TestAccAwsDxPrivateVirtualInterface_dxGateway
--- PASS: TestAccAwsDxPrivateVirtualInterface_dxGateway (589.50s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	590.384s

@ewbankkit
Copy link
Contributor

This PR is now ready for review.

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.

LGTM, thanks @slapula and @ewbankkit! 🚀

@@ -97,17 +115,17 @@ func dxVirtualInterfaceStateRefresh(conn *directconnect.DirectConnect, vifId str
}
}

func dxVirtualInterfaceWaitUntilAvailable(d *schema.ResourceData, conn *directconnect.DirectConnect, pending, target []string) error {
func dxVirtualInterfaceWaitUntilAvailable(conn *directconnect.DirectConnect, vifId string, timeout time.Duration, pending, target []string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

😍

@bflad bflad added this to the v1.42.0 milestone Oct 30, 2018
@bflad bflad merged commit 27d3c7c into hashicorp:master Oct 30, 2018
bflad added a commit that referenced this pull request Oct 30, 2018
@bflad
Copy link
Contributor

bflad commented Nov 1, 2018

This has been released in version 1.42.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
documentation Introduces or discusses updates to documentation. service/directconnect Issues and PRs that pertain to the directconnect service. size/L Managed by automation to categorize the size of a PR. 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.

Feature request: Direct Connect support for changing network MTU
3 participants