/// <summary> /// Initializes a new instance of the AutoScaleRun class. /// </summary> /// <param name="timestamp">The time at which the autoscale formula was /// last evaluated.</param> /// <param name="results">The final values of all variables used in the /// evaluation of the autoscale formula.</param> /// <param name="error">Details of the error encountered evaluating the /// autoscale formula on the pool, if the evaluation was /// unsuccessful.</param> public AutoScaleRun(System.DateTime timestamp, string results = default(string), AutoScaleRunError error = default(AutoScaleRunError)) { Timestamp = timestamp; Results = results; Error = error; CustomInit(); }
public void GetPoolResizeError() { var autoScaleRunError = new Models.AutoScaleRunError { Code = "InsufficientSampleData", Message = "Autoscale evaluation failed due to insufficient sample data", Values = new List <Models.NameValuePair> { new Models.NameValuePair { Name = "Message", Value = "Line 1, Col 24: Insufficient data from data set: $RunningTasks wanted 100%, received 0%" } } }; var autoScaleError = new Models.AutoScaleRun { Error = autoScaleRunError }; BatchSharedKeyCredentials credentials = ClientUnitTestCommon.CreateDummySharedKeyCredential(); using (BatchClient client = BatchClient.Open(credentials)) { Protocol.RequestInterceptor interceptor = new Protocol.RequestInterceptor(baseRequest => { var request = (Protocol.BatchRequest <Models.PoolGetOptions, AzureOperationResponse <Models.CloudPool, Models.PoolGetHeaders> >)baseRequest; request.ServiceRequestFunc = async(token) => { var response = new AzureOperationResponse <Models.CloudPool, Models.PoolGetHeaders> { Body = new Models.CloudPool { DisplayName = "batch-test", AutoScaleFormula = "$RunningTasks.GetSample(10 * TimeInterval_Second, 0 * TimeInterval_Second, 100);", AutoScaleRun = autoScaleError, EnableAutoScale = true, } }; var task = Task.FromResult(response); return(await task); }; }); var pool = client.PoolOperations.GetPool("batch-test", additionalBehaviors: new List <BatchClientBehavior> { interceptor }); Assert.Equal("batch-test", pool.DisplayName); Assert.Equal(pool.AutoScaleEnabled, true); Assert.Equal(pool.AutoScaleRun.Error.Code, "InsufficientSampleData"); Assert.Equal(pool.AutoScaleRun.Error.Message, "Autoscale evaluation failed due to insufficient sample data"); Assert.Equal(pool.AutoScaleRun.Error.Values.First().Name, "Message"); Assert.Equal(pool.AutoScaleRun.Error.Values.First().Value, "Line 1, Col 24: Insufficient data from data set: $RunningTasks wanted 100%, received 0%"); } }
public void GetPoolResizeError() { var autoScaleRunError = new AutoScaleRunError { Code = "InsufficientSampleData", Message = "Autoscale evaluation failed due to insufficient sample data", Values = new List <NameValuePair> { new NameValuePair { Name = "Message", Value = "Line 1, Col 24: Insufficient data from data set: $RunningTasks wanted 100%, received 0%" } } }; var autoScaleError = new AutoScaleRun { Error = autoScaleRunError }; using (var client = FakeBatchClient.ConnectWithFakeCredentials(ClientUnitTestCommon.DummyBaseUrl)) { client.FakeProtocolLayer.GetPoolHandler = (skipToken, behaviors) => Task.FromResult( new AzureOperationResponse <ProxyModels.CloudPool, ProxyModels.PoolGetHeaders> { Body = new ProxyModels.CloudPool { DisplayName = "batch-test", AutoScaleFormula = "$RunningTasks.GetSample(10 * TimeInterval_Second, 0 * TimeInterval_Second, 100);", AutoScaleRun = autoScaleError, EnableAutoScale = true, } }); var pool = client.PoolOperations.GetPool("batch-test"); Assert.Equal("batch-test", pool.DisplayName); Assert.Equal(pool.AutoScaleEnabled, true); Assert.Equal(pool.AutoScaleRun.Error.Code, "InsufficientSampleData"); Assert.Equal(pool.AutoScaleRun.Error.Message, "Autoscale evaluation failed due to insufficient sample data"); Assert.Equal(pool.AutoScaleRun.Error.Values.First().Name, "Message"); Assert.Equal(pool.AutoScaleRun.Error.Values.First().Value, "Line 1, Col 24: Insufficient data from data set: $RunningTasks wanted 100%, received 0%"); } }
internal AutoScaleRunError(Models.AutoScaleRunError protocolObject) { this.code = protocolObject.Code; this.message = protocolObject.Message; this.values = NameValuePair.ConvertFromProtocolCollectionReadOnly(protocolObject.Values); }