Skip to content

Commit 9ef949f

Browse files
committed
Merge remote-tracking branch 'remotes/Azure/preview' into worm-preview
# Conflicts: # src/Storage/Commands.Storage/packages.config # tools/LocalFeed/Microsoft.Azure.PowerShell.Aks.1.0.96-preview.nupkg # tools/LocalFeed/Microsoft.Azure.PowerShell.Authentication.1.0.96-preview.nupkg # tools/LocalFeed/Microsoft.Azure.PowerShell.Authentication.Abstractions.1.0.96-preview.nupkg # tools/LocalFeed/Microsoft.Azure.PowerShell.Authentication.ResourceManager.1.0.96-preview.nupkg # tools/LocalFeed/Microsoft.Azure.PowerShell.Authorization.1.0.96-preview.nupkg # tools/LocalFeed/Microsoft.Azure.PowerShell.Common.1.0.96-preview.nupkg # tools/LocalFeed/Microsoft.Azure.PowerShell.Compute.1.0.96-preview.nupkg # tools/LocalFeed/Microsoft.Azure.PowerShell.Graph.Rbac.1.0.96-preview.nupkg # tools/LocalFeed/Microsoft.Azure.PowerShell.KeyVault.1.0.96-preview.nupkg # tools/LocalFeed/Microsoft.Azure.PowerShell.Network.1.0.96-preview.nupkg # tools/LocalFeed/Microsoft.Azure.PowerShell.ResourceManager.1.0.96-preview.nupkg # tools/LocalFeed/Microsoft.Azure.PowerShell.ScenarioTest.1.0.96-preview.nupkg # tools/LocalFeed/Microsoft.Azure.PowerShell.ScenarioTest.ResourceManager.1.0.96-preview.nupkg # tools/LocalFeed/Microsoft.Azure.PowerShell.ServiceManagement.1.0.96-preview.nupkg # tools/LocalFeed/Microsoft.Azure.PowerShell.Storage.1.0.96-preview.nupkg # tools/LocalFeed/Microsoft.Azure.PowerShell.Storage.Management.1.0.96-preview.nupkg # tools/LocalFeed/Microsoft.Azure.PowerShell.Strategies.1.0.96-preview.nupkg # tools/LocalFeed/Microsoft.Azure.PowerShell.Websites.1.0.96-preview.nupkg
2 parents 1be3166 + 8ac94d8 commit 9ef949f

File tree

281 files changed

+150525
-77193
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

281 files changed

+150525
-77193
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ before_install:
2525
# https://github.com/travis-ci/travis-ci/issues/1066#issuecomment-383489298
2626
script:
2727
- sudo dotnet msbuild build.proj /t:BuildNetcore /p:Configuration=$CONFIG || travis_terminate 1
28-
- sudo dotnet tools/StaticAnalysis/bin/$CONFIG/netcoreapp2.1/StaticAnalysis.Netcore.dll -p src/Package/$CONFIG -r src/Package -u
28+
- sudo dotnet tools/StaticAnalysis/bin/$CONFIG/netcoreapp2.1/StaticAnalysis.Netcore.dll -p src/Package/$CONFIG -r src/Package -u || travis_terminate 1
2929
- sudo pwsh -NonInteractive -NoLogo -NoProfile -File tools/TestModuleLoading.ps1 || travis_terminate 1
3030
- sudo dotnet test src/Azure.PowerShell.Netcore.Test.sln --filter "AcceptanceType=CheckIn&RunType!=DesktopOnly" --configuration $CONFIG
3131

NuGet.Config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
66
<add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
77
<add key="powershell-core" value="https://powershell.myget.org/F/powershell-core/api/v3/index.json" />
8+
<add key="myget-azure-powershell" value="https://www.myget.org/F/azure-powershell/api/v3/index.json" />
89
</packageSources>
910
</configuration>

