Skip to content

Commit a60a431

Browse files
author
Ziyue Zheng
authored
Add MonitorTestRunner to replace TestsController (#18201)
1 parent 3938a0d commit a60a431

13 files changed

+131
-359
lines changed

src/Monitor/Monitor.Test/ScenarioTests/ActionGroupsTests.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,22 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System;
1615
using Microsoft.WindowsAzure.Commands.ScenarioTest;
17-
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
1816
using Xunit;
19-
using Microsoft.Azure.ServiceManagement.Common.Models;
2017

2118
namespace Microsoft.Azure.Commands.Insights.Test.ScenarioTests
2219
{
23-
public class ActionGroupsTests : RMTestBase
20+
public class ActionGroupsTests : MonitorTestRunner
2421
{
25-
public XunitTracingInterceptor _logger;
26-
27-
public ActionGroupsTests(Xunit.Abstractions.ITestOutputHelper output)
22+
public ActionGroupsTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
2823
{
29-
_logger = new XunitTracingInterceptor(output);
30-
XunitTracingInterceptor.AddToContext(_logger);
3124
}
3225

3326
[Fact]
3427
[Trait(Category.AcceptanceType, Category.CheckIn)]
3528
public void TestAddGetListSetRemoveActionGroup()
3629
{
37-
TestsController.NewInstance.RunPsTest(_logger, "Test-AddGetListSetRemoveActionGroup");
30+
TestRunner.RunTestScript("Test-AddGetListSetRemoveActionGroup");
3831
}
3932
}
4033
}

src/Monitor/Monitor.Test/ScenarioTests/ActivityLogAlertsTests.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,22 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Microsoft.Azure.ServiceManagement.Common.Models;
1615
using Microsoft.WindowsAzure.Commands.ScenarioTest;
17-
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
1816
using Xunit;
1917

2018
namespace Microsoft.Azure.Commands.Insights.Test.ScenarioTests
2119
{
22-
public class ActivityLogAlertsTests : RMTestBase
20+
public class ActivityLogAlertsTests : MonitorTestRunner
2321
{
24-
public XunitTracingInterceptor _logger;
25-
26-
public ActivityLogAlertsTests(Xunit.Abstractions.ITestOutputHelper output)
22+
public ActivityLogAlertsTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
2723
{
28-
_logger = new XunitTracingInterceptor(output);
29-
XunitTracingInterceptor.AddToContext(_logger);
3024
}
3125

3226
[Fact]
3327
[Trait(Category.AcceptanceType, Category.CheckIn)]
3428
public void TestSetGetListUpdateRemoveActivityLogAlert()
3529
{
36-
TestsController.NewInstance.RunPsTest(_logger, "Test-SetGetListUpdateRemoveActivityLogAlert");
30+
TestRunner.RunTestScript("Test-SetGetListUpdateRemoveActivityLogAlert");
3731
}
3832
}
3933
}

src/Monitor/Monitor.Test/ScenarioTests/ActivityLogsTests.cs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,42 +12,36 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Microsoft.Azure.ServiceManagement.Common.Models;
1615
using Microsoft.WindowsAzure.Commands.ScenarioTest;
17-
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
1816
using Xunit;
1917

2018
namespace Microsoft.Azure.Commands.Insights.Test.ScenarioTests
2119
{
22-
public class ActivityLogsTests : RMTestBase
20+
public class ActivityLogsTests : MonitorTestRunner
2321
{
24-
public XunitTracingInterceptor _logger;
25-
26-
public ActivityLogsTests(Xunit.Abstractions.ITestOutputHelper output)
22+
public ActivityLogsTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
2723
{
28-
_logger = new XunitTracingInterceptor(output);
29-
XunitTracingInterceptor.AddToContext(_logger);
3024
}
3125

3226
[Fact]
3327
[Trait(Category.AcceptanceType, Category.CheckIn)]
3428
public void TestGetAzureLogAllParameters()
3529
{
36-
TestsController.NewInstance.RunPsTest(_logger, "Test-GetAzureLogAllParameters");
30+
TestRunner.RunTestScript("Test-GetAzureLogAllParameters");
3731
}
3832

3933
[Fact]
4034
[Trait(Category.AcceptanceType, Category.CheckIn)]
4135
public void TestGetAzureSubscriptionIdLogMaxEvents()
4236
{
43-
TestsController.NewInstance.RunPsTest(_logger, "Test-GetAzureSubscriptionIdLogMaxEvents");
37+
TestRunner.RunTestScript("Test-GetAzureSubscriptionIdLogMaxEvents");
4438
}
4539

4640
[Fact]
4741
[Trait(Category.AcceptanceType, Category.CheckIn)]
4842
public void TestGetAzureSubscriptionIdLogPaged()
4943
{
50-
TestsController.NewInstance.RunPsTest(_logger, "Test-GetAzureSubscriptionIdLogPaged");
44+
TestRunner.RunTestScript("Test-GetAzureSubscriptionIdLogPaged");
5145
}
5246
}
5347
}

src/Monitor/Monitor.Test/ScenarioTests/AlertsTests.cs

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,147 +12,141 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Microsoft.Azure.ServiceManagement.Common.Models;
1615
using Microsoft.WindowsAzure.Commands.ScenarioTest;
17-
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
1816
using Xunit;
1917

2018
namespace Microsoft.Azure.Commands.Insights.Test.ScenarioTests
2119
{
22-
public class AlertsTests : RMTestBase
20+
public class AlertsTests : MonitorTestRunner
2321
{
24-
public XunitTracingInterceptor _logger;
25-
26-
public AlertsTests(Xunit.Abstractions.ITestOutputHelper output)
22+
public AlertsTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
2723
{
28-
_logger = new XunitTracingInterceptor(output);
29-
XunitTracingInterceptor.AddToContext(_logger);
3024
}
3125

3226
[Fact]
3327
[Trait(Category.AcceptanceType, Category.CheckIn)]
3428
public void TestNewAzureRmAlertRuleWebhook()
3529
{
36-
TestsController.NewInstance.RunPsTest(_logger, "Test-NewAzureRmAlertRuleWebhook");
30+
TestRunner.RunTestScript("Test-NewAzureRmAlertRuleWebhook");
3731
}
3832

3933
[Fact]
4034
[Trait(Category.AcceptanceType, Category.CheckIn)]
4135
public void TestNewAzureRmAlertRuleEmail()
4236
{
43-
TestsController.NewInstance.RunPsTest(_logger, "Test-NewAzureRmAlertRuleEmail");
37+
TestRunner.RunTestScript("Test-NewAzureRmAlertRuleEmail");
4438
}
4539

4640
[Fact]
4741
[Trait(Category.AcceptanceType, Category.CheckIn)]
4842
public void TestAddAzureRmMetricAlertRule()
4943
{
50-
TestsController.NewInstance.RunPsTest(_logger, "Test-AddAzureRmMetricAlertRule");
44+
TestRunner.RunTestScript("Test-AddAzureRmMetricAlertRule");
5145
}
5246

5347
[Fact]
5448
[Trait(Category.AcceptanceType, Category.CheckIn)]
5549
public void TestAddAzureRmWebtestAlertRule()
5650
{
57-
TestsController.NewInstance.RunPsTest(_logger, "Test-AddAzureRmWebtestAlertRule");
51+
TestRunner.RunTestScript("Test-AddAzureRmWebtestAlertRule");
5852
}
5953

6054
[Fact]
6155
[Trait(Category.AcceptanceType, Category.CheckIn)]
6256
public void TestGetAzureRmAlertRule()
6357
{
64-
TestsController.NewInstance.RunPsTest(_logger, "Test-GetAzureRmAlertRule");
58+
TestRunner.RunTestScript("Test-GetAzureRmAlertRule");
6559
}
6660

6761
[Fact]
6862
[Trait(Category.AcceptanceType, Category.CheckIn)]
6963
public void TestGetAzureRmAlertRuleByName()
7064
{
71-
TestsController.NewInstance.RunPsTest(_logger, "Test-GetAzureRmAlertRuleByName");
65+
TestRunner.RunTestScript("Test-GetAzureRmAlertRuleByName");
7266
}
7367

7468
[Fact]
7569
[Trait(Category.AcceptanceType, Category.CheckIn)]
7670
public void TestRemoveAzureRmAlertRule()
7771
{
78-
TestsController.NewInstance.RunPsTest(_logger, "Test-RemoveAzureRmAlertRule");
72+
TestRunner.RunTestScript("Test-RemoveAzureRmAlertRule");
7973
}
8074

8175
[Fact]
8276
[Trait(Category.AcceptanceType, Category.CheckIn)]
8377
public void TestGetAzureRmAlertHistory()
8478
{
85-
TestsController.NewInstance.RunPsTest(_logger, "Test-GetAzureRmAlertHistory");
79+
TestRunner.RunTestScript("Test-GetAzureRmAlertHistory");
8680
}
8781

8882
[Fact]
8983
[Trait(Category.AcceptanceType, Category.CheckIn)]
9084
public void TestGetAzureRmMetricAlertRuleV2()
9185
{
92-
TestsController.NewInstance.RunPsTest(_logger, "Test-GetAzureRmMetricAlertRuleV2");
86+
TestRunner.RunTestScript("Test-GetAzureRmMetricAlertRuleV2");
9387
}
9488

9589
[Fact]
9690
[Trait(Category.AcceptanceType, Category.CheckIn)]
9791
public void TestRemoveAzureRmMetricAlertRuleV2()
9892
{
99-
TestsController.NewInstance.RunPsTest(_logger, "Test-RemoveAzureRmAlertRuleV2");
93+
TestRunner.RunTestScript("Test-RemoveAzureRmAlertRuleV2");
10094
}
10195

10296
[Fact]
10397
[Trait(Category.AcceptanceType, Category.CheckIn)]
10498
public void TestAddAzureRmMetricAlertRuleV2()
10599
{
106-
TestsController.NewInstance.RunPsTest(_logger, "Test-AddAzureRmMetricAlertRuleV2");
100+
TestRunner.RunTestScript("Test-AddAzureRmMetricAlertRuleV2");
107101
}
108102

109103
[Fact]
110104
[Trait(Category.AcceptanceType, Category.CheckIn)]
111105
public void TestAddAzureRmMetricAlertRuleV2WithoutActionGroup()
112106
{
113-
TestsController.NewInstance.RunPsTest(_logger, "Test-AddAzureRmMetricAlertRuleV2-NoActionGroup");
107+
TestRunner.RunTestScript("Test-AddAzureRmMetricAlertRuleV2-NoActionGroup");
114108
}
115109

116110
[Fact]
117111
[Trait(Category.AcceptanceType, Category.CheckIn)]
118112
public void TestAddAzureRmMetricAlertRuleV2WithActionGroupId()
119113
{
120-
TestsController.NewInstance.RunPsTest(_logger, "Test-AddAzureRmMetricAlertRuleV2-ActionGroupId");
114+
TestRunner.RunTestScript("Test-AddAzureRmMetricAlertRuleV2-ActionGroupId");
121115
}
122116

123117
[Fact]
124118
[Trait(Category.AcceptanceType, Category.CheckIn)]
125119
public void TestAddAzureRmMetricAlertRuleV2WithSkipMetricValidation()
126120
{
127-
TestsController.NewInstance.RunPsTest(_logger, "Test-AddAzureRmMetricAlertRuleV2-SkipMetricValidation");
121+
TestRunner.RunTestScript("Test-AddAzureRmMetricAlertRuleV2-SkipMetricValidation");
128122
}
129123

130124
[Fact]
131125
[Trait(Category.AcceptanceType, Category.CheckIn)]
132126
public void TestAddAzureRmMetricAlertRuleV2WithAutoMitigate()
133127
{
134-
TestsController.NewInstance.RunPsTest(_logger, "Test-AddAzureRmMetricAlertRuleV2-autoMitigate");
128+
TestRunner.RunTestScript("Test-AddAzureRmMetricAlertRuleV2-autoMitigate");
135129
}
136130

137131
[Fact]
138132
[Trait(Category.AcceptanceType, Category.CheckIn)]
139133
public void TestDisableAzureRmMetricAlertRuleV2WithActionGroups()
140134
{
141-
TestsController.NewInstance.RunPsTest(_logger, "Test-DisableAzureRmMetricAlertRuleV2WithActionGroups");
135+
TestRunner.RunTestScript("Test-DisableAzureRmMetricAlertRuleV2WithActionGroups");
142136
}
143137

144138
[Fact]
145139
[Trait(Category.AcceptanceType, Category.CheckIn)]
146140
public void TestAddAzureRmDynamicMetricAlertRuleV2()
147141
{
148-
TestsController.NewInstance.RunPsTest(_logger, "Test-AddAzureRmMetricAlertRuleV2-DynamicThreshold");
142+
TestRunner.RunTestScript("Test-AddAzureRmMetricAlertRuleV2-DynamicThreshold");
149143
}
150144

151145
[Fact]
152146
[Trait(Category.AcceptanceType, Category.LiveOnly)]
153147
public void TestAddAzureRmWebtestAlertRuleV2()
154148
{
155-
TestsController.NewInstance.RunPsTest(_logger, "Test-AddAzureRmMetricAlertRuleV2-Webtest");
149+
TestRunner.RunTestScript("Test-AddAzureRmMetricAlertRuleV2-Webtest");
156150
}
157151
}
158152
}

src/Monitor/Monitor.Test/ScenarioTests/AutoscaleTests.cs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,70 +12,64 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Microsoft.Azure.ServiceManagement.Common.Models;
1615
using Microsoft.WindowsAzure.Commands.ScenarioTest;
17-
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
1816
using Xunit;
1917

2018
namespace Microsoft.Azure.Commands.Insights.Test.ScenarioTests
2119
{
22-
public class AutoscaleTests : RMTestBase
20+
public class AutoscaleTests : MonitorTestRunner
2321
{
24-
public XunitTracingInterceptor _logger;
25-
26-
public AutoscaleTests(Xunit.Abstractions.ITestOutputHelper output)
22+
public AutoscaleTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
2723
{
28-
_logger = new XunitTracingInterceptor(output);
29-
XunitTracingInterceptor.AddToContext(_logger);
3024
}
3125

3226
[Fact]
3327
[Trait(Category.AcceptanceType, Category.CheckIn)]
3428
public void TestAddAzureRmAutoscaleSetting()
3529
{
36-
TestsController.NewInstance.RunPsTest(_logger, "Test-AddAzureRmAutoscaleSetting");
30+
TestRunner.RunTestScript("Test-AddAzureRmAutoscaleSetting");
3731
}
3832

3933
[Fact]
4034
[Trait(Category.AcceptanceType, Category.CheckIn)]
4135
public void TestGetAzureRmAutoscaleSetting()
4236
{
43-
TestsController.NewInstance.RunPsTest(_logger, "Test-GetAzureRmAutoscaleSetting");
37+
TestRunner.RunTestScript("Test-GetAzureRmAutoscaleSetting");
4438
}
4539

4640
[Fact]
4741
[Trait(Category.AcceptanceType, Category.CheckIn)]
4842
public void TestGetAzureRmAutoscaleSettingByName()
4943
{
50-
TestsController.NewInstance.RunPsTest(_logger, "Test-GetAzureRmAutoscaleSettingByName");
44+
TestRunner.RunTestScript("Test-GetAzureRmAutoscaleSettingByName");
5145
}
5246

5347
[Fact]
5448
[Trait(Category.AcceptanceType, Category.CheckIn)]
5549
public void TestRemoveAzureRmAutoscaleSetting()
5650
{
57-
TestsController.NewInstance.RunPsTest(_logger, "Test-RemoveAzureRmAutoscaleSetting");
51+
TestRunner.RunTestScript("Test-RemoveAzureRmAutoscaleSetting");
5852
}
5953

6054
[Fact]
6155
[Trait(Category.AcceptanceType, Category.CheckIn)]
6256
public void TestGetAzureRmAutoscaleHistory()
6357
{
64-
TestsController.NewInstance.RunPsTest(_logger, "Test-GetAzureRmAutoscaleHistory");
58+
TestRunner.RunTestScript("Test-GetAzureRmAutoscaleHistory");
6559
}
6660

6761
[Fact]
6862
[Trait(Category.AcceptanceType, Category.CheckIn)]
6963
public void TestNewAzureRmAutoscaleNotification()
7064
{
71-
TestsController.NewInstance.RunPsTest(_logger, "Test-NewAzureRmAutoscaleNotification");
65+
TestRunner.RunTestScript("Test-NewAzureRmAutoscaleNotification");
7266
}
7367

7468
[Fact]
7569
[Trait(Category.AcceptanceType, Category.CheckIn)]
7670
public void TestNewAzureRmAutoscaleWebhook()
7771
{
78-
TestsController.NewInstance.RunPsTest(_logger, "Test-NewAzureRmAutoscaleWebhook");
72+
TestRunner.RunTestScript("Test-NewAzureRmAutoscaleWebhook");
7973
}
8074
}
8175
}

0 commit comments

Comments
 (0)