Skip to content

Commit

Permalink
Merge pull request Azure#3864 from v-Ajnava/EHFixes
Browse files Browse the repository at this point in the history
EventHub: bug fix and New SDK Nuget version
  • Loading branch information
markcowl authored May 2, 2017
2 parents c00b1c7 + 51a7d3f commit fc39589
Show file tree
Hide file tree
Showing 18 changed files with 793 additions and 538 deletions.
4 changes: 4 additions & 0 deletions src/ResourceManager/EventHub/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
-->
## Current Release

* Bug fix :
Fix for Set-AzureRmEventHubNamespace cmdlet error - 'Tier' cannot be null, where it should be 'SkuName'
Set-AzureRmEventHub - Fix 'Object reference not set to an instance of an object' error while updating EventHub

## Version 0.2.0

## Version 0.1.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\..\..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props')" />
<Import Project="..\..\..\packages\xunit.core.2.1.0\build\portable-net45+win8+wp8+wpa81\xunit.core.props" Condition="Exists('..\..\..\packages\xunit.core.2.1.0\build\portable-net45+win8+wp8+wpa81\xunit.core.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
Expand All @@ -11,7 +11,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Microsoft.Azure.Commands.EventHubs.Test</RootNamespace>
<AssemblyName>Microsoft.Azure.Commands.EventHubs.Test</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
Expand Down Expand Up @@ -57,17 +57,27 @@
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.EventHub, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.EventHub.0.0.1-preview\lib\net45\Microsoft.Azure.Management.EventHub.dll</HintPath>
<Private>True</Private>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.EventHub.1.2.0\lib\net452\Microsoft.Azure.Management.EventHub.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=2.28.3.860, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.28.3\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms, Version=2.28.3.860, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.28.3\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.2.3.5\lib\net45\Microsoft.Rest.ClientRuntime.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.2.3.6\lib\net45\Microsoft.Rest.ClientRuntime.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime.Azure, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.3.3.5\lib\net45\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.Authentication.2.2.12\lib\net45\Microsoft.Rest.ClientRuntime.Azure.Authentication.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.TestFramework, Version=1.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.TestFramework.1.6.0\lib\net45\Microsoft.Rest.ClientRuntime.Azure.TestFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Storage, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Storage.5.1.1\lib\net40\Microsoft.WindowsAzure.Management.Storage.dll</HintPath>
<Private>True</Private>
Expand All @@ -84,14 +94,6 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Test.HttpRecorder.1.6.7-preview\lib\net45\Microsoft.Azure.Test.HttpRecorder.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=2.28.3.860, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.28.3\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.TestFramework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.TestFramework.1.3.6-preview\lib\net45\Microsoft.Rest.ClientRuntime.Azure.TestFramework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Moq">
<HintPath>..\..\..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -173,19 +175,19 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.EventHub.Test.ScenarioTests.ConsumerGroupsTests\ConsumerGroupsCRUD.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.EventHub.Test.ScenarioTests.EventHubsTests\EventHubsAuthorizationRulesCRUD.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.EventHub.Test.ScenarioTests.EventHubsTests\EventHubsCRUD.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.EventHub.Test.ScenarioTests.NamespaceTests\NamespaceAuthorizationRulesCRUD.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.EventHub.Test.ScenarioTests.NamespaceTests\NamespaceCRUD.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,8 @@ function ConsumerGroupsTests

Write-Debug " Get the created namespace within the resource group"
$createdNamespace = Get-AzureRmEventHubNamespace -ResourceGroup $resourceGroupName -NamespaceName $namespaceName
Assert-True {$createdNamespace.Count -eq 1}

$found = 0

if ($createdNamespace.Name -eq $namespaceName)
{
$found = 1
Assert-AreEqual $location $createdNamespace.Location
break
}


Assert-True {$found -eq 0} "Namespace created earlier is not found."
Assert-True {$createdNamespace.Name -eq $namespaceName} "Namespace created earlier is not found."

Write-Debug " Create new eventHub "
$msgRetentionInDays = 3
Expand All @@ -96,8 +85,7 @@ function ConsumerGroupsTests
$createdEventHub = Get-AzureRmEventHub -ResourceGroup $resourceGroupName -NamespaceName $namespaceName -EventHubName $result.Name

$createdEventHub = Get-AzureRmEventHub -ResourceGroup $resourceGroupName -NamespaceName $namespaceName -EventHubName $eventHubName
Assert-True {$createdEventHub.Count -eq 1}

Assert-True {$createdEventHub.Name -eq $eventHubName} "Namespace created earlier is not found."

Write-Debug " Create a new ConsumerGroup "
$result_ConsumerGroup = New-AzureRmEventHubConsumerGroup -ResourceGroup $resourceGroupName -NamespaceName $namespaceName -EventHubName $eventHubName -ConsumerGroupName $consumerGroupName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,50 +83,27 @@ function EventHubsTests
Write-Debug " Get the created namespace within the resource group"
$createdNamespace = Get-AzureRmEventHubNamespace -ResourceGroup $resourceGroupName -NamespaceName $namespaceName

# Assert
Assert-True {$createdNamespace.Count -eq 1}

$found = 0

if ($createdNamespace.Name -eq $namespaceName)
{
$found = 1
Assert-AreEqual $location $createdNamespace.Location
break
}

Assert-True {$found -eq 0} "Namespace created earlier is not found."
Assert-True {$createdNamespace.Name -eq $namespaceName} "Namespace created earlier is not found."

# Create a EventHub
Write-Debug " Create new eventHub "
$msgRetentionInDays = 3
$partionCount = 2
$result = New-AzureRmEventHub -ResourceGroup $resourceGroupName -NamespaceName $namespaceName -Location $location -EventHubName $eventHubName -MessageRetentionInDays $msgRetentionInDays -PartitionCount $partionCount



Write-Debug " Get the created Eventhub "
$createdEventHub = Get-AzureRmEventHub -ResourceGroup $resourceGroupName -NamespaceName $namespaceName -EventHubName $result.Name

# Assert
Assert-True {$createdEventHub.Count -eq 1}
Assert-True {$createdEventHub.Name -eq $eventHubName} "EventHub created earlier is not found."

# Get the Created Eventhub
Write-Debug " Get all the created EventHub "
$createdEventHubList = Get-AzureRmEventHub -ResourceGroup $resourceGroupName -NamespaceName $namespaceName

# Assert
$found = 0
for ($i = 0; $i -lt $createdEventHubList.Count; $i++)
{
if ($createdEventHubList[$i].Name -eq $createdEventHub.Name)
{
$found = $found + 1
}
}

# Assert
Assert-True {$found -eq 0} "EventHub created earlier is not found."
Assert-True {$createdEventHub.Count -eq 1} "EventHub created earlier is not found in list"

# Update the Created EventHub
Write-Debug " Update the first EventHub "
Expand Down Expand Up @@ -184,18 +161,7 @@ function EventHubsAuthTests
$createdNamespace = Get-AzureRmEventHubNamespace -ResourceGroup $resourceGroupName -NamespaceName $namespaceName

# Assert
Assert-True {$createdNamespace.Count -eq 1}
$found = 0

if ($createdNamespace.Name -eq $namespaceName)
{
$found = 1
Assert-AreEqual $location $createdNamespace.Location
break
}

# Assert
Assert-True {$found -eq 0} "Namespace created earlier is not found."
Assert-True {$createdNamespace.Name -eq $namespaceName} "Namespace created earlier is not found."

# Create New EventHub
Write-Debug " Create new eventHub "
Expand All @@ -207,7 +173,7 @@ function EventHubsAuthTests
$createdEventHub = Get-AzureRmEventHub -ResourceGroup $resourceGroupName -NamespaceName $namespaceName -EventHubName $result_eventHub.Name

# Assert
Assert-True {$createdEventHub.Count -eq 1}
Assert-True {$createdEventHub.Name -eq $eventHubName} "EventHub created earlier is not found."

# Create Eventhub Authorization Rule
Write-Debug "Create a EventHub Authorization Rule"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,9 @@ function NamespaceAuthTests

Write-Debug " Get the created namespace within the resource group"
$createdNamespace = Get-AzureRmEventHubNamespace -ResourceGroup $resourceGroupName -NamespaceName $namespaceName
Assert-True {$createdNamespace.Count -eq 1}

$found = 0

if ($createdNamespace.Name -eq $namespaceName)
{
$found = 1
Assert-AreEqual $location $createdNamespace.Location
break
}

Assert-True {$found -eq 0} "Namespace created earlier is not found."
#Assert
Assert-True {$createdNamespace.Name -eq $namespaceName} "Namespace created earlier is not found."

Write-Debug "Create a Namespace Authorization Rule"
Write-Debug "Auth Rule name : $authRuleName"
Expand Down Expand Up @@ -227,16 +218,7 @@ function NamespaceTests
$createdNamespace = Get-AzureRmEventHubNamespace -ResourceGroup $resourceGroupName -NamespaceName $namespaceName
Assert-True {$createdNamespace.Count -eq 1}

$found = 0

if ($createdNamespace.Name -eq $namespaceName)
{
$found = 1
Assert-AreEqual $location $createdNamespace.Location
break
}

Assert-True {$found -eq 0} "Namespace created earlier is not found."
Assert-True {$createdNamespace.Name -eq $namespaceName} "Namespace created earlier is not found."


Write-Debug "Namespace name : $namespaceName2"
Expand All @@ -245,40 +227,14 @@ function NamespaceTests

