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

Test_CLI_VsServer/ManageEnvironments fails when there's an unrelated deployment with 'env2' in its name #4748

Open
JeffreyCA opened this issue Feb 1, 2025 · 0 comments
Labels
Milestone

Comments

@JeffreyCA
Copy link
Contributor

Test file: https://github.com/Azure/azure-dev/blob/main/cli/azd/test/functional/testdata/vs-server/tests/AcceptanceTests.cs

Repro steps

  1. In the Azure subscription where functional tests are run, create a deployment that has "env2" in the name.

    One way using Azure CLI:

    main.bicep:

    targetScope = 'subscription'
    
    param resourceGroupName string
    
    resource newRG 'Microsoft.Resources/resourceGroups@2024-03-01' = {
      name: resourceGroupName
      location: 'East US'
    }
    az deployment sub create --name myenv2deployment --location eastus --template-file main.bicep --parameters resourceGroupName=<resource group name>
    
  2. Run the test Test_CLI_VsServer/ManageEnvironments. If using VS Code, you can use the Test explorer:

    Image

Observed

The test fails with:

vs_server_test.go:199: DIR: /var/folders/ps/c0906c6x6pnghyl4jw54srz00000gn/T/Test_CLI_VsServerManageEnvironments792598557/001
aspire_test.go:357: 701ms [t-out] Test run for /Users/runner/work/1/s/cli/azd/test/functional/testdata/vs-server/tests/bin/Debug/net8.0/AzdVsServerTests.dll (.NETCoreApp,Version=v8.0)
aspire_test.go:357: 771ms [t-out] VSTest version 17.11.1 (x64)
aspire_test.go:357: 772ms [t-out]
aspire_test.go:357: 866ms [t-out] Starting test execution, please wait...
aspire_test.go:357: 892ms [t-out] A total of 1 test files matched the specified pattern.
aspire_test.go:357: 13.018s [svr-out] [9IxdLZ5Z7oI= spinner] Analyzing Aspire Application (this might take a moment...)
aspire_test.go:357: 19.341s [svr-out] [9IxdLZ5Z7oI= spinner] Analyzing Aspire Application (this might take a moment...)
aspire_test.go:357: 24.836s [svr-out] [9IxdLZ5Z7oI= spinner] Initialize bicep provider
aspire_test.go:357: 28.611s [svr-out] [9IxdLZ5Z7oI= spinner] Discovering resources to delete...
aspire_test.go:357: 34.557s [t-out]   Failed ManageEnvironments [32 s]
aspire_test.go:357: 34.557s [t-out]   Error Message:
aspire_test.go:357: 34.557s [t-out]    StreamJsonRpc.RemoteInvocationException : deleting infrastructure: error deleting Azure resources: getting resources to delete: environment name not found in deployment tags
aspire_test.go:357: 34.557s [t-out]   Stack Trace:
aspire_test.go:357: 34.557s [t-out]      at StreamJsonRpc.JsonRpc.InvokeCoreAsync[TResult](RequestId id, String targetName, IReadOnlyList`1 arguments, IReadOnlyList`1 positionalArgumentDeclaredTypes, IReadOnlyDictionary`2 namedArgumentDeclaredTypes, CancellationToken cancellationToken, Boolean isParameterObject)
aspire_test.go:357: 34.557s [t-out]    at AzdVsServerTests.AcceptanceTests.ManageEnvironments() in /Users/runner/work/1/s/cli/azd/test/functional/testdata/vs-server/tests/AcceptanceTests.cs:line 108
aspire_test.go:357: 34.557s [t-out]    at NUnit.Framework.Internal.TaskAwaitAdapter.GenericAdapter`1.BlockUntilCompleted()
aspire_test.go:357: 34.557s [t-out]    at NUnit.Framework.Internal.MessagePumpStrategy.NoMessagePumpStrategy.WaitForCompletion(AwaitAdapter awaiter)
aspire_test.go:357: 34.557s [t-out]    at NUnit.Framework.Internal.AsyncToSyncAdapter.Await[TResult](Func`1 invoke)
aspire_test.go:357: 34.557s [t-out]    at NUnit.Framework.Internal.AsyncToSyncAdapter.Await(Func`1 invoke)
aspire_test.go:357: 34.557s [t-out]    at NUnit.Framework.Internal.Commands.TestMethodCommand.RunTestMethod(TestExecutionContext context)
aspire_test.go:357: 34.557s [t-out]    at NUnit.Framework.Internal.Commands.TestMethodCommand.Execute(TestExecutionContext context)
aspire_test.go:357: 34.557s [t-out]    at NUnit.Framework.Internal.Execution.SimpleWorkItem.<>c__DisplayClass3_0.<PerformWork>b__0()
aspire_test.go:357: 34.557s [t-out]    at NUnit.Framework.Internal.ContextUtils.<>c__DisplayClass1_0`1.<DoIsolated>b__0(Object _)
aspire_test.go:357: 34.557s [t-out]    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
aspire_test.go:357: 34.557s [t-out] --- End of stack trace from previous location ---
aspire_test.go:357: 34.557s [t-out]    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
aspire_test.go:357: 34.557s [t-out]    at NUnit.Framework.Internal.ContextUtils.DoIsolated(ContextCallback callback, Object state)
aspire_test.go:357: 34.557s [t-out]    at NUnit.Framework.Internal.ContextUtils.DoIsolated[T](Func`1 func)
aspire_test.go:357: 34.557s [t-out]    at NUnit.Framework.Internal.Execution.SimpleWorkItem.PerformWork()

Additional info

Place where error is returned:

// Get the environment name from the deployment tags
envName, has := subscriptionDeployment.Tags[azure.TagKeyAzdEnvName]
if !has || envName == nil {
return nil, fmt.Errorf("environment name not found in deployment tags")
}

This seems to be where we iterate through deployments and check if the hint env2 is in the deployment name:

// Fallback: Match on hint
if hint != "" && strings.Contains(deployment.Name, hint) {
matchingDeployments = append(matchingDeployments, deployment)
}

@rajeshkamal5050 rajeshkamal5050 added this to the Backlog milestone Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants