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

Update testing to new approach #33

Merged
merged 1 commit into from
Oct 8, 2019

Conversation

ivankorn
Copy link
Contributor

@ivankorn ivankorn commented Sep 23, 2019

Fixes #29

  • Migrated to Cloud Build as documented here.

Please note following deviations from migration document:

  • exact list of roles on the project (and other resources) has been granted instead of owner
  • for_each instead of count.index is used to create a number of instances of resource.
  • pause of 120 sec (determined experimentally) is used to wait for APIs to get enabled as a workaround for the provider issue
  • pause of 120 sec (determined experimentally) is used to wait for permissions to get granted as a workaround for the provider issue

test/setup/main.tf Outdated Show resolved Hide resolved
version = "~> 3.0"

name = "ci-{{ cookiecutter.module_name|replace('-', '_') }}"
random_project_id = "true"
Copy link

Choose a reason for hiding this comment

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

It boolean variable, so quotes should be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ingwarr, thank you for review! Fixed

Copy link
Contributor

Choose a reason for hiding this comment

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

Except you didn't fix it...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good eye, @morgante! Fixed
But actually, shouldn't we raise this in the module that came from ?
Thanks!

@ivankorn
Copy link
Contributor Author

CI is green, RP got 2 approvals. @morgante, @aaron-lane, would you mind reviewing it please?

Please note following deviations from migration document:

  • exact list of roles on the project (and other resources) has been granted instead of owner
  • for_each instead of count.index is used to create a number of instances of resource.
  • pause of 120 sec (determined experimentally) is used to wait for APIs to get enabled as a workaround for the provider issue
  • pause of 120 sec (determined experimentally) is used to wait for permissions to get granted as a workaround for the provider issue

image

@ivankorn ivankorn marked this pull request as ready for review September 27, 2019 14:55
Copy link
Contributor

@morgante morgante left a comment

Choose a reason for hiding this comment

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

Overall looking good, some minor feedback.

test/setup/make_source.sh Outdated Show resolved Hide resolved
test/setup/main.tf Show resolved Hide resolved
version = "~> 3.0"

name = "ci-{{ cookiecutter.module_name|replace('-', '_') }}"
random_project_id = "true"
Copy link
Contributor

Choose a reason for hiding this comment

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

Except you didn't fix it...

CONTRIBUTING.md Outdated Show resolved Hide resolved

# shellcheck disable=SC2086,SC2154
{ echo "export TF_VAR_project_id='$project_id'"; \
echo "export TF_VAR_parent_resource_project='$project_id'"; \
Copy link
Contributor

Choose a reason for hiding this comment

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

We shouldn't need to output this twice. Just update the tests to take project_id as the input variable name.

Copy link
Contributor Author

@ivankorn ivankorn Sep 27, 2019

Choose a reason for hiding this comment

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

@morgante, should we, what if in some cases it's different ?

Copy link
Contributor

Choose a reason for hiding this comment

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

It should never be different.

]

log_export_billing_account_roles = [
# Required to associate billing accounts to new projects
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure we need this? The tests themselves shouldn't be creating any new projects (the project creation happens in the prepare step).

Copy link
Contributor Author

@ivankorn ivankorn Sep 27, 2019

Choose a reason for hiding this comment

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

@morgante, the prepare creates project while the computed values tests is doing association to billing account which requires the billing user and the project creator roles for the tests them-self.

"roles/logging.configWriter",

# Required to associate billing accounts to new projects
"roles/billing.projectManager",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why needed? We don't create new projects in fixtures.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The prepare creates project while the computed values tests is doing association to billing account


log_export_folder_roles = [
# Required to spin up a project within the log_export folder
"roles/resourcemanager.projectCreator",
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, where are we creating a new project besides in the setup phase?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is meant for the setup phase so the required project for running tests can be created.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, so that's not required. Please try to understand how this actually executes instead of putting in unnecessary permissions.

test/setup is applied using the Cloud Build service account. So permissions needed only to run the setup stage do NOT need to be added here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@morgante, sorry for confusion. I just double-checked that with this force-push. The permission is required for tests them-self for the computed values test suite and can't take it out.
It's used here
image

Copy link
Contributor Author

@ivankorn ivankorn left a comment

Choose a reason for hiding this comment

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

@morgante thank you for in-depth review! Fixed and commented all the comments!


log_export_folder_roles = [
# Required to spin up a project within the log_export folder
"roles/resourcemanager.projectCreator",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is meant for the setup phase so the required project for running tests can be created.


# shellcheck disable=SC2086,SC2154
{ echo "export TF_VAR_project_id='$project_id'"; \
echo "export TF_VAR_parent_resource_project='$project_id'"; \
Copy link
Contributor Author

@ivankorn ivankorn Sep 27, 2019

Choose a reason for hiding this comment

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

@morgante, should we, what if in some cases it's different ?

"roles/logging.configWriter",

# Required to associate billing accounts to new projects
"roles/billing.projectManager",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The prepare creates project while the computed values tests is doing association to billing account

]

log_export_billing_account_roles = [
# Required to associate billing accounts to new projects
Copy link
Contributor Author

@ivankorn ivankorn Sep 27, 2019

Choose a reason for hiding this comment

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

@morgante, the prepare creates project while the computed values tests is doing association to billing account which requires the billing user and the project creator roles for the tests them-self.

test/setup/main.tf Show resolved Hide resolved
test/setup/make_source.sh Outdated Show resolved Hide resolved
version = "~> 3.0"

name = "ci-{{ cookiecutter.module_name|replace('-', '_') }}"
random_project_id = "true"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good eye, @morgante! Fixed
But actually, shouldn't we raise this in the module that came from ?
Thanks!

CONTRIBUTING.md Outdated Show resolved Hide resolved

# shellcheck disable=SC2086,SC2154
{ echo "export TF_VAR_project_id='$project_id'"; \
echo "export TF_VAR_parent_resource_project='$project_id'"; \
Copy link
Contributor

Choose a reason for hiding this comment

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

It should never be different.

@morgante morgante merged commit 56394ac into terraform-google-modules:master Oct 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update testing to new approach
5 participants