Skip to content

Fix issues with running RunKeyVaultTests.ps1. #2509

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 2 commits into from
Jun 29, 2016

Conversation

adarce
Copy link
Member

@adarce adarce commented Jun 23, 2016

Background

When attempting to run the Azure Key Vault PowerShell tests via the RunKeyVaultTests.ps1 script, the following 5 tests would fail:

Test_ImportByokWithDefaultAttributes
Test_ImportByokWith1024BitKey
Test_ImportByokWithCustomAttributes
Test_GetAllKeys
Test_GetKeyVersions

The first 3 BYOK tests failed because they test against dummy .byok files that were generated with a specific subscription ID that may not match the subscription ID of whomever is running the tests. The last 2 tests failed because they attempt to reference [Microsoft.WindowsAzure.Testing.TestUtilities], which cannot be found.

Moreover, this PowerShell script was difficult to use if we didn't want to provide our own vault to test against for both the data plane and the control plane, but we instead wanted the script to generate its own temporary vault. Also, we sometimes would like to programmatically skip Active Directory related tests for certain environments (instead of having it hardcoded to always skip for Fairfax environments). Finally, the PowerShell script could use some cleanup with respect to formatting whitespace, fleshing out docstrings, and general organization.

The Change

This change addresses the above issues by:

  • Guarding the 3 BYOK tests with an if condition that tests the subscription ID.
  • Replacing Wait($timeout * 1000) with Start-Sleep -Seconds $timeout.
  • Saving/restoring temporary vault state for both the control plane and data plane tests.
  • Exposing the $NoADCmdLetMode parameter.
  • Generally improving the coding style.

@azurecla
Copy link

Hi @adarce, I'm your friendly neighborhood Azure Pull Request Bot (You can call me AZPRBOT). Thanks for your contribution!


It looks like you're working at Microsoft (adarce). If you're full-time, we DON'T require a contribution license agreement.



If you are a vendor, DO please sign the electronic contribution license agreement. It will take 2 minutes and there's no faxing! https://cla.azure.com.

TTYL, AZPRBOT;


Start-Sleep -Seconds $timeout
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert this back to [Microsoft.WindowsAzure.Testing.TestUtilities]::Wait. We do not want to do sleep waits in playback mode.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hovsepm It seems that this issue has come up before (see: #1846 (comment)). I have updated my pull request to use the workaround recommended by @markcowl here: (#1846 (comment)).

@hovsepm
Copy link
Contributor

hovsepm commented Jun 24, 2016

@adarce please squash your commits.

@hovsepm
Copy link
Contributor

hovsepm commented Jun 24, 2016

@pomortaz do you need to sign-off? :)

@pomortaz
Copy link
Contributor

@hovsepm thanks for the review. I've already signed off. :)

@adarce adarce force-pushed the feature/fix-RunKeyVaultTests branch from 5134036 to 1174593 Compare June 25, 2016 01:47
## Background

When attempting to run the Azure Key Vault PowerShell tests via the
`RunKeyVaultTests.ps1` script, the following 5 tests would fail:
```
Test_ImportByokWithDefaultAttributes
Test_ImportByokWith1024BitKey
Test_ImportByokWithCustomAttributes
Test_GetAllKeys
Test_GetKeyVersions
```

The first 3 BYOK tests failed because they test against dummy `.byok`
files that were generated with a specific subscription ID that may not
match the subscription ID of whomever is running the tests. The last 2
tests failed because they attempt to reference
`[Microsoft.WindowsAzure.Testing.TestUtilities]`, which cannot be found.

Moreover, this PowerShell script was difficult to use if we didn't want
to provide our own vault to test against for both the data plane and the
control plane, but we instead wanted the script to generate its own
temporary vault. Also, we sometimes would like to programmatically skip
Active Directory related tests for certain environments (instead of
having it hardcoded to always skip for Fairfax environments). Finally,
the PowerShell script could use some cleanup with respect to formatting
whitespace, fleshing out docstrings, and general organization.

## The Change

This change addresses the above issues by:

- Guarding the 3 BYOK tests with an if condition that tests the
  subscription ID.
- Replacing `Wait($timeout * 1000)` with
  `Start-Sleep -Seconds $timeout`.
- Saving/restoring temporary vault state for both the control plane and
  data plane tests.
- Exposing the `$NoADCmdLetMode` parameter.
- Generally improving the coding style.
@adarce adarce force-pushed the feature/fix-RunKeyVaultTests branch from 1174593 to c752abc Compare June 25, 2016 02:42
@adarce
Copy link
Member Author

adarce commented Jun 28, 2016

@hovsepm I have squashed my commits, as requested. Please let me know if there's anything else I can improve!

@@ -37,6 +37,8 @@ Param($rgName, $location, $tagName, $tagValue)
Assert-AreEqual "Standard" $actual.Sku
Assert-AreEqual $false $actual.EnabledForDeployment

if ($global:noADCmdLetMode) {return;}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't like this. This just skips the test without letting us know that's what happened. A better solution would be to store the needed subscriptionId in the mocks, which is how most tests solve similar issues.

@markcowl
Copy link
Member

@adarce a few comments

- Stopped skipping Test-CreateNewVault if noADCmdLetMode.
- Removed PSHCommon directory and instead updated Common.ps1 from ScenarioTests.Common.
- Used TestMockSupport.RunningMocked for Wait-Seconds instead.
@adarce adarce force-pushed the feature/fix-RunKeyVaultTests branch from bf65a77 to 367159e Compare June 28, 2016 23:48
@adarce
Copy link
Member Author

adarce commented Jun 29, 2016

@markcowl I've pushed a commit that hopefully addresses each of your concerns. Let me know if there's anything else I can improve!

@markcowl
Copy link
Member

@markcowl
Copy link
Member

LGTM once the on-demand run passes

@markcowl markcowl merged commit 9bcda5b into Azure:dev Jun 29, 2016
@adarce adarce deleted the feature/fix-RunKeyVaultTests branch December 15, 2016 01:20
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.

5 participants