Skip to content

Commit

Permalink
added new Boolean property KafkaEnabled to enable Kafka for the Event…
Browse files Browse the repository at this point in the history
… Hub namepsace (#4961)
  • Loading branch information
rrama-Microsoft authored and dsgouda committed Oct 29, 2018
1 parent 59c76f2 commit 5a90680
Show file tree
Hide file tree
Showing 81 changed files with 31,069 additions and 2,378 deletions.
2 changes: 1 addition & 1 deletion src/SDKs/EventHub/AzSdk.RP.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--This file and it's contents are updated at build time moving or editing might result in build failure. Take due deligence while editing this file-->
<PropertyGroup>
<AzureApiTag>EventHub_2018-01-01-preview;</AzureApiTag>
<AzureApiTag>EventHub_2017-04-01;</AzureApiTag>
<PackageTags>$(PackageTags);$(CommonTags);$(AzureApiTag);</PackageTags>
</PropertyGroup>
</Project>
12 changes: 1 addition & 11 deletions src/SDKs/EventHub/EventHub.Tests/EventHub.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,7 @@
<Authors>Microsoft Corporation</Authors>
<AssemblyName>EventHub.Tests</AssemblyName>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Tests\ScenarioTests.ConsumergroupsTests.CRUD_Length.cs" />
<Compile Remove="Tests\ScenarioTests.DisasterRecoveryAlertnateNameTests.CRUD.cs" />
<Compile Remove="Tests\ScenarioTests.DisasterRecoveryTests.CRUD.cs" />
<Compile Remove="Tests\ScenarioTests.EventHubskiptopTests.cs" />
<Compile Remove="Tests\ScenarioTests.EventHubsTests.CRUDAuthorizationRules.cs" />
<Compile Remove="Tests\ScenarioTests.EventHubsTests.CRUDAuthorizationRules_Length.cs" />
<Compile Remove="Tests\ScenarioTests.EventHubTests.CRUD.cs" />
<Compile Remove="Tests\ScenarioTests.NamespaceTests.CRUDAuthorizationRules.cs" />
</ItemGroup>
</PropertyGroup>

<ItemGroup>
<!-- <PackageReference Include="Microsoft.Azure.Management.EventHub" Version="1.2.0" /> -->
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.

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.

Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,17 @@ public static class EventHubManagementHelper
internal const string NamespacePrefix = "sdk-Namespace-";
internal const string AuthorizationRulesPrefix = "sdk-Authrules-";
internal const string DefaultNamespaceAuthorizationRule = "RootManageSharedAccessKey";
internal const string IPFilterRulesPrefix = "sdk-IPFilterRules-";
internal const string VirtualNetworkRulesPrefix = "sdk-VirtualNetworkRules-";
internal const string EventHubPrefix = "sdk-EventHub-";
internal const string ConsumerGroupPrefix = "sdk-ConsumerGroup-";
internal const string DisasterRecoveryPrefix = "sdk-DisasterRecovery-";


public static EventHub2018PreviewManagementClient GetEventHubManagementClient(MockContext context, RecordedDelegatingHandler handler)
public static EventHubManagementClient GetEventHubManagementClient(MockContext context, RecordedDelegatingHandler handler)
{
if (handler != null)
{
handler.IsPassThrough = true;
EventHub2018PreviewManagementClient nhManagementClient = context.GetServiceClient<EventHub2018PreviewManagementClient>(handlers: handler);
EventHubManagementClient nhManagementClient = context.GetServiceClient<EventHubManagementClient>(handlers: handler);
return nhManagementClient;
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.


namespace EventHub.Tests.ScenarioTests
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using Microsoft.Azure.Management.EventHub;
using Microsoft.Azure.Management.EventHub.Models;
using Microsoft.Rest.Azure;
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
using TestHelper;
using Xunit;
public partial class ScenarioTests
{
[Fact]
public void ConsumerGroupsCreateGetUpdateDelete()
{
using (MockContext context = MockContext.Start(this.GetType().FullName))
{
InitializeClients(context);

var location = this.ResourceManagementClient.GetLocationFromProvider();

var resourceGroup = this.ResourceManagementClient.TryGetResourceGroup(location);
if (string.IsNullOrWhiteSpace(resourceGroup))
{
resourceGroup = TestUtilities.GenerateName(EventHubManagementHelper.ResourceGroupPrefix);
this.ResourceManagementClient.TryRegisterResourceGroup(location, resourceGroup);
}

var namespaceName = TestUtilities.GenerateName(EventHubManagementHelper.NamespacePrefix);
var createNamespaceResponse = this.EventHubManagementClient.Namespaces.CreateOrUpdate(resourceGroup, namespaceName,
new EHNamespace()
{
Location = location,
Sku = new Sku
{
Name = SkuName.Standard,
Tier = SkuTier.Standard
},
Tags = new Dictionary<string, string>()
{
{"tag1", "value1"},
{"tag2", "value2"}
}
});

Assert.NotNull(createNamespaceResponse);
Assert.Equal(createNamespaceResponse.Name, namespaceName);

TestUtilities.Wait(TimeSpan.FromSeconds(5));

// Create Eventhub
var eventhubName = TestUtilities.GenerateName(EventHubManagementHelper.EventHubPrefix);

var createEventhubResponse = this.EventHubManagementClient.EventHubs.CreateOrUpdate(resourceGroup, namespaceName, eventhubName,
new Eventhub() { MessageRetentionInDays = 5 });

Assert.NotNull(createEventhubResponse);
Assert.Equal(createEventhubResponse.Name, eventhubName);

//Get the created EventHub
var geteventhubResponse = EventHubManagementClient.EventHubs.Get(resourceGroup, namespaceName, eventhubName);
Assert.NotNull(geteventhubResponse);
Assert.Equal(EntityStatus.Active, geteventhubResponse.Status);
Assert.Equal(geteventhubResponse.Name, eventhubName);

// Create ConsumerGroup.
var consumergroupName = TestUtilities.GenerateName(EventHubManagementHelper.ConsumerGroupPrefix);
string UserMetadata = "Newly Created";
var createConsumergroupResponse = EventHubManagementClient.ConsumerGroups.CreateOrUpdate(resourceGroup, namespaceName, eventhubName, consumergroupName, new ConsumerGroup { UserMetadata = UserMetadata});
Assert.NotNull(createConsumergroupResponse);
Assert.Equal(createConsumergroupResponse.Name, consumergroupName);

// Get Created ConsumerGroup
var getConsumergroupGetResponse = EventHubManagementClient.ConsumerGroups.Get(resourceGroup, namespaceName, eventhubName, consumergroupName);
Assert.NotNull(getConsumergroupGetResponse);
Assert.Equal(getConsumergroupGetResponse.Name, consumergroupName);

// Get all ConsumerGroup
var getSubscriptionsListAllResponse = EventHubManagementClient.ConsumerGroups.ListByEventHub(resourceGroup, namespaceName, eventhubName);
Assert.NotNull(getSubscriptionsListAllResponse);
Assert.True(getSubscriptionsListAllResponse.All(ns => ns.Id.Contains(resourceGroup)));

//Update the Created consumergroup
createConsumergroupResponse.UserMetadata = "Updated the user meta data";
var updateconsumergroupResponse = EventHubManagementClient.ConsumerGroups.CreateOrUpdate(resourceGroup, namespaceName, eventhubName, consumergroupName, createConsumergroupResponse);
Assert.NotNull(updateconsumergroupResponse);
Assert.Equal(updateconsumergroupResponse.Name, createConsumergroupResponse.Name);
Assert.Equal("Updated the user meta data", updateconsumergroupResponse.UserMetadata);

// Get Created ConsumerGroup
var getConsumergroupResponse = EventHubManagementClient.ConsumerGroups.Get(resourceGroup, namespaceName, eventhubName, consumergroupName);
Assert.NotNull(getConsumergroupResponse);
Assert.Equal(getConsumergroupResponse.Name, consumergroupName);
Assert.Equal(getConsumergroupResponse.UserMetadata, updateconsumergroupResponse.UserMetadata);

// Delete Created ConsumerGroup and check for the NotFound exception
EventHubManagementClient.ConsumerGroups.Delete(resourceGroup, namespaceName, eventhubName, consumergroupName);

// Delete Created EventHub and check for the NotFound exception
EventHubManagementClient.EventHubs.Delete(resourceGroup, namespaceName, eventhubName);

// Delete namespace
EventHubManagementClient.Namespaces.Delete(resourceGroup, namespaceName);

//Subscription end
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.


namespace EventHub.Tests.ScenarioTests
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using Microsoft.Azure.Management.EventHub;
using Microsoft.Azure.Management.EventHub.Models;
using Microsoft.Rest.Azure;
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
using TestHelper;
using Xunit;
public partial class ScenarioTests
{
[Fact]
public void ConsumerGroupsCreateGetUpdateDelete_Length()
{
using (MockContext context = MockContext.Start(this.GetType().FullName))
{
InitializeClients(context);

var location = this.ResourceManagementClient.GetLocationFromProvider();

var resourceGroup = this.ResourceManagementClient.TryGetResourceGroup(location);
if (string.IsNullOrWhiteSpace(resourceGroup))
{
resourceGroup = TestUtilities.GenerateName(EventHubManagementHelper.ResourceGroupPrefix);
this.ResourceManagementClient.TryRegisterResourceGroup(location, resourceGroup);
}

var namespaceName = TestUtilities.GenerateName(EventHubManagementHelper.NamespacePrefix);
var createNamespaceResponse = this.EventHubManagementClient.Namespaces.CreateOrUpdate(resourceGroup, namespaceName,
new EHNamespace()
{
Location = location,
Sku = new Sku
{
Name = SkuName.Standard,
Tier = SkuTier.Standard
},
Tags = new Dictionary<string, string>()
{
{"tag1", "value1"},
{"tag2", "value2"}
}
});

Assert.NotNull(createNamespaceResponse);
Assert.Equal(createNamespaceResponse.Name, namespaceName);

TestUtilities.Wait(TimeSpan.FromSeconds(5));

// Create Eventhub
var eventhubName = EventHubManagementHelper.EventHubPrefix + "thisisthenamewithmorethan53charschecktoverifytheremovlaof50charsnamelengthlimit";

var createEventhubResponse = this.EventHubManagementClient.EventHubs.CreateOrUpdate(resourceGroup, namespaceName, eventhubName,
new Eventhub() { MessageRetentionInDays = 5 });

Assert.NotNull(createEventhubResponse);
Assert.Equal(createEventhubResponse.Name, eventhubName);

//Get the created EventHub
var geteventhubResponse = EventHubManagementClient.EventHubs.Get(resourceGroup, namespaceName, eventhubName);
Assert.NotNull(geteventhubResponse);
Assert.Equal(EntityStatus.Active, geteventhubResponse.Status);
Assert.Equal(geteventhubResponse.Name, eventhubName);

// Create ConsumerGroup.
var consumergroupName = "thisisthenamewithmorethan53charschecktoverifqwert";
string UserMetadata = "Newly Created";
var createConsumergroupResponse = EventHubManagementClient.ConsumerGroups.CreateOrUpdate(resourceGroup, namespaceName, eventhubName, consumergroupName, new ConsumerGroup { UserMetadata = UserMetadata});
Assert.NotNull(createConsumergroupResponse);
Assert.Equal(createConsumergroupResponse.Name, consumergroupName);

// Get Created ConsumerGroup
var getConsumergroupGetResponse = EventHubManagementClient.ConsumerGroups.Get(resourceGroup, namespaceName, eventhubName, consumergroupName);
Assert.NotNull(getConsumergroupGetResponse);
Assert.Equal(getConsumergroupGetResponse.Name, consumergroupName);

// Get all ConsumerGroup
var getSubscriptionsListAllResponse = EventHubManagementClient.ConsumerGroups.ListByEventHub(resourceGroup, namespaceName, eventhubName);
Assert.NotNull(getSubscriptionsListAllResponse);
Assert.True(getSubscriptionsListAllResponse.All(ns => ns.Id.Contains(resourceGroup)));

//Update the Created consumergroup
createConsumergroupResponse.UserMetadata = "Updated the user meta data";
var updateconsumergroupResponse = EventHubManagementClient.ConsumerGroups.CreateOrUpdate(resourceGroup, namespaceName, eventhubName, consumergroupName, createConsumergroupResponse);
Assert.NotNull(updateconsumergroupResponse);
Assert.Equal(updateconsumergroupResponse.Name, createConsumergroupResponse.Name);
Assert.Equal("Updated the user meta data", updateconsumergroupResponse.UserMetadata);

// Get Created ConsumerGroup
var getConsumergroupResponse = EventHubManagementClient.ConsumerGroups.Get(resourceGroup, namespaceName, eventhubName, consumergroupName);
Assert.NotNull(getConsumergroupResponse);
Assert.Equal(getConsumergroupResponse.Name, consumergroupName);
Assert.Equal(getConsumergroupResponse.UserMetadata, updateconsumergroupResponse.UserMetadata);

// Delete Created ConsumerGroup and check for the NotFound exception
EventHubManagementClient.ConsumerGroups.Delete(resourceGroup, namespaceName, eventhubName, consumergroupName);

// Delete Created EventHub and check for the NotFound exception
EventHubManagementClient.EventHubs.Delete(resourceGroup, namespaceName, eventhubName);

// Delete namespace
EventHubManagementClient.Namespaces.Delete(resourceGroup, namespaceName);

//Subscription end
}
}
}
}
Loading

0 comments on commit 5a90680

Please sign in to comment.