build.proj

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@
172172
<PropertyGroup>
173173
<NuGetCommand>$(MSBuildProjectDirectory)\tools\NuGet.exe</NuGetCommand>
174174
<LibraryNugetPackageFolder>$(LibrarySourceFolder)\packages</LibraryNugetPackageFolder>
175-
<NuGetRestoreConfigFile>$(MSBuildProjectDirectory)\restore.config</NuGetRestoreConfigFile>
175+
<NuGetRestoreConfigFile>$(MSBuildProjectDirectory)\NuGet.Config</NuGetRestoreConfigFile>
176176
<NuGetRestoreConfigSwitch>-ConfigFile &quot;$(NuGetRestoreConfigFile)&quot;</NuGetRestoreConfigSwitch>
177177
<NuGetRestorePackageSetting>-PackagesDirectory $(LibraryNugetPackageFolder)</NuGetRestorePackageSetting>
178178
<NuGetLocalBuildTaskPackages>-PackagesDirectory $(LibraryToolsFolder)\BuildPackagesTask\packages</NuGetLocalBuildTaskPackages>
@@ -191,16 +191,6 @@
191191
-->
192192
<Target Name="RestoreNugetPackages" Condition="$(SkipNugetRestore) == 'false'">
193193
<Message Importance="high" Text="Restore Nuget packages..." />
194-
195-
<Delete Files="$(NuGetRestoreConfigFile)" />
196-
<WriteLinesToFile
197-
File="$(NuGetRestoreConfigFile)"
198-
Lines="&lt;configuration&gt;&lt;/configuration&gt;"
199-
Overwrite="true"
200-
Encoding="Unicode"/>
201-
202-
<Exec Command="$(NuGetCommand) sources add -Name LocalFeed -Source &quot;$(LocalFeedFolder)&quot; $(NuGetRestoreConfigSwitch)"/>
203-
<Exec Command="$(NuGetCommand) sources add -Name nugetRemote -Source &quot;https://api.nuget.org/v3/index.json&quot; $(NuGetRestoreConfigSwitch)"/>
204194
<!-- Restore packages -->
205195
<Exec Command="$(NuGetCommand) restore %(StackSolution.FullPath) $(NuGetRestoreConfigSwitch) $(NuGetRestorePackageSetting)"
206196
Condition="'$(Scope)' == 'All' or '$(Scope)' == 'Stack'"
@@ -218,8 +208,6 @@
218208
ContinueOnError="false" />
219209
<!--Restore the xunit runner needed to run unit tests-->
220210
<Exec Command="$(NuGetCommand) restore $(MSBuildProjectDirectory)\packages.config -PackagesDirectory $(MSBuildProjectDirectory)\packages" />
221-
222-
<Delete Files="$(NuGetRestoreConfigFile)" />
223211
</Target>
224212

225213
<Target Name="FilterBuild">
@@ -259,16 +247,7 @@
259247
<Message Text=""/>
260248

261249
<!-- Restore packages -->
262-
<Delete Files="$(NuGetRestoreConfigFile)" />
263-
<WriteLinesToFile
264-
File="$(NuGetRestoreConfigFile)"
265-
Lines="&lt;configuration&gt;&lt;/configuration&gt;"
266-
Overwrite="true"
267-
Encoding="Unicode"/>
268-
<Exec Command="$(NuGetCommand) sources add -Name LocalFeed -Source &quot;$(MSBuildProjectDirectory)\tools\LocalFeed&quot; $(NuGetRestoreConfigSwitch)"/>
269-
<Exec Command="$(NuGetCommand) sources add -Name nugetRemote -Source &quot;https://api.nuget.org/v3/index.json&quot; $(NuGetRestoreConfigSwitch)"/>
270250
<Exec Command="$(NuGetCommand) restore %(CmdletSolutionsToBuild.FullPath) $(NuGetRestoreConfigSwitch) $(NuGetRestorePackageSetting)" ContinueOnError="false" />
271-
<Delete Files="$(NuGetRestoreConfigFile)" />
272251
</Target>
273252

