Skip to content

Commit 96c6603

Browse files
author
Maddie Clayton
authored
Merge pull request Azure#7117 from Azure/AddKusto-2
Kusto: Add kusto API
2 parents 6fb6830 + 69345c0 commit 96c6603

File tree

52 files changed

+45258
-2
lines changed

Some content is hidden

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

52 files changed

+45258
-2
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<Import Project="$(ProjectDir)..\..\..\..\tools\Common.Netcore.Dependencies.Test.targets" />
4+
5+
<PropertyGroup>
6+
<TargetFrameworks>netcoreapp2.1;netcoreapp2.0</TargetFrameworks>
7+
<AssemblyName>Microsoft.Azure.PowerShell.Cmdlets.Kusto.Test</AssemblyName>
8+
<RootNamespace>Microsoft.Azure.Commands.Kusto.Test</RootNamespace>
9+
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
10+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
11+
<WarningsAsErrors />
12+
<IsPackable>false</IsPackable>
13+
</PropertyGroup>
14+
15+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
16+
<DelaySign>false</DelaySign>
17+
<DefineConstants>TRACE;DEBUG;NETSTANDARD</DefineConstants>
18+
</PropertyGroup>
19+
20+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
21+
<SignAssembly>true</SignAssembly>
22+
<DelaySign>true</DelaySign>
23+
<AssemblyOriginatorKeyFile>MSSharedLibKey.snk</AssemblyOriginatorKeyFile>
24+
<DefineConstants>TRACE;RELEASE;NETSTANDARD;SIGN</DefineConstants>
25+
</PropertyGroup>
26+
27+
<ItemGroup>
28+
<PackageReference Include="Microsoft.Azure.Management.Kusto" Version="0.9.0-preview" />
29+
</ItemGroup>
30+
31+
<ItemGroup>
32+
<ProjectReference Include="..\Commands.Kusto\Commands.Kusto.Netcore.csproj" />
33+
</ItemGroup>
34+
35+
<ItemGroup>
36+
<None Update="SessionRecords\**\*.json">
37+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
38+
</None>
39+
<None Update="ScenarioTests\*.ps1">
40+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
41+
</None>
42+
</ItemGroup>
43+
</Project>
160 Bytes
Binary file not shown.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
using Xunit;
5+
6+
// General Information about an assembly is controlled through the following
7+
// set of attributes. Change these attribute values to modify the information
8+
// associated with an assembly.
9+
[assembly: AssemblyTitle("Commands.Kusto.Test")]
10+
[assembly: AssemblyDescription("")]
11+
[assembly: AssemblyConfiguration("")]
12+
[assembly: AssemblyCompany("")]
13+
[assembly: AssemblyProduct("Commands.Kusto.Test")]
14+
[assembly: AssemblyCopyright("Copyright © 2018")]
15+
[assembly: AssemblyTrademark("")]
16+
[assembly: AssemblyCulture("")]
17+
18+
// Setting ComVisible to false makes the types in this assembly not visible
19+
// to COM components. If you need to access a type in this assembly from
20+
// COM, set the ComVisible attribute to true on that type.
21+
[assembly: ComVisible(false)]
22+
23+
// The following GUID is for the ID of the typelib if this project is exposed to COM
24+
[assembly: Guid("05e8f0bd-c388-4fd7-b3e9-b06049fe8131")]
25+
26+
// Version information for an assembly consists of the following four values:
27+
//
28+
// Major Version
29+
// Minor Version
30+
// Build Number
31+
// Revision
32+
//
33+
// You can specify all the values or you can default the Build and Revision Numbers
34+
// by using the '*' as shown below:
35+
// [assembly: AssemblyVersion("1.0.*")]
36+
[assembly: AssemblyVersion("1.0.0.0")]
37+
[assembly: AssemblyFileVersion("1.0.0.0")]
38+
[assembly: CollectionBehavior(DisableTestParallelization = true)]
Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
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+
<#
16+
.SYNOPSIS
17+
Gets resource location for testing.
18+
#>
19+
function Get-Cluster-Location
20+
{
21+
return Get-Location "Microsoft.Kusto" "operations" "Central US"
22+
}
23+
24+
function Get-RG-Location
25+
{
26+
Get-Location "Microsoft.Resources" "resourceGroups" "Central US"
27+
}
28+
29+
<#
30+
.SYNOPSIS
31+
Gets a name of the resource group testing.
32+
#>
33+
function Get-RG-Name
34+
{
35+
return getAssetname
36+
#return "KustoPSClientTest"
37+
}
38+
39+
<#
40+
.SYNOPSIS
41+
Gets a name of the cluster testing.
42+
#>
43+
function Get-Cluster-Name
44+
{
45+
return getAssetName
46+
#return "kustopsclienttest"
47+
}
48+
49+
<#
50+
.SYNOPSIS
51+
Gets a sku name
52+
#>
53+
function Get-Sku
54+
{
55+
return "D13_v2"
56+
}
57+
58+
<#
59+
.SYNOPSIS
60+
Gets a sku diferent sku name.
61+
#>
62+
function Get-Updated-Sku
63+
{
64+
return "D14_v2"
65+
}
66+
67+
<#
68+
.SYNOPSIS
69+
Gets a name of a not existing resource group for testing.
70+
#>
71+
function Get-Cluster-Resource-Type
72+
{
73+
return "Microsoft.Kusto/Clusters"
74+
}
75+
76+
<#
77+
.SYNOPSIS
78+
Gets a cluster resource id
79+
#>
80+
function Get-Cluster-Resource-Id
81+
{
82+
Param([string]$Subscription,
83+
[string]$ResourceGroupName,
84+
[string]$ClusterName)
85+
return "/subscriptions/$Subscription/resourceGroups/$ResourceGroupName/providers/Microsoft.Kusto/clusters/$ClusterName"
86+
}
87+
88+
<#
89+
.SYNOPSIS
90+
Gets a database resource id
91+
#>
92+
function Get-Database-Resource-Id
93+
{
94+
Param([string]$Subscription,
95+
[string]$ResourceGroupName,
96+
[string]$ClusterName,
97+
[string]$DatabaseName)
98+
$clusterResourceId = Get-Cluster-Resource-Id -Subscription $Subscription -ResourceGroupName $ResourceGroupName -ClusterName $ClusterName
99+
return "$clusterResourceId/databases/$DatabaseName"
100+
}
101+
102+
103+
<#
104+
.SYNOPSIS
105+
Gets a database name
106+
#>
107+
function Get-Database-Name
108+
{
109+
return getAssetName
110+
}
111+
112+
<#
113+
.SYNOPSIS
114+
Gets a database type
115+
#>
116+
function Get-Database-Type
117+
{
118+
return "Microsoft.Kusto/Clusters/Databases"
119+
}
120+
121+
<#
122+
.SYNOPSIS
123+
Gets a database soft delet perios in days parameter
124+
#>
125+
function Get-Soft-Delete-Period-In-Days
126+
{
127+
return 4
128+
}
129+
130+
<#
131+
.SYNOPSIS
132+
Gets a database hot cache period in days
133+
#>
134+
function Get-Hot-Cache-Period-In-Days
135+
{
136+
return 2
137+
}
138+
139+
<#
140+
.SYNOPSIS
141+
Gets a different database soft delet perios in days parameter ( for testing update)
142+
#>
143+
function Get-Updated-Soft-Delete-Period-In-Days
144+
{
145+
return 6
146+
}
147+
148+
<#
149+
.SYNOPSIS
150+
Gets a different database hot cache period in days (for testring update)
151+
#>
152+
function Get-Updated-Hot-Cache-Period-In-Days
153+
{
154+
return 3
155+
}
156+
157+
<#
158+
.SYNOPSIS
159+
Gets a the database does not exist message
160+
#>
161+
function Get-Database-Not-Exist-Message
162+
{
163+
Param([string]$DatabaseName)
164+
return "$DatabaseName' is not found"
165+
}
166+
167+
<#
168+
.SYNOPSIS
169+
Gets a the cluster does not exist message
170+
#>
171+
function Get-Cluster-Not-Exist-Message
172+
{
173+
Param([string]$ResourceGroupName,
174+
[string]$ClusterName)
175+
return "'Microsoft.Kusto/clusters/$ClusterName' under resource group '$ResourceGroupName' was not found"
176+
}
177+
178+
179+
<#
180+
.SYNOPSIS
181+
Gets a the cluster does not exist message
182+
#>
183+
function Get-Cluster-Name-Exists-Message
184+
{
185+
Param([string]$ClusterName)
186+
return "Name '$ClusterName' with type Engine is already taken. Please specify a different name"
187+
}
188+
189+
190+
<#
191+
.SYNOPSIS
192+
Executes a cmdlet and enables ignoring of errors if desired
193+
NOTE: this only catches errors that are thrown. If the command calls to Write-Error
194+
the user must specify the errorAction to be silent or store the record in an error variable.
195+
#>
196+
function Invoke-HandledCmdlet
197+
{
198+
param
199+
(
200+
[ScriptBlock] $Command,
201+
[switch] $IgnoreFailures
202+
)
203+
204+
try
205+
{
206+
&$Command
207+
}
208+
catch
209+
{
210+
if(!$IgnoreFailures)
211+
{
212+
throw;
213+
}
214+
}
215+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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 Microsoft.WindowsAzure.Commands.ScenarioTest;
16+
using Microsoft.Azure.ServiceManagement.Common.Models;
17+
using Xunit;
18+
using Microsoft.Azure.Commands.ScenarioTest;
19+
20+
namespace Microsoft.Azure.Commands.Kusto.Test.ScenarioTests
21+
{
22+
public class KustoClusterTests : KustoTestsBase
23+
{
24+
private readonly XunitTracingInterceptor _logger;
25+
26+
public KustoClusterTests(Xunit.Abstractions.ITestOutputHelper output)
27+
{
28+
_logger = new XunitTracingInterceptor(output);
29+
XunitTracingInterceptor.AddToContext(_logger);
30+
TestExecutionHelpers.SetUpSessionAndProfile();
31+
}
32+
33+
[Fact]
34+
[Trait(Category.AcceptanceType, Category.CheckIn)]
35+
public void TestKustoClusterLifecycle()
36+
{
37+
NewInstance.RunPsTest(_logger, "Test-KustoClusterLifecycle");
38+
}
39+
40+
[Fact]
41+
[Trait(Category.AcceptanceType, Category.CheckIn)]
42+
public void TestKustoClusterName()
43+
{
44+
NewInstance.RunPsTest(_logger, "Test-KustoClusterName");
45+
}
46+
47+
[Fact]
48+
[Trait(Category.AcceptanceType, Category.CheckIn)]
49+
public void TestKustoClusterUpdate()
50+
{
51+
NewInstance.RunPsTest(_logger, "Test-KustoClusterUpdate");
52+
}
53+
54+
[Fact]
55+
[Trait(Category.AcceptanceType, Category.CheckIn)]
56+
public void TestKustoClusterSuspendResume()
57+
{
58+
NewInstance.RunPsTest(_logger, "Test-KustoClusterSuspendResume");
59+
}
60+
61+
[Fact]
62+
[Trait(Category.AcceptanceType, Category.CheckIn)]
63+
public void TestKustoClusterRemove()
64+
{
65+
NewInstance.RunPsTest(_logger, "Test-KustoClusterRemove");
66+
}
67+
68+
}
69+
}

0 commit comments

Comments
 (0)