Skip to content

Commit f71bce9

Browse files
author
Hovsep
authored
[Release 1.6.0] Fixed ParseTemplateParameterFileContents_DeserializeWithCorrectType test flakiness. (#2571)
* Fixed ParseTemplateParameterFileContents_DeserializeWithCorrectType test flakiness. * fixed SaveAzureWebsiteLogWithNoFileExtensionTest flakiness
1 parent 842e7eb commit f71bce9

File tree

2 files changed

+64
-54
lines changed

2 files changed

+64
-54
lines changed

src/ResourceManager/Resources/Commands.Resources.Test/Models.ResourceGroups/GalleryTemplatesClientTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
using Xunit;
3232
using Xunit.Abstractions;
3333
using Microsoft.Azure.ServiceManagemenet.Common.Models;
34+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
3435

3536
namespace Microsoft.Azure.Commands.Resources.Test.Models
3637
{
@@ -503,7 +504,7 @@ public void ParseTemplateParameterFileContents_DeserializeWithCorrectType()
503504
TestExecutionHelpers.RetryAction(() =>
504505
{
505506
Dictionary<string, TemplateFileParameterV1> result =
506-
TemplateUtility.ParseTemplateParameterFileContents(@"Resources\WebSite.param.dev.json");
507+
TemplateUtility.ParseTemplateParameterFileContents(@"Resources\WebSite.param.dev.json".AsAbsoluteLocation());
507508
Assert.Equal(true, result["isWorker"].Value);
508509
Assert.Equal((System.Int64) 1, result["numberOfWorker"].Value);
509510
});

src/ServiceManagement/Services/Commands.Test/Websites/SaveAzureWebsiteLogTests.cs

Lines changed: 62 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@
2828
using Microsoft.WindowsAzure.Commands.Websites;
2929
using Moq;
3030
using Microsoft.Azure.Commands.Common.Authentication;
31+
using Microsoft.WindowsAzure.Commands.Common.Test;
3132

3233
namespace Microsoft.WindowsAzure.Commands.Test.Websites
3334
{
34-
35+
3536
public class SaveAzureWebsiteLogTests : WebsitesTestBase
3637
{
3738
private Site site1 = new Site
@@ -83,13 +84,13 @@ public void SaveAzureWebsiteLogTest()
8384
// Test
8485
SaveAzureWebsiteLogCommand getAzureWebsiteLogCommand = new SaveAzureWebsiteLogCommand(deploymentChannel)
8586
{
86-
Name = "website1",
87+
Name = "website1",
8788
ShareChannel = true,
8889
WebsitesClient = clientMock.Object,
8990
CommandRuntime = new MockCommandRuntime(),
9091
};
9192
currentProfile = new AzureSMProfile();
92-
var subscription = new AzureSubscription{Id = new Guid(base.subscriptionId) };
93+
var subscription = new AzureSubscription { Id = new Guid(base.subscriptionId) };
9394
subscription.Properties[AzureSubscription.Property.Default] = "True";
9495
currentProfile.Subscriptions[new Guid(base.subscriptionId)] = subscription;
9596

@@ -103,61 +104,69 @@ public void SaveAzureWebsiteLogTest()
103104
[Trait(Category.AcceptanceType, Category.CheckIn)]
104105
public void SaveAzureWebsiteLogWithNoFileExtensionTest()
105106
{
106-
// Setup
107-
string expectedOutput = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "file_without_ext.zip");
108-
109-
SimpleDeploymentServiceManagement deploymentChannel = new SimpleDeploymentServiceManagement
110-
{
111-
DownloadLogsThunk = ar => new MemoryStream(Encoding.UTF8.GetBytes("test with no extension"))
112-
};
113-
114-
// Test
115-
SaveAzureWebsiteLogCommand getAzureWebsiteLogCommand = new SaveAzureWebsiteLogCommand(deploymentChannel)
116-
{
117-
Name = "website1",
118-
ShareChannel = true,
119-
WebsitesClient = clientMock.Object,
120-
CommandRuntime = new MockCommandRuntime(),
121-
Output = "file_without_ext"
122-
};
123-
currentProfile = new AzureSMProfile();
124-
var subscription = new AzureSubscription{Id = new Guid(base.subscriptionId) };
125-
subscription.Properties[AzureSubscription.Property.Default] = "True";
126-
currentProfile.Subscriptions[new Guid(base.subscriptionId)] = subscription;
127-
128-
getAzureWebsiteLogCommand.DefaultCurrentPath = AppDomain.CurrentDomain.BaseDirectory;
129-
getAzureWebsiteLogCommand.ExecuteCmdlet();
130-
Assert.Equal("test with no extension", FileUtilities.DataStore.ReadFileAsText(expectedOutput));
107+
TestExecutionHelpers.RetryAction(
108+
() =>
109+
{
110+
// Setup
111+
string expectedOutput = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "file_without_ext.zip");
112+
113+
SimpleDeploymentServiceManagement deploymentChannel = new SimpleDeploymentServiceManagement
114+
{
115+
DownloadLogsThunk = ar => new MemoryStream(Encoding.UTF8.GetBytes("test with no extension"))
116+
};
117+
118+
// Test
119+
SaveAzureWebsiteLogCommand getAzureWebsiteLogCommand = new SaveAzureWebsiteLogCommand(deploymentChannel)
120+
{
121+
Name = "website1",
122+
ShareChannel = true,
123+
WebsitesClient = clientMock.Object,
124+
CommandRuntime = new MockCommandRuntime(),
125+
Output = "file_without_ext"
126+
};
127+
currentProfile = new AzureSMProfile();
128+
var subscription = new AzureSubscription { Id = new Guid(base.subscriptionId) };
129+
subscription.Properties[AzureSubscription.Property.Default] = "True";
130+
currentProfile.Subscriptions[new Guid(base.subscriptionId)] = subscription;
131+
132+
getAzureWebsiteLogCommand.DefaultCurrentPath = AppDomain.CurrentDomain.BaseDirectory;
133+
getAzureWebsiteLogCommand.ExecuteCmdlet();
134+
Assert.Equal("test with no extension", FileUtilities.DataStore.ReadFileAsText(expectedOutput));
135+
});
131136
}
132137

133-
[Fact(Skip = "Flaky test")]
138+
[Fact]
134139
[Trait(Category.AcceptanceType, Category.CheckIn)]
135140
public void SaveAzureWebsiteLogWithSlotTest()
136141
{
137-
// Setup
138-
SimpleDeploymentServiceManagement deploymentChannel = new SimpleDeploymentServiceManagement
139-
{
140-
DownloadLogsThunk = ar => new MemoryStream(Encoding.UTF8.GetBytes("test"))
141-
};
142-
143-
// Test
144-
SaveAzureWebsiteLogCommand getAzureWebsiteLogCommand = new SaveAzureWebsiteLogCommand(deploymentChannel)
145-
{
146-
Name = "website1",
147-
ShareChannel = true,
148-
WebsitesClient = clientMock.Object,
149-
CommandRuntime = new MockCommandRuntime(),
150-
Slot = slot
151-
};
152-
currentProfile = new AzureSMProfile();
153-
var subscription = new AzureSubscription{Id = new Guid(base.subscriptionId) };
154-
subscription.Properties[AzureSubscription.Property.Default] = "True";
155-
currentProfile.Subscriptions[new Guid(base.subscriptionId)] = subscription;
156-
157-
getAzureWebsiteLogCommand.DefaultCurrentPath = AppDomain.CurrentDomain.BaseDirectory;
158-
getAzureWebsiteLogCommand.ExecuteCmdlet();
159-
Assert.Equal("test", FileUtilities.DataStore.ReadFileAsText(
160-
Path.Combine(AppDomain.CurrentDomain.BaseDirectory, SaveAzureWebsiteLogCommand.DefaultOutput)));
142+
TestExecutionHelpers.RetryAction(
143+
() =>
144+
{
145+
// Setup
146+
SimpleDeploymentServiceManagement deploymentChannel = new SimpleDeploymentServiceManagement
147+
{
148+
DownloadLogsThunk = ar => new MemoryStream(Encoding.UTF8.GetBytes("test"))
149+
};
150+
151+
// Test
152+
SaveAzureWebsiteLogCommand getAzureWebsiteLogCommand = new SaveAzureWebsiteLogCommand(deploymentChannel)
153+
{
154+
Name = "website1",
155+
ShareChannel = true,
156+
WebsitesClient = clientMock.Object,
157+
CommandRuntime = new MockCommandRuntime(),
158+
Slot = slot
159+
};
160+
currentProfile = new AzureSMProfile();
161+
var subscription = new AzureSubscription { Id = new Guid(base.subscriptionId) };
162+
subscription.Properties[AzureSubscription.Property.Default] = "True";
163+
currentProfile.Subscriptions[new Guid(base.subscriptionId)] = subscription;
164+
165+
getAzureWebsiteLogCommand.DefaultCurrentPath = AppDomain.CurrentDomain.BaseDirectory;
166+
getAzureWebsiteLogCommand.ExecuteCmdlet();
167+
Assert.Equal("test", FileUtilities.DataStore.ReadFileAsText(
168+
Path.Combine(AppDomain.CurrentDomain.BaseDirectory, SaveAzureWebsiteLogCommand.DefaultOutput)));
169+
});
161170
}
162171
}
163172
}

0 commit comments

Comments
 (0)