Skip to content

[Release 1.6.0] Fixed ParseTemplateParameterFileContents_DeserializeWithCorrectType test flakiness. #2571

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
using Xunit;
using Xunit.Abstractions;
using Microsoft.Azure.ServiceManagemenet.Common.Models;
using Microsoft.WindowsAzure.Commands.Utilities.Common;

namespace Microsoft.Azure.Commands.Resources.Test.Models
{
Expand Down Expand Up @@ -503,7 +504,7 @@ public void ParseTemplateParameterFileContents_DeserializeWithCorrectType()
TestExecutionHelpers.RetryAction(() =>
{
Dictionary<string, TemplateFileParameterV1> result =
TemplateUtility.ParseTemplateParameterFileContents(@"Resources\WebSite.param.dev.json");
TemplateUtility.ParseTemplateParameterFileContents(@"Resources\WebSite.param.dev.json".AsAbsoluteLocation());
Assert.Equal(true, result["isWorker"].Value);
Assert.Equal((System.Int64) 1, result["numberOfWorker"].Value);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@
using Microsoft.WindowsAzure.Commands.Websites;
using Moq;
using Microsoft.Azure.Commands.Common.Authentication;
using Microsoft.WindowsAzure.Commands.Common.Test;

namespace Microsoft.WindowsAzure.Commands.Test.Websites
{

public class SaveAzureWebsiteLogTests : WebsitesTestBase
{
private Site site1 = new Site
Expand Down Expand Up @@ -83,13 +84,13 @@ public void SaveAzureWebsiteLogTest()
// Test
SaveAzureWebsiteLogCommand getAzureWebsiteLogCommand = new SaveAzureWebsiteLogCommand(deploymentChannel)
{
Name = "website1",
Name = "website1",
ShareChannel = true,
WebsitesClient = clientMock.Object,
CommandRuntime = new MockCommandRuntime(),
};
currentProfile = new AzureSMProfile();
var subscription = new AzureSubscription{Id = new Guid(base.subscriptionId) };
var subscription = new AzureSubscription { Id = new Guid(base.subscriptionId) };
subscription.Properties[AzureSubscription.Property.Default] = "True";
currentProfile.Subscriptions[new Guid(base.subscriptionId)] = subscription;

Expand All @@ -103,61 +104,69 @@ public void SaveAzureWebsiteLogTest()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void SaveAzureWebsiteLogWithNoFileExtensionTest()
{
// Setup
string expectedOutput = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "file_without_ext.zip");

SimpleDeploymentServiceManagement deploymentChannel = new SimpleDeploymentServiceManagement
{
DownloadLogsThunk = ar => new MemoryStream(Encoding.UTF8.GetBytes("test with no extension"))
};

// Test
SaveAzureWebsiteLogCommand getAzureWebsiteLogCommand = new SaveAzureWebsiteLogCommand(deploymentChannel)
{
Name = "website1",
ShareChannel = true,
WebsitesClient = clientMock.Object,
CommandRuntime = new MockCommandRuntime(),
Output = "file_without_ext"
};
currentProfile = new AzureSMProfile();
var subscription = new AzureSubscription{Id = new Guid(base.subscriptionId) };
subscription.Properties[AzureSubscription.Property.Default] = "True";
currentProfile.Subscriptions[new Guid(base.subscriptionId)] = subscription;

getAzureWebsiteLogCommand.DefaultCurrentPath = AppDomain.CurrentDomain.BaseDirectory;
getAzureWebsiteLogCommand.ExecuteCmdlet();
Assert.Equal("test with no extension", FileUtilities.DataStore.ReadFileAsText(expectedOutput));
TestExecutionHelpers.RetryAction(
() =>
{
// Setup
string expectedOutput = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "file_without_ext.zip");

SimpleDeploymentServiceManagement deploymentChannel = new SimpleDeploymentServiceManagement
{
DownloadLogsThunk = ar => new MemoryStream(Encoding.UTF8.GetBytes("test with no extension"))
};

// Test
SaveAzureWebsiteLogCommand getAzureWebsiteLogCommand = new SaveAzureWebsiteLogCommand(deploymentChannel)
{
Name = "website1",
ShareChannel = true,
WebsitesClient = clientMock.Object,
CommandRuntime = new MockCommandRuntime(),
Output = "file_without_ext"
};
currentProfile = new AzureSMProfile();
var subscription = new AzureSubscription { Id = new Guid(base.subscriptionId) };
subscription.Properties[AzureSubscription.Property.Default] = "True";
currentProfile.Subscriptions[new Guid(base.subscriptionId)] = subscription;

getAzureWebsiteLogCommand.DefaultCurrentPath = AppDomain.CurrentDomain.BaseDirectory;
getAzureWebsiteLogCommand.ExecuteCmdlet();
Assert.Equal("test with no extension", FileUtilities.DataStore.ReadFileAsText(expectedOutput));
});
}

[Fact(Skip = "Flaky test")]
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void SaveAzureWebsiteLogWithSlotTest()
{
// Setup
SimpleDeploymentServiceManagement deploymentChannel = new SimpleDeploymentServiceManagement
{
DownloadLogsThunk = ar => new MemoryStream(Encoding.UTF8.GetBytes("test"))
};

// Test
SaveAzureWebsiteLogCommand getAzureWebsiteLogCommand = new SaveAzureWebsiteLogCommand(deploymentChannel)
{
Name = "website1",
ShareChannel = true,
WebsitesClient = clientMock.Object,
CommandRuntime = new MockCommandRuntime(),
Slot = slot
};
currentProfile = new AzureSMProfile();
var subscription = new AzureSubscription{Id = new Guid(base.subscriptionId) };
subscription.Properties[AzureSubscription.Property.Default] = "True";
currentProfile.Subscriptions[new Guid(base.subscriptionId)] = subscription;

getAzureWebsiteLogCommand.DefaultCurrentPath = AppDomain.CurrentDomain.BaseDirectory;
getAzureWebsiteLogCommand.ExecuteCmdlet();
Assert.Equal("test", FileUtilities.DataStore.ReadFileAsText(
Path.Combine(AppDomain.CurrentDomain.BaseDirectory, SaveAzureWebsiteLogCommand.DefaultOutput)));
TestExecutionHelpers.RetryAction(
() =>
{
// Setup
SimpleDeploymentServiceManagement deploymentChannel = new SimpleDeploymentServiceManagement
{
DownloadLogsThunk = ar => new MemoryStream(Encoding.UTF8.GetBytes("test"))
};

// Test
SaveAzureWebsiteLogCommand getAzureWebsiteLogCommand = new SaveAzureWebsiteLogCommand(deploymentChannel)
{
Name = "website1",
ShareChannel = true,
WebsitesClient = clientMock.Object,
CommandRuntime = new MockCommandRuntime(),
Slot = slot
};
currentProfile = new AzureSMProfile();
var subscription = new AzureSubscription { Id = new Guid(base.subscriptionId) };
subscription.Properties[AzureSubscription.Property.Default] = "True";
currentProfile.Subscriptions[new Guid(base.subscriptionId)] = subscription;

getAzureWebsiteLogCommand.DefaultCurrentPath = AppDomain.CurrentDomain.BaseDirectory;
getAzureWebsiteLogCommand.ExecuteCmdlet();
Assert.Equal("test", FileUtilities.DataStore.ReadFileAsText(
Path.Combine(AppDomain.CurrentDomain.BaseDirectory, SaveAzureWebsiteLogCommand.DefaultOutput)));
});
}
}
}