public void ListWithoutResourceGroupTest() { TestUtilities.StartTest(); var _client = RedisCacheManagementTestUtilities.GetRedisManagementClient(this); RedisListResponse listResponse = _client.Redis.List(null); Assert.NotNull(listResponse.RequestId); Assert.True(listResponse.Value.Count >= 1); bool found = false; foreach (RedisResource response in listResponse.Value) { if (response.Id.Contains(fixture.RedisCacheName)) { found = true; Assert.Contains(fixture.RedisCacheName, response.Id); Assert.Equal(fixture.RedisCacheName, response.Name); Assert.True("succeeded".Equals(response.Properties.ProvisioningState, StringComparison.InvariantCultureIgnoreCase)); Assert.Equal(SkuName.Basic, response.Properties.Sku.Name); Assert.Equal(SkuFamily.C, response.Properties.Sku.Family); Assert.Equal(0, response.Properties.Sku.Capacity); Assert.Contains(fixture.RedisCacheName, response.Properties.HostName); Assert.Equal(6379, response.Properties.Port); Assert.Equal(6380, response.Properties.SslPort); } } Assert.True(found, "Cache created by fixture is not found."); TestUtilities.EndTest(); }
public void ListWithoutResourceGroupTest() { using (var context = MockContext.Start(this.GetType())) { var _client = RedisCacheManagementTestUtilities.GetRedisManagementClient(this, context); IPage <RedisResource> listResponse = _client.Redis.ListBySubscription(); Assert.True(listResponse.Count() >= 1); bool found = false; foreach (RedisResource response in listResponse) { if (response.Id.Contains(fixture.RedisCacheName)) { found = true; Assert.Contains(fixture.RedisCacheName, response.Id); Assert.Equal(fixture.RedisCacheName, response.Name); Assert.Equal(ProvisioningState.Succeeded, response.ProvisioningState, ignoreCase: true); Assert.Equal(SkuName.Basic, response.Sku.Name); Assert.Equal(SkuFamily.C, response.Sku.Family); Assert.Equal(0, response.Sku.Capacity); Assert.Contains(fixture.RedisCacheName, response.HostName); Assert.Equal(6379, response.Port); Assert.Equal(6380, response.SslPort); } } Assert.True(found, "Cache created by fixture is not found."); } }
public void TryCreatingCache(string resourceGroupName, string cacheName, string location) { var redisClient = RedisCacheManagementTestUtilities.GetRedisManagementClient(_testBase, _context); var createResponse = redisClient.Redis.Create(resourceGroupName: resourceGroupName, name: cacheName, parameters: new RedisCreateParameters { Location = location, Sku = new Microsoft.Azure.Management.Redis.Models.Sku() { Name = SkuName.Basic, Family = SkuFamily.C, Capacity = 0 } }); RedisResource response = redisClient.Redis.Get(resourceGroupName: resourceGroupName, name: cacheName); ThrowIfTrue(!response.Id.Contains(cacheName), "Cache name not found inside Id."); ThrowIfTrue(!response.Name.Equals(cacheName), string.Format("Cache name is not equal to {0}", cacheName)); ThrowIfTrue(!response.HostName.Contains(cacheName), "Cache name not found inside host name."); // wait for maximum 30 minutes for cache to create for (int i = 0; i < 60; i++) { TestUtilities.Wait(new TimeSpan(0, 0, 30)); RedisResource responseGet = redisClient.Redis.Get(resourceGroupName: resourceGroupName, name: cacheName); if ("succeeded".Equals(responseGet.ProvisioningState, StringComparison.OrdinalIgnoreCase)) { break; } ThrowIfTrue(i == 60, "Cache is not in succeeded state even after 30 min."); } }
public void BeginCreateFunctionalTest() { using (var context = MockContext.Start(this.GetType())) { var _redisCacheManagementHelper = new RedisCacheManagementHelper(this, context); _redisCacheManagementHelper.TryRegisterSubscriptionForResource(); var resourceGroupName = TestUtilities.GenerateName("RedisBegin"); var redisCacheName = TestUtilities.GenerateName("RedisBegin"); var _client = RedisCacheManagementTestUtilities.GetRedisManagementClient(this, context); _redisCacheManagementHelper.TryCreateResourceGroup(resourceGroupName, RedisCacheManagementHelper.Location); RedisResource response = _client.Redis.BeginCreate(resourceGroupName, redisCacheName, parameters: new RedisCreateParameters { Location = RedisCacheManagementHelper.Location, Sku = new Sku() { Name = SkuName.Premium, Family = SkuFamily.P, Capacity = 1 }, MinimumTlsVersion = TlsVersion.OneFullStopTwo, ReplicasPerMaster = 2, RedisVersion = "6", }); Assert.Contains(redisCacheName, response.Id); Assert.Equal(redisCacheName, response.Name); Assert.Equal(ProvisioningState.Creating, response.ProvisioningState, ignoreCase: true); Assert.Equal(SkuName.Premium, response.Sku.Name); Assert.Equal(SkuFamily.P, response.Sku.Family); Assert.Equal(TlsVersion.OneFullStopTwo, response.MinimumTlsVersion); Assert.Equal(2, response.ReplicasPerMaster); Assert.Equal("6", response.RedisVersion.Split(".")[0]); Assert.Equal(3, response.Instances.Count); for (int i = 0; i < response.Instances.Count; i++) { Assert.Equal(15000 + i, response.Instances[i].SslPort); Assert.Null(response.Instances[i].NonSslPort); Assert.Null(response.Instances[i].ShardId); Assert.Null(response.Instances[i].Zone); } for (int i = 0; i < 60; i++) { response = _client.Redis.Get(resourceGroupName, redisCacheName); if (ProvisioningState.Succeeded.Equals(response.ProvisioningState, StringComparison.OrdinalIgnoreCase)) { break; } TestUtilities.Wait(new TimeSpan(0, 0, 30)); } _client.Redis.Delete(resourceGroupName: resourceGroupName, name: redisCacheName); _redisCacheManagementHelper.DeleteResourceGroup(resourceGroupName); } }
public void ListKeysTest() { using (var context = MockContext.Start(this.GetType())) { var _client = RedisCacheManagementTestUtilities.GetRedisManagementClient(this, context); var response = _client.Redis.ListKeys(resourceGroupName: fixture.ResourceGroupName, name: fixture.RedisCacheName); Assert.NotNull(response.PrimaryKey); Assert.NotNull(response.SecondaryKey); } }
public void ListKeysTest() { TestUtilities.StartTest(); var _client = RedisCacheManagementTestUtilities.GetRedisManagementClient(this); RedisListKeysResponse response = _client.Redis.ListKeys(resourceGroupName: fixture.ResourceGroupName, name: fixture.RedisCacheName); Assert.NotNull(response.PrimaryKey); Assert.NotNull(response.SecondaryKey); TestUtilities.EndTest(); }
public void RegenerateKeyTest() { using (var context = MockContext.Start(this.GetType())) { var _client = RedisCacheManagementTestUtilities.GetRedisManagementClient(this, context); var beforeRegenerateResponse = _client.Redis.ListKeys(resourceGroupName: fixture.ResourceGroupName, name: fixture.RedisCacheName); var afterRegenerateResponse = _client.Redis.RegenerateKey(resourceGroupName: fixture.ResourceGroupName, name: fixture.RedisCacheName, parameters: new RedisRegenerateKeyParameters() { KeyType = RedisKeyType.Primary }); Assert.NotEqual(beforeRegenerateResponse.PrimaryKey, afterRegenerateResponse.PrimaryKey); Assert.Equal(beforeRegenerateResponse.SecondaryKey, afterRegenerateResponse.SecondaryKey); } }
public void BeginCreateFunctionalTest() { using (var context = MockContext.Start(this.GetType().FullName)) { var _redisCacheManagementHelper = new RedisCacheManagementHelper(this, context); _redisCacheManagementHelper.TryRegisterSubscriptionForResource(); var resourceGroupName = TestUtilities.GenerateName("RedisBegin"); var redisCacheName = TestUtilities.GenerateName("RedisBegin"); var _client = RedisCacheManagementTestUtilities.GetRedisManagementClient(this, context); _redisCacheManagementHelper.TryCreateResourceGroup(resourceGroupName, RedisCacheManagementHelper.Location); RedisResource response = _client.Redis.BeginCreate(resourceGroupName, redisCacheName, parameters: new RedisCreateParameters { Location = RedisCacheManagementHelper.Location, Sku = new Sku() { Name = SkuName.Premium, Family = SkuFamily.P, Capacity = 1 } }); Assert.Contains(redisCacheName, response.Id); Assert.Equal(redisCacheName, response.Name); Assert.Equal("creating", response.ProvisioningState, ignoreCase: true); Assert.Equal(SkuName.Premium, response.Sku.Name); Assert.Equal(SkuFamily.P, response.Sku.Family); for (int i = 0; i < 60; i++) { response = _client.Redis.Get(resourceGroupName, redisCacheName); if ("succeeded".Equals(response.ProvisioningState, StringComparison.OrdinalIgnoreCase)) { break; } TestUtilities.Wait(new TimeSpan(0, 0, 30)); } _client.Redis.Delete(resourceGroupName: resourceGroupName, name: redisCacheName); _redisCacheManagementHelper.DeleteResourceGroup(resourceGroupName); } }
public void GetTest() { using (var context = MockContext.Start(this.GetType())) { var _client = RedisCacheManagementTestUtilities.GetRedisManagementClient(this, context); RedisResource response = _client.Redis.Get(resourceGroupName: fixture.ResourceGroupName, name: fixture.RedisCacheName); Assert.Contains(fixture.RedisCacheName, response.Id); Assert.Equal(fixture.RedisCacheName, response.Name); Assert.Equal(ProvisioningState.Succeeded, response.ProvisioningState, ignoreCase: true); Assert.Equal(SkuName.Basic, response.Sku.Name); Assert.Equal(SkuFamily.C, response.Sku.Family); Assert.Equal(0, response.Sku.Capacity); Assert.Contains(fixture.RedisCacheName, response.HostName); Assert.Equal(6379, response.Port); Assert.Equal(6380, response.SslPort); } }
public void GetTest() { TestUtilities.StartTest(); var _client = RedisCacheManagementTestUtilities.GetRedisManagementClient(this); RedisGetResponse response = _client.Redis.Get(resourceGroupName: fixture.ResourceGroupName, name: fixture.RedisCacheName); Assert.NotNull(response.RequestId); Assert.Contains(fixture.RedisCacheName, response.Resource.Id); Assert.Equal(fixture.RedisCacheName, response.Resource.Name); Assert.True("succeeded".Equals(response.Resource.Properties.ProvisioningState, StringComparison.InvariantCultureIgnoreCase)); Assert.Equal(SkuName.Basic, response.Resource.Properties.Sku.Name); Assert.Equal(SkuFamily.C, response.Resource.Properties.Sku.Family); Assert.Equal(0, response.Resource.Properties.Sku.Capacity); Assert.Contains(fixture.RedisCacheName, response.Resource.Properties.HostName); Assert.Equal(6379, response.Resource.Properties.Port); Assert.Equal(6380, response.Resource.Properties.SslPort); TestUtilities.EndTest(); }
public void RegenerateKeyTest() { TestUtilities.StartTest(); var _client = RedisCacheManagementTestUtilities.GetRedisManagementClient(this); RedisListKeysResponse beforeRegenerateResponse = _client.Redis.ListKeys(resourceGroupName: fixture.ResourceGroupName, name: fixture.RedisCacheName); AzureOperationResponse response = _client.Redis.RegenerateKey(resourceGroupName: fixture.ResourceGroupName, name: fixture.RedisCacheName, parameters: new RedisRegenerateKeyParameters() { KeyType = RedisKeyType.Primary }); Assert.NotNull(response.RequestId); RedisListKeysResponse afterRegenerateResponse = _client.Redis.ListKeys(resourceGroupName: fixture.ResourceGroupName, name: fixture.RedisCacheName); Assert.NotEqual(beforeRegenerateResponse.PrimaryKey, afterRegenerateResponse.PrimaryKey); Assert.Equal(beforeRegenerateResponse.SecondaryKey, afterRegenerateResponse.SecondaryKey); TestUtilities.EndTest(); }
public void RebootBothNodesTest() { using (var context = MockContext.Start(this.GetType().FullName)) { var _client = RedisCacheManagementTestUtilities.GetRedisManagementClient(this, context); // First try to get cache and verify that it is premium cache RedisResource response = _client.Redis.Get(resourceGroupName: "MyResourceGroup", name: "sunnyprimary"); Assert.Contains("sunnyprimary", response.Id); Assert.Equal("sunnyprimary", response.Name); Assert.True("succeeded".Equals(response.ProvisioningState, StringComparison.OrdinalIgnoreCase)); Assert.Equal(SkuName.Premium, response.Sku.Name); Assert.Equal(SkuFamily.P, response.Sku.Family); RedisRebootParameters rebootParameter = new RedisRebootParameters { RebootType = RebootType.AllNodes }; _client.Redis.ForceReboot(resourceGroupName: "MyResourceGroup", name: "sunnyprimary", parameters: rebootParameter); } }
public void RebootBothNodesTest() { using (var context = MockContext.Start(this.GetType().FullName)) { var _redisCacheManagementHelper = new RedisCacheManagementHelper(this, context); _redisCacheManagementHelper.TryRegisterSubscriptionForResource(); var resourceGroupName = TestUtilities.GenerateName("RedisReboot"); var redisCacheName = TestUtilities.GenerateName("RedisReboot"); var _client = RedisCacheManagementTestUtilities.GetRedisManagementClient(this, context); _redisCacheManagementHelper.TryCreateResourceGroup(resourceGroupName, RedisCacheManagementHelper.Location); _client.Redis.Create(resourceGroupName, redisCacheName, parameters: new RedisCreateParameters { Location = RedisCacheManagementHelper.Location, Sku = new Sku() { Name = SkuName.Premium, Family = SkuFamily.P, Capacity = 1 } }); // First try to get cache and verify that it is premium cache RedisResource response = _client.Redis.Get(resourceGroupName, redisCacheName); Assert.Contains(redisCacheName, response.Id); Assert.Equal(redisCacheName, response.Name); Assert.Equal("succeeded", response.ProvisioningState, ignoreCase: true); Assert.Equal(SkuName.Premium, response.Sku.Name); Assert.Equal(SkuFamily.P, response.Sku.Family); RedisRebootParameters rebootParameter = new RedisRebootParameters { RebootType = RebootType.AllNodes }; _client.Redis.ForceReboot(resourceGroupName, redisCacheName, parameters: rebootParameter); } }
public void PatchSchedules_PutGetDelete() { using (var context = MockContext.Start(this.GetType().FullName)) { var _client = RedisCacheManagementTestUtilities.GetRedisManagementClient(this, context); // First try to get cache and verify that it is premium cache RedisResource response = _client.Redis.Get(resourceGroupName: "sunnyjapan", name: "sunny-scheduling-dv2"); Assert.Contains("sunny-scheduling-dv2", response.Id); Assert.Equal("sunny-scheduling-dv2", response.Name); Assert.True("succeeded".Equals(response.ProvisioningState, StringComparison.OrdinalIgnoreCase)); Assert.Equal(SkuName.Premium, response.Sku.Name); Assert.Equal(SkuFamily.P, response.Sku.Family); ScheduleEntry[] entries = new ScheduleEntry[] { new ScheduleEntry { DayOfWeek = DayOfWeekEnum.Monday, StartHourUtc = 10, MaintenanceWindow = TimeSpan.FromHours(10) }, new ScheduleEntry { DayOfWeek = DayOfWeekEnum.Tuesday, StartHourUtc = 11, MaintenanceWindow = TimeSpan.FromHours(11) } }; ValidateResponseForSchedulePatch(_client.PatchSchedules.CreateOrUpdate(resourceGroupName: "sunnyjapan", name: "sunny-scheduling-dv2", parameters: new RedisPatchSchedulesRequest(entries))); ValidateResponseForSchedulePatch(_client.PatchSchedules.Get(resourceGroupName: "sunnyjapan", name: "sunny-scheduling-dv2")); _client.PatchSchedules.Delete(resourceGroupName: "sunnyjapan", name: "sunny-scheduling-dv2"); var ex = Assert.Throws <CloudException>(() => _client.PatchSchedules.Get(resourceGroupName: "sunnyjapan", name: "sunny-scheduling-dv2")); Assert.Contains("There are no patch schedules found for redis cache 'sunny-scheduling-dv2'", ex.Message); Assert.Equal(HttpStatusCode.NotFound, ex.Response.StatusCode); } }
public void UpdateEnableNonSslPortBugTest() { TestUtilities.StartTest(); var _client = RedisCacheManagementTestUtilities.GetRedisManagementClient(this); RedisGetResponse responseGet = _client.Redis.Get(resourceGroupName: "SunnySDK25", name: "sunnysdk25-centralus"); Assert.True(responseGet.Resource.Properties.EnableNonSslPort.Value); Dictionary <string, string> redisConfiguration = new Dictionary <string, string>(); redisConfiguration.Add("maxmemory-policy", "allkeys-lru"); RedisCreateOrUpdateResponse responseCreate = _client.Redis.CreateOrUpdate(resourceGroupName: "SunnySDK25", name: "sunnysdk25-centralus", parameters: new RedisCreateOrUpdateParameters { Location = "Central US", Properties = new RedisProperties { RedisVersion = "2.8", Sku = new Sku() { Name = SkuName.Standard, Family = SkuFamily.C, Capacity = 2 }, RedisConfiguration = redisConfiguration } }); Assert.Equal(6379, responseCreate.Resource.Properties.Port); Assert.Equal(6380, responseCreate.Resource.Properties.SslPort); Assert.True(responseCreate.Resource.Properties.EnableNonSslPort.Value); TestUtilities.EndTest(); }
public void CreateUpdateDeleteTest() { TestUtilities.StartTest(); var _client = RedisCacheManagementTestUtilities.GetRedisManagementClient(this); RedisCreateOrUpdateResponse responseCreate = _client.Redis.CreateOrUpdate(resourceGroupName: fixture.ResourceGroupName, name: fixture.RedisCacheName, parameters: new RedisCreateOrUpdateParameters { Location = fixture.Location, Properties = new RedisProperties { RedisVersion = "2.8", Sku = new Sku() { Name = SkuName.Basic, Family = SkuFamily.C, Capacity = 0 } } }); Assert.NotNull(responseCreate.RequestId); Assert.Contains(fixture.RedisCacheName, responseCreate.Resource.Id); Assert.Equal(fixture.Location, responseCreate.Resource.Location); Assert.Equal(fixture.RedisCacheName, responseCreate.Resource.Name); Assert.Equal("Microsoft.Cache/Redis", responseCreate.Resource.Type); Assert.True("creating".Equals(responseCreate.Resource.Properties.ProvisioningState, StringComparison.InvariantCultureIgnoreCase)); Assert.Equal(SkuName.Basic, responseCreate.Resource.Properties.Sku.Name); Assert.Equal(SkuFamily.C, responseCreate.Resource.Properties.Sku.Family); Assert.Equal(0, responseCreate.Resource.Properties.Sku.Capacity); Assert.Contains("2.8", responseCreate.Resource.Properties.RedisVersion); Assert.Contains(fixture.RedisCacheName, responseCreate.Resource.Properties.HostName); Assert.Equal(6379, responseCreate.Resource.Properties.Port); Assert.Equal(6380, responseCreate.Resource.Properties.SslPort); Assert.False(responseCreate.Resource.Properties.EnableNonSslPort); // wait for maximum 30 minutes for cache to create for (int i = 0; i < 60; i++) { TestUtilities.Wait(new TimeSpan(0, 0, 30)); RedisGetResponse responseGet = _client.Redis.Get(resourceGroupName: fixture.ResourceGroupName, name: fixture.RedisCacheName); if ("succeeded".Equals(responseGet.Resource.Properties.ProvisioningState, StringComparison.InvariantCultureIgnoreCase)) { break; } Assert.False(i == 60, "Cache is not in succeeded state even after 30 min."); } RedisCreateOrUpdateResponse responseUpdate = _client.Redis.CreateOrUpdate(resourceGroupName: fixture.ResourceGroupName, name: fixture.RedisCacheName, parameters: new RedisCreateOrUpdateParameters { Location = fixture.Location, Properties = new RedisProperties { RedisVersion = "2.8", Sku = new Sku() { Name = SkuName.Basic, Family = SkuFamily.C, Capacity = 0 }, RedisConfiguration = new Dictionary <string, string>() { { "maxmemory-policy", "allkeys-lru" } }, EnableNonSslPort = true } }); Assert.NotNull(responseUpdate.RequestId); Assert.Contains(fixture.RedisCacheName, responseUpdate.Resource.Id); Assert.Equal(fixture.Location, responseUpdate.Resource.Location); Assert.Equal(fixture.RedisCacheName, responseUpdate.Resource.Name); Assert.Equal("Microsoft.Cache/Redis", responseUpdate.Resource.Type); Assert.Equal(SkuName.Basic, responseUpdate.Resource.Properties.Sku.Name); Assert.Equal(SkuFamily.C, responseUpdate.Resource.Properties.Sku.Family); Assert.Equal(0, responseUpdate.Resource.Properties.Sku.Capacity); Assert.Contains("2.8", responseUpdate.Resource.Properties.RedisVersion); Assert.Equal("allkeys-lru", responseUpdate.Resource.Properties.RedisConfiguration["maxmemory-policy"]); Assert.Contains(fixture.RedisCacheName, responseUpdate.Resource.Properties.HostName); Assert.Equal(6379, responseUpdate.Resource.Properties.Port); Assert.Equal(6380, responseUpdate.Resource.Properties.SslPort); Assert.True(responseUpdate.Resource.Properties.EnableNonSslPort); AzureOperationResponse responseDelete = _client.Redis.Delete(resourceGroupName: fixture.ResourceGroupName, name: fixture.RedisCacheName); List <HttpStatusCode> acceptedStatusCodes = new List <HttpStatusCode>(); acceptedStatusCodes.Add(HttpStatusCode.OK); acceptedStatusCodes.Add(HttpStatusCode.Accepted); acceptedStatusCodes.Add(HttpStatusCode.NotFound); Assert.Contains <HttpStatusCode>(responseDelete.StatusCode, acceptedStatusCodes); Assert.NotNull(responseDelete.RequestId); TestUtilities.EndTest(); }
public void PatchSchedules_PutGetDelete() { using (var context = MockContext.Start(this.GetType().FullName)) { var _redisCacheManagementHelper = new RedisCacheManagementHelper(this, context); _redisCacheManagementHelper.TryRegisterSubscriptionForResource(); var resourceGroupName = TestUtilities.GenerateName("RedisSchedules"); var redisCacheName = TestUtilities.GenerateName("RedisSchedules"); var _client = RedisCacheManagementTestUtilities.GetRedisManagementClient(this, context); _redisCacheManagementHelper.TryCreateResourceGroup(resourceGroupName, RedisCacheManagementHelper.Location); _client.Redis.Create(resourceGroupName, redisCacheName, parameters: new RedisCreateParameters { Location = RedisCacheManagementHelper.Location, Sku = new Sku() { Name = SkuName.Premium, Family = SkuFamily.P, Capacity = 1 } }); // First try to get cache and verify that it is premium cache RedisResource response = _client.Redis.Get(resourceGroupName, redisCacheName); Assert.Contains(redisCacheName, response.Id); Assert.Equal(redisCacheName, response.Name); Assert.Equal("succeeded", response.ProvisioningState, ignoreCase: true); Assert.Equal(SkuName.Premium, response.Sku.Name); Assert.Equal(SkuFamily.P, response.Sku.Family); ScheduleEntry[] entries = new ScheduleEntry[] { new ScheduleEntry { DayOfWeek = DayOfWeekEnum.Monday, StartHourUtc = 10, MaintenanceWindow = TimeSpan.FromHours(10) }, new ScheduleEntry { DayOfWeek = DayOfWeekEnum.Tuesday, StartHourUtc = 11, MaintenanceWindow = TimeSpan.FromHours(11) } }; ValidateResponseForSchedulePatch( _client.PatchSchedules.CreateOrUpdate( resourceGroupName, redisCacheName, parameters: new RedisPatchSchedule(entries)), redisCacheName); ValidateResponseForSchedulePatch( _client.PatchSchedules.Get(resourceGroupName, redisCacheName), redisCacheName); _client.PatchSchedules.Delete(resourceGroupName, redisCacheName); var ex = Assert.Throws <CloudException>(() => _client.PatchSchedules.Get(resourceGroupName, redisCacheName)); Assert.Contains("There are no patch schedules found for redis cache", ex.Message); } }
public void CreateUpdateDeleteTest() { using (var context = MockContext.Start(this.GetType().FullName)) { var _client = RedisCacheManagementTestUtilities.GetRedisManagementClient(this, context); RedisResourceWithAccessKey responseCreate = _client.Redis.CreateOrUpdate(resourceGroupName: fixture.ResourceGroupName, name: fixture.RedisCacheName, parameters: new RedisCreateOrUpdateParameters { Location = fixture.Location, Sku = new Sku() { Name = SkuName.Basic, Family = SkuFamily.C, Capacity = 0 } }); Assert.Contains(fixture.RedisCacheName, responseCreate.Id); Assert.Equal(fixture.Location, responseCreate.Location); Assert.Equal(fixture.RedisCacheName, responseCreate.Name); Assert.Equal("Microsoft.Cache/Redis", responseCreate.Type); Assert.True("creating".Equals(responseCreate.ProvisioningState, StringComparison.OrdinalIgnoreCase)); Assert.Equal(SkuName.Basic, responseCreate.Sku.Name); Assert.Equal(SkuFamily.C, responseCreate.Sku.Family); Assert.Equal(0, responseCreate.Sku.Capacity); Assert.Contains(fixture.RedisCacheName, responseCreate.HostName); Assert.Equal(6379, responseCreate.Port); Assert.Equal(6380, responseCreate.SslPort); Assert.False(responseCreate.EnableNonSslPort); // wait for maximum 30 minutes for cache to create for (int i = 0; i < 60; i++) { TestUtilities.Wait(new TimeSpan(0, 0, 30)); RedisResource responseGet = _client.Redis.Get(resourceGroupName: fixture.ResourceGroupName, name: fixture.RedisCacheName); if ("succeeded".Equals(responseGet.ProvisioningState, StringComparison.OrdinalIgnoreCase)) { break; } Assert.False(i == 60, "Cache is not in succeeded state even after 30 min."); } RedisResourceWithAccessKey responseUpdate = _client.Redis.CreateOrUpdate(resourceGroupName: fixture.ResourceGroupName, name: fixture.RedisCacheName, parameters: new RedisCreateOrUpdateParameters { Location = fixture.Location, Sku = new Sku() { Name = SkuName.Basic, Family = SkuFamily.C, Capacity = 0 }, RedisConfiguration = new Dictionary <string, string>() { { "maxmemory-policy", "allkeys-lru" } }, EnableNonSslPort = true }); Assert.Contains(fixture.RedisCacheName, responseUpdate.Id); Assert.Equal(fixture.Location, responseUpdate.Location); Assert.Equal(fixture.RedisCacheName, responseUpdate.Name); Assert.Equal("Microsoft.Cache/Redis", responseUpdate.Type); Assert.Equal(SkuName.Basic, responseUpdate.Sku.Name); Assert.Equal(SkuFamily.C, responseUpdate.Sku.Family); Assert.Equal(0, responseUpdate.Sku.Capacity); Assert.Equal("allkeys-lru", responseUpdate.RedisConfiguration["maxmemory-policy"]); Assert.Contains(fixture.RedisCacheName, responseUpdate.HostName); Assert.Equal(6379, responseUpdate.Port); Assert.Equal(6380, responseUpdate.SslPort); Assert.True(responseUpdate.EnableNonSslPort); _client.Redis.Delete(resourceGroupName: fixture.ResourceGroupName, name: fixture.RedisCacheName); } }
public void CreateUpdateDeleteTest() { using (var context = MockContext.Start(this.GetType())) { var _client = RedisCacheManagementTestUtilities.GetRedisManagementClient(this, context); _client.Redis.CheckNameAvailability( parameters: new CheckNameAvailabilityParameters { Name = fixture.RedisCacheName, Type = "Microsoft.Cache/Redis" }); var responseCreate = _client.Redis.Create(resourceGroupName: fixture.ResourceGroupName, name: fixture.RedisCacheName, parameters: new RedisCreateParameters { Location = RedisCacheManagementHelper.Location, Sku = new Sku() { Name = SkuName.Basic, Family = SkuFamily.C, Capacity = 0 } }); Assert.Contains(fixture.RedisCacheName, responseCreate.Id); Assert.Equal(RedisCacheManagementHelper.Location, responseCreate.Location); Assert.Equal(fixture.RedisCacheName, responseCreate.Name); Assert.Equal("Microsoft.Cache/Redis", responseCreate.Type); Assert.Equal("succeeded", responseCreate.ProvisioningState, ignoreCase: true); Assert.Equal(SkuName.Basic, responseCreate.Sku.Name); Assert.Equal(SkuFamily.C, responseCreate.Sku.Family); Assert.Equal(0, responseCreate.Sku.Capacity); Assert.Contains(fixture.RedisCacheName, responseCreate.HostName); Assert.Equal(6379, responseCreate.Port); Assert.Equal(6380, responseCreate.SslPort); Assert.False(responseCreate.EnableNonSslPort); var responseUpdate = _client.Redis.Update(resourceGroupName: fixture.ResourceGroupName, name: fixture.RedisCacheName, parameters: new RedisUpdateParameters { Sku = new Sku() { Name = SkuName.Basic, Family = SkuFamily.C, Capacity = 0 }, RedisConfiguration = new RedisCommonPropertiesRedisConfiguration() { MaxmemoryPolicy = "allkeys-lru" }, EnableNonSslPort = true }); Assert.Contains(fixture.RedisCacheName, responseUpdate.Id); Assert.Equal(RedisCacheManagementHelper.Location, responseUpdate.Location); Assert.Equal(fixture.RedisCacheName, responseUpdate.Name); Assert.Equal("Microsoft.Cache/Redis", responseUpdate.Type); Assert.Equal(SkuName.Basic, responseUpdate.Sku.Name); Assert.Equal(SkuFamily.C, responseUpdate.Sku.Family); Assert.Equal(0, responseUpdate.Sku.Capacity); Assert.Equal("allkeys-lru", responseUpdate.RedisConfiguration.MaxmemoryPolicy); Assert.Contains(fixture.RedisCacheName, responseUpdate.HostName); Assert.Equal(6379, responseUpdate.Port); Assert.Equal(6380, responseUpdate.SslPort); Assert.True(responseUpdate.EnableNonSslPort); _client.Redis.Delete(resourceGroupName: fixture.ResourceGroupName, name: fixture.RedisCacheName); } }
public void CreateUpdateDeleteClusterCacheTest() { TestUtilities.StartTest(); var _client = RedisCacheManagementTestUtilities.GetRedisManagementClient(this); RedisCreateOrUpdateResponse responseCreate = _client.Redis.CreateOrUpdate(resourceGroupName: fixture.ResourceGroupName, name: fixture.RedisClusterCacheName, parameters: new RedisCreateOrUpdateParameters { Location = fixture.ClusterCacheLocation, Properties = new RedisProperties { RedisVersion = "3.0", Sku = new Sku() { Name = SkuName.Premium, Family = SkuFamily.P, Capacity = 1 }, ShardCount = 2, TenantSettings = new Dictionary <string, string>() { { "some-key", "some-value" } } } }); Assert.Contains(fixture.RedisClusterCacheName, responseCreate.Resource.Id); Assert.Equal(fixture.ClusterCacheLocation, responseCreate.Resource.Location); Assert.Equal(fixture.RedisClusterCacheName, responseCreate.Resource.Name); Assert.True("creating".Equals(responseCreate.Resource.Properties.ProvisioningState, StringComparison.InvariantCultureIgnoreCase)); Assert.Equal(SkuName.Premium, responseCreate.Resource.Properties.Sku.Name); Assert.Equal(SkuFamily.P, responseCreate.Resource.Properties.Sku.Family); Assert.Equal(1, responseCreate.Resource.Properties.Sku.Capacity); Assert.Contains(fixture.RedisClusterCacheName, responseCreate.Resource.Properties.HostName); Assert.Equal(6379, responseCreate.Resource.Properties.Port); Assert.Equal(6380, responseCreate.Resource.Properties.SslPort); Assert.False(responseCreate.Resource.Properties.EnableNonSslPort.Value); Assert.Equal(2, responseCreate.Resource.Properties.ShardCount.Value); Assert.Equal("some-value", responseCreate.Resource.Properties.TenantSettings["some-key"]); // wait for maximum 30 minutes for cache to create for (int i = 0; i < 60; i++) { TestUtilities.Wait(new TimeSpan(0, 0, 30)); RedisGetResponse responseGet = _client.Redis.Get(resourceGroupName: fixture.ResourceGroupName, name: fixture.RedisClusterCacheName); if ("succeeded".Equals(responseGet.Resource.Properties.ProvisioningState, StringComparison.InvariantCultureIgnoreCase)) { break; } Assert.False(i == 60, "Cache is not in succeeded state even after 30 min."); } RedisCreateOrUpdateResponse responseUpdate = _client.Redis.CreateOrUpdate(resourceGroupName: fixture.ResourceGroupName, name: fixture.RedisClusterCacheName, parameters: new RedisCreateOrUpdateParameters { Location = fixture.ClusterCacheLocation, Properties = new RedisProperties { Sku = new Sku() { Name = SkuName.Premium, Family = SkuFamily.P, Capacity = 1 }, TenantSettings = new Dictionary <string, string>() { { "some-key-1", "some-value-1" } } } }); Assert.Equal("some-value-1", responseUpdate.Resource.Properties.TenantSettings["some-key-1"]); AzureOperationResponse responseDelete = _client.Redis.Delete(resourceGroupName: fixture.ResourceGroupName, name: fixture.RedisClusterCacheName); List <HttpStatusCode> acceptedStatusCodes = new List <HttpStatusCode>(); acceptedStatusCodes.Add(HttpStatusCode.OK); acceptedStatusCodes.Add(HttpStatusCode.Accepted); acceptedStatusCodes.Add(HttpStatusCode.NotFound); Assert.Contains <HttpStatusCode>(responseDelete.StatusCode, acceptedStatusCodes); Assert.NotNull(responseDelete.RequestId); TestUtilities.EndTest(); }
public void ManagedIdentityCreateUpdateFunctionalTest() { using (var context = MockContext.Start(this.GetType())) { var _redisCacheManagementHelper = new RedisCacheManagementHelper(this, context); _redisCacheManagementHelper.TryRegisterSubscriptionForResource(); var resourceGroupName = TestUtilities.GenerateName("RedisBegin"); var redisCacheName = TestUtilities.GenerateName("RedisBegin"); var _client = RedisCacheManagementTestUtilities.GetRedisManagementClient(this, context); RedisResource response; _redisCacheManagementHelper.TryCreateResourceGroup(resourceGroupName, RedisCacheManagementHelper.Location); response = _client.Redis.BeginCreate(resourceGroupName, redisCacheName, parameters: new RedisCreateParameters { Location = RedisCacheManagementHelper.Location, Sku = new Sku() { Name = SkuName.Premium, Family = SkuFamily.P, Capacity = 1 }, Identity = new ManagedServiceIdentity(type: ManagedServiceIdentityType.SystemAssignedUserAssigned , userAssignedIdentities: new Dictionary <String, UserAssignedIdentity> { { "/subscriptions/0ee2a145-4d40-44f4-b764-67b40274f1ac/resourceGroups/prn-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test", new UserAssignedIdentity() }, } ) }); Assert.Contains(redisCacheName, response.Id); Assert.Equal(redisCacheName, response.Name); Assert.Equal(ProvisioningState.Creating, response.ProvisioningState, ignoreCase: true); Assert.Equal(SkuName.Premium, response.Sku.Name); Assert.Equal(SkuFamily.P, response.Sku.Family); Assert.Equal(ManagedServiceIdentityType.SystemAssignedUserAssigned, response.Identity.Type); Assert.NotNull(response.Identity.PrincipalId); Assert.NotEmpty(response.Identity.UserAssignedIdentities); for (int i = 0; i < 60; i++) { response = _client.Redis.Get(resourceGroupName, redisCacheName); if (ProvisioningState.Succeeded.Equals(response.ProvisioningState, StringComparison.OrdinalIgnoreCase)) { break; } TestUtilities.Wait(new TimeSpan(0, 0, 30)); } response = _client.Redis.Update(resourceGroupName, redisCacheName, parameters: new RedisUpdateParameters { Identity = new ManagedServiceIdentity(type: ManagedServiceIdentityType.SystemAssigned ) }); Assert.Equal(ManagedServiceIdentityType.SystemAssigned, response.Identity.Type); Assert.NotNull(response.Identity.PrincipalId); Assert.Null(response.Identity.UserAssignedIdentities); if (Utility.IsLiveTest()) { Thread.Sleep(60000); } response = _client.Redis.Update(resourceGroupName, redisCacheName, parameters: new RedisUpdateParameters { Identity = new ManagedServiceIdentity(type: ManagedServiceIdentityType.UserAssigned , userAssignedIdentities: new Dictionary <String, UserAssignedIdentity> { { "/subscriptions/0ee2a145-4d40-44f4-b764-67b40274f1ac/resourceGroups/prn-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test", new UserAssignedIdentity() }, } ) }); Assert.Equal(ManagedServiceIdentityType.UserAssigned, response.Identity.Type); Assert.NotEmpty(response.Identity.UserAssignedIdentities); Assert.Null(response.Identity.PrincipalId); if (Utility.IsLiveTest()) { Thread.Sleep(60000); } response = _client.Redis.Update(resourceGroupName, redisCacheName, parameters: new RedisUpdateParameters { Identity = new ManagedServiceIdentity(type: ManagedServiceIdentityType.None ) }); Assert.Null(response.Identity); _client.Redis.Delete(resourceGroupName: resourceGroupName, name: redisCacheName); _redisCacheManagementHelper.DeleteResourceGroup(resourceGroupName); } }
public void GeoReplicationFunctionalTest() { using (var context = MockContext.Start(this.GetType())) { var resourceGroupName = TestUtilities.GenerateName("RedisGeo"); var redisCacheName1 = TestUtilities.GenerateName("RedisGeo1"); var redisCacheName2 = TestUtilities.GenerateName("RedisGeo2"); var _redisCacheManagementHelper = new RedisCacheManagementHelper(this, context); _redisCacheManagementHelper.TryRegisterSubscriptionForResource(); _redisCacheManagementHelper.TryCreateResourceGroup(resourceGroupName, RedisCacheManagementHelper.Location); var _client = RedisCacheManagementTestUtilities.GetRedisManagementClient(this, context); // Create cache in ncus RedisResource ncResponse = _client.Redis.BeginCreate(resourceGroupName, redisCacheName1, parameters: new RedisCreateParameters { Location = RedisCacheManagementHelper.Location, Sku = new Sku() { Name = SkuName.Premium, Family = SkuFamily.P, Capacity = 1 } }); Assert.Contains(redisCacheName1, ncResponse.Id); Assert.Equal(redisCacheName1, ncResponse.Name); Assert.Equal("creating", ncResponse.ProvisioningState, ignoreCase: true); Assert.Equal(SkuName.Premium, ncResponse.Sku.Name); Assert.Equal(SkuFamily.P, ncResponse.Sku.Family); // Create cache in scus RedisResource scResponse = _client.Redis.BeginCreate(resourceGroupName, redisCacheName2, parameters: new RedisCreateParameters { Location = RedisCacheManagementHelper.SecondaryLocation, Sku = new Sku() { Name = SkuName.Premium, Family = SkuFamily.P, Capacity = 1 } }); Assert.Contains(redisCacheName2, scResponse.Id); Assert.Equal(redisCacheName2, scResponse.Name); Assert.Equal("creating", scResponse.ProvisioningState, ignoreCase: true); Assert.Equal(SkuName.Premium, scResponse.Sku.Name); Assert.Equal(SkuFamily.P, scResponse.Sku.Family); // Wait for both cache creation to comeplete for (int i = 0; i < 120; i++) { ncResponse = _client.Redis.Get(resourceGroupName, redisCacheName1); scResponse = _client.Redis.Get(resourceGroupName, redisCacheName2); if ("succeeded".Equals(ncResponse.ProvisioningState, StringComparison.OrdinalIgnoreCase) && "succeeded".Equals(scResponse.ProvisioningState, StringComparison.OrdinalIgnoreCase)) { break; } TestUtilities.Wait(new TimeSpan(0, 0, 30)); } // Fail if any of 2 cache is not created successfully Assert.Equal("succeeded", ncResponse.ProvisioningState, ignoreCase: true); Assert.Equal("succeeded", scResponse.ProvisioningState, ignoreCase: true); // Set up replication link RedisLinkedServerWithProperties linkServerWithProperties = _client.LinkedServer.Create(resourceGroupName, redisCacheName1, redisCacheName2, new RedisLinkedServerCreateParameters { LinkedRedisCacheId = scResponse.Id, LinkedRedisCacheLocation = RedisCacheManagementHelper.SecondaryLocation, ServerRole = ReplicationRole.Secondary }); Assert.Equal(redisCacheName2, linkServerWithProperties.Name); Assert.Equal(scResponse.Id, linkServerWithProperties.LinkedRedisCacheId); Assert.Equal(RedisCacheManagementHelper.SecondaryLocation, linkServerWithProperties.LinkedRedisCacheLocation); Assert.Equal(ReplicationRole.Secondary, linkServerWithProperties.ServerRole); Assert.Equal("succeeded", linkServerWithProperties.ProvisioningState, ignoreCase: true); // test get response from primary RedisLinkedServerWithProperties primaryLinkProperties = _client.LinkedServer.Get(resourceGroupName, redisCacheName1, redisCacheName2); Assert.Equal(scResponse.Id, primaryLinkProperties.LinkedRedisCacheId); Assert.Equal(RedisCacheManagementHelper.SecondaryLocation, primaryLinkProperties.LinkedRedisCacheLocation); Assert.Equal(ReplicationRole.Secondary, primaryLinkProperties.ServerRole); // test list response from primary IPage <RedisLinkedServerWithProperties> allPrimaryLinkProperties = _client.LinkedServer.List(resourceGroupName, redisCacheName1); Assert.Single(allPrimaryLinkProperties); // test get response from secondary RedisLinkedServerWithProperties secondaryLinkProperties = _client.LinkedServer.Get(resourceGroupName, redisCacheName2, redisCacheName1); Assert.Equal(ncResponse.Id, secondaryLinkProperties.LinkedRedisCacheId); Assert.Equal(RedisCacheManagementHelper.Location, secondaryLinkProperties.LinkedRedisCacheLocation); Assert.Equal(ReplicationRole.Primary, secondaryLinkProperties.ServerRole); // test list response from secondary IPage <RedisLinkedServerWithProperties> allSecondaryLinkProperties = _client.LinkedServer.List(resourceGroupName, redisCacheName2); Assert.Single(allSecondaryLinkProperties); // Delete link on primary _client.LinkedServer.Delete(resourceGroupName, redisCacheName1, redisCacheName2); // links should disappear in 5 min IPage <RedisLinkedServerWithProperties> afterDeletePrimaryLinkProperties = null; IPage <RedisLinkedServerWithProperties> afterDeleteSecondaryLinkProperties = null; for (int i = 0; i < 10; i++) { TestUtilities.Wait(new TimeSpan(0, 0, 30)); afterDeletePrimaryLinkProperties = _client.LinkedServer.List(resourceGroupName, redisCacheName1); afterDeleteSecondaryLinkProperties = _client.LinkedServer.List(resourceGroupName, redisCacheName2); if (afterDeletePrimaryLinkProperties.Count() == 0 && afterDeleteSecondaryLinkProperties.Count() == 0) { break; } } Assert.NotNull(afterDeletePrimaryLinkProperties); Assert.Empty(afterDeletePrimaryLinkProperties); Assert.NotNull(afterDeleteSecondaryLinkProperties); Assert.Empty(afterDeleteSecondaryLinkProperties); // Clean up both caches and delete resource group _client.Redis.Delete(resourceGroupName: resourceGroupName, name: redisCacheName1); _client.Redis.Delete(resourceGroupName: resourceGroupName, name: redisCacheName2); _redisCacheManagementHelper.DeleteResourceGroup(resourceGroupName); } }
public void FirewallFunctionalTest() { using (var context = MockContext.Start(this.GetType())) { var _redisCacheManagementHelper = new RedisCacheManagementHelper(this, context); _redisCacheManagementHelper.TryRegisterSubscriptionForResource(); var resourceGroupName = TestUtilities.GenerateName("RedisFirewall"); var redisCacheName = TestUtilities.GenerateName("RedisFirewall"); var _client = RedisCacheManagementTestUtilities.GetRedisManagementClient(this, context); _redisCacheManagementHelper.TryCreateResourceGroup(resourceGroupName, RedisCacheManagementHelper.Location); _client.Redis.Create(resourceGroupName, redisCacheName, parameters: new RedisCreateParameters { Location = RedisCacheManagementHelper.Location, Sku = new Sku() { Name = SkuName.Premium, Family = SkuFamily.P, Capacity = 1 } }); // First try to get cache and verify that it is premium cache RedisResource response = _client.Redis.Get(resourceGroupName, redisCacheName); Assert.Contains(redisCacheName, response.Id); Assert.Equal(redisCacheName, response.Name); Assert.Equal(ProvisioningState.Succeeded, response.ProvisioningState, ignoreCase: true); Assert.Equal(SkuName.Premium, response.Sku.Name); Assert.Equal(SkuFamily.P, response.Sku.Family); // Set firewall rule for 10.0.0.0 to 10.0.0.32 RedisFirewallRule ruleOne = _client.FirewallRules.CreateOrUpdate(resourceGroupName, redisCacheName, "RuleOne", new RedisFirewallRuleCreateParameters { StartIP = "10.0.0.0", EndIP = "10.0.0.32" }); Assert.Equal("10.0.0.0", ruleOne.StartIP); Assert.Equal("10.0.0.32", ruleOne.EndIP); // Set firewall rule for 10.0.0.64 to 10.0.0.128 RedisFirewallRule ruleTwo = _client.FirewallRules.CreateOrUpdate(resourceGroupName, redisCacheName, "RuleTwo", new RedisFirewallRuleCreateParameters { StartIP = "10.0.0.64", EndIP = "10.0.0.128" }); Assert.Equal("10.0.0.64", ruleTwo.StartIP); Assert.Equal("10.0.0.128", ruleTwo.EndIP); // Get test ruleOne = _client.FirewallRules.Get(resourceGroupName, redisCacheName, "RuleOne"); Assert.Equal("10.0.0.0", ruleOne.StartIP); Assert.Equal("10.0.0.32", ruleOne.EndIP); ruleTwo = _client.FirewallRules.Get(resourceGroupName, redisCacheName, "RuleTwo"); Assert.Equal("10.0.0.64", ruleTwo.StartIP); Assert.Equal("10.0.0.128", ruleTwo.EndIP); // List test IPage <RedisFirewallRule> rules = _client.FirewallRules.List(resourceGroupName, redisCacheName); Assert.Equal(2, rules.Count()); // Delete _client.FirewallRules.Delete(resourceGroupName, redisCacheName, "RuleTwo"); if (Utility.IsLiveTest()) { Thread.Sleep(6000); } rules = _client.FirewallRules.List(resourceGroupName, redisCacheName); Assert.Single(rules); Assert.Equal("10.0.0.0", rules.First().StartIP); Assert.Equal("10.0.0.32", rules.First().EndIP); } }