Skip to content

Commit 116d337

Browse files
committed
updates to failed requests sim
1 parent 14cbe8a commit 116d337

4 files changed

Lines changed: 22 additions & 25 deletions

File tree

src/PerfProblemSimulator/Services/FailedRequestService.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,14 +297,21 @@ private async Task SendFailedRequest(CancellationToken cancellationToken)
297297
client.BaseAddress = new Uri(_baseUrl!);
298298
client.Timeout = TimeSpan.FromSeconds(30);
299299

300-
var jsonContent = JsonSerializer.Serialize(FailureRequestBody);
301-
using var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
300+
// Build query string for GET request (LoadTestController uses [HttpGet] with [FromQuery] params)
301+
// Values match the FailureRequestBody constants above
302+
var queryParams = "?baselineDelayMs=1500" +
303+
"&workIterations=500" +
304+
"&bufferSizeKb=100" +
305+
"&softLimit=10000" +
306+
"&degradationFactor=0" +
307+
"&errorAfter=1" +
308+
"&errorPercent=100";
302309

303310
_logger.LogDebug(
304311
"Sending failed request {RequestId} to {Url}",
305-
requestId, $"{_baseUrl}/api/loadtest");
312+
requestId, $"{_baseUrl}/api/loadtest{queryParams}");
306313

307-
var response = await client.PostAsync("/api/loadtest", content, cancellationToken);
314+
var response = await client.GetAsync($"/api/loadtest{queryParams}", cancellationToken);
308315

309316
stopwatch.Stop();
310317

