-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
Accept CLI option for the number of parallel ops in a test run's plan/apply #36323
Changes from 5 commits
a58a31b
8b5da33
6b36064
1059cc5
19ba9b4
b61a295
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
kind: ENHANCEMENTS | ||
body: Terraform Test command now accepts a -parallelism=n option, which sets the number of parallel operations in a test run's plan/apply operation. | ||
time: 2025-01-23T10:18:38.979866+01:00 | ||
custom: | ||
Issue: "34237" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,10 @@ type Test struct { | |
// will be executed. | ||
Filter []string | ||
|
||
// OperationParallelism is the limit Terraform places on total parallel operations | ||
// during the plan or apply command within a single test run. | ||
OperationParallelism int | ||
|
||
// TestDirectory allows the user to override the directory that the test | ||
// command will use to discover test files, defaults to "tests". Regardless | ||
// of the value here, test files within the configuration directory will | ||
|
@@ -55,6 +59,7 @@ func ParseTest(args []string) (*Test, tfdiags.Diagnostics) { | |
cmdFlags.BoolVar(&jsonOutput, "json", false, "json") | ||
cmdFlags.StringVar(&test.JUnitXMLFile, "junit-xml", "", "junit-xml") | ||
cmdFlags.BoolVar(&test.Verbose, "verbose", false, "verbose") | ||
cmdFlags.IntVar(&test.OperationParallelism, "parallelism", DefaultParallelism, "parallelism") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm thinking of the future, if we ever want the users to control parallelism of the test runs themselves. Perhaps this should actually be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we are going to have that as a flag, then yes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's likely we'll still get a request to control the parallelism from the CLI even if we provide the option in the configuration. For example, we have #34359 asking to override the But, perhaps keeping |
||
|
||
// TODO: Finalise the name of this flag. | ||
cmdFlags.StringVar(&test.CloudRunSource, "cloud-run", "", "cloud-run") | ||
|
@@ -73,6 +78,10 @@ func ParseTest(args []string) (*Test, tfdiags.Diagnostics) { | |
"The -junit-xml option is currently not compatible with remote test execution via the -cloud-run flag. If you are interested in JUnit XML output for remotely-executed tests please open an issue in GitHub.")) | ||
} | ||
|
||
if test.OperationParallelism < 1 { | ||
test.OperationParallelism = DefaultParallelism | ||
} | ||
|
||
switch { | ||
case jsonOutput: | ||
test.ViewType = ViewJSON | ||
|
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.
Just want to sanity check, that this being 0 will be overridden with a default at the API level?
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.
When the value is not given, i.e when the API calls the CLI, we use a default value. That override is done here, not at the API level