Write-Debug "Get all the namespaces created in the resourceGroup"
$allCreatedNamespace = Get-AzureRmEventHubNamespace -ResourceGroup $secondResourceGroup

$found = 0
for ($i = 0; $i -lt $allCreatedNamespace.Count; $i++)
{
if ($allCreatedNamespace[$i].Name -eq $namespaceName2)
{
$found = 1
Assert-AreEqual $location $allCreatedNamespace[$i].Location
break
}
}

Assert-True {$found -eq 0} "Namespace created earlier is not found."

#Assert
Assert-True {$allCreatedNamespace.Count -ge 0 } "Namespace created earlier is not found. in list"

Write-Debug "Get all the namespaces created in the subscription"
$allCreatedNamespace = Get-AzureRmEventHubNamespace

$found = 0
for ($i = 0; $i -lt $allCreatedNamespace.Count; $i++)
{
if ($allCreatedNamespace[$i].Name -eq $namespaceName)
{
$found = $found + 1
Assert-AreEqual $location $allCreatedNamespace[$i].Location
}

if ($allCreatedNamespace[$i].Name -eq $namespaceName2)
{
$found = $found + 1
Assert-AreEqual $location $allCreatedNamespace[$i].Location
}
}

Assert-True {$found -eq 0} "Namespaces created earlier is not found."

Assert-True {$allCreatedNamespace.Count -ge 0} "Namespaces created earlier is not found."

Write-Debug " Delete namespaces"
Remove-AzureRmEventHubNamespace -ResourceGroup $secondResourceGroup -NamespaceName $namespaceName2
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Gallery" version="2.6.2-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Authorization" version="1.0.2" targetFramework="net45" />
<package id="Microsoft.Azure.Management.EventHub" version="0.0.1-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.EventHub" version="1.2.0" targetFramework="net452" />
<package id="Microsoft.Azure.Management.Resources" version="2.20.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Storage" version="3.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Websites" version="1.2.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.6.7-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.7.0" targetFramework="net45" />
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net45" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net45" />
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="2.28.1" targetFramework="net45" />
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="2.28.3" targetFramework="net452" />
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="net45" />
<package id="Microsoft.Rest.ClientRuntime" version="2.3.5" targetFramework="net45" />
<package id="Microsoft.Rest.ClientRuntime" version="2.3.6" targetFramework="net452" />
<package id="Microsoft.Rest.ClientRuntime.Azure" version="3.3.5" targetFramework="net45" />
<package id="Microsoft.Rest.ClientRuntime.Azure.TestFramework" version="1.3.6-preview" targetFramework="net45" />
<package id="Microsoft.Rest.ClientRuntime.Azure.Authentication" version="2.2.12" targetFramework="net452" />
<package id="Microsoft.Rest.ClientRuntime.Azure.TestFramework" version="1.6.0" targetFramework="net452" />
<package id="Moq" version="4.2.1510.2205" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
<package id="xunit" version="2.1.0" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,9 @@ public override void ExecuteCmdlet()
{
ConsumerGroupAttributes consumerGroup = new ConsumerGroupAttributes();

EventHubAttributes getEventHub = Client.GetEventHub(ResourceGroupName, NamespaceName, EventHubName);

consumerGroup.Name = ConsumerGroupName;
consumerGroup.Location = getEventHub.Location;
var getnamespace = Client.GetNamespace(ResourceGroupName, NamespaceName);
consumerGroup.Location = getnamespace.Location;

if (!string.IsNullOrEmpty(UserMetadata))
consumerGroup.UserMetadata = UserMetadata;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ public override void ExecuteCmdlet()
{
ConsumerGroupAttributes consumerGroup = new ConsumerGroupAttributes();

EventHubAttributes getEventHub = Client.GetEventHub(ResourceGroupName, NamespaceName, EventHubName);
var getnamespace = Client.GetNamespace(ResourceGroupName, NamespaceName);

consumerGroup.Name = ConsumerGroupName;
consumerGroup.Location = getEventHub.Location;
consumerGroup.Location = getnamespace.Location;

if (!string.IsNullOrEmpty(UserMetadata))
consumerGroup.UserMetadata = UserMetadata;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@ public override void ExecuteCmdlet()
if (partitionCount.HasValue)
eventHub.PartitionCount = partitionCount;
}

if(ShouldProcess(target:EventHubName, action: string.Format("Updating EventHub:{0} of NameSpace:{1}",EventHubName,NamespaceName)))

eventHub.Location = Client.GetNamespace(ResourceGroupName, NamespaceName).Location;

if (ShouldProcess(target:EventHubName, action: string.Format("Updating EventHub:{0} of NameSpace:{1}",EventHubName,NamespaceName)))
{
WriteObject(Client.CreateOrUpdateEventHub(ResourceGroupName, NamespaceName, eventHub.Name, eventHub));
}
Expand Down
Loading

0 comments on commit fc39589

Please sign in to comment.