src/PerfProblemSimulator/wwwroot/css/dashboard.css

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -720,26 +720,26 @@ body {
720720

721721
/* Failed Request Simulator Styles (HTTP 5xx generation) */
722722
.btn-failedrequest {
723-
background: linear-gradient(135deg, #ff1493 0%, #c71585 100%);
723+
background: linear-gradient(135deg, #8B4513 0%, #6b3410 100%);
724724
color: white;
725-
border: 2px solid #ff69b4;
725+
border: 2px solid #a0522d;
726726
animation: pulse-fail 2.5s infinite;
727727
flex: 1;
728728
}
729729

730730
.btn-failedrequest:hover:not(:disabled) {
731-
background: linear-gradient(135deg, #ff69b4 0%, #ff1493 100%);
732-
border-color: #ff85c1;
731+
background: linear-gradient(135deg, #a0522d 0%, #8B4513 100%);
732+
border-color: #cd853f;
733733
}
734734

735735
@keyframes pulse-fail {
736-
0%, 100% { box-shadow: 0 0 5px rgba(255, 20, 147, 0.3); }
737-
50% { box-shadow: 0 0 12px rgba(255, 20, 147, 0.5); }
736+
0%, 100% { box-shadow: 0 0 5px rgba(139, 69, 19, 0.3); }
737+
50% { box-shadow: 0 0 12px rgba(139, 69, 19, 0.5); }
738738
}
739739

740740
.failedrequest-group {
741-
border: 2px solid #ff1493;
742-
background: rgba(255, 20, 147, 0.05);
741+
border: 2px solid #8B4513;
742+
background: rgba(139, 69, 19, 0.05);
743743
}
744744

745745
.slowrequest-status.active {
@@ -903,7 +903,7 @@ body {
903903
.log-entry.memory { color: var(--color-memory); }
904904
.log-entry.threads { color: var(--color-threads); }
905905
.log-entry.slowrequest { color: #b8860b; } /* Dark goldenrod for slow requests */
906-
.log-entry.failedrequests { color: #ff1493; } /* Hot pink for failed requests */
906+
.log-entry.failedrequests { color: #8B4513; } /* Medium brown for failed requests */
907907
.log-entry.crash { color: var(--color-danger); }
908908
.log-entry.loadtest { color: var(--color-primary); } /* .NET theme: blue */
909909
.log-entry.system { color: var(--color-text-muted); }

src/PerfProblemSimulator/wwwroot/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ <h3>❌ Failed Requests <span class="control-tooltip" data-tooltip="Generates HT
163163
</div>
164164
<div class="btn-group">
165165
<button class="btn btn-trigger btn-failedrequest" id="btnStartFailedRequests">❌ Generate Failures</button>
166-
<button class="btn btn-stop" id="btnStopFailedRequests">⬛ Stop</button>
167166
</div>
168167
</div>
169168

src/PerfProblemSimulator/wwwroot/js/dashboard.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,13 +1224,11 @@ async function startFailedRequests() {
12241224
const requestCount = parseInt(document.getElementById('failedRequestCount').value) || 10;
12251225

12261226
const startBtn = document.getElementById('btnStartFailedRequests');
1227-
const stopBtn = document.getElementById('btnStopFailedRequests');
12281227

12291228
try {
12301229
logEvent('failedrequests', `Generating ${requestCount} HTTP 500 errors...`);
12311230

12321231
startBtn.disabled = true;
1233-
stopBtn.disabled = false;
12341232

12351233
const response = await fetch(`${CONFIG.apiBaseUrl}/failedrequest/start`, {
12361234
method: 'POST',
@@ -1251,21 +1249,20 @@ async function startFailedRequests() {
12511249
const error = await response.json();
12521250
logEvent('failedrequests', `Failed to start: ${error.message || error.title || 'Unknown error'}`);
12531251
startBtn.disabled = false;
1254-
stopBtn.disabled = true;
12551252
}
12561253
} catch (err) {
12571254
logEvent('failedrequests', `Request failed: ${err.message}`);
12581255
startBtn.disabled = false;
1259-
stopBtn.disabled = true;
12601256
}
12611257
}
12621258

12631259
/**
12641260
* Stops the failed request simulator.
1261+
* Note: Stop button removed from UI - requests complete too quickly to intervene.
1262+
* This function retained for API compatibility.
12651263
*/
12661264
async function stopFailedRequests() {
12671265
const startBtn = document.getElementById('btnStartFailedRequests');
1268-
const stopBtn = document.getElementById('btnStopFailedRequests');
12691266

12701267
try {
12711268
logEvent('failedrequests', 'Stopping failed request simulator...');
@@ -1286,7 +1283,6 @@ async function stopFailedRequests() {
12861283
logEvent('failedrequests', `Request failed: ${err.message}`);
12871284
} finally {
12881285
startBtn.disabled = false;
1289-
stopBtn.disabled = true;
12901286
}
12911287
}
12921288

@@ -1295,7 +1291,6 @@ async function stopFailedRequests() {
12951291
*/
12961292
async function pollFailedRequestStatus() {
12971293
const startBtn = document.getElementById('btnStartFailedRequests');
1298-
const stopBtn = document.getElementById('btnStopFailedRequests');
12991294

13001295
try {
13011296
const response = await fetch(`${CONFIG.apiBaseUrl}/failedrequest/status`);
@@ -1308,7 +1303,6 @@ async function pollFailedRequestStatus() {
13081303
} else {
13091304
// Simulation ended
13101305
startBtn.disabled = false;
1311-
stopBtn.disabled = true;
13121306
removeSimulationsByType('failedrequest');
13131307

13141308
if (status.requestsCompleted > 0) {
@@ -1319,7 +1313,6 @@ async function pollFailedRequestStatus() {
13191313
} catch (err) {
13201314
// Connection lost - probably a restart
13211315
startBtn.disabled = false;
1322-
stopBtn.disabled = true;
13231316
}
13241317
}
13251318

@@ -1659,11 +1652,9 @@ document.addEventListener('DOMContentLoaded', async () => {
16591652
document.getElementById('btnStartSlowRequests').addEventListener('click', startSlowRequests);
16601653
document.getElementById('btnStopSlowRequests').addEventListener('click', stopSlowRequests);
16611654
document.getElementById('btnStartFailedRequests').addEventListener('click', startFailedRequests);
1662-
document.getElementById('btnStopFailedRequests').addEventListener('click', stopFailedRequests);
16631655

16641656
// Initialize slow request Stop button as disabled
16651657
document.getElementById('btnStopSlowRequests').disabled = true;
1666-
document.getElementById('btnStopFailedRequests').disabled = true;
16671658

16681659
// Wire up side panel toggle
16691660
initializeSidePanel();

0 commit comments

Comments
 (0)