-
Notifications
You must be signed in to change notification settings - Fork 92
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
Conversation
test/setup/main.tf
Outdated
version = "~> 3.0" | ||
|
||
name = "ci-{{ cookiecutter.module_name|replace('-', '_') }}" | ||
random_project_id = "true" |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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!
30b2256
to
03d8031
Compare
0a6ff54
to
59dfa95
Compare
3650d09
to
d9bd46a
Compare
CI is green, RP got 2 approvals. @morgante, @aaron-lane, would you mind reviewing it please? Please note following deviations from migration document:
|
There was a problem hiding this 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/main.tf
Outdated
version = "~> 3.0" | ||
|
||
name = "ci-{{ cookiecutter.module_name|replace('-', '_') }}" | ||
random_project_id = "true" |
There was a problem hiding this comment.
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...
|
||
# shellcheck disable=SC2086,SC2154 | ||
{ echo "export TF_VAR_project_id='$project_id'"; \ | ||
echo "export TF_VAR_parent_resource_project='$project_id'"; \ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this 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", |
There was a problem hiding this comment.
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'"; \ |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
Outdated
version = "~> 3.0" | ||
|
||
name = "ci-{{ cookiecutter.module_name|replace('-', '_') }}" | ||
random_project_id = "true" |
There was a problem hiding this comment.
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!
|
||
# shellcheck disable=SC2086,SC2154 | ||
{ echo "export TF_VAR_project_id='$project_id'"; \ | ||
echo "export TF_VAR_parent_resource_project='$project_id'"; \ |
There was a problem hiding this comment.
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.
Fixes #29
Please note following deviations from migration document:
for_each
instead of count.index is used to create a number of instances of resource.