Skip to content

Commit 18a74ef

Browse files
authored
Merge pull request #2643 from SiddharthChatrolaMs/dev
New cmdlets added for patch schedule
2 parents 74850f3 + 3007b7d commit 18a74ef

File tree

13 files changed

+1138
-12
lines changed

13 files changed

+1138
-12
lines changed

ChangeLog.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
##2016.07.11 version 1.6.0
1+
* Azure Redis Cache
2+
* New cmdlet added for New-AzureRmRedisCacheScheduleEntry
3+
* New cmdlet added for New-AzureRmRedisCachePatchSchedule
4+
* New cmdlet added for Get-AzureRmRedisCachePatchSchedule
5+
* New cmdlet added for Remove-AzureRmRedisCachePatchSchedule
6+
##2016.07.11 version 1.6.0
27
* **Behavioral change for -Force, –Confirm and $ConfirmPreference parameters for all cmdlets. We are changing this implementation to be in line with PowerShell guidelines. For most cmdlets, this means removing the Force parameter and to skip the ShouldProcess prompt, users will need to include the parameter: ‘-Confirm:$false’ in their PowerShell scripts.** This changes are addressing following issues:
38
* Correct implementation of –WhatIf functionality, allowing a user to determine the effects of a cmdlet or script without making any actual changes
49
* Control over prompting using a session-wide $ConfirmPreference, so that the user is prompted based on the impact of a prospective change (as reported in the ConfirmImpact setting in the cmdlet)

src/ResourceManager/RedisCache/Commands.RedisCache.Test/Commands.RedisCache.Test.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@
233233
<None Include="SessionRecords\Microsoft.Azure.Commands.RedisCache.Test.ScenarioTests.RedisCacheTests\TestRedisCacheClustering.json">
234234
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
235235
</None>
236+
<None Include="SessionRecords\Microsoft.Azure.Commands.RedisCache.Test.ScenarioTests.RedisCacheTests\TestRedisCachePatchSchedules.json">
237+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
238+
</None>
236239
<None Include="SessionRecords\Microsoft.Azure.Commands.RedisCache.Test.ScenarioTests.RedisCacheTests\TestRedisCachePipeline.json">
237240
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
238241
</None>

src/ResourceManager/RedisCache/Commands.RedisCache.Test/ScenarioTests/RedisCacheTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,12 @@ public void TestImportAzureRmRedisCache()
103103
{
104104
RedisCacheController.NewInstance.RunPowerShellTest("Test-ImportAzureRmRedisCache");
105105
}
106+
107+
[Fact]
108+
[Trait(Category.AcceptanceType, Category.CheckIn)]
109+
public void TestRedisCachePatchSchedules()
110+
{
111+
RedisCacheController.NewInstance.RunPowerShellTest("Test-RedisCachePatchSchedules");
112+
}
106113
}
107114
}

src/ResourceManager/RedisCache/Commands.RedisCache.Test/ScenarioTests/RedisCacheTests.ps1

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,63 @@ function Test-ImportAzureRmRedisCache
463463
Import-AzureRmRedisCache -ResourceGroupName $resourceGroupName -Name $cacheName -Files $files -Force
464464
}
465465

