Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 27, 2025

Tests in internal/controllers were creating resources sequentially with multiple CreateResourceAndWait() calls, hiding potential issues with resource ordering and dependency resolution.

Changes

Modified 7 test files to use CreateResourcesAndWait() for parallel resource creation:

API Management tests (3 files)

  • Combined product/policy, api/versionset, and authorization resource creation flows
  • Converted 6 ARMID references to within-cluster references using tc.MakeReferenceFromResource()
  • Reduced 48 sequential calls to 15 parallel calls

Example:

// Before
tc.CreateResourceAndWait(&product)
tc.CreateResourceAndWait(&productPolicy)

// After
tc.CreateResourcesAndWait(&product, &productPolicy)
// Before: ARMID reference
versionSetReference := genruntime.ResourceReference{
    ARMID: *versionSet.Status.Id,
}

// After: within-cluster reference
versionSetReference := tc.MakeReferenceFromResource(&versionSet)

Other tests

  • authorization_roleassignment_20220401_test.go: managed identity + storage account
  • crd_sql_server_test.go: security alert policy + vulnerability assessment
  • machinelearning_workspaces_20240401_test.go: network security group + rule
  • containerservice_managedcluster_crud_v1api20231001_test.go: storage account + key vault

Impact

Total: ~56 sequential calls reduced to ~19 parallel calls across 7 files. Owner references ensure proper dependency ordering during parallel creation.

Tests will need rerecording against live Azure to validate parallel creation behavior and surface any edge cases in resource sequencing.

Original prompt

This section details on the original issue you should resolve

<issue_title>Modify coded tests to create resources in parallel</issue_title>
<issue_description>Describe the current behavior

We've identified that some of our coded tests (in the internal/controllers package) create all the resources one at a time and therefore don't reveal whether there are issues with our sequencing/ordering of resource creation.

Describe the improvement

Instead of calling CreateResourceAndWait() one at a time, we should modify the tests to call CreateResourcesAndWait() (the plural form) to create everything at once.

This may require rerecording the tests against live Azure, and may also flush out some edge case bugs we need to address.

Copilot Instructions

Scan tests in the controllers package to find cases where a single test makes multiple calls to CreateResourceAndWait() and there's a straightforward reordering of the code to group all the resource creations together into a single call.

  • If you spot any cases where the ARM ID of a resource is read from a newly created resource and used to construct a resource reference, modify that to use a within-cluster resource reference instead.
  • No changes outside the controllers package are required.
    </issue_description>

Comments on the Issue (you are @copilot in this section)

@matthchr Would be good to do but low priority. @theunrepentantgeek Still interested. @matthchr Still interested in this, though many of the new ones do this by default, the old ones don't do it as well. @matthchr Still interested in doing this - will see if copilot can help us here.

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Modify coded tests to create resources in parallel Modify controller tests to create resources in parallel Oct 27, 2025
@theunrepentantgeek theunrepentantgeek marked this pull request as ready for review October 27, 2025 23:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

Modify coded tests to create resources in parallel

2 participants