-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
… Hub namepsace (#4961)
- Loading branch information
There are no files selected for viewing
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> |
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.
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 | ||
} | ||
} | ||
} | ||
} |