Skip to content

Conversation

hashimoon
Copy link
Contributor

@hashimoon hashimoon commented Sep 6, 2025

Description

Introduces 'agent_execution_mode' and 'agent_pool_id' fields to the registry module test_config schema, supporting both agent and remote execution modes. Adds validation to prevent agent_pool_id from being set when execution mode is 'remote', updates create, update, and read logic, and provides comprehensive acceptance tests for new behaviors. Also updates dependencies to latest versions.

Screenshot 2025-09-05 at 11 17 09 PM Screenshot 2025-09-05 at 11 17 28 PM Screenshot 2025-09-05 at 11 17 47 PM Screenshot 2025-09-05 at 11 18 03 PM

Remember to:

Testing plan

  1. Create a registry module with agent execution mode:
    - Apply the first Terraform config above
    - Verify in TFE/TFC UI that the module's test configuration shows agent execution mode
    - Verify the specified agent pool is being used
  2. Update from remote to agent execution mode:
    - Start with a module using remote execution
    - Update the configuration to use agent execution mode with an agent pool
    - Run terraform apply and verify the change is applied successfully
  3. Clear agent pool configuration:
    - Start with a module using agent execution mode
    - Change agent_execution_mode back to "remote" and remove agent_pool_id
    - Verify the module reverts to remote execution
  4. Validation testing:
    - Attempt to set agent_pool_id without setting agent_execution_mode = "agent"
    - Verify that Terraform returns the appropriate validation error

External links

Include any links here that might be helpful for people reviewing your PR. If there are none, feel free to delete this section.

Output from acceptance tests

Please run applicable acceptance tests locally and include the output here. See testing.md to learn how to run acceptance tests.

If you are an external contributor, your contribution(s) will first be reviewed before running them against the project's CI pipeline.

go test -v ./internal/provider -run "TestAccTFERegistryModule_agentExecutionModeWithAgentPool|TestAccTFERegistryModule_remoteExecutionModeWithoutAgentPool|TestAccTFERegistryModule_agentPoolFieldClearing|TestAccTFERegistryModule_remoteExecutionModeWithAgentPoolError"
=== RUN   TestAccTFERegistryModule_agentExecutionModeWithAgentPool
--- PASS: TestAccTFERegistryModule_agentExecutionModeWithAgentPool (6.03s)
=== RUN   TestAccTFERegistryModule_remoteExecutionModeWithoutAgentPool
--- PASS: TestAccTFERegistryModule_remoteExecutionModeWithoutAgentPool (5.48s)
=== RUN   TestAccTFERegistryModule_agentPoolFieldClearing
--- PASS: TestAccTFERegistryModule_agentPoolFieldClearing (5.41s)
=== RUN   TestAccTFERegistryModule_remoteExecutionModeWithAgentPoolError
--- PASS: TestAccTFERegistryModule_remoteExecutionModeWithAgentPoolError (0.22s)
PASS
ok  	github.com/hashicorp/terraform-provider-tfe/internal/provider	17.628s
...

Rollback Plan

Changes to Security Controls

@hashimoon hashimoon requested a review from a team as a code owner September 6, 2025 06:04
@hashimoon hashimoon force-pushed the hashiomoon/TF-27883-agent-pool branch 2 times, most recently from 01cc650 to 155e0ca Compare September 6, 2025 06:26
@hashimoon hashimoon force-pushed the hashiomoon/TF-27883-agent-pool branch from 155e0ca to 0cab058 Compare September 22, 2025 17:28
@hashimoon hashimoon force-pushed the hashiomoon/TF-27883-agent-pool branch from f45ef43 to 4217cce Compare October 1, 2025 22:48
Introduces 'agent_execution_mode' and 'agent_pool_id' fields to the registry module test_config schema, supporting both agent and remote execution modes. Adds validation to prevent agent_pool_id from being set when execution mode is 'remote', updates create, update, and read logic, and provides comprehensive acceptance tests for new behaviors. Also updates dependencies to latest versions.
@hashimoon hashimoon force-pushed the hashiomoon/TF-27883-agent-pool branch from 0a7ac4f to 92e9804 Compare October 2, 2025 23:47
Changed test config handling to always initialize RegistryModuleTestConfigOptions when testConfig is not nil, and set TestsEnabled only if present. This improves robustness and prevents potential nil pointer issues.
Increased the test matrix from 1 to 8 parallel jobs for improved CI performance. Updated the report merging step to include all new test summary directories.
Adds cache-dependency-path to Go setup steps for improved caching and renames lint step for clarity. Updates test action to run tests in parallel and removes 'go mod tidy' from dependency sync.
Removes the empty string check and ensures agent_execution_mode is always set when AgentExecutionMode is not nil, converting its value to a string.
Introduces debug log statements to trace the values of agent_execution_mode and agent_pool_id during creation and reading of TFE registry modules. This aids in troubleshooting and verifying correct configuration handling.
Adds logic to update the registry module's test_config with agent_execution_mode after creation, since the API does not accept agent_execution_mode during initial creation. The update is performed if agent_execution_mode is specified in the test_config.
Eliminates post-creation update logic for agent_execution_mode in test_config, as the API does not accept this field during creation. Now, agent_execution_mode is set to 'agent' during read when agent_pool_id is present.
Eliminated various log.Printf debug statements from resourceTFERegistryModuleCreateWithVCS and resourceTFERegistryModuleRead to clean up output and improve code clarity.
Adds 'agent_execution_mode' with value 'agent' to testConfigValues when 'agent_pool_id' is set, ensuring correct execution mode is specified for registry module tests.
Eliminated the call to skipIfEnterprise in TestAccTFERegistryModule_agentExecutionModeWithAgentPool, allowing the test to run in all environments.
Modified the test to verify that the 'test_config.0.tests_enabled' attribute is not present instead of 'test_config.0'. This provides a more precise check for the absence of the tests_enabled field in the resource.
Removes redundant override of agent_execution_mode when agent_pool_id is set and ensures agent_execution_mode uses the original value from TestConfig. This prevents unintended value changes in the test configuration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant