Skip to content

Commit ffaaf49

Browse files
frrossmsamisi01isra-fel
authored
Check in basic managed Cassandra cmdlets (Azure#16181)
* Add support for MongoDB backup commands in CosmosDB * Added New Cmdlet for getting backup information for MongoDB. * Update New/Update database account cmdlet to update backupredundancy * Added New Cmdlet for getting locations * Add Cassandra MI support to CosmosDB cmdlets * organize change log Co-authored-by: REDMOND\amisi <amisi@microsoft.com> Co-authored-by: Yeming Liu <11371776+isra-fel@users.noreply.github.com>
1 parent 093863f commit ffaaf49

34 files changed

+9007
-7
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<PsModuleName>CosmosDB</PsModuleName>
44
</PropertyGroup>
55
<Import Project="$(MSBuildThisFileDirectory)..\..\Az.Test.props" />
66
<ItemGroup>
77
<PackageReference Include="Microsoft.Azure.Management.Network" Version="21.0.0" />
88
<PackageReference Include="Microsoft.Azure.Management.CosmosDB" Version="3.3.0" />
9-
</ItemGroup>
9+
</ItemGroup>
1010
</Project>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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 Xunit;
17+
18+
namespace Microsoft.Azure.Commands.CosmosDB.Test.ScenarioTests.ScenarioTest
19+
{
20+
public class ManagedCassandraOperationsTests
21+
{
22+
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;
23+
24+
public ManagedCassandraOperationsTests(Xunit.Abstractions.ITestOutputHelper output)
25+
{
26+
_logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
27+
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
28+
}
29+
30+
[Fact]
31+
[Trait(Category.AcceptanceType, Category.CheckIn)]
32+
public void TestManagedCassandraClusterCreateUpdateGetCmdlets()
33+
{
34+
TestController.NewInstance.RunPowerShellTest(_logger, "Test-ManagedCassandraCreateUpdateGetCmdlets");
35+
}
36+
}
37+
}
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
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+
Test Cassandra Cluster CRUD cmdlets using Name paramter set
18+
#>
19+
function Test-ManagedCassandraCreateUpdateGetCmdlets
20+
{
21+
$RgName = "nova-powershell-tests-rg"
22+
$ClusterName = "cluster8ea4cb76-7009-4b56-b09c-13dad8371a42"
23+
$DCName = "dc1"
24+
$Location = "central us"
25+
$VnetName = "cassandra-mi-vnet"
26+
27+
Try {
28+
# Because New-AzRoleAssignmentWithId in tools\ScenarioTest.ResourceManager\AzureRM.Resources.ps1
29+
# is broken, we can't assign the Network Contributor role to virtual networks in the test. Therefore you
30+
# must set up a resource group with the following PowerShell script:
31+
#
32+
# $RgName = "nova-powershell-tests-rg"
33+
# $Location = "central us"
34+
# $resourceGroup = New-AzResourceGroup -ResourceGroupName $RgName -Location $Location
35+
# $vnetProperties = @{
36+
# Name = 'cassandra-mi-vnet'
37+
# ResourceGroupName = $RgName
38+
# Location = $Location
39+
# AddressPrefix = '10.0.0.0/16'
40+
# }
41+
# $vnet = New-AzVirtualNetwork @vnetProperties
42+
# $subnetProperties = @{
43+
# Name = 'default'
44+
# VirtualNetwork = $vnet
45+
# AddressPrefix = '10.0.0.0/24'
46+
# }
47+
# $subnet = Add-AzVirtualNetworkSubnetConfig @subnetProperties
48+
# $vnet = $vnet | Set-AzVirtualNetwork
49+
# New-AzRoleAssignment -ObjectId "e5007d2c-4b13-4a74-9b6a-605d99f03501" -RoleDefinitionName 'Network Contributor' -Scope $SubnetId
50+
# $SubnetId = $vnet.Subnets[0].Id
51+
#
52+
# then set this variable to the $SubnetId value produced by the script.
53+
$SubnetId = "/subscriptions/dd31ecae-4522-468e-8b27-5befd051dd53/resourceGroups/nova-powershell-tests-rg/providers/Microsoft.Network/virtualNetworks/cassandra-mi-vnet/subnets/default"
54+
55+
$initialClusterCount = (Get-AzManagedCassandraCluster -ResourceGroupName $RgName).Count
56+
57+
$response = New-AzManagedCassandraCluster `
58+
-ResourceGroupName $RgName `
59+
-ClusterName $ClusterName `
60+
-Location $Location `
61+
-InitialCassandraAdminPassword "password" `
62+
-DelegatedManagementSubnetId $SubnetId
63+
Assert-AreEqual "Succeeded" $response.Properties.ProvisioningState
64+
Assert-AreEqual $ClusterName $response.Name
65+
Assert-AreEqual 0 $response.Properties.ExternalSeedNodes.Count
66+
67+
$clusterId = $response.Id
68+
69+
$cluster = Get-AzManagedCassandraCluster -ResourceGroupName $RgName -ClusterName $ClusterName
70+
Assert-AreEqual "Succeeded" $cluster.Properties.ProvisioningState
71+
Assert-AreEqual $SubnetId $cluster.Properties.DelegatedManagementSubnetId
72+
Assert-AreEqual $true $cluster.Properties.RepairEnabled
73+
74+
$cluster2 = Get-AzManagedCassandraCluster -ResourceId $clusterId
75+
Assert-AreEqual $cluster.Id $cluster2.Id
76+
Assert-AreEqual $cluster.Location $cluster2.Location
77+
Assert-AreEqual $cluster.Properties.HoursBetweenBackups $cluster2.Properties.HoursBetweenBackups
78+
Assert-AreEqual $cluster.Properties.CassandraVersion $cluster2.Properties.CassandraVersion
79+
80+
Update-AzManagedCassandraCluster -ResourceId $clusterId `
81+
-ExternalSeedNode "127.0.0.1", "127.0.0.2", "127.0.0.3"
82+
while ($true) {
83+
$response = Get-AzManagedCassandraCluster -ResourceId $clusterId
84+
if ($response.Properties.ExternalSeedNodes.Count -eq 3)
85+
{
86+
break
87+
}
88+
Start-Sleep -s 1
89+
}
90+
$response = Get-AzManagedCassandraCluster -ResourceId $clusterId
91+
Assert-AreEqual 3 $response.Properties.ExternalSeedNodes.Count
92+
93+
$dcResponse = New-AzManagedCassandraDatacenter `
94+
-ResourceGroupName $RgName `
95+
-ClusterName $ClusterName `
96+
-DatacenterName $DCName `
97+
-Location $Location `
98+
-NodeCount 3 `
99+
-DelegatedSubnetId $SubnetId
100+
Assert-AreEqual "Succeeded" $dcResponse.Properties.ProvisioningState
101+
Assert-AreEqual 3 $dcResponse.Properties.NodeCount
102+
103+
$dcId = $dcResponse.Id
104+
105+
$dc = Get-AzManagedCassandraDatacenter -ResourceGroupName $RgName -ClusterName $ClusterName -DatacenterName $DCName
106+
Assert-AreEqual "Succeeded" $dc.Properties.ProvisioningState
107+
Assert-AreEqual 3 $dc.Properties.NodeCount
108+
109+
$dc2 = Get-AzManagedCassandraDatacenter -ResourceId $dcId
110+
Assert-AreEqual $dc.Id $dc2.Id
111+
Assert-AreEqual $dc.Name $dc2.Name
112+
Assert-AreEqual $dc.Properties.NodeCount $dc2.Properties.NodeCount
113+
114+
Remove-AzManagedCassandraDatacenter -ResourceId $dcId
115+
116+
Remove-AzManagedCassandraCluster -ResourceId $clusterId
117+
}
118+
Finally {
119+
}
120+
}
121+

src/CosmosDB/CosmosDB.Test/SessionRecords/Microsoft.Azure.Commands.CosmosDB.Test.ScenarioTests.ScenarioTest.ManagedCassandraOperationsTests/TestManagedCassandraClusterCreateUpdateGetCmdlets.json

Lines changed: 5216 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)