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

Improve region validation, only print log message in create cluster command #300

Merged
merged 1 commit into from
Nov 4, 2018

Conversation

errordeveloper
Copy link
Contributor

Description

Improve region validation, only print log message in create cluster command

Checklist

  • Code compiles correctly (i.e make build)
  • All tests passing (i.e. make test)

EKSRegionUSWest2,
EKSRegionUSEast1,
EKSRegionEUWest1,
func SupportedRegions() []string {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As you cannot declare const []string, we prefer a function here. The previous version was written before we've adopted this convention. Just FYI :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Noted! 🔥

Copy link
Contributor

@gotjosh gotjosh left a comment

Choose a reason for hiding this comment

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

Looks good from this side of fence. 🎉 🥇

Stricly for my understanding, what's the policy on tests? Noticed we don't have any for either of these files. Altough I recognise something like IsSupportedRegion is quite trivial, my brain was expecting a test for it.

@@ -248,7 +248,6 @@ func newSession(clusterConfig *api.ClusterConfig, endpoint string, credentials *
}
}

logger.Info("using region %s", clusterConfig.Region)
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 - I noticed this as part of my previous change but decided to leave it out as I wasn't really sure if it was relevant for other calls. Seems like it is when we are actually creating the cluster.

EKSRegionUSWest2,
EKSRegionUSEast1,
EKSRegionEUWest1,
func SupportedRegions() []string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Noted! 🔥

@errordeveloper
Copy link
Contributor Author

errordeveloper commented Nov 3, 2018

Stricly for my understanding, what's the policy on tests? Noticed we don't have any for either of these files.

Good question 👍. It'd be nice to have a clear policy stated somewhere. At the moment we avoid trivial tests, and favour testing critical code path and integration tests are getting into a shape, but need more love.

Integration tests live in integration/creategetdelete_test.go. These will need to get expanded in several different ways, but we've not had a chance to think it trough just yet.

Packages like pkg/az and pkg/cloudconfig have an okay test coverage, and those are sort of clean and simple packages, each of which does one very specific thing. Packages like pkg/eks and pkg/eks/api are much broader, but also largely trivial (except from a few funcs, like eks.New and it's newSession helper, which largely rely on the AWS SDK and will need some mocking, but I'm not sure if it'd worse it).

Most of critical path test are in pkg/cfn/builder/api_test.go, and those had been growing, but also getting a little wild and surely in need of a cleanup.

What I think would be very nice is a kind of introspective integration test, where cluster would be created in stages and in the process of that several checks would be done. Perhaps we can do this in the current integration suite in a way, but that may need new code that fetches state from CloudFormation etc, as we exec eksctl and thereby don't have access to internal structures unless we over-engineer some kind of channel to it... However, some kind of dry-run mode that spews out CloudFormation definitions maybe a thing to think about, that could be useful for this and in few other cases, but that may need review of certain assumptions, which maybe a good thing anyway. What I'm thinking of is the coupling of cluster and nodegroup stacks, I don't think we can create nodegroup stack template without having a live cluster (or a mock of it), which is fine for most uses, but obviously isn't ideal for proper dry-run mode.

Anyway, a bit of a brain dump, but hopefully still useful. So to sum up, I'd rather we work on end-to-end testing with introspection, then test trivial units in a race for some coverage figure. Hope it makes sense :)

@errordeveloper errordeveloper merged commit 186610b into master Nov 4, 2018
@errordeveloper errordeveloper deleted the region-validation branch November 6, 2018 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants