Skip to content

Commit 3ab1abe

Browse files
committed
Merge branch 'Az-StorageSync-v5-Final' of github.com:ankushbindlish2/azure-powershell into storage-sync2
2 parents 61f3940 + e321aab commit 3ab1abe

File tree

147 files changed

+18324
-16889
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+18324
-16889
lines changed

src/StorageSync/StorageSync.Test/Common/MockEcsManagementInteropClient.cs

Lines changed: 427 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Commands.StorageSync.Interop.Clients;
16+
using Commands.StorageSync.Interop.DataObjects;
17+
using Commands.StorageSync.Interop.Interfaces;
18+
using Microsoft.Azure.Commands.StorageSync.Common;
19+
using Microsoft.Azure.Commands.StorageSync.Interfaces;
20+
using Microsoft.Azure.Test.HttpRecorder;
21+
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
22+
using System;
23+
using System.Text.RegularExpressions;
24+
25+
namespace StorageSync.Test.Common
26+
{
27+
/// <summary>
28+
/// Class StorageSyncResourceManager.
29+
/// Implements the <see cref="Microsoft.Azure.Commands.StorageSync.Common.IStorageSyncResourceManager" />
30+
/// Implements the <see cref="Microsoft.Azure.Commands.StorageSync.Interfaces.IStorageSyncResourceManager" />
31+
/// </summary>
32+
/// <seealso cref="Microsoft.Azure.Commands.StorageSync.Interfaces.IStorageSyncResourceManager" />
33+
/// <seealso cref="Microsoft.Azure.Commands.StorageSync.Common.IStorageSyncResourceManager" />
34+
public class MockStorageSyncResourceManager : IStorageSyncResourceManager
35+
{
36+
37+
/// <summary>
38+
/// Initializes a new instance of the <see cref="MockStorageSyncResourceManager"/> class.
39+
/// </summary>
40+
/// <param name="testName">Name of the test.</param>
41+
public MockStorageSyncResourceManager(string testName)
42+
{
43+
TestName = testName;
44+
}
45+
46+
/// <summary>
47+
/// The is playback mode
48+
/// </summary>
49+
private bool? isPlaybackMode;
50+
51+
/// <summary>
52+
/// Gets a value indicating whether this instance is playback mode.
53+
/// </summary>
54+
/// <value><c>true</c> if this instance is playback mode; otherwise, <c>false</c>.</value>
55+
/// <exception cref="NotSupportedException"></exception>
56+
protected bool IsPlaybackMode
57+
{
58+
get
59+
{
60+
if (!isPlaybackMode.HasValue)
61+
{
62+
if (Microsoft.Azure.Test.HttpRecorder.HttpMockServer.Mode == Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode.Playback)
63+
{
64+
isPlaybackMode = true;
65+
}
66+
else if (Microsoft.Azure.Test.HttpRecorder.HttpMockServer.Mode == Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode.Record)
67+
{
68+
isPlaybackMode = false;
69+
70+
}
71+
else
72+
{
73+
throw new NotSupportedException($"{Microsoft.Azure.Test.HttpRecorder.HttpMockServer.Mode} Mode is not supported");
74+
}
75+
}
76+
return isPlaybackMode.Value;
77+
}
78+
}
79+
80+
/// <summary>
81+
/// Gets the name of the test.
82+
/// </summary>
83+
/// <value>The name of the test.</value>
84+
public string TestName
85+
{
86+
get;
87+
}
88+
89+
/// <summary>
90+
/// Creates the ecs management.
91+
/// </summary>
92+
/// <returns>IEcsManagement.</returns>
93+
public IEcsManagement CreateEcsManagement() => IsPlaybackMode ? new MockEcsManagementInteropClient() as IEcsManagement : new EcsManagementInteropClient();
94+
95+
/// <summary>
96+
/// Gets the unique identifier.
97+
/// </summary>
98+
/// <param name="testName">Name of the test.</param>
99+
/// <returns>Guid.</returns>
100+
public Guid GetGuid(string testName) => Microsoft.Azure.Test.HttpRecorder.HttpMockServer.GetAssetGuid(testName);
101+
102+
/// <summary>
103+
/// Gets the afs agent installer path.
104+
/// </summary>
105+
/// <param name="afsAgentInstallerPath">The afs agent installer path.</param>
106+
/// <returns>System.String.</returns>
107+
public bool TryGetAfsAgentInstallerPath(out string afsAgentInstallerPath)
108+
{
109+
afsAgentInstallerPath = @"C:\Program Files\Azure\StorageSyncAgent\";
110+
return true;
111+
}
112+
113+
/// <summary>
114+
/// Gets the afs agent version.
115+
/// </summary>
116+
/// <param name="afsAgentVersion">The afs agent version.</param>
117+
/// <returns>System.String.</returns>
118+
public bool TryGetAfsAgentVersion(out string afsAgentVersion)
119+
{
120+
afsAgentVersion = @"5.0.2.0";
121+
return true;
122+
}
123+
124+
/// <summary>
125+
/// Updates the server registration data.
126+
/// </summary>
127+
/// <param name="pServerRegistrationData">The p server registration data.</param>
128+
/// <returns>ServerRegistrationData.</returns>
129+
public ServerRegistrationData UpdateServerRegistrationData(ServerRegistrationData pServerRegistrationData)
130+
{
131+
pServerRegistrationData.Id = Microsoft.Azure.Test.HttpRecorder.HttpMockServer.GetVariable(StorageSyncConstants.SyncServerId, pServerRegistrationData.Id);
132+
pServerRegistrationData.ServerId = Guid.Parse(Regex.Match(pServerRegistrationData.Id, @"([^/]+)$").Value);
133+
return pServerRegistrationData;
134+
}
135+
136+
/// <summary>
137+
/// Waits for access propogation.
138+
/// </summary>
139+
public void WaitForAccessPropogation()
140+
{
141+
if (!IsPlaybackMode)
142+
{
143+
System.Threading.Thread.Sleep(40 * 1000);
144+
}
145+
}
146+
147+
public string GetTenantId()
148+
{
149+
string tenantId = null;
150+
151+
if (IsPlaybackMode)
152+
{
153+
if (HttpMockServer.Variables.ContainsKey(StorageSyncConstants.TenantId))
154+
{
155+
tenantId = HttpMockServer.GetVariable(StorageSyncConstants.TenantId, null);
156+
}
157+
}
158+
return tenantId;
159+
}
160+
}
161+
}

