Skip to content

[Resources] Fix issue preventing deployment of Template Specs located outside of the current subscription context #13483

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

Merged
merged 5 commits into from
Nov 30, 2020

Conversation

stuartko
Copy link
Contributor

Description

Fixes issue preventing deployment of Template Specs located outside of the current subscription context. Issue is described here: Azure/template-specs#40

Checklist

  • I have read the Submitting Changes section of CONTRIBUTING.md
  • The title of the PR is clear and informative
  • The appropriate ChangeLog.md file(s) has been updated:
    • For any service, the ChangeLog.md file can be found at src/{{SERVICE}}/{{SERVICE}}/ChangeLog.md
    • A snippet outlining the change(s) made in the PR should be written under the ## Upcoming Release header -- no new version header should be added
  • The PR does not introduce breaking changes
  • If applicable, the changes made in the PR have proper test coverage
  • For public API changes to cmdlets:
    • a cmdlet design review was approved for the changes in this repository (Microsoft internal only)
      • {Please put the link here}
    • the markdown help files have been regenerated using the commands listed here

@msJinLei
Copy link
Contributor

@stuartko Do you have any test case to cover the issue you fix?

@stuartko
Copy link
Contributor Author

@stuartko Do you have any test case to cover the issue you fix?

I do not. My understanding is that as it’s a multi-subscription action, the current test framework is not setup well to handle that. Is that understanding correct? I see many other cross-subscription operations do not have tests for this reason as well.

@stuartko
Copy link
Contributor Author

My understanding is that as it’s a multi-subscription action, the current test framework is not setup well to handle that. Is that understanding correct?

@msJinLei : Can you confirm?

I only see one test (in Az.Accounts) in Az Powershell that is using multiple subscription contexts and it comes with an asterisk that it requires a tenant with two subscriptions that are both relevant to the test.

Given these limitations, I do not believe a cross-subscription test can be safely implemented for this hotfix.

@stuartko
Copy link
Contributor Author

Adding back "needs-review" label to get reviewer confirmation for previous question in the PR thread. I believe this PR should be good to merge?

@msJinLei
Copy link
Contributor

/azp run

@azure-pipelines
Copy link
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

@msJinLei
Copy link
Contributor

msJinLei commented Nov 19, 2020

My understanding is that as it’s a multi-subscription action, the current test framework is not setup well to handle that. Is that understanding correct?

@msJinLei : Can you confirm?

I only see one test (in Az.Accounts) in Az Powershell that is using multiple subscription contexts and it comes with an asterisk that it requires a tenant with two subscriptions that are both relevant to the test.

Given these limitations, I do not believe a cross-subscription test can be safely implemented for this hotfix.

Sorry for delayed reponse. You can use unit test rather than scenario test so that test data can be mocked.
https://github.com/Azure/azure-powershell/blob/master/src/Resources/Resources.Test/ResourceGroups/SetAzureResourceGroupCommandTests.cs

@stuartko
Copy link
Contributor Author

@msJinLei: It was more involved than anticipated due to some shell-only assumptions in the original cmdlet implementation, but I've now completed adding a unit test to cover the missing coverage for the bug being fixed.

Can you review/approve?

@stuartko
Copy link
Contributor Author

Can someone please review? We need to have this change in before Code Complete for the next release.

@msJinLei
Copy link
Contributor

msJinLei commented Nov 27, 2020

@msJinLei: It was more involved than anticipated due to some shell-only assumptions in the original cmdlet implementation, but I've now completed adding a unit test to cover the missing coverage for the bug being fixed.

Can you review/approve?

Great!

There's a failed test case about path format in mac and linux.

2020-11-23T09:51:24.3167640Z   [xUnit.net 00:02:05.19]     Microsoft.Azure.Commands.Resources.Test.NewAzureResourceGroupDeploymentCommandTests.ResolvesDynamicParametersWithCrossSubTemplateSpec [FAIL]
2020-11-23T09:51:24.3353190Z     X Microsoft.Azure.Commands.Resources.Test.NewAzureResourceGroupDeploymentCommandTests.ResolvesDynamicParametersWithCrossSubTemplateSpec [9ms]
2020-11-23T09:51:24.3361432Z EXEC : error Message:  [/home/vsts/work/1/s/build.proj]
2020-11-23T09:51:24.3363762Z      System.IO.FileNotFoundException : Could not find file '/home/vsts/work/1/s/src/Resources/Resources.Test/bin/Debug/netcoreapp2.1/Resources\sampleTemplateFile.json'.
2020-11-23T09:51:24.3364657Z     Stack Trace:
2020-11-23T09:51:24.3365336Z        at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
2020-11-23T09:51:24.3366123Z      at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
2020-11-23T09:51:24.3366963Z      at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
2020-11-23T09:51:24.3367794Z      at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
2020-11-23T09:51:24.3368541Z      at System.IO.File.InternalReadAllText(String path, Encoding encoding)
2020-11-23T09:51:24.3369159Z      at System.IO.File.ReadAllText(String path)

@stuartko
Copy link
Contributor Author

@msJinLei : The issue on Unix based systems is now fixed. We need this change in for the next powershell release, can we have this merged today so we hit the code complete deadline?

@msJinLei msJinLei merged commit 3e5b6cb into master Nov 30, 2020
@wyunchi-ms wyunchi-ms deleted the stuartko/Nov20_CrossSubTemplateSpecDeployments branch January 10, 2024 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants