Skip to content

Commit

Permalink
IoT Hub SDK upgrade and test updates (#14300)
Browse files Browse the repository at this point in the history
* Update IoTHub management SDK to 3.0.0

* Added GWV2 feature string to PSCapabilities

* Added Storage to Tests, updated tests and recordings

* Added test playback check for new-azstoragecontainer call

* ChangeLog updates

* Updated DPS tests to match new IoTHub SDK version

* Added reference to Storage.Management to include Az.Storage.psd1 in test restore
  • Loading branch information
c-ryan-k authored and wyunchi-ms committed Mar 2, 2021
1 parent 04ce323 commit 0922575
Show file tree
Hide file tree
Showing 29 changed files with 9,694 additions and 9,197 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Devices" Version="1.22.0" />
<PackageReference Include="Microsoft.Azure.Management.DeviceProvisioningServices" Version="0.10.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.IotHub" Version="2.10.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.IotHub" Version="3.0.0" />
</ItemGroup>

</Project>

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/IotHub/IotHub.Test/IotHub.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Devices" Version="1.22.0" />
<PackageReference Include="Microsoft.Azure.Management.EventHub" Version="2.7.0" />
<PackageReference Include="Microsoft.Azure.Management.IotHub" Version="2.10.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.IotHub" Version="3.0.0" />
<PackageReference Include="Microsoft.Azure.Management.Storage" Version="19.0.0" />
</ItemGroup>

</Project>
11 changes: 11 additions & 0 deletions src/IotHub/IotHub.Test/ScenarioTests/IotHubController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

using System.Diagnostics;
using Microsoft.Azure.Management.EventHub;
using Microsoft.Azure.Management.Storage;
using Microsoft.Azure.Management.Internal.Resources;
using System;
using System.Collections.Generic;
Expand All @@ -36,6 +37,8 @@ public sealed class IotHubController

public IotHubClient IotHubClient { get; private set; }

public StorageManagementClient StorageClient { get; private set; }

public EventHubManagementClient EHClient { get; private set; }

public string UserDomain { get; private set; }
Expand Down Expand Up @@ -75,6 +78,7 @@ public void RunPsTestWorkflow(
{
{"Microsoft.Resources", null},
{"Microsoft.Features", null},
{"Microsoft.Storage", null },
{"Microsoft.Authorization", null}
};
var providersToIgnore = new Dictionary<string, string>
Expand All @@ -98,6 +102,7 @@ public void RunPsTestWorkflow(
_helper.RMProfileModule,
_helper.GetRMModulePath(@"AzureRM.IotHub.psd1"),
_helper.GetRMModulePath(@"AzureRM.EventHub.psd1"),
_helper.GetRMModulePath(@"AzureRM.Storage.psd1"),
"AzureRM.Resources.ps1");

try
Expand All @@ -120,10 +125,12 @@ private void SetupManagementClients(MockContext context)
{
ResourceManagementClient = GetResourceManagementClient(context);
IotHubClient = GetIotHubClient(context);
StorageClient = GetStorageManagementClient(context);
EHClient = GetEHClient(context);

_helper.SetupManagementClients(ResourceManagementClient,
IotHubClient,
StorageClient,
EHClient);
}

Expand All @@ -136,6 +143,10 @@ private static IotHubClient GetIotHubClient(MockContext context)
{
return context.GetServiceClient<IotHubClient>(Rest.ClientRuntime.Azure.TestFramework.TestEnvironmentFactory.GetTestEnvironment());
}
private static StorageManagementClient GetStorageManagementClient(MockContext context)
{
return context.GetServiceClient<StorageManagementClient>(Rest.ClientRuntime.Azure.TestFramework.TestEnvironmentFactory.GetTestEnvironment());
}

private static EventHubManagementClient GetEHClient(MockContext context)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function Test-AzureRmIotHubModuleLifecycle
Assert-True { $module.Authentication.Type -eq 'SelfSigned' }

# Invoke direct method on device module
$errorMessage = 'Timed out waiting for device to connect.'
$errorMessage = "The operation failed because the requested device isn't online or hasn't registered the direct method callback."
Assert-ThrowsContains { Invoke-AzIotHubModuleMethod -ResourceGroupName $ResourceGroupName -IotHubName $IotHubName -DeviceId $device1 -ModuleId $module1 -Name "SetTelemetryInterval" } $errorMessage

# Update Module
Expand Down
35 changes: 25 additions & 10 deletions src/IotHub/IotHub.Test/ScenarioTests/IotHubRoutingTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,6 @@ Test all iothub routing cmdlets
#>
function Test-AzureRmIotHubRoutingLifecycle
{
##############################################################
# Set these to the proper azure storage account information.
$azureStorageResourceGroupName = 'pshardcodedrg1234'
$azureStorageSubscriptionId = '91d12660-3dec-467a-be2a-213b5544ddc0'
$ascConnectionString = 'DefaultEndpointsProtocol=https;AccountName=pshardcodedstorage1234;AccountKey=W1ujKNLtPmMtaNqZfOCUU5cnYMI8bQeF9ODce4riISyT2RSXiIxcwuwQhzCmIuwPWi82ParLfbq1bOF5ypUnPw==;EndpointSuffix=core.windows.net'
$containerName1 = 'container1'
$containerName2 = 'container2'
##############################################################

$Location = Get-Location "Microsoft.Devices" "IotHubs" "WEST US 2"
$IotHubName = getAssetName
$ResourceGroupName = getAssetName
Expand All @@ -56,7 +47,31 @@ function Test-AzureRmIotHubRoutingLifecycle
$resourceGroup = New-AzResourceGroup -Name $ResourceGroupName -Location $Location

# Create Iot Hub
$iothub = New-AzIotHub -Name $IotHubName -ResourceGroupName $ResourceGroupName -Location $Location -SkuName $Sku -Units 1
$iothub = New-AzIotHub -Name $IotHubName -ResourceGroupName $ResourceGroupName -Location $Location -SkuName $Sku -Units 1
$subscriptionId = $iothub.SubscriptionId

# Setup storage account
$azureStorageResourceGroupName = $ResourceGroupName
$azureStorageSubscriptionId = $subscriptionId
$azureStorageAccountName = getAssetName
$containerName1 = 'container1'
$containerName2 = 'container2'

# Create storage account
$storageAccount = New-AzStorageAccount -ResourceGroupName $azureStorageResourceGroupName -AccountName $azureStorageAccountName -Location westus -SkuName Standard_GRS
$key = Get-AzStorageAccountKey -ResourceGroupName $azureStorageResourceGroupName -Name $azureStorageAccountName;
$context = New-AzStorageContext -StorageAccountName $azureStorageAccountName -StorageAccountKey $key.Value[0];


# Create containers
if ([Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode -ne [Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode]::Playback)
{
New-AzStorageContainer -Name $containerName1 -Context $context
New-AzStorageContainer -Name $containerName2 -Context $context
}

# Get connection string
$ascConnectionString = $context.ConnectionString

# Create new eventHub namespace
$eventHubNamespace = New-AzEventHubNamespace -ResourceGroup $ResourceGroupName -NamespaceName $namespaceName -Location $Location
Expand Down
2 changes: 0 additions & 2 deletions src/IotHub/IotHub.Test/ScenarioTests/IotHubTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ function Test-AzureRmIotHubLifecycle
$Location = Get-Location "Microsoft.Devices" "IotHub"
$IotHubName = getAssetName
$ResourceGroupName = getAssetName
$SubscriptionId = '91d12660-3dec-467a-be2a-213b5544ddc0'
$Sku = "B1"
$namespaceName = getAssetName 'eventHub'
$eventHubName = getAssetName
Expand Down Expand Up @@ -105,7 +104,6 @@ function Test-AzureRmIotHubLifecycle
Assert-True { $allIotHubsInResourceGroup.Count -eq 1 }
Assert-True { $iotHub.Name -eq $IotHubName }
Assert-True { $iotHub.Resourcegroup -eq $ResourceGroupName }
Assert-True { $iotHub.Subscriptionid -eq $SubscriptionId }
Assert-True { $iotHub.Properties.Routing.Routes.Count -eq 1}
Assert-True { $iotHub.Properties.Routing.Routes[0].Name -eq "route"}
Assert-True { $iotHub.Properties.Routing.Endpoints.EventHubs[0].Name -eq "eh1"}
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading

0 comments on commit 0922575

Please sign in to comment.