src/StorageSync/StorageSync.Test/ScenarioTests/CloudEndpointTests.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,44 +21,69 @@
2121

2222
namespace StorageSyncTests
2323
{
24+
/// <summary>
25+
/// Class CloudEndpointTests.
26+
/// </summary>
2427
public class CloudEndpointTests
2528
{
29+
/// <summary>
30+
/// The logger
31+
/// </summary>
2632
private readonly XunitTracingInterceptor _logger;
2733

34+
/// <summary>
35+
/// Initializes a new instance of the <see cref="CloudEndpointTests"/> class.
36+
/// </summary>
37+
/// <param name="output">The output.</param>
2838
public CloudEndpointTests(ITestOutputHelper output)
2939
{
3040
_logger = new XunitTracingInterceptor(output);
3141
XunitTracingInterceptor.AddToContext(_logger);
3242
}
3343

44+
/// <summary>
45+
/// Defines the test method TestCloudEndpoint.
46+
/// </summary>
3447
[Fact]
3548
[Trait(Category.AcceptanceType, Category.CheckIn)]
3649
public void TestCloudEndpoint()
3750
{
3851
TestController.NewInstance.RunPsTest(_logger, "Test-CloudEndpoint");
3952
}
4053

54+
/// <summary>
55+
/// Defines the test method TestNewCloudEndpoint.
56+
/// </summary>
4157
[Fact]
4258
[Trait(Category.AcceptanceType, Category.CheckIn)]
4359
public void TestNewCloudEndpoint()
4460
{
4561
TestController.NewInstance.RunPsTest(_logger, "Test-NewCloudEndpoint");
4662
}
4763

64+
/// <summary>
65+
/// Defines the test method TestGetCloudEndpoint.
66+
/// </summary>
4867
[Fact]
4968
[Trait(Category.AcceptanceType, Category.CheckIn)]
5069
public void TestGetCloudEndpoint()
5170
{
5271
TestController.NewInstance.RunPsTest(_logger, "Test-GetCloudEndpoint");
5372
}
5473

74+
/// <summary>
75+
/// Defines the test method TestGetCloudEndpointParentObject.
76+
/// </summary>
5577
[Fact]
5678
[Trait(Category.AcceptanceType, Category.CheckIn)]
5779
public void TestGetCloudEndpointParentObject()
5880
{
5981
TestController.NewInstance.RunPsTest(_logger, "Test-GetCloudEndpointParentObject");
6082
}
6183

84+
/// <summary>
85+
/// Defines the test method TestGetCloudEndpointParentResourceId.
86+
/// </summary>
6287
[Fact]
6388
[Trait(Category.AcceptanceType, Category.CheckIn)]
6489
public void TestGetCloudEndpointParentResourceId()
@@ -67,27 +92,39 @@ public void TestGetCloudEndpointParentResourceId()
6792
}
6893

6994

95+
/// <summary>
96+
/// Defines the test method TestGetCloudEndpoints.
97+
/// </summary>
7098
[Fact]
7199
[Trait(Category.AcceptanceType, Category.CheckIn)]
72100
public void TestGetCloudEndpoints()
73101
{
74102
TestController.NewInstance.RunPsTest(_logger, "Test-GetCloudEndpoints");
75103
}
76104

105+
/// <summary>
106+
/// Defines the test method TestRemoveCloudEndpoint.
107+
/// </summary>
77108
[Fact]
78109
[Trait(Category.AcceptanceType, Category.CheckIn)]
79110
public void TestRemoveCloudEndpoint()
80111
{
81112
TestController.NewInstance.RunPsTest(_logger, "Test-RemoveCloudEndpoint");
82113
}
83114

115+
/// <summary>
116+
/// Defines the test method TestRemoveCloudEndpointResourceId.
117+
/// </summary>
84118
[Fact]
85119
[Trait(Category.AcceptanceType, Category.CheckIn)]
86120
public void TestRemoveCloudEndpointResourceId()
87121
{
88122
TestController.NewInstance.RunPsTest(_logger, "Test-RemoveCloudEndpointResourceId");
89123
}
90124

125+
/// <summary>
126+
/// Defines the test method TestRemoveCloudEndpointInputObject.
127+
/// </summary>
91128
[Fact]
92129
[Trait(Category.AcceptanceType, Category.CheckIn)]
93130
public void TestRemoveCloudEndpointInputObject()

0 commit comments

Comments
 (0)