466+
<#
467+
.SYNOPSIS
468+
Tests schedule patching
469+
#>
470+
function Test-RedisCachePatchSchedules
471+
{
472+
$resourceGroupName = "SiddharthsSub"
473+
$cacheName = "sunny-premium"
474+
475+
$weekend = New-AzureRmRedisCacheScheduleEntry -DayOfWeek "Weekend" -StartHourUtc 2 -MaintenanceWindow "06:00:00"
476+
$thursday = New-AzureRmRedisCacheScheduleEntry -DayOfWeek "Thursday" -StartHourUtc 10 -MaintenanceWindow "09:00:00"
477+
478+
$createResult = New-AzureRmRedisCachePatchSchedule -ResourceGroupName $resourceGroupName -Name $cacheName -Entries @($weekend, $thursday)
479+
Assert-True {$createResult.Count -eq 3}
480+
foreach ($scheduleEntry in $createResult)
481+
{
482+
if($scheduleEntry.DayOfWeek -eq "Thursday")
483+
{
484+
Assert-AreEqual 10 $scheduleEntry.StartHourUtc
485+
Assert-AreEqual "09:00:00" $scheduleEntry.MaintenanceWindow
486+
}
487+
elseif($scheduleEntry.DayOfWeek -eq "Saturday" -or $scheduleEntry.DayOfWeek -eq "Sunday")
488+
{
489+
Assert-AreEqual 2 $scheduleEntry.StartHourUtc
490+
Assert-AreEqual "06:00:00" $scheduleEntry.MaintenanceWindow
491+
}
492+
else
493+
{
494+
Assert-True $false "Unknown DayOfWeek."
495+
}
496+
}
497+
498+
$getResult = Get-AzureRmRedisCachePatchSchedule -ResourceGroupName $resourceGroupName -Name $cacheName
499+
Assert-True {$getResult.Count -eq 3}
500+
foreach ($scheduleEntry in $getResult)
501+
{
502+
if($scheduleEntry.DayOfWeek -eq "Thursday")
503+
{
504+
Assert-AreEqual 10 $scheduleEntry.StartHourUtc
505+
Assert-AreEqual "09:00:00" $scheduleEntry.MaintenanceWindow
506+
}
507+
elseif($scheduleEntry.DayOfWeek -eq "Saturday" -or $scheduleEntry.DayOfWeek -eq "Sunday")
508+
{
509+
Assert-AreEqual 2 $scheduleEntry.StartHourUtc
510+
Assert-AreEqual "06:00:00" $scheduleEntry.MaintenanceWindow
511+
}
512+
else
513+
{
514+
Assert-True $false "Unknown DayOfWeek."
515+
}
516+
}
517+
518+
Remove-AzureRmRedisCachePatchSchedule -ResourceGroupName $resourceGroupName -Name $cacheName
519+
520+
Assert-ThrowsContains {Get-AzureRmRedisCachePatchSchedule -ResourceGroupName $resourceGroupName -Name $cacheName} "There are no patch schedules found for redis cache 'sunny-premium'"
521+
}
522+
466523
<#
467524
.SYNOPSIS
468525
Sleeps but only during recording.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,251 @@
1+
{
2+
"Entries": [
3+
{
4+
"RequestUri": "/subscriptions/592cc9de-a3cd-4d70-9bc1-c1a28a3625b5/resourceGroups/SiddharthsSub/providers/Microsoft.Cache/Redis/sunny-premium/patchSchedules/default?api-version=2016-04-01",
5+
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvNTkyY2M5ZGUtYTNjZC00ZDcwLTliYzEtYzFhMjhhMzYyNWI1L3Jlc291cmNlR3JvdXBzL1NpZGRoYXJ0aHNTdWIvcHJvdmlkZXJzL01pY3Jvc29mdC5DYWNoZS9SZWRpcy9zdW5ueS1wcmVtaXVtL3BhdGNoU2NoZWR1bGVzL2RlZmF1bHQ/YXBpLXZlcnNpb249MjAxNi0wNC0wMQ==",
6+
"RequestMethod": "PUT",
7+
"RequestBody": "{\r\n \"properties\": {\r\n \"scheduleEntries\": [\r\n {\r\n \"dayOfWeek\": \"Saturday\",\r\n \"startHourUtc\": 2,\r\n \"maintenanceWindow\": \"PT6H\"\r\n },\r\n {\r\n \"dayOfWeek\": \"Sunday\",\r\n \"startHourUtc\": 2,\r\n \"maintenanceWindow\": \"PT6H\"\r\n },\r\n {\r\n \"dayOfWeek\": \"Thursday\",\r\n \"startHourUtc\": 10,\r\n \"maintenanceWindow\": \"PT9H\"\r\n }\r\n ]\r\n }\r\n}",
8+
"RequestHeaders": {
9+
"Content-Type": [
10+
"application/json; charset=utf-8"
11+
],
12+
"Content-Length": [
13+
"413"
14+
],
15+
"x-ms-client-request-id": [
16+
"42cd27d7-4e09-47d7-b7f8-9b0393d75ee9"
17+
],
18+
"accept-language": [
19+
"en-US"
20+
],
21+
"User-Agent": [
22+
"Microsoft.Azure.Management.Redis.RedisManagementClient/3.1.0.0"
23+
]
24+
},
25+
"ResponseBody": "{\r\n \"id\": \"/subscriptions/592cc9de-a3cd-4d70-9bc1-c1a28a3625b5/resourceGroups/SiddharthsSub/providers/Microsoft.Cache/Redis/sunny-premium/patchSchedules/default\",\r\n \"location\": \"West US\",\r\n \"name\": \"sunny-premium/default\",\r\n \"type\": \"Microsoft.Cache/Redis/PatchSchedules\",\r\n \"properties\": {\r\n \"scheduleEntries\": [\r\n {\r\n \"dayOfWeek\": \"Saturday\",\r\n \"startHourUtc\": 2,\r\n \"maintenanceWindow\": \"PT6H\"\r\n },\r\n {\r\n \"dayOfWeek\": \"Sunday\",\r\n \"startHourUtc\": 2,\r\n \"maintenanceWindow\": \"PT6H\"\r\n },\r\n {\r\n \"dayOfWeek\": \"Thursday\",\r\n \"startHourUtc\": 10,\r\n \"maintenanceWindow\": \"PT9H\"\r\n }\r\n ]\r\n }\r\n}",
26+
"ResponseHeaders": {
27+
"Content-Length": [
28+
"497"
29+
],
30+
"Content-Type": [
31+
"application/json; charset=utf-8"
32+
],
33+
"Expires": [
34+
"-1"
35+
],
36+
"Pragma": [
37+
"no-cache"
38+
],
39+
"x-ms-request-id": [
40+
"d640bc6c-2bce-4439-81e0-adaad9bddd1f"
41+
],
42+
"x-rp-server-mvid": [
43+
"ee94f66d-6cbf-4677-9102-16a91b3a282c"
44+
],
45+
"Strict-Transport-Security": [
46+
"max-age=31536000; includeSubDomains"
47+
],
48+
"x-ms-ratelimit-remaining-subscription-writes": [
49+
"1199"
50+
],
51+
"x-ms-correlation-request-id": [
52+
"5421c08b-3f59-4cd9-ae7b-4d06d65330fa"
53+
],
54+
"x-ms-routing-request-id": [
55+
"CENTRALUS:20160708T184237Z:5421c08b-3f59-4cd9-ae7b-4d06d65330fa"
56+
],
57+
"Cache-Control": [
58+
"no-cache"
59+
],
60+
"Date": [
61+
"Fri, 08 Jul 2016 18:42:37 GMT"
62+
],
63+
"Server": [
64+
"Microsoft-HTTPAPI/2.0"
65+
]
66+
},
67+
"StatusCode": 200
68+
},
69+
{
70+
"RequestUri": "/subscriptions/592cc9de-a3cd-4d70-9bc1-c1a28a3625b5/resourceGroups/SiddharthsSub/providers/Microsoft.Cache/Redis/sunny-premium/patchSchedules/default?api-version=2016-04-01",
71+
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvNTkyY2M5ZGUtYTNjZC00ZDcwLTliYzEtYzFhMjhhMzYyNWI1L3Jlc291cmNlR3JvdXBzL1NpZGRoYXJ0aHNTdWIvcHJvdmlkZXJzL01pY3Jvc29mdC5DYWNoZS9SZWRpcy9zdW5ueS1wcmVtaXVtL3BhdGNoU2NoZWR1bGVzL2RlZmF1bHQ/YXBpLXZlcnNpb249MjAxNi0wNC0wMQ==",
72+
"RequestMethod": "GET",
73+
"RequestBody": "",
74+
"RequestHeaders": {
75+
"x-ms-client-request-id": [
76+
"324e4dce-c420-43f0-b675-78b30f26b77a"
77+
],
78+
"accept-language": [
79+
"en-US"
80+
],
81+
"User-Agent": [
82+
"Microsoft.Azure.Management.Redis.RedisManagementClient/3.1.0.0"
83+
]
84+
},
85+
"ResponseBody": "{\r\n \"id\": \"/subscriptions/592cc9de-a3cd-4d70-9bc1-c1a28a3625b5/resourceGroups/SiddharthsSub/providers/Microsoft.Cache/Redis/sunny-premium/patchSchedules/default\",\r\n \"location\": \"West US\",\r\n \"name\": \"sunny-premium/default\",\r\n \"type\": \"Microsoft.Cache/Redis/PatchSchedules\",\r\n \"properties\": {\r\n \"scheduleEntries\": [\r\n {\r\n \"dayOfWeek\": \"Saturday\",\r\n \"startHourUtc\": 2,\r\n \"maintenanceWindow\": \"PT6H\"\r\n },\r\n {\r\n \"dayOfWeek\": \"Sunday\",\r\n \"startHourUtc\": 2,\r\n \"maintenanceWindow\": \"PT6H\"\r\n },\r\n {\r\n \"dayOfWeek\": \"Thursday\",\r\n \"startHourUtc\": 10,\r\n \"maintenanceWindow\": \"PT9H\"\r\n }\r\n ]\r\n }\r\n}",
86+
"ResponseHeaders": {
87+
"Content-Length": [
88+
"497"
89+
],
90+
"Content-Type": [
91+
"application/json; charset=utf-8"
92+
],
93+
"Expires": [
94+
"-1"
95+
],
96+
"Pragma": [
97+
"no-cache"
98+
],
99+
"x-ms-request-id": [
100+
"1a881c23-8a3b-426f-89b7-704393c01584"
101+
],
102+
"x-rp-server-mvid": [
103+
"ee94f66d-6cbf-4677-9102-16a91b3a282c"
104+
],
105+
"Strict-Transport-Security": [
106+
"max-age=31536000; includeSubDomains"
107+
],
108+
"x-ms-ratelimit-remaining-subscription-reads": [
109+
"14999"
110+
],
111+
"x-ms-correlation-request-id": [
112+
"b88c1321-5d7e-4de7-b5af-4a6d82d9cc29"
113+
],
114+
"x-ms-routing-request-id": [
115+
"CENTRALUS:20160708T184237Z:b88c1321-5d7e-4de7-b5af-4a6d82d9cc29"
116+
],
117+
"Cache-Control": [
118+
"no-cache"
119+
],
120+
"Date": [
121+
"Fri, 08 Jul 2016 18:42:37 GMT"
122+
],
123+
"Server": [
124+
"Microsoft-HTTPAPI/2.0"
125+
]
126+
},
127+
"StatusCode": 200
128+
},
129+
{
130+
"RequestUri": "/subscriptions/592cc9de-a3cd-4d70-9bc1-c1a28a3625b5/resourceGroups/SiddharthsSub/providers/Microsoft.Cache/Redis/sunny-premium/patchSchedules/default?api-version=2016-04-01",
131+
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvNTkyY2M5ZGUtYTNjZC00ZDcwLTliYzEtYzFhMjhhMzYyNWI1L3Jlc291cmNlR3JvdXBzL1NpZGRoYXJ0aHNTdWIvcHJvdmlkZXJzL01pY3Jvc29mdC5DYWNoZS9SZWRpcy9zdW5ueS1wcmVtaXVtL3BhdGNoU2NoZWR1bGVzL2RlZmF1bHQ/YXBpLXZlcnNpb249MjAxNi0wNC0wMQ==",
132+
"RequestMethod": "GET",
133+
"RequestBody": "",
134+
"RequestHeaders": {
135+
"x-ms-client-request-id": [
136+
"14a4a385-a71c-47af-a95f-7bbf6d014e83"
137+
],
138+
"accept-language": [
139+
"en-US"
140+
],
141+
"User-Agent": [
142+
"Microsoft.Azure.Management.Redis.RedisManagementClient/3.1.0.0"
143+
]
144+
},
145+
"ResponseBody": "{\r\n \"error\": {\r\n \"code\": \"ResourceNotFound\",\r\n \"message\": \"There are no patch schedules found for redis cache 'sunny-premium'.\\r\\nRequestID=391c4d63-ee26-4815-aa51-95ef2e2e1014\",\r\n \"target\": null\r\n }\r\n}",
146+
"ResponseHeaders": {
147+
"Content-Length": [
148+
"181"
149+
],
150+
"Content-Type": [
151+
"application/json; charset=utf-8"
152+
],
153+
"Expires": [
154+
"-1"
155+
],
156+
"Pragma": [
157+
"no-cache"
158+
],
159+
"x-ms-request-id": [
160+
"391c4d63-ee26-4815-aa51-95ef2e2e1014"
161+
],
162+
"x-rp-server-mvid": [
163+
"ee94f66d-6cbf-4677-9102-16a91b3a282c"
164+
],
165+
"Strict-Transport-Security": [
166+
"max-age=31536000; includeSubDomains"
167+
],
168+
"x-ms-ratelimit-remaining-subscription-reads": [
169+
"14998"
170+
],
171+
"x-ms-correlation-request-id": [
172+
"ad39410b-e1a7-4591-bb67-f7f63cbae0fa"
173+
],
174+
"x-ms-routing-request-id": [
175+
"CENTRALUS:20160708T184238Z:ad39410b-e1a7-4591-bb67-f7f63cbae0fa"
176+
],
177+
"Cache-Control": [
178+
"no-cache"
179+
],
180+
"Date": [
181+
"Fri, 08 Jul 2016 18:42:37 GMT"
182+
],
183+
"Server": [
184+
"Microsoft-HTTPAPI/2.0"
185+
]
186+
},
187+
"StatusCode": 404
188+
},
189+
{
190+
"RequestUri": "/subscriptions/592cc9de-a3cd-4d70-9bc1-c1a28a3625b5/resourceGroups/SiddharthsSub/providers/Microsoft.Cache/Redis/sunny-premium/patchSchedules/default?api-version=2016-04-01",
191+
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvNTkyY2M5ZGUtYTNjZC00ZDcwLTliYzEtYzFhMjhhMzYyNWI1L3Jlc291cmNlR3JvdXBzL1NpZGRoYXJ0aHNTdWIvcHJvdmlkZXJzL01pY3Jvc29mdC5DYWNoZS9SZWRpcy9zdW5ueS1wcmVtaXVtL3BhdGNoU2NoZWR1bGVzL2RlZmF1bHQ/YXBpLXZlcnNpb249MjAxNi0wNC0wMQ==",
192+
"RequestMethod": "DELETE",
193+
"RequestBody": "",
194+
"RequestHeaders": {
195+
"x-ms-client-request-id": [
196+
"bf82e809-a66d-4b73-84a0-24c63a1a32df"
197+
],
198+
"accept-language": [
199+
"en-US"
200+
],
201+
"User-Agent": [
202+
"Microsoft.Azure.Management.Redis.RedisManagementClient/3.1.0.0"
203+
]
204+
},
205+
"ResponseBody": "",
206+
"ResponseHeaders": {
207+
"Content-Length": [
208+
"0"
209+
],
210+
"Expires": [
211+
"-1"
212+
],
213+
"Pragma": [
214+
"no-cache"
215+
],
216+
"x-ms-request-id": [
217+
"186590eb-25c0-40bf-81c6-7804aa2f11aa"
218+
],
219+
"x-rp-server-mvid": [
220+
"ee94f66d-6cbf-4677-9102-16a91b3a282c"
221+
],
222+
"Strict-Transport-Security": [
223+
"max-age=31536000; includeSubDomains"
224+
],
225+
"x-ms-ratelimit-remaining-subscription-writes": [
226+
"1198"
227+
],
228+
"x-ms-correlation-request-id": [
229+
"afecf077-f66b-479b-9f2d-28762401276d"
230+
],
231+
"x-ms-routing-request-id": [
232+
"CENTRALUS:20160708T184237Z:afecf077-f66b-479b-9f2d-28762401276d"
233+
],
234+
"Cache-Control": [
235+
"no-cache"
236+
],
237+
"Date": [
238+
"Fri, 08 Jul 2016 18:42:37 GMT"
239+
],
240+
"Server": [
241+
"Microsoft-HTTPAPI/2.0"
242+
]
243+
},
244+
"StatusCode": 200
245+
}
246+
],
247+
"Names": {},
248+
"Variables": {
249+
"SubscriptionId": "592cc9de-a3cd-4d70-9bc1-c1a28a3625b5"
250+
}
251+
}

