#pragma warning disable RECS0154 // Parameter is never used /// <summary> /// Converts the SqlPool model into Azure API parameters /// </summary> /// <param name="model"></param> /// <returns></returns> protected ElasticPoolCreateOrUpdateParameters CreateOptions(SqlPool model) #pragma warning restore RECS0154 // Parameter is never used { var props = new ElasticPoolCreateOrUpdateProperties { Edition = "Basic", Dtu = 200, DatabaseDtuMin = 0, DatabaseDtuMax = 5, }; return(new ElasticPoolCreateOrUpdateParameters { Location = Region.Location, Properties = props }); }
public void ElasticPoolCrud() { var handler = new BasicDelegatingHandler(); using (UndoContext context = UndoContext.Current) { context.Start(); string resPoolName = TestUtilities.GenerateName("csm-sql-respoolcrud"); string resPool2Name = TestUtilities.GenerateName("csm-sql-respoolcrud"); Sql2ScenarioHelper.RunServerTestInEnvironment( handler, "12.0", (sqlClient, resGroupName, server) => { ////////////////////////////////////////////////////////////////////// // Create Elastic Pool Test with all values specified (Default values) var pool1Properties = new ElasticPoolCreateOrUpdateProperties() { Edition = "Standard", Dtu = 200, DatabaseDtuMax = 100, DatabaseDtuMin = 10, StorageMB = 204800 }; var pool1 = sqlClient.ElasticPools.CreateOrUpdate(resGroupName, server.Name, resPoolName, new ElasticPoolCreateOrUpdateParameters() { Location = server.Location, Properties = pool1Properties }); TestUtilities.ValidateOperationResponse(pool1, HttpStatusCode.Created); ValidateElasticPool( pool1.ElasticPool, resPoolName, pool1Properties.Edition, pool1Properties.DatabaseDtuMax, pool1Properties.DatabaseDtuMin, pool1Properties.Dtu, pool1Properties.StorageMB); var pool2Properties = new ElasticPoolCreateOrUpdateProperties() { Edition = "Standard", }; var pool2 = sqlClient.ElasticPools.CreateOrUpdate(resGroupName, server.Name, resPool2Name, new ElasticPoolCreateOrUpdateParameters() { Location = server.Location, Properties = pool2Properties }); TestUtilities.ValidateOperationResponse(pool2, HttpStatusCode.Created); ValidateElasticPool( pool2.ElasticPool, resPool2Name, pool1Properties.Edition, 100, 0, 200, 204800); ////////////////////////////////////////////////////////////////////// // Update Elastic Pool Test pool1Properties.Dtu = 200; pool1Properties.DatabaseDtuMax = 50; pool1Properties.DatabaseDtuMin = 0; var pool3 = sqlClient.ElasticPools.CreateOrUpdate(resGroupName, server.Name, resPoolName, new ElasticPoolCreateOrUpdateParameters() { Location = server.Location, Properties = pool1Properties }); TestUtilities.ValidateOperationResponse(pool3, HttpStatusCode.OK); ValidateElasticPool( pool3.ElasticPool, resPoolName, pool1Properties.Edition, pool1Properties.DatabaseDtuMax, pool1Properties.DatabaseDtuMin, pool1Properties.Dtu, pool1Properties.StorageMB); ////////////////////////////////////////////////////////////////////// // Get Elastic Pool Test. var pool4 = sqlClient.ElasticPools.Get(resGroupName, server.Name, resPoolName); TestUtilities.ValidateOperationResponse(pool4, HttpStatusCode.OK); ValidateElasticPool( pool4.ElasticPool, resPoolName, pool3.ElasticPool.Properties.Edition, pool3.ElasticPool.Properties.DatabaseDtuMax, pool3.ElasticPool.Properties.DatabaseDtuMin, pool3.ElasticPool.Properties.Dtu, pool3.ElasticPool.Properties.StorageMB); ////////////////////////////////////////////////////////////////////// // Get Elastic Pool Test. var pools = sqlClient.ElasticPools.List(resGroupName, server.Name); TestUtilities.ValidateOperationResponse(pools, HttpStatusCode.OK); Assert.Equal(2, pools.ElasticPools.Count); ////////////////////////////////////////////////////////////////////// // Get Elastic Pool Activity Test. var activity = sqlClient.ElasticPools.ListActivity(resGroupName, server.Name, resPoolName); TestUtilities.ValidateOperationResponse(activity, HttpStatusCode.OK); Assert.True(activity.ElasticPoolActivities.Count > 0); ////////////////////////////////////////////////////////////////////// // Delete Elastic Pool Test. var resp = sqlClient.ElasticPools.Delete(resGroupName, server.Name, pool1.ElasticPool.Name); TestUtilities.ValidateOperationResponse(resp, HttpStatusCode.OK); resp = sqlClient.ElasticPools.Delete(resGroupName, server.Name, pool2.ElasticPool.Name); TestUtilities.ValidateOperationResponse(resp, HttpStatusCode.OK); }); } }
public void ElasticPoolDatabaseOperations() { var handler = new BasicDelegatingHandler(); using (UndoContext context = UndoContext.Current) { context.Start(); string resPoolName = TestUtilities.GenerateName("csm-sql-respoolcrud"); Sql2ScenarioHelper.RunServerTestInEnvironment( handler, "12.0", (sqlClient, resGroupName, server) => { ////////////////////////////////////////////////////////////////////// // Create Elastic Pool Test with all values specified (Default values) var pool1Properties = new ElasticPoolCreateOrUpdateProperties() { Edition = "Standard", Dtu = 200, DatabaseDtuMax = 100, DatabaseDtuMin = 10, StorageMB = 204800 }; var pool1 = sqlClient.ElasticPools.CreateOrUpdate(resGroupName, server.Name, resPoolName, new ElasticPoolCreateOrUpdateParameters() { Location = server.Location, Properties = pool1Properties }); TestUtilities.ValidateOperationResponse(pool1, HttpStatusCode.Created); //////////////////////////////////////////////////////////////////// // Create database in Elastic Pool var databaseName = TestUtilities.GenerateName("csm-sql-respoolcrud"); var db1 = sqlClient.Databases.CreateOrUpdate(resGroupName, server.Name, databaseName, new DatabaseCreateOrUpdateParameters() { Location = server.Location, Properties = new DatabaseCreateOrUpdateProperties() { ElasticPoolName = pool1.ElasticPool.Name, } }); TestUtilities.ValidateOperationResponse(db1, HttpStatusCode.Created); ////////////////////////////////////////////////////////////////////// // Move database into Elastic Pool var database2Name = TestUtilities.GenerateName("csm-sql-respoolcrud"); var db2 = sqlClient.Databases.CreateOrUpdate(resGroupName, server.Name, database2Name, new DatabaseCreateOrUpdateParameters() { Location = server.Location, Properties = new DatabaseCreateOrUpdateProperties() { Edition = "Basic" } }); TestUtilities.ValidateOperationResponse(db2, HttpStatusCode.Created); var moveResult = sqlClient.Databases.CreateOrUpdate(resGroupName, server.Name, database2Name, new DatabaseCreateOrUpdateParameters() { Location = server.Location, Properties = new DatabaseCreateOrUpdateProperties() { ElasticPoolName = pool1.ElasticPool.Name, } }); TestUtilities.ValidateOperationResponse(moveResult, HttpStatusCode.OK); ////////////////////////////////////////////////////////////////////// // Get database acitivity var activity = sqlClient.ElasticPools.ListDatabaseActivity(resGroupName, server.Name, resPoolName); TestUtilities.ValidateOperationResponse(moveResult, HttpStatusCode.OK); Assert.True(activity.ElasticPoolDatabaseActivities.Count > 0); }); } }