Skip to content

Commit

Permalink
fix servicebus tests (#25742)
Browse files Browse the repository at this point in the history
* fix servicebus tests

* re-record tests

* comment disaster recovery test

* ignore tests in live mode

* delete one line
  • Loading branch information
Yao725 authored Dec 13, 2021
1 parent cd3ceed commit f81209e
Show file tree
Hide file tree
Showing 53 changed files with 331,704 additions and 131,098 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,13 @@ public static void VerifyNamespaceProperties(ServiceBusNamespace sBNamespace, bo
Assert.AreEqual(SkuTier.Standard, sBNamespace.Data.Sku.Tier);
}
}

public void IgnoreTestInLiveMode()
{
if (Mode == RecordedTestMode.Live)
{
Assert.Ignore();
}
}
}
}

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.

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.

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.

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.

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 @@ -18,25 +18,11 @@ public class DisasterRecoveryTests : ServiceBusTestBase
public DisasterRecoveryTests(bool isAsync) : base(isAsync)
{
}
[TearDown]
public async Task ClearNamespaces()
{
//remove all namespaces under current resource group
if (_resourceGroup != null)
{
ServiceBusNamespaceCollection namespaceCollection = _resourceGroup.GetServiceBusNamespaces();
List<ServiceBusNamespace> namespaceList = await namespaceCollection.GetAllAsync().ToEnumerableAsync();
foreach (ServiceBusNamespace serviceBusNamespace in namespaceList)
{
await serviceBusNamespace.DeleteAsync();
}
_resourceGroup = null;
}
}
[Test]
[RecordedTest]
public async Task CreateGetUpdateDeleteDisasterRecovery()
{
IgnoreTestInLiveMode();
_resourceGroup = await CreateResourceGroupAsync();
//create namespace1
string namespaceName1 = await CreateValidNamespaceName("testnamespacemgmt");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public QueueTests(bool isAsync) : base(isAsync)
[SetUp]
public async Task CreateNamespaceAndGetQueueCollection()
{
IgnoreTestInLiveMode();
_resourceGroup = await CreateResourceGroupAsync();
string namespaceName = await CreateValidNamespaceName("testnamespacemgmt");
ServiceBusNamespaceCollection namespaceCollection = _resourceGroup.GetServiceBusNamespaces();
Expand All @@ -34,25 +35,11 @@ public async Task CreateNamespaceAndGetQueueCollection()
ServiceBusNamespace serviceBusNamespace = (await namespaceCollection.CreateOrUpdateAsync(namespaceName, parameters)).Value;
_queueCollection = serviceBusNamespace.GetServiceBusQueues();
}
[TearDown]
public async Task ClearNamespaces()
{
//remove all namespaces under current resource group
if (_resourceGroup != null)
{
ServiceBusNamespaceCollection namespaceCollection = _resourceGroup.GetServiceBusNamespaces();
List<ServiceBusNamespace> namespaceList = await namespaceCollection.GetAllAsync().ToEnumerableAsync();
foreach (ServiceBusNamespace serviceBusNamespace in namespaceList)
{
await serviceBusNamespace.DeleteAsync();
}
_resourceGroup = null;
}
}
[Test]
[RecordedTest]
public async Task CreateDeleteQueue()
{
IgnoreTestInLiveMode();
//create queue
string queueName = Recording.GenerateAssetName("queue");
ServiceBusQueue queue = (await _queueCollection.CreateOrUpdateAsync(queueName, new ServiceBusQueueData())).Value;
Expand All @@ -77,6 +64,7 @@ public async Task CreateDeleteQueue()
[RecordedTest]
public async Task GetAllQueues()
{
IgnoreTestInLiveMode();
//create ten queues
for (int i = 0; i < 10; i++)
{
Expand All @@ -95,6 +83,7 @@ public async Task GetAllQueues()
[RecordedTest]
public async Task UpdateQueue()
{
IgnoreTestInLiveMode();
//create queue
string queueName = Recording.GenerateAssetName("queue");
ServiceBusQueue queue = (await _queueCollection.CreateOrUpdateAsync(queueName, new ServiceBusQueueData())).Value;
Expand All @@ -114,6 +103,7 @@ public async Task UpdateQueue()
[RecordedTest]
public async Task QueueCreateGetUpdateDeleteAuthorizationRule()
{
IgnoreTestInLiveMode();
//create queue
string queueName = Recording.GenerateAssetName("queue");
ServiceBusQueue queue = (await _queueCollection.CreateOrUpdateAsync(queueName, new ServiceBusQueueData())).Value;
Expand Down Expand Up @@ -169,6 +159,7 @@ public async Task QueueCreateGetUpdateDeleteAuthorizationRule()
[RecordedTest]
public async Task QueueAuthorizationRuleRegenerateKey()
{
IgnoreTestInLiveMode();
//create queue
string queueName = Recording.GenerateAssetName("queue");
ServiceBusQueue queue = (await _queueCollection.CreateOrUpdateAsync(queueName, new ServiceBusQueueData())).Value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public RuleTests(bool isAsync) : base(isAsync)
[RecordedTest]
public async Task CreateGetUpdateDeleteRule()
{
IgnoreTestInLiveMode();

const string strSqlExp = "myproperty=test";

//create namespace
Expand Down Expand Up @@ -80,8 +82,6 @@ public async Task CreateGetUpdateDeleteRule()

await rule1.DeleteAsync();
await rule2.DeleteAsync();
await serviceBusSubscription.DeleteAsync();
await serviceBusNamespace.DeleteAsync();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,11 @@ public class ServiceBusNamespaceTests : ServiceBusTestBase
public ServiceBusNamespaceTests(bool isAsync) : base(isAsync)
{
}
[TearDown]
public async Task ClearNamespaces()
{
//remove all namespaces under current resource group
if (_resourceGroup != null)
{
ServiceBusNamespaceCollection namespaceCollection = _resourceGroup.GetServiceBusNamespaces();
List<ServiceBusNamespace> namespaceList = await namespaceCollection.GetAllAsync().ToEnumerableAsync();
foreach (ServiceBusNamespace serviceBusNamespace in namespaceList)
{
await serviceBusNamespace.DeleteAsync();
}
_resourceGroup = null;
}
}
[Test]
[RecordedTest]
public async Task CreateDeleteNamespace()
{
IgnoreTestInLiveMode();
//create namespace and wait for completion
string namespaceName = await CreateValidNamespaceName(namespacePrefix);
_resourceGroup = await CreateResourceGroupAsync();
Expand All @@ -66,6 +52,7 @@ public async Task CreateDeleteNamespace()
[RecordedTest]
public async Task CreateNamespaceWithZoneRedundant()
{
IgnoreTestInLiveMode();
//create namespace and wait for completion
string namespaceName = await CreateValidNamespaceName(namespacePrefix);
_resourceGroup = await CreateResourceGroupAsync();
Expand All @@ -87,6 +74,7 @@ public async Task CreateNamespaceWithZoneRedundant()
[RecordedTest]
public async Task UpdateNamespace()
{
IgnoreTestInLiveMode();
//create namespace
string namespaceName = await CreateValidNamespaceName(namespacePrefix);
_resourceGroup = await CreateResourceGroupAsync();
Expand All @@ -113,6 +101,7 @@ public async Task UpdateNamespace()
[RecordedTest]
public async Task GetAllNamespaces()
{
IgnoreTestInLiveMode();
//create two namespaces
_resourceGroup = await CreateResourceGroupAsync();
ServiceBusNamespaceCollection namespaceCollection = _resourceGroup.GetServiceBusNamespaces();
Expand Down Expand Up @@ -142,6 +131,7 @@ public async Task GetAllNamespaces()
[RecordedTest]
public async Task GetNamespacesInSubscription()
{
IgnoreTestInLiveMode();
//create two namespaces in two resourcegroups
string namespaceName1 = await CreateValidNamespaceName(namespacePrefix);
_resourceGroup = await CreateResourceGroupAsync();
Expand All @@ -168,14 +158,13 @@ public async Task GetNamespacesInSubscription()
VerifyNamespaceProperties(namespace2, true);
Assert.AreEqual(namespace1.Id.ResourceGroupName, _resourceGroup.Id.Name);
Assert.AreEqual(namespace2.Id.ResourceGroupName, resourceGroup.Id.Name);

await namespace2.DeleteAsync();
}

[Test]
[RecordedTest]
public async Task GetPrivateLinkResources()
{
IgnoreTestInLiveMode();
//create namespace
_resourceGroup = await CreateResourceGroupAsync();
ServiceBusNamespaceCollection namespaceCollection = _resourceGroup.GetServiceBusNamespaces();
Expand Down Expand Up @@ -236,6 +225,7 @@ public async Task CreateGetDeletePrivateEndPointConnection()
[RecordedTest]
public async Task NamespaceCreateGetUpdateDeleteAuthorizationRule()
{
IgnoreTestInLiveMode();
//create namespace
_resourceGroup = await CreateResourceGroupAsync();
ServiceBusNamespaceCollection namespaceCollection = _resourceGroup.GetServiceBusNamespaces();
Expand Down Expand Up @@ -300,6 +290,7 @@ public async Task NamespaceCreateGetUpdateDeleteAuthorizationRule()
[RecordedTest]
public async Task NamespaceAuthorizationRuleRegenerateKey()
{
IgnoreTestInLiveMode();
//create namespace
_resourceGroup = await CreateResourceGroupAsync();
ServiceBusNamespaceCollection namespaceCollection = _resourceGroup.GetServiceBusNamespaces();
Expand Down Expand Up @@ -341,6 +332,7 @@ public async Task NamespaceAuthorizationRuleRegenerateKey()
[RecordedTest]
public async Task SetGetNetworkRuleSets()
{
IgnoreTestInLiveMode();
//create namespace with premium
_resourceGroup = await CreateResourceGroupAsync();
ServiceBusNamespaceCollection namespaceCollection = _resourceGroup.GetServiceBusNamespaces();
Expand Down Expand Up @@ -422,6 +414,7 @@ public async Task SetGetNetworkRuleSets()
[RecordedTest]
public async Task StandardToPremiumMigration()
{
IgnoreTestInLiveMode();
//create namespace with premium
_resourceGroup = await CreateResourceGroupAsync();
ServiceBusNamespaceCollection namespaceCollection = _resourceGroup.GetServiceBusNamespaces();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public SubscriptionTests(bool isAsync) : base(isAsync)
[RecordedTest]
public async Task CreateGetUpdateDeleteSubscription()
{
IgnoreTestInLiveMode();
//create namespace
ResourceGroup resourceGroup = await CreateResourceGroupAsync();
string namespaceName = await CreateValidNamespaceName("testnamespacemgmt");
Expand Down Expand Up @@ -85,13 +86,6 @@ public async Task CreateGetUpdateDeleteSubscription()
//delete subscription
await serviceBusSubscription.DeleteAsync();
Assert.IsFalse(await serviceBusSubscriptionCollection.CheckIfExistsAsync(subscriptionName));

//delete created topics
await topic.DeleteAsync();
await topic1.DeleteAsync();

//delete namespace
await serviceBusNamespace.DeleteAsync();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public TopicTests(bool isAsync): base(isAsync)
[SetUp]
public async Task CreateNamespaceAndGetTopicCollection()
{
IgnoreTestInLiveMode();
_resourceGroup = await CreateResourceGroupAsync();
string namespaceName = await CreateValidNamespaceName("testnamespacemgmt");
ServiceBusNamespaceCollection namespaceCollection = _resourceGroup.GetServiceBusNamespaces();
Expand All @@ -37,26 +38,11 @@ public async Task CreateNamespaceAndGetTopicCollection()
_topicCollection = serviceBusNamespace.GetServiceBusTopics();
}

[TearDown]
public async Task ClearNamespaces()
{
//remove all namespaces under current resource group
if (_resourceGroup != null)
{
ServiceBusNamespaceCollection namespaceCollection = _resourceGroup.GetServiceBusNamespaces();
List<ServiceBusNamespace> namespaceList = await namespaceCollection.GetAllAsync().ToEnumerableAsync();
foreach (ServiceBusNamespace serviceBusNamespace in namespaceList)
{
await serviceBusNamespace.DeleteAsync();
}
_resourceGroup = null;
}
}

[Test]
[RecordedTest]
public async Task CreateDeleteTopic()
{
IgnoreTestInLiveMode();
//create topic
string topicName = Recording.GenerateAssetName("topic");
ServiceBusTopic topic = (await _topicCollection.CreateOrUpdateAsync(topicName, new ServiceBusTopicData())).Value;
Expand All @@ -81,6 +67,7 @@ public async Task CreateDeleteTopic()
[RecordedTest]
public async Task GetAllTopics()
{
IgnoreTestInLiveMode();
//create ten queues
for (int i = 0; i < 10; i++)
{
Expand All @@ -99,6 +86,7 @@ public async Task GetAllTopics()
[RecordedTest]
public async Task UpdateTopic()
{
IgnoreTestInLiveMode();
//create topic
string topicName = Recording.GenerateAssetName("topic");
ServiceBusTopic topic = (await _topicCollection.CreateOrUpdateAsync(topicName, new ServiceBusTopicData())).Value;
Expand All @@ -115,6 +103,7 @@ public async Task UpdateTopic()
[RecordedTest]
public async Task TopicCreateGetUpdateDeleteAuthorizationRule()
{
IgnoreTestInLiveMode();
//create topic
string topicName = Recording.GenerateAssetName("topic");
ServiceBusTopic topic = (await _topicCollection.CreateOrUpdateAsync(topicName, new ServiceBusTopicData())).Value;
Expand Down Expand Up @@ -170,6 +159,7 @@ public async Task TopicCreateGetUpdateDeleteAuthorizationRule()
[RecordedTest]
public async Task TopicAuthorizationRuleRegenerateKey()
{
IgnoreTestInLiveMode();
//create topic
string topicName = Recording.GenerateAssetName("topic");
ServiceBusTopic topic = (await _topicCollection.CreateOrUpdateAsync(topicName, new ServiceBusTopicData())).Value;
Expand Down

0 comments on commit f81209e

Please sign in to comment.