Skip to content

. #174

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 31 commits into from
Oct 27, 2015
Merged

. #174

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
cf7dfc8
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
eshaparmar Oct 2, 2015
9d3cb5a
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
eshaparmar Oct 12, 2015
fe17544
Adding Get-DiagnosticSettings and Set-DiagnosticSettings commands
vcanaa Oct 22, 2015
e35736e
Merge remote-tracking branch 'upstream/dev' into dev
vcanaa Oct 22, 2015
4255c69
Bad merge fix
vcanaa Oct 22, 2015
708fb92
Graph: Add the includeDirectoryObjectReferences flag to the GetObject…
namratab Oct 23, 2015
9a0ebce
Merge branch 'dev' of github.com:Azure/azure-powershell into dev
namratab Oct 23, 2015
3a1ce91
Remove app.config
namratab Oct 23, 2015
1d57a65
Merge branch 'dev' of github.com:namratab/azure-powershell into dev
namratab Oct 23, 2015
15fff78
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
eshaparmar Oct 23, 2015
2ae86b8
Refactor parameter sets for GetResource
vivsriaus Oct 23, 2015
fdb8e88
Merge pull request #1162 from vivsriaus/GetResourceName
ogail Oct 26, 2015
97a1cc7
Merge pull request #1159 from namratab/dev
stankovski Oct 26, 2015
9529324
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
eshaparmar Oct 26, 2015
2fab238
Update default extension handler version to 2.*
eshaparmar Oct 26, 2015
c3c6654
Fix requests to metricDefinitions in SQL tests
vcanaa Oct 26, 2015
0280104
Renaming DiagnosticSetting commands to AzureRmDiagnosticSetting
vcanaa Oct 26, 2015
83140bd
Merge pull request #1169 from dscsolutions/version-update
stankovski Oct 26, 2015
e523a2c
Merge pull request #1154 from AuxMon/dev
stankovski Oct 26, 2015
a7d4aa0
Emit nested deployment operation statuses when submitting templates w…
vivsriaus Oct 26, 2015
5d59da9
[#105517610] Enable login and creating context with no subscriptions
Oct 26, 2015
842678b
Merge pull request #1170 from vivsriaus/NestedTemplate
stankovski Oct 26, 2015
3c585e7
Added test to set AzureRmContext without SubscriptionId
Oct 26, 2015
361af2b
Fixed failing tests.
Oct 26, 2015
4da3ac5
Fixed indentation
Oct 26, 2015
98534cd
Fixed help information for Set-AzureRmContext
Oct 27, 2015
04199a4
DocumentationUpdateAndSomeFixes
shuagarw Oct 27, 2015
4c05d4d
Merge branch 'dev' of github.com:Azure/azure-powershell into Document…
shuagarw Oct 27, 2015
709f18a
Formatting changes
shuagarw Oct 27, 2015
25f5fe3
Merge pull request #1171 from hovsepm/dev
stankovski Oct 27, 2015
dd85df9
Merge pull request #1175 from shuagarw/DocumentationUpdatesAndFixes
stankovski Oct 27, 2015
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
1 change: 1 addition & 0 deletions src/Common/Commands.Common/Commands.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@
<Compile Include="TestMockSupport.cs" />
<Compile Include="PSAzureAccount.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ValidateGuidNotEmpty.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
Expand Down
27 changes: 27 additions & 0 deletions src/Common/Commands.Common/ValidateGuidNotEmpty.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using System.Text;
using System.Threading.Tasks;

namespace Microsoft.WindowsAzure.Commands.Common
{
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
public class ValidateGuidNotEmptyAttribute : ValidateArgumentsAttribute
{
protected override void Validate(object arguments, EngineIntrinsics engineIntrinsics)
{
if (arguments == null)
{
throw new ValidationMetadataException("Specify a parameter of type 'System.Guid' and try again.");
}

Guid param = (Guid)arguments;
if (param == Guid.Empty)
{
throw new ValidationMetadataException("Specify a non empty value of type 'System.Guid' and try again.");
}
}
}
}
4 changes: 3 additions & 1 deletion src/ResourceManager/Insights/AzureRM.Insights.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ ScriptsToProcess = @()
TypesToProcess = @()

# Format files (.ps1xml) to be loaded when importing this module
FormatsToProcess = @()
FormatsToProcess = @(
'.\Microsoft.Azure.Commands.Insights.format.ps1xml'
)

# Modules to import as nested modules of the module specified in ModuleToProcess
NestedModules = @(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Insights">
<HintPath>..\..\..\packages\Microsoft.Azure.Insights.0.7.7-preview\lib\net45\Microsoft.Azure.Insights.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Insights.0.9.1-preview\lib\net45\Microsoft.Azure.Insights.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down Expand Up @@ -150,11 +150,14 @@
<Compile Include="Autoscale\NewAutoscaleProfileCommandTests.cs" />
<Compile Include="Autoscale\NewAutoscaleRuleCommandTests.cs" />
<Compile Include="Autoscale\RemoveAutoscaleSettingCommandTests.cs" />
<Compile Include="Diagnostics\SetDiagnosticSettingCommandTests.cs" />
<Compile Include="Diagnostics\GetDiagnosticSettingCommandTests.cs" />
<Compile Include="Events\GetAzureRmLogCommandTests.cs" />
<Compile Include="Metrics\FormatMetricsAsTableCommandTests.cs" />
<Compile Include="Metrics\GetMetricDefinitionsCommandTests.cs" />
<Compile Include="Metrics\GetMetricsCommandTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ScenarioTests\AzureRmDiagnosticSettingTests.cs" />
<Compile Include="ScenarioTests\AlertsTests.cs" />
<Compile Include="ScenarioTests\AutoscaleTests.cs" />
<Compile Include="ScenarioTests\EventsTests.cs" />
Expand Down Expand Up @@ -185,6 +188,9 @@
<ItemGroup>
<None Include="MSSharedLibKey.snk" />
<None Include="packages.config" />
<None Include="ScenarioTests\AzureRmDiagnosticSettingTests.ps1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\AlertsTests.ps1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand All @@ -203,6 +209,12 @@
<None Include="ScenarioTests\UsageMetricsTests.ps1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Insights.Test.ScenarioTests.AzureRmDiagnosticSettingTests\TestSetAzureRmDiagnosticSetting.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Insights.Test.ScenarioTests.AzureRmDiagnosticSettingTests\TestGetAzureRmDiagnosticSetting.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Insights.Test.ScenarioTests.AlertsTests\TestAddAlertRule.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Management.Automation;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure.Commands.Insights.Alerts;
using Microsoft.Azure.Commands.Insights.Diagnostics;
using Microsoft.Azure.Management.Insights;
using Microsoft.Azure.Management.Insights.Models;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Moq;
using Xunit;

namespace Microsoft.Azure.Commands.Insights.Test.Diagnostics
{
public class GetDiagnosticSettingCommandTests
{
private readonly GetAzureRmDiagnosticSettingCommand cmdlet;
private readonly Mock<InsightsManagementClient> insightsManagementClientMock;
private readonly Mock<IServiceDiagnosticSettingsOperations> insightsDiagnosticsOperationsMock;
private Mock<ICommandRuntime> commandRuntimeMock;
private ServiceDiagnosticSettingsGetResponse response;
private RuleCreateOrUpdateParameters createOrUpdatePrms;
private const string resourceId = "/subscriptions/123/resourcegroups/rg/providers/rp/resource/myresource";
private string calledResourceId;

public GetDiagnosticSettingCommandTests()
{
insightsDiagnosticsOperationsMock = new Mock<IServiceDiagnosticSettingsOperations>();
insightsManagementClientMock = new Mock<InsightsManagementClient>();
commandRuntimeMock = new Mock<ICommandRuntime>();
cmdlet = new GetAzureRmDiagnosticSettingCommand()
{
CommandRuntime = commandRuntimeMock.Object,
InsightsManagementClient = insightsManagementClientMock.Object
};

response = new ServiceDiagnosticSettingsGetResponse
{
RequestId = Guid.NewGuid().ToString(),
StatusCode = HttpStatusCode.OK,
Properties = new ServiceDiagnosticSettings
{
StorageAccountId = "/subscriptions/123/resourcegroups/rg/providers/microsoft.storage/accounts/myaccount",
Logs = new List<LogSettings>
{
new LogSettings
{
Category = "TestCategory1",
Enabled = true
},
new LogSettings
{
Category = "TestCategory2",
Enabled = false
}
},
Metrics = new List<MetricSettings>
{
new MetricSettings
{
TimeGrain = TimeSpan.FromMinutes(1),
Enabled = false
},
new MetricSettings
{
TimeGrain = TimeSpan.FromHours(1)
}
}
}
};

insightsDiagnosticsOperationsMock.Setup(f => f.GetAsync(It.IsAny<string>(), It.IsAny<CancellationToken>()))
.Returns(Task.FromResult<ServiceDiagnosticSettingsGetResponse>(response))
.Callback((string resourceId, CancellationToken cancellationToken) =>
{
this.calledResourceId = resourceId;
});

insightsManagementClientMock.SetupGet(f => f.ServiceDiagnosticSettingsOperations).Returns(this.insightsDiagnosticsOperationsMock.Object);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void AddAlertRuleCommandParametersProcessing()
{
cmdlet.ResourceId = resourceId;
cmdlet.ExecuteCmdlet();

Assert.Equal(resourceId, calledResourceId);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure.Commands.Insights.Alerts;
using Microsoft.Azure.Commands.Insights.Diagnostics;
using Microsoft.Azure.Management.Insights;
using Microsoft.Azure.Management.Insights.Models;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Moq;
using Xunit;

namespace Microsoft.Azure.Commands.Insights.Test.Diagnostics
{
public class SetDiagnosticSettingCommandTests
{
private readonly SetAzureRmDiagnosticSettingCommand cmdlet;
private readonly Mock<InsightsManagementClient> insightsManagementClientMock;
private readonly Mock<IServiceDiagnosticSettingsOperations> insightsDiagnosticsOperationsMock;
private Mock<ICommandRuntime> commandRuntimeMock;
private ServiceDiagnosticSettingsGetResponse response;
private RuleCreateOrUpdateParameters createOrUpdatePrms;
private const string resourceId = "/subscriptions/123/resourcegroups/rg/providers/rp/resource/myresource";
private const string storageAccountId = "/subscriptions/123/resourcegroups/rg/providers/microsoft.storage/accounts/myaccount";
private string calledResourceId;
ServiceDiagnosticSettingsPutParameters calledPutParameters;

public SetDiagnosticSettingCommandTests()
{
insightsDiagnosticsOperationsMock = new Mock<IServiceDiagnosticSettingsOperations>();
insightsManagementClientMock = new Mock<InsightsManagementClient>();
commandRuntimeMock = new Mock<ICommandRuntime>();
cmdlet = new SetAzureRmDiagnosticSettingCommand()
{
CommandRuntime = commandRuntimeMock.Object,
InsightsManagementClient = insightsManagementClientMock.Object
};

response = new ServiceDiagnosticSettingsGetResponse
{
RequestId = Guid.NewGuid().ToString(),
StatusCode = HttpStatusCode.OK,
Properties = new ServiceDiagnosticSettings
{
StorageAccountId = storageAccountId,
Logs = new List<LogSettings>
{
new LogSettings
{
Category = "TestCategory1",
Enabled = true
},
new LogSettings
{
Category = "TestCategory2",
Enabled = false
}
},
Metrics = new List<MetricSettings>
{
new MetricSettings
{
TimeGrain = TimeSpan.FromMinutes(1),
Enabled = false
},
new MetricSettings
{
TimeGrain = TimeSpan.FromHours(1),
Enabled = true
}
}
}
};

insightsDiagnosticsOperationsMock.Setup(f => f.GetAsync(It.IsAny<string>()))
.Returns(Task.FromResult<ServiceDiagnosticSettingsGetResponse>(response))
.Callback((string resourceId) =>
{
this.calledResourceId = resourceId;
});

insightsDiagnosticsOperationsMock.Setup(f => f.PutAsync(It.IsAny<string>(), It.IsAny<ServiceDiagnosticSettingsPutParameters>()))
.Returns(Task.FromResult<EmptyResponse>(new EmptyResponse()))
.Callback((string resourceId, ServiceDiagnosticSettingsPutParameters putParameters) =>
{
this.calledResourceId = resourceId;
this.calledPutParameters = putParameters;
});

insightsManagementClientMock.SetupGet(f => f.ServiceDiagnosticSettingsOperations).Returns(this.insightsDiagnosticsOperationsMock.Object);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
using Xunit;

namespace Microsoft.Azure.Commands.Insights.Test.ScenarioTests
{
public class AzureRmDiagnosticSettingTests : RMTestBase
{
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetAzureRmDiagnosticSetting()
{
TestsController.NewInstance.RunPsTest("Test-GetAzureRmDiagnosticSetting");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSetAzureRmDiagnosticSetting()
{
TestsController.NewInstance.RunPsTest("Test-SetAzureRmDiagnosticSetting");
}
}
}
Loading