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

re-added tests #5049

Merged
merged 2 commits into from
Jul 3, 2018
Merged

re-added tests #5049

merged 2 commits into from
Jul 3, 2018

Conversation

eggsbenjamin
Copy link
Contributor

Unit test got lost when merging with latest master #3316

Re-added.

@ghost ghost added the size/S Managed by automation to categorize the size of a PR. label Jul 2, 2018
@eggsbenjamin
Copy link
Contributor Author

Hey @bflad these tests got lost when I merged with the latest master in #3316 sorry mate. All passing but good to have to prevent regressions.

@bflad bflad added tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/lambda Issues and PRs that pertain to the lambda service. labels Jul 2, 2018
@bflad bflad added this to the v1.26.0 milestone Jul 2, 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.

This is currently not working for me, but it did tease out a Terraform panic that should be fixed

=== RUN   TestAccAWSLambdaAlias_routingconfig
panic: interface conversion: interface {} is map[string]interface {}, not float64

goroutine 5188 [running]:
github.com/terraform-providers/terraform-provider-aws/aws.expandFloat64Map(0xc420ba1c20, 0xc420ba1c20)
	/Users/bflad/go/src/github.com/terraform-providers/terraform-provider-aws/aws/structure.go:799 +0x1cb
github.com/terraform-providers/terraform-provider-aws/aws.expandLambdaAliasRoutingConfiguration(0xc4207d18a0, 0x1, 0x1, 0x339a8c0)
	/Users/bflad/go/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_lambda_alias.go:177 +0xc8
github.com/terraform-providers/terraform-provider-aws/aws.resourceAwsLambdaAliasCreate(0xc4204f1c70, 0x387fda0, 0xc420c34840, 0xc4204f1c70, 0x0)
	/Users/bflad/go/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_lambda_alias.go:76 +0x391

Which can be fixed with:

# inside expandLambdaAliasRoutingConfiguration
	if v, ok := m["additional_version_weights"]; ok {
		aliasRoutingConfiguration.AdditionalVersionWeights = expandFloat64Map(v.(map[string]interface{}))
	}

@@ -78,6 +79,35 @@ func TestAccAWSLambdaAlias_nameupdate(t *testing.T) {
})
}

func TestAccAWSLambdaAlias_routingconfig(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This acceptance test is currently failing for me:

make testacc TEST=./aws TESTARGS='-run=TestAccAWSLambdaAlias_routingconfig'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSLambdaAlias_routingconfig -timeout 120m
=== RUN   TestAccAWSLambdaAlias_routingconfig
--- FAIL: TestAccAWSLambdaAlias_routingconfig (86.12s)
	testing.go:518: Step 0 error: Error applying: 1 error(s) occurred:

		* aws_lambda_alias.lambda_alias_test: 1 error(s) occurred:

		* aws_lambda_alias.lambda_alias_test: Error creating Lambda alias: ResourceNotFoundException: Function not found: arn:aws:lambda:us-west-2:187416307283:function:tf_acc_lambda_func_alias_basic_vmhu4b4h:2
			status code: 404, request id: 8e743c6f-7e17-11e8-81bb-0f6cecc9e91a
FAIL
FAIL	github.com/terraform-providers/terraform-provider-aws/aws	86.161s

Its complaining because version 2 of the Lambda function (newly created in the test) does not exist. I'm not sure its possible to create this configuration without at least two versions of the Lambda function existing already. When trying to set the routing configuration in the existing test configuration to:

  routing_config   = {
    additional_version_weights = {
      "1" = 0.5
    }
  }

I get:

		* aws_lambda_alias.lambda_alias_test: Error creating Lambda alias: InvalidParameterValueException: Invalid function version 1. Function version 1 is already included in routing configuration.
			status code: 400, request id: 6f7ccbcf-7e16-11e8-b729-25d25f4dd472

Copy link
Contributor Author

@eggsbenjamin eggsbenjamin Jul 2, 2018

Choose a reason for hiding this comment

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

@bflad my poor merge resulted in this test getting lost sorry.

It creates multiple versions in order for traffic shifting to be possible and tests that the routing config can be added an removed. Acceptance tests passing.

=== RUN   TestAccAWSLambdaAlias_routingconfig
--- PASS: TestAccAWSLambdaAlias_routingconfig (74.10s)
PASS
ok      github.com/eggsbenjamin/terraform-provider-aws/aws      74.131s

@bflad bflad removed this from the v1.26.0 milestone Jul 2, 2018
@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 Jul 2, 2018
@bflad bflad added this to the v1.26.0 milestone Jul 3, 2018
@bflad bflad added bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. and removed tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Jul 3, 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.

Thanks so much @eggsbenjamin!! Looks good. 🚀

make testacc TEST=./aws TESTARGS='-run=TestAccAWSLambdaAlias'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSLambdaAlias -timeout 120m
=== RUN   TestAccAWSLambdaAlias_basic
--- PASS: TestAccAWSLambdaAlias_basic (33.15s)
=== RUN   TestAccAWSLambdaAlias_nameupdate
--- PASS: TestAccAWSLambdaAlias_nameupdate (41.00s)
=== RUN   TestAccAWSLambdaAlias_routingconfig
--- PASS: TestAccAWSLambdaAlias_routingconfig (51.19s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	125.391s

@@ -190,8 +190,8 @@ func expandLambdaAliasRoutingConfiguration(l []interface{}) *lambda.AliasRouting

m := l[0].(map[string]interface{})

if _, ok := m["additional_version_weights"]; ok {
aliasRoutingConfiguration.AdditionalVersionWeights = expandFloat64Map(m)
if v, ok := m["additional_version_weights"]; ok {
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for fixing this! 💯

@bflad bflad merged commit f41c5c0 into hashicorp:master Jul 3, 2018
@ghost
Copy link

ghost commented Apr 4, 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 4, 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. crash Results from or addresses a Terraform crash or kernel panic. service/lambda Issues and PRs that pertain to the lambda service. size/M Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants