-
Notifications
You must be signed in to change notification settings - Fork 16
experimental: faster tfversion tests #493
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
base: main
Are you sure you want to change the base?
Conversation
* Find Terraform binaries that we've already downloaded instead of repeatedly downloading them * Read a TF_LOG_INSTALLER environment variable to log hc-install activity. Works best with a branch of hc-install that prepends log levels to logged messages. * What if? Could provider installation be optimized? Before: ``` $ time go test ./tfversion -count=1 ok github.com/hashicorp/terraform-plugin-testing/tfversion 223.588s go test ./tfversion -count=1 45.66s user 29.61s system 33% cpu 3:44.32 total ``` After: ``` $ time go test ./tfversion -count=1 ok github.com/hashicorp/terraform-plugin-testing/tfversion 58.465s go test ./tfversion -count=1 22.14s user 12.61s system 58% cpu 58.982 total ```
InstallDir: tfDir, | ||
Product: product.Terraform, | ||
Version: tfVersion, | ||
}) | ||
} | ||
sources = append(sources, findSource, releasesSource) |
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.
This is the part that makes this faster. Instead of a "releases source," use a "find source" and a "releases source."
strings.TrimRight(tempDir, string(os.PathSeparator)), | ||
"plugintest-terraform", | ||
strconv.Itoa(os.Getpid()), | ||
tfVersion.String(), |
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.
One directory per-version, per-process.
ok github.com/hashicorp/terraform-plugin-testing/tfversion 16.360s TF_LOG_INSTALLER=info go test -v ./tfversion 25.66s user 14.50s system 236% cpu 16.969 total
For fun, not to be merged.
The
tfversion
tests are fairly unique in that they specify"TF_ACC_TERRAFORM_VERSION"
. As a consequence, each of these tests downloads Terraform into its own temporary directory. This PR asks: what if they shared one temporary directory?TF_LOG_INSTALLER
environment variable to log hc-install activity. Works best with a branch of hc-install that prepends log levels to logged messages.Before:
After: