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

Remove all instances of GOOGLE_XPN_HOST_PROJECT environment variable. #815

Merged
merged 6 commits into from
Dec 11, 2017

Conversation

nat-henderson
Copy link
Contributor

Instead of GOOGLE_XPN_HOST_PROJECT being required to run some tests, I added the ability to create and tear down the necessary project structure. This allows us to remove one environment variable, and use two others which are already widely-required: org and billing ID.

After this PR, no instances of GOOGLE_XPN_HOST_PROJECT appear in the repository. This closes #715.

Instead of GOOGLE_XPN_HOST_PROJECT being required to run some tests, I added the ability to create and tear down the necessary project structure.
This allows us to remove one environment variable, and use two others which are already widely-required: org and billing ID.
@@ -200,6 +200,35 @@ func testAccCheckComputeDiskDestroy(s *terraform.State) error {
return nil
}

func testAccCheckComputeDiskExistsInProject(n, p string, disk *compute.Disk) resource.TestCheckFunc {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't like that I had to do this (this is a copy of testAccCheckComputeDiskExists with an extra project parameter, which I hate) but I wasn't sure how I could avoid that. The other method (here and in all three files) uses the default project. I'm a little too new to Go to know what the right move here was - I wanted to make the project an argument in testAccCheckComputeDiskExists, but don't know how to get the name of the default project at the call site. I assume this cannot be right - please let me know what would be right.

Copy link
Contributor

Choose a reason for hiding this comment

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

getTestProjectFromEnv() is the method you are looking for.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh, thank you! That seems better. I'll make that change and ping you again.

@nat-henderson
Copy link
Contributor Author

I think @rosbo is the right person to look at this.

@rosbo rosbo self-requested a review December 1, 2017 23:24
@rosbo rosbo self-assigned this Dec 1, 2017
@nat-henderson
Copy link
Contributor Author

Okay, I made that change - I'm struggling to run all the tests I've changed, now - running into quota issues on my personal account, and don't have an Organization that I can use in the google.com org. Do we have CI that will run these tests in a canonical environment?

@@ -345,29 +345,43 @@ resource "google_compute_disk" "foobar" {
}`, diskName)
}

func testAccComputeDisk_fromSnapshot(firstDiskName, snapshotName, diskName, xpn_host string, ref_selector string) string {
func testAccComputeDisk_fromSnapshot(projectName, firstDiskName, snapshotName, diskName, org, billingId, ref_selector string) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was this test using the XPN project in the first place instead of the regular test project?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure - I can't see any reason that it ought to be.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should re-write it using the default test project to avoid having to create extra test project.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, and done.

@@ -350,7 +351,7 @@ func testAccCheckComputeInstanceTemplateDestroy(s *terraform.State) error {
return nil
}

func testAccCheckComputeInstanceTemplateExists(n string, instanceTemplate *compute.InstanceTemplate) resource.TestCheckFunc {
func testAccCheckComputeInstanceTemplateExists(n, p string, instanceTemplate *compute.InstanceTemplate) resource.TestCheckFunc {
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding a second method: testAccCheckComputeInstanceTemplateXPNExists

func testAccCheckComputeInstanceTemplateExists(n string, instanceTemplate *compute.InstanceTemplate) resource.TestCheckFunc {
  return testAccCheckComputeInstanceTemplateXPNExists(n, getTestProjectFromEnv(), instanceTemplate)
} 

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 idea, done.

@@ -873,7 +874,7 @@ func testAccCheckComputeInstanceDestroy(s *terraform.State) error {
return nil
}

func testAccCheckComputeInstanceExists(n string, instance *compute.Instance) resource.TestCheckFunc {
func testAccCheckComputeInstanceExists(n, p string, instance *compute.Instance) resource.TestCheckFunc {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment than for instance template.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same.

Copy link
Contributor

@rosbo rosbo left a comment

Choose a reason for hiding this comment

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

Merge at will :)

@nat-henderson nat-henderson merged commit 5766f2b into hashicorp:master Dec 11, 2017
@nat-henderson nat-henderson deleted the remove_xpn_var branch December 11, 2017 22:07
@nat-henderson
Copy link
Contributor Author

Cool, I'm not planning to add to the changelog for this since it's 100% internal. what should I do to remove the now-unnecessary environment variable from our test environment? @rosbo or @paddycarver might know?

@paddycarver
Copy link
Contributor

I'll take care of it! Thanks for making this happen. 😁

@ghost
Copy link

ghost commented Mar 30, 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. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost unassigned rosbo Mar 30, 2020
@ghost ghost locked and limited conversation to collaborators Mar 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove GOOGLE_XPN_HOST_PROJECT env variable
3 participants