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

How to test magic modules contribution #6952

Closed
dhvogel opened this issue Aug 6, 2020 · 10 comments
Closed

How to test magic modules contribution #6952

dhvogel opened this issue Aug 6, 2020 · 10 comments

Comments

@dhvogel
Copy link

dhvogel commented Aug 6, 2020

Hi Magic Modules Team --
I am trying to test a contribution to the Magic Modules repository [0]. To achieve this, I perform the following steps:

  1. Generate terraform provider code from the magic modules contribution:
.../magic-modules$ bundle exec compiler -a -v "ga" -e 
  terraform -o "$GOPATH/src/github.com/terraform-providers/terraform-provider-google"
  1. cd into the directory with the generated terraform provider code:
.../magic-modules$ cd 
  "$GOPATH/src/github.com/terraform-providers/terraform-provider-google"
  1. attempt to run the test in question (this is an app engine contribution, so the app engine resource test):
.../terraform-provider-google$ make testacc TEST=./google 
  TESTARGS='-run=TestAccAppEngineStandardAppVersion_update'

However, when I try to run the test, I see the following error message:

$ make testacc TEST=./google TESTARGS='-run=TestAccAppEngineStandardAppVersion_update'
==> Checking source code against gofmt...
==> Checking that code complies with gofmt requirements...
go generate  ./...
TF_ACC=1 TF_SCHEMA_PANIC_ON_ERROR=1 go test ./google -v -run=TestAccAppEngineStandardAppVersion_update -timeout 240m -ldflags="-X=github.com/terraform-providers/terraform-provider-google/version.ProviderVersion=acc"
# github.com/terraform-providers/terraform-provider-google-beta/google-beta
../../../../pkg/mod/github.com/terraform-providers/terraform-provider-google-beta@v1.20.0/google-beta/resource_sql_database_instance.go:520:50: too many arguments in call to config.clientSqlAdmin.Users.Delete
	have (string, string, string, string)
	want (string, string)
../../../../pkg/mod/github.com/terraform-providers/terraform-provider-google-beta@v1.20.0/google-beta/resource_sql_user.go:174:48: too many arguments in call to config.clientSqlAdmin.Users.Update
	have (string, string, string, string, *sqladmin.User)
	want (string, string, *sqladmin.User)
../../../../pkg/mod/github.com/terraform-providers/terraform-provider-google-beta@v1.20.0/google-beta/resource_sql_user.go:209:47: too many arguments in call to config.clientSqlAdmin.Users.Delete
	have (string, string, string, string)
	want (string, string)
FAIL	github.com/terraform-providers/terraform-provider-google/google [build failed]
FAIL
make: *** [testacc] Error 2

This appears to be due to a bug in a dependency package, github.com/terraform-providers/terraform-provider-google-beta@v1.20.0. I don't believe I need this package to run the test, because the contribution is to the GA provider, not the beta provider. However, I am new to Go and not sure how to ignore it in the test command. How can I run the test without trying to compile this dependency?

[0] GoogleCloudPlatform/magic-modules#3789

@edwardmedia edwardmedia self-assigned this Aug 6, 2020
@edwardmedia
Copy link
Contributor

@dhvogel thank you for your efforts to the contributions. I would suggest review the docs and follow the steps before running the tests.

https://github.com/terraform-providers/terraform-provider-google/blob/master/.github/CONTRIBUTING.md#tests

@dhvogel
Copy link
Author

dhvogel commented Aug 6, 2020

I have, and even after following those steps, I am seeing an error compiling a dependency.

@edwardmedia
Copy link
Contributor

@dhvogel looks like you built the ga but I have no idea why it references beta ( see in the log )
For this particular test, the Terraform runner needs "billing.resourceAssociations.create"

@dhvogel
Copy link
Author

dhvogel commented Aug 6, 2020

Yes, and the lack of billing permissions was the error encountered in #6908.

When I pull the latest terraform-google-provider from head, I can run the test just fine, so I am sure this is not an IAM issue.

This issue only occurs when I generate the terraform-google-provider code from the upstream magic-modules contribution.

@edwardmedia
Copy link
Contributor

edwardmedia commented Aug 6, 2020

@dhvogel have you run git diff for your generated terraform-google-provider against the GH's? The result might tell you something...

@dhvogel
Copy link
Author

dhvogel commented Aug 6, 2020

git diff shows me, among other things:

--- a/go.mod
+++ b/go.mod
@@ -15,10 +15,12 @@ require (
        github.com/hashicorp/go-cleanhttp v0.5.1
        github.com/hashicorp/go-multierror v1.0.0
        github.com/hashicorp/go-version v1.2.0
+       github.com/hashicorp/terraform v0.12.29 // indirect
        github.com/hashicorp/terraform-plugin-sdk v1.11.0
        github.com/mitchellh/hashstructure v1.0.0
        github.com/sirupsen/logrus v1.2.0 // indirect
        github.com/stoewer/go-strcase v1.0.2
+       github.com/terraform-providers/terraform-provider-google-beta v1.20.0
        github.com/terraform-providers/terraform-provider-random v0.0.0-20190925200408-30dac3233094
        golang.org/x/net v0.0.0-20200625001655-4c5254603344
        golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d

It's automatically pulling in github.com/terraform-providers/terraform-provider-google-beta v1.20.0, which appears to have the bug that is preventing compilation.

Unfortunately when I try to manually bump the version to v2.0.0, I see the following error message:

go.mod:23: require github.com/terraform-providers/terraform-provider-google-beta: version "v2.0.0" invalid: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v2

@edwardmedia
Copy link
Contributor

edwardmedia commented Aug 14, 2020

@dhvogel
I had a similar problem with myself. For my case, I did

  1. delete all terraform@v0.xx.xx under $GOPATH/pkg/mod/github.com/hashicorp/.
  2. make sure you get the latest https://github.com/hashicorp/terraform-provider-google.git before you build MM.
  3. double check go version. Mine is go1.14.

Let me know if that work for you

@edwardmedia
Copy link
Contributor

@dhvogel do you have more questions?

@edwardmedia
Copy link
Contributor

@dhvogel closing this question now. Feel free to reopen it if you still have questions Thanks

@ghost
Copy link

ghost commented Sep 21, 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 👉 hashibot-feedback@hashicorp.com. Thanks!

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

No branches or pull requests

2 participants