274253
<!-- Build all flavors of the Cmdlets -->

src/ResourceManager/IotHub/Commands.IotHub.Test/Commands.IotHub.Test.csproj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,13 @@
4242
<Private>True</Private>
4343
</Reference>
4444
<Reference Include="Microsoft.Azure.Management.IotHub, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
45-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.IotHub.2.0.0\lib\net452\Microsoft.Azure.Management.IotHub.dll</HintPath>
45+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.IotHub.2.1.0\lib\net452\Microsoft.Azure.Management.IotHub.dll</HintPath>
4646
<Private>True</Private>
4747
</Reference>
4848
</ItemGroup>
4949
<ItemGroup>
5050
<Compile Include="ScenarioTests\IotHubController.cs" />
51+
<Compile Include="ScenarioTests\IotHubRoutingTests.cs" />
5152
<Compile Include="ScenarioTests\IotHubTests.cs" />
5253
<Compile Include="Properties\AssemblyInfo.cs" />
5354
</ItemGroup>
@@ -57,9 +58,15 @@
5758
</None>
5859
<None Include="ScenarioTests\Assert.ps1" />
5960
<None Include="ScenarioTests\Common.ps1" />
61+
<None Include="ScenarioTests\IotHubRoutingTests.ps1">
62+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
63+
</None>
6064
<None Include="ScenarioTests\IotHubTests.ps1">
6165
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
6266
</None>
67+
<None Include="SessionRecords\Microsoft.Azure.Commands.IotHub.Test.ScenarioTests.IotHubRoutingTests\TestAzureIotHubRoutingLifeCycle.json">
68+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
69+
</None>
6370
<None Include="SessionRecords\Microsoft.Azure.Commands.IotHub.Test.ScenarioTests.IotHubTests\TestAzureIotHubCertificateLifeCycle.json">
6471
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
6572
</None>

src/ResourceManager/IotHub/Commands.IotHub.Test/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Reflection;
2-
using System.Runtime.CompilerServices;
32
using System.Runtime.InteropServices;
3+
using Xunit;
44

