/// <summary> /// Downscale timer elapsed method /// </summary> /// <param name="sender">The timer object</param> /// <param name="e">Elapsed event arguments</param> /// <param name="totalClients">Total number of clients connected to the signaling server</param> /// <param name="servers">The list of servers </param> private async void DownscaleElapsedMethod(object sender, ElapsedEventArgs e, int totalClients, List <ConnectedServer> servers) { var deletePoolId = string.Empty; if (this.batchService.GetAutoscalingStatus(totalClients, servers, out deletePoolId) == AutoscalingStatus.DownscaleRenderingPool) { var controller = new Cloud3DSTKController { Request = new HttpRequestMessage() }; controller.Request.Properties.Add( HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration()); // Create a json body with the pool id to be deleted var json = new DeletePoolApiJsonBody { PoolId = deletePoolId }; // Scale down and remove pool var result = await controller.DeletePool((JObject)JToken.FromObject(json)); } this.downscaleTimer.Stop(); }
public async Task DeletePoolReturnsInvalidRequestWhenPoolIdIsMissing() { var controller = ControllerExtensions.NewCloudController(); // Create a json body with no pool id var jsonBody = new DeletePoolApiJsonBody { }; var result = await controller.DeletePool((JObject)JToken.FromObject(jsonBody)); Assert.IsInstanceOfType(result, typeof(HttpResponseMessage)); Assert.IsTrue(((ObjectContent)(result as HttpResponseMessage).Content).Value.ToString().Equals(ApiResultMessages.ErrorPoolIdRequired)); }
public async Task FunctionalDeletePoolIdTest() { var batchService = new BatchService(ConfigurationHelper.GetConfiguration()); var controller = ControllerExtensions.NewCloudController(); // Create a json body with a specific pool id var jsonBody = new DeletePoolApiJsonBody { PoolId = "TEST_RENDERING" }; var result = await controller.DeletePool((JObject)JToken.FromObject(jsonBody)); Assert.IsInstanceOfType(result, typeof(HttpResponseMessage)); Assert.IsTrue(result.IsSuccessStatusCode); var pool = batchService.GetPoolsInBatch(); Assert.IsTrue(pool?.FirstOrDefault(p => p.Id == jsonBody.PoolId).State == Microsoft.Azure.Batch.Common.PoolState.Deleting); }