src/ResourceManager/RedisCache/Commands.RedisCache/Commands.RedisCache.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@
153153
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
154154
</ItemGroup>
155155
<ItemGroup>
156+
<Compile Include="Commands\RemoveAzureRedisCachePatchSchedule.cs" />
157+
<Compile Include="Commands\NewAzureRedisCacheScheduleEntry.cs" />
158+
<Compile Include="Commands\GetAzureRedisCachePatchSchedule.cs" />
159+
<Compile Include="Commands\NewAzureRedisCachePatchSchedule.cs" />
156160
<Compile Include="Commands\ResetAzureRedisCache.cs" />
157161
<Compile Include="Commands\ExportAzureRedisCache.cs" />
158162
<Compile Include="Commands\ImportAzureRedisCache.cs" />
@@ -164,6 +168,7 @@
164168
<Compile Include="Commands\GetAzureRedisCache.cs" />
165169
<Compile Include="Commands\RemoveAzureRedisCache.cs" />
166170
<Compile Include="Commands\NewAzureRedisCache.cs" />
171+
<Compile Include="Models\PSScheduleEntry.cs" />
167172
<Compile Include="Models\RedisCacheAttributesWithAccessKeys.cs" />
168173
<Compile Include="Models\RedisCacheAttributes.cs" />
169174
<Compile Include="Models\RedisCacheClient.cs" />

0 commit comments

Comments
 (0)