Skip to content

Commit 9a0a93a

Browse files
committed
Adding managed cache Retirement warning message and tests
1 parent 75035b3 commit 9a0a93a

14 files changed

+55
-12
lines changed

src/ServiceManagement/ManagedCache/Commands.ManagedCache.Test/ScenarioTests/ManagedCacheTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,12 @@ public void TestManagedCacheNamedCacheDoNotExists()
5050
{
5151
this.RunPowerShellTest("Test-ManagedCacheNamedCacheDoNotExists");
5252
}
53+
54+
[Fact]
55+
[Trait(Category.AcceptanceType, Category.CheckIn)]
56+
public void TestRetirementWarningMessage()
57+
{
58+
this.RunPowerShellTest("Test-RetirementWarningMessage");
59+
}
5360
}
5461
}

src/ServiceManagement/ManagedCache/Commands.ManagedCache.Test/ScenarioTests/ManagedCacheTests.ps1

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function Test-ListLocationsSupportCaching
5454
{
5555
$allLocations = Get-AzureManagedCacheLocation
5656

57-
Assert-AreNotEqual 0 $allLocations.Count
57+
Assert-AreNotEqual 0 $allLocations.Count
5858

5959
$found = $FALSE
6060
foreach ($location in $allLocations)
@@ -68,6 +68,34 @@ function Test-ListLocationsSupportCaching
6868
Assert-True {$found}
6969
}
7070

71+
72+
########################## Cache Retirement Warning message test #############################
73+
<#
74+
.SYNOPSIS
75+
Cache Retirement Warning message test
76+
#>
77+
function Test-RetirementWarningMessage
78+
{
79+
$warningBeforeRetirement = "The Azure Managed Cache Service will be retired on 11/30/2016. Please migrate to the Azure Redis Cache Service. For more information, see http://go.microsoft.com/fwlink/?LinkID=717458"
80+
$warningAfterRetirement = "The Azure Managed Cache Service has been retired as of 11/30/2016. Please migrate to the Azure Redis Cache Service. For more information, see http://go.microsoft.com/fwlink/?LinkID=717458"
81+
82+
$datetime = Get-Date
83+
$datetime = $datetime.ToUniversalTime()
84+
$cacheRetired = $datetime -gt "2016-12-01 00:00:00Z"
85+
86+
#Test warning
87+
Get-AzureManagedCacheLocation -WarningVariable warning
88+
89+
if($cacheRetired)
90+
{
91+
Assert-AreEqual $warningAfterRetirement $warning
92+
}
93+
else
94+
{
95+
Assert-AreEqual $warningBeforeRetirement $warning
96+
}
97+
}
98+
7199
########################## Managed Cache (Named cache) Scenario Tests #############################
72100
<#
73101
.SYNOPSIS

src/ServiceManagement/ManagedCache/Commands.ManagedCache/PSCacheClient.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,14 @@ public CloudServiceResource SetNamedCache(string cacheServiceName, string namedC
284284
return cacheResource;
285285
}
286286

287+
public string GetManagedCacheRetirementMessage()
288+
{
289+
var managedCacheRetirementDate = new DateTime(2016, 12, 01, 00, 00, 00, DateTimeKind.Utc);
290+
return DateTime.UtcNow > managedCacheRetirementDate
291+
? "The Azure Managed Cache Service has been retired as of 11/30/2016. Please migrate to the Azure Redis Cache Service. For more information, see http://go.microsoft.com/fwlink/?LinkID=717458"
292+
: "The Azure Managed Cache Service will be retired on 11/30/2016. Please migrate to the Azure Redis Cache Service. For more information, see http://go.microsoft.com/fwlink/?LinkID=717458";
293+
}
294+
287295
public void RemoveNamedCache(string cacheServiceName, string namedCacheName, Action<bool, string, string, string, Action> ConfirmAction, bool force)
288296
{
289297
if ("default".Equals(namedCacheName))

src/ServiceManagement/ManagedCache/Commands.ManagedCache/Service/GetAzureManagedCache.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class GetAzureManagedCache : ManagedCacheCmdletBase
2828

2929
public override void ExecuteCmdlet()
3030
{
31-
WriteWarning("Managed Cache will be retired on 11/30/2016. Please migrate to Azure Redis Cache. For more information, see http://go.microsoft.com/fwlink/?LinkID=717458");
31+
WriteWarning(CacheClient.GetManagedCacheRetirementMessage());
3232

3333
List<PSCacheService> cacheServices = CacheClient.GetCacheServices(Name);
3434
if (!string.IsNullOrEmpty(Name) && cacheServices.Count == 0)

src/ServiceManagement/ManagedCache/Commands.ManagedCache/Service/GetAzureManagedCacheAccessKey.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class GetAzureManagedCacheAccessKey : ManagedCacheCmdletBase
2727

2828
public override void ExecuteCmdlet()
2929
{
30-
WriteWarning("Managed Cache will be retired on 11/30/2016. Please migrate to Azure Redis Cache. For more information, see http://go.microsoft.com/fwlink/?LinkID=717458");
30+
WriteWarning(CacheClient.GetManagedCacheRetirementMessage());
3131

3232
CachingKeysResponse response = CacheClient.GetAccessKeys(Name);
3333
WriteObject(new CacheAccessKeys(Name, response));

src/ServiceManagement/ManagedCache/Commands.ManagedCache/Service/GetAzureManagedCacheLocation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class AzureManagedCacheLocation : ManagedCacheCmdletBase
2424
{
2525
public override void ExecuteCmdlet()
2626
{
27-
WriteWarning("Managed Cache will be retired on 11/30/2016. Please migrate to Azure Redis Cache. For more information, see http://go.microsoft.com/fwlink/?LinkID=717458");
27+
WriteWarning(CacheClient.GetManagedCacheRetirementMessage());
2828

2929
List<Microsoft.Azure.Management.ManagedCache.Models.RegionsResponse.Region> locations = CacheClient.GetLocations();
3030
WriteObject(locations);

src/ServiceManagement/ManagedCache/Commands.ManagedCache/Service/GetAzureManagedCacheNamedCache.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class GetAzureManagedCacheNamedCache : ManagedCacheCmdletBase
3030

3131
public override void ExecuteCmdlet()
3232
{
33-
WriteWarning("Managed Cache will be retired on 11/30/2016. Please migrate to Azure Redis Cache. For more information, see http://go.microsoft.com/fwlink/?LinkID=717458");
33+
WriteWarning(CacheClient.GetManagedCacheRetirementMessage());
3434

3535
string cacheServiceName = CacheClient.NormalizeCacheServiceName(Name);
3636
CacheClient.ProgressRecorder = (p) => { WriteVerbose(p); };

src/ServiceManagement/ManagedCache/Commands.ManagedCache/Service/NewAzureManagedCache.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class NewAzureManagedCache : ManagedCacheCmdletBase, IDynamicParameters
3737

3838
public override void ExecuteCmdlet()
3939
{
40-
WriteWarning("Managed Cache will be retired on 11/30/2016. Please migrate to Azure Redis Cache. For more information, see http://go.microsoft.com/fwlink/?LinkID=717458");
40+
WriteWarning(CacheClient.GetManagedCacheRetirementMessage());
4141

4242
cacheServiceName = CacheClient.NormalizeCacheServiceName(Name);
4343

src/ServiceManagement/ManagedCache/Commands.ManagedCache/Service/NewAzureManagedCacheAccessKey.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class NewAzureManagedCacheAccessKey : ManagedCacheCmdletBase
3434

3535
public override void ExecuteCmdlet()
3636
{
37-
WriteWarning("Managed Cache will be retired on 11/30/2016. Please migrate to Azure Redis Cache. For more information, see http://go.microsoft.com/fwlink/?LinkID=717458");
37+
WriteWarning(CacheClient.GetManagedCacheRetirementMessage());
3838

3939
if (string.IsNullOrEmpty(KeyType))
4040
{

src/ServiceManagement/ManagedCache/Commands.ManagedCache/Service/NewAzureManagedCacheNamedCache.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class NewAzureManagedCacheNamedCache : ManagedCacheCmdletBase
5050

5151
public override void ExecuteCmdlet()
5252
{
53-
WriteWarning("Managed Cache will be retired on 11/30/2016. Please migrate to Azure Redis Cache. For more information, see http://go.microsoft.com/fwlink/?LinkID=717458");
53+
WriteWarning(CacheClient.GetManagedCacheRetirementMessage());
5454

5555
if (string.IsNullOrEmpty(ExpiryPolicy))
5656
{

src/ServiceManagement/ManagedCache/Commands.ManagedCache/Service/RemoveAzureManagedCache.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class RemoveAzureManagedCache : ManagedCacheCmdletBase
3131

3232
public override void ExecuteCmdlet()
3333
{
34-
WriteWarning("Managed Cache will be retired on 11/30/2016. Please migrate to Azure Redis Cache. For more information, see http://go.microsoft.com/fwlink/?LinkID=717458");
34+
WriteWarning(CacheClient.GetManagedCacheRetirementMessage());
3535

3636
ConfirmAction(
3737
Force.IsPresent,

src/ServiceManagement/ManagedCache/Commands.ManagedCache/Service/RemoveAzureManagedCacheNamedCache.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class RemoveAzureManagedCacheNamedCache : ManagedCacheCmdletBase
3737

3838
public override void ExecuteCmdlet()
3939
{
40-
WriteWarning("Managed Cache will be retired on 11/30/2016. Please migrate to Azure Redis Cache. For more information, see http://go.microsoft.com/fwlink/?LinkID=717458");
40+
WriteWarning(CacheClient.GetManagedCacheRetirementMessage());
4141

4242
string cacheServiceName = CacheClient.NormalizeCacheServiceName(Name);
4343
CacheClient.ProgressRecorder = (p) => { WriteVerbose(p); };

src/ServiceManagement/ManagedCache/Commands.ManagedCache/Service/SetAzureManagedCache.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class SetAzureManagedCache : ManagedCacheCmdletBase, IDynamicParameters
3838

3939
public override void ExecuteCmdlet()
4040
{
41-
WriteWarning("Managed Cache will be retired on 11/30/2016. Please migrate to Azure Redis Cache. For more information, see http://go.microsoft.com/fwlink/?LinkID=717458");
41+
WriteWarning(CacheClient.GetManagedCacheRetirementMessage());
4242

4343
CacheClient.ProgressRecorder = (message) => { WriteVerbose(message); };
4444
string memory = memoryDynamicParameterSet.GetMemoryValue(Sku);

src/ServiceManagement/ManagedCache/Commands.ManagedCache/Service/SetAzureManagedCacheNamedCache.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class SetAzureManagedCacheNamedCache : ManagedCacheCmdletBase
5353

5454
public override void ExecuteCmdlet()
5555
{
56-
WriteWarning("Managed Cache will be retired on 11/30/2016. Please migrate to Azure Redis Cache. For more information, see http://go.microsoft.com/fwlink/?LinkID=717458");
56+
WriteWarning(CacheClient.GetManagedCacheRetirementMessage());
5757

5858
if (string.IsNullOrEmpty(ExpiryPolicy))
5959
{

0 commit comments

Comments
 (0)