Skip to content

Commit 22275e5

Browse files
author
rhamlett_microsoft
committed
More, you guessed it, load test fixes
1 parent 9fa6879 commit 22275e5

1 file changed

Lines changed: 26 additions & 29 deletions

File tree

src/PerfProblemSimulator/Controllers/LoadTestController.cs

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -138,22 +138,20 @@ public LoadTestController(
138138
*
139139
* ALTERNATIVE: GET with query parameters
140140
* GET /api/loadtest?workIterations=1000&bufferSizeKb=100
141-
* Simpler but less flexible for complex parameters.
142141
*
143142
* URL PATTERN:
144143
* The [controller] token is replaced with "loadtest" (class name minus "Controller")
145-
* Full URL: POST https://your-app.azurewebsites.net/api/loadtest
144+
* Full URL: GET https://your-app.azurewebsites.net/api/loadtest
146145
*/
147146

148147
/// <summary>
149-
/// Executes a load test probe request that performs lightweight work.
148+
/// Executes a load test request with configurable resource consumption.
150149
/// </summary>
151-
/// <param name="bodyRequest">Load test parameters as JSON body (optional).</param>
152-
/// <param name="workIterations">CPU work ms per cycle (workIterations/100). Query param fallback.</param>
153-
/// <param name="bufferSizeKb">Memory buffer size in KB. Query param fallback.</param>
154-
/// <param name="baselineDelayMs">Minimum request duration in ms. Query param fallback.</param>
155-
/// <param name="softLimit">Concurrent requests before degradation. Query param fallback.</param>
156-
/// <param name="degradationFactor">Additional delay ms per request over limit. Query param fallback.</param>
150+
/// <param name="workIterations">CPU work intensity (ms of spin per cycle = workIterations / 100). Default: 1000.</param>
151+
/// <param name="bufferSizeKb">Memory buffer held for request duration in KB. Default: 100.</param>
152+
/// <param name="baselineDelayMs">Minimum request duration in ms. Default: 500.</param>
153+
/// <param name="softLimit">Concurrent requests before degradation begins. Default: 5.</param>
154+
/// <param name="degradationFactor">Additional delay (ms) per request over soft limit. Default: 200.</param>
157155
/// <param name="cancellationToken">Cancellation token from the HTTP request pipeline.</param>
158156
/// <returns>Load test result with timing and diagnostic information.</returns>
159157
/// <remarks>
@@ -213,39 +211,38 @@ public LoadTestController(
213211
/// </remarks>
214212
/// <response code="200">Load test completed successfully with timing details.</response>
215213
/// <response code="500">Request exceeded 120s and random exception was triggered.</response>
216-
[HttpPost]
217-
[Consumes("application/json", "text/plain", "application/x-www-form-urlencoded")]
214+
[HttpGet]
218215
[ProducesResponseType(typeof(LoadTestResult), StatusCodes.Status200OK)]
219216
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status500InternalServerError)]
220217
public async Task<IActionResult> ExecuteLoadTest(
221-
[FromBody] LoadTestRequest? bodyRequest = null,
222-
[FromQuery] int? workIterations = null,
223-
[FromQuery] int? bufferSizeKb = null,
224-
[FromQuery] int? baselineDelayMs = null,
225-
[FromQuery] int? softLimit = null,
226-
[FromQuery] int? degradationFactor = null,
218+
[FromQuery] int workIterations = 1000,
219+
[FromQuery] int bufferSizeKb = 100,
220+
[FromQuery] int baselineDelayMs = 500,
221+
[FromQuery] int softLimit = 5,
222+
[FromQuery] int degradationFactor = 200,
227223
CancellationToken cancellationToken = default)
228224
{
229225
/*
230226
* =====================================================================
231-
* FLEXIBLE ENDPOINT - JSON BODY OR QUERY PARAMETERS
227+
* QUERY PARAMETER ENDPOINT
232228
* =====================================================================
233229
*
234-
* Accepts either:
235-
* 1. POST with JSON body (Content-Type: application/json)
236-
* 2. GET/POST with query parameters (no Content-Type required)
230+
* GET /api/loadtest?workIterations=5000&bufferSizeKb=1000&baselineDelayMs=500
237231
*
238-
* JSON body takes precedence if provided.
232+
* Simple to use from:
233+
* - Browser: just paste URL
234+
* - curl: curl "http://localhost/api/loadtest?workIterations=5000"
235+
* - Azure Load Testing: set URL directly
236+
* - JMeter: HTTP Request sampler
239237
*/
240238

241-
// Use body if provided, otherwise build from query params with defaults
242-
var request = bodyRequest ?? new LoadTestRequest
239+
var request = new LoadTestRequest
243240
{
244-
WorkIterations = workIterations ?? 1000,
245-
BufferSizeKb = bufferSizeKb ?? 100,
246-
BaselineDelayMs = baselineDelayMs ?? 500,
247-
SoftLimit = softLimit ?? 5,
248-
DegradationFactor = degradationFactor ?? 200
241+
WorkIterations = workIterations,
242+
BufferSizeKb = bufferSizeKb,
243+
BaselineDelayMs = baselineDelayMs,
244+
SoftLimit = softLimit,
245+
DegradationFactor = degradationFactor
249246
};
250247

251248
_logger.LogDebug(

0 commit comments

Comments
 (0)