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

add support for route53 health check #259

Merged
merged 1 commit into from
Feb 17, 2021
Merged

Conversation

moadibfr
Copy link
Contributor

Q A
πŸ› Bug fix? no
πŸš€ New feature? yes
⚠ Deprecations? no
❌ BC Break no
πŸ”— Related issues #211
❓ Documentation yes

Description

add support for route53 health check

@moadibfr moadibfr requested a review from a team as a code owner February 15, 2021 13:56
@codecov
Copy link

codecov bot commented Feb 15, 2021

Codecov Report

Merging #259 (f18ce79) into main (cfcde7f) will increase coverage by 0.04%.
The diff coverage is 72.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #259      +/-   ##
==========================================
+ Coverage   69.21%   69.25%   +0.04%     
==========================================
  Files         229      234       +5     
  Lines        5068     5143      +75     
==========================================
+ Hits         3508     3562      +54     
- Misses       1279     1295      +16     
- Partials      281      286       +5     
Impacted Files Coverage Ξ”
pkg/remote/aws/init.go 0.00% <0.00%> (ΓΈ)
pkg/remote/aws/route53_health_check_supplier.go 58.33% <58.33%> (ΓΈ)
pkg/remote/aws/repository/route53_repository.go 63.63% <63.63%> (ΓΈ)
.../deserializer/route53_health_check_deserializer.go 64.28% <64.28%> (ΓΈ)
pkg/resource/aws/aws_route53_health_check_ext.go 95.45% <95.45%> (ΓΈ)
pkg/iac/deserializers.go 100.00% <100.00%> (ΓΈ)
pkg/resource/aws/aws_route53_health_check.go 100.00% <100.00%> (ΓΈ)
... and 2 more

"dynamodb:DescribeContinuousBackups"
"dynamodb:DescribeContinuousBackups",
"route53:ListHealthChecks",
"route53:GetHealthCheck"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we try to keep these permissions in order and put the two new route53 policies just next to the others. Thanks :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok I'll group them by service

go.sum Outdated
@@ -126,6 +126,7 @@ github.com/aws/aws-sdk-go v1.30.12/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZve
github.com/aws/aws-sdk-go v1.31.9/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0=
github.com/aws/aws-sdk-go v1.34.2 h1:9vCknCdTAmmV4ht7lPuda7aJXzllXwEQyCMZKJHjBrM=
github.com/aws/aws-sdk-go v1.34.2/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0=
github.com/aws/aws-sdk-go v1.37.8 h1:9kywcbuz6vQuTf+FD+U7FshafrHzmqUCjgAEiLuIJ8U=
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this mandatory ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm not sure I'll try without that

},
{
test: "cannot list health check",
dirName: "route53_health_check_list_error",
Copy link
Contributor

@wbeuil wbeuil Feb 15, 2021

Choose a reason for hiding this comment

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

Do we want to keep 2 empty results since the first test has the same result ?

Copy link
Contributor

@eliecharra eliecharra Feb 15, 2021

Choose a reason for hiding this comment

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

We are testing error behavior there it's not the same think that testing no results are returned from AWS side

Copy link
Contributor

@wbeuil wbeuil Feb 15, 2021

Choose a reason for hiding this comment

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

From the product point of view it is indeed not the same, but as of the mocked golden file reader we return a slice of []resource.Resource which here is an empty array.

I can easily see a future where we could want to test other errors and where with this logic the number of useless results can only increase exponentially.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't get your point, we need this test to test theses lines of code :

image

Copy link
Contributor

Choose a reason for hiding this comment

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

You could test this line like this:

{
  test:    "cannot list health check",
  dirName: "route53_health_check_empty",
  mocks: func(client *mocks.Route53Repository) {
    client.On("ListAllHealthChecks").Return(nil, awserr.NewRequestFailure(nil, 403, ""))
  },
  err: remoteerror.NewResourceEnumerationError(awserr.NewRequestFailure(nil, 403, ""), resourceaws.AwsRoute53HealthCheckResourceType),
}

Look at the dirName here. I reused the one with empty results so that we don't need to create another empty results but with different naming. I did it like that in SQS.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

May I suggest that we stop at the error testing if it fail so we use no folder at all for error testing ? it's not really useful to test the list values and it's not mandatory that this return an empty list.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok it cannot work as we need the schema. I think we should find a way to use only one schema if we want to save space I'm not a really big fan of generating golden file for a test and using them for another...

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm good with that, we should find a way to reuse schema

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok then let's break it into 2 PRs, this one and mine on cloudfront will still have this kind of different folder with its own results and schema. Another PR will deal with a new architecture where we use only one schema per resource. Are you ok with that ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for now i reused empty test folder like you asked, But yeah we should do a dedicated pr to refactor this

Copy link
Contributor

@eliecharra eliecharra left a comment

Choose a reason for hiding this comment

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

Maybe this is not the right place to rename this file

image

pkg/resource/aws/aws_route53_health_check_test.go Outdated Show resolved Hide resolved
pkg/resource/aws/aws_route53_health_check_test.go Outdated Show resolved Hide resolved
pkg/resource/aws/aws_route53_health_check_ext_test.go Outdated Show resolved Hide resolved
@moadibfr moadibfr force-pushed the fea/route53_health_check branch 4 times, most recently from 69eadc0 to 9e32da4 Compare February 15, 2021 20:12
Copy link
Contributor

@eliecharra eliecharra left a comment

Choose a reason for hiding this comment

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

⚠️ You have removed pkg/resource/aws/aws_security_group_rule_test.go

pkg/remote/aws/route53_health_check_supplier_test.go Outdated Show resolved Hide resolved
fakeClient := mocks.Route53Repository{}
c.mocks(&fakeClient)
provider := testmocks.NewMockedGoldenTFProvider(c.dirName, providerLibrary.Provider(terraform.AWS), shouldUpdate)
SNSTopicDeserializer := awsdeserializer.NewRoute53HealthCheckDeserializer()
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you just change here the naming of the variable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🀦

eliecharra
eliecharra previously approved these changes Feb 16, 2021
@eliecharra eliecharra added the kind/enhancement New feature or improvement label Feb 16, 2021
@moadibfr moadibfr merged commit 0410d8b into main Feb 17, 2021
@moadibfr moadibfr deleted the fea/route53_health_check branch February 17, 2021 09:02
@eliecharra eliecharra linked an issue Feb 18, 2021 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for aws_route53_health_check
3 participants