55
// General Information about an assembly is controlled through the following
66
// set of attributes. Change these attribute values to modify the information
@@ -34,3 +34,4 @@
3434
// [assembly: AssemblyVersion("1.0.*")]
3535
[assembly: AssemblyVersion("3.0.0")]
3636
[assembly: AssemblyFileVersion("3.0.0")]
37+
[assembly: CollectionBehavior(DisableTestParallelization = true)]
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.ServiceManagemenet.Common.Models;
16+
using Microsoft.Azure.Test;
17+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
18+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
19+
using Xunit;
20+
using Xunit.Abstractions;
21+
22+
namespace Microsoft.Azure.Commands.IotHub.Test.ScenarioTests
23+
{
24+
public class IotHubRoutingTests : RMTestBase
25+
{
26+
public XunitTracingInterceptor _logger;
27+
28+
public IotHubRoutingTests(ITestOutputHelper output)
29+
{
30+
_logger = new XunitTracingInterceptor(output);
31+
XunitTracingInterceptor.AddToContext(_logger);
32+
}
33+
34+
[Fact]
35+
[Trait(Category.AcceptanceType, Category.CheckIn)]
36+
[Trait("Re-record", "ClientRuntime changes")]
37+
public void TestAzureIotHubRoutingLifeCycle()
38+
{
39+
IotHubController.NewInstance.RunPsTestWorkflow(
40+
_logger,
41+
() => { return new[] { "Test-AzureRmIotHubRoutingLifecycle" }; },
42+
null,
43+
null,
44+
TestUtilities.GetCallingClass(),
45+
TestUtilities.GetCurrentMethodName());
46+
}
47+
}
48+
}
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# ----------------------------------------------------------------------------------
2+
#
3+
# Copyright Microsoft Corporation
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# ----------------------------------------------------------------------------------
14+
15+
16+
#################################
17+
## IotHub Routing Cmdlets ##
18+
#################################
19+
20+
<#
21+
.SYNOPSIS
22+
Test all iothub routing cmdlets
23+
#>
24+
function Test-AzureRmIotHubRoutingLifecycle
25+
{
26+
$Location = Get-Location "Microsoft.Devices" "IotHub"
27+
$IotHubName = getAssetName
28+
$ResourceGroupName = getAssetName
29+
$namespaceName = getAssetName 'eventHub'
30+
$eventHubName = getAssetName
31+
$authRuleName = getAssetName
32+
$endpointName = getAssetName
33+
$routeName = getAssetName
34+
$Sku = "S1"
35+
$EndpointTypeEventHub = [Microsoft.Azure.Commands.Management.IotHub.Models.PSEndpointType] "EventHub"
36+
$RoutingSourceTwinChangeEvents = [Microsoft.Azure.Commands.Management.IotHub.Models.PSRoutingSource] "TwinChangeEvents"
37+
$RoutingSourceDeviceMessages = [Microsoft.Azure.Commands.Management.IotHub.Models.PSRoutingSource] "DeviceMessages"
38+
39+
# Create or Update Resource Group
40+
$resourceGroup = New-AzureRmResourceGroup -Name $ResourceGroupName -Location $Location
41+
42+
# Create Iot Hub
43+
$iothub = New-AzureRmIotHub -Name $IotHubName -ResourceGroupName $ResourceGroupName -Location $Location -SkuName $Sku -Units 1
44+
45+
# Create new eventHub namespace
46+
$eventHubNamespace = New-AzureRmEventHubNamespace -ResourceGroup $ResourceGroupName -NamespaceName $namespaceName -Location $Location
47+
Wait-Seconds 15
48+
Assert-True {$eventHubNamespace.ProvisioningState -eq "Succeeded"}
49+
$regexMatches = $eventHubNamespace.Id | Select-String -Pattern '^/subscriptions/(.*)/resourceGroups/(.*)/providers/(.*)$'
50+
$eventHubSubscriptionId = $regexMatches.Matches.Groups[1].Value
51+
$eventHubResourceGroup = $regexMatches.Matches.Groups[2].Value
52+
53+
# Create new eventHub
54+
$msgRetentionInDays = 3
55+
$partionCount = 2
56+
$eventHub = New-AzureRmEventHub -ResourceGroup $ResourceGroupName -NamespaceName $namespaceName -EventHubName $eventHubName -MessageRetentionInDays $msgRetentionInDays -PartitionCount $partionCount
57+
58+
# Create AuthRule for eventhub
59+
$rights = "Listen","Send"
60+
$authRule = New-AzureRmEventHubAuthorizationRule -ResourceGroup $ResourceGroupName -NamespaceName $namespaceName -EventHubName $eventHubName -AuthorizationRuleName $authRuleName -Rights $rights
61+
$keys = Get-AzureRmEventHubKey -ResourceGroup $ResourceGroupName -NamespaceName $namespaceName -EventHubName $eventHubName -AuthorizationRuleName $authRuleName
62+
$ehConnectionString = $keys.PrimaryConnectionString
63+
64+
# Get all routing endpoints
65+
$routingEndpoints = Get-AzureRmIotHubRoutingEndpoint -ResourceGroupName $ResourceGroupName -Name $IotHubName
66+
Assert-True { $routingEndpoints.Count -eq 0}
67+
68+
# Add event hub endpoint
69+
$newRoutingEndpoint = Add-AzureRmIotHubRoutingEndpoint -ResourceGroupName $ResourceGroupName -Name $IotHubName -EndpointName $endpointName -EndpointType $EndpointTypeEventHub -EndpointResourceGroup $eventHubResourceGroup -EndpointSubscriptionId $eventHubSubscriptionId -ConnectionString $ehConnectionString
70+
Assert-True { $newRoutingEndpoint.ResourceGroup -eq $eventHubResourceGroup}
71+
Assert-True { $newRoutingEndpoint.SubscriptionId -eq $eventHubSubscriptionId}
72+
Assert-True { $newRoutingEndpoint.Name -eq $endpointName}
73+
74+
# Get all routing endpoints
75+
$updatedRoutingEndpoints = Get-AzureRmIotHubRoutingEndpoint -ResourceGroupName $ResourceGroupName -Name $IotHubName
76+
Assert-True { $updatedRoutingEndpoints.Count -eq 1}
77+
Assert-True { $updatedRoutingEndpoints[0].ResourceGroup -eq $eventHubResourceGroup}
78+
Assert-True { $updatedRoutingEndpoints[0].SubscriptionId -eq $eventHubSubscriptionId}
79+
Assert-True { $updatedRoutingEndpoints[0].Name -eq $endpointName}
80+
81+
# Get all routes
82+
$routes = Get-AzureRmIotHubRoute -ResourceGroupName $ResourceGroupName -Name $IotHubName
83+
Assert-True { $routingEndpoints.Count -eq 0}
84+
85+
# Add new route
86+
$newRoute = Add-AzureRmIotHubRoute -ResourceGroupName $ResourceGroupName -Name $IotHubName -RouteName $routeName -Source $RoutingSourceDeviceMessages -EndpointName $endpointName
87+
Assert-True { $newRoute.Name -eq $routeName}
88+
Assert-True { $newRoute.Source -eq $RoutingSourceDeviceMessages}
89+
Assert-True { $newRoute.EndpointNames -eq $endpointName}
90+
Assert-False { $newRoute.IsEnabled }
91+
92+
# Get all routes
93+
$routes = Get-AzureRmIotHubRoute -ResourceGroupName $ResourceGroupName -Name $IotHubName
94+
Assert-True { $routes.Count -eq 1}
95+
Assert-True { $routes[0].Name -eq $routeName}
96+
Assert-True { $routes[0].Source -eq $RoutingSourceDeviceMessages}
97+
Assert-True { $routes[0].EndpointNames -eq $endpointName}
98+
Assert-False { $routes[0].IsEnabled }
99+
100+
# Set route
101+
$updatedRoute = Set-AzureRmIotHubRoute -ResourceGroupName $ResourceGroupName -Name $IotHubName -RouteName $routeName -Source $RoutingSourceTwinChangeEvents -Enabled
102+
Assert-True { $updatedRoute.Name -eq $routeName}
103+
Assert-True { $updatedRoute.Source -eq $RoutingSourceTwinChangeEvents}
104+
Assert-True { $updatedRoute.EndpointNames -eq $endpointName}
105+
Assert-True { $updatedRoute.IsEnabled }
106+
107+
# Test All Routes
108+
$testRouteOutput = Test-AzureRmIotHubRoute -ResourceGroupName $ResourceGroupName -Name $IotHubName -Source $RoutingSourceTwinChangeEvents
109+
Assert-True { $testRouteOutput.Count -eq 1}
110+
Assert-True { $testRouteOutput[0].Name -eq $routeName}
111+
Assert-True { $testRouteOutput[0].Source -eq $RoutingSourceTwinChangeEvents}
112+
Assert-True { $testRouteOutput[0].EndpointNames -eq $endpointName}
113+
Assert-True { $testRouteOutput[0].IsEnabled }
114+
115+
# Delete Route
116+
$result = Remove-AzureRmIotHubRoute -ResourceGroupName $ResourceGroupName -Name $IotHubName -RouteName $routeName -Passthru
117+
Assert-True { $result }
118+
119+
# Delete routing endpoint
120+
$result = Remove-AzureRmIotHubRoutingEndpoint -ResourceGroupName $ResourceGroupName -Name $IotHubName -EndpointName $endpointName -Passthru
121+
Assert-True { $result }
122+
123+
# Remove IotHub
124+
Remove-AzureRmIotHub -ResourceGroupName $ResourceGroupName -Name $IotHubName
125+
}

0 commit comments

Comments
 (0)