Skip to content

Add workspace load testing#58

Merged
arktronic-sep merged 6 commits into
sep:mainfrom
arktronic:main
Jul 3, 2026
Merged

Add workspace load testing#58
arktronic-sep merged 6 commits into
sep:mainfrom
arktronic:main

Conversation

@arktronic

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a Development-only, Admin-protected Razor Page that seeds a “load test” workspace with many checks and synthetic historical check results to exercise dashboard/query performance in SAMA.

Changes:

  • Added /Dev/LoadTest Razor Page + handler to generate a new workspace with N checks.
  • Seeded synthetic CheckResult history across a configurable number of days for each generated check.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
SAMA.Web/Pages/Dev/LoadTest.cshtml.cs Implements the dev-only POST handler that creates the workspace, checks, and historical check results.
SAMA.Web/Pages/Dev/LoadTest.cshtml Adds a simple form UI to configure and trigger workspace load-test data creation.

Comment on lines +50 to +53
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier) ?? "system";
var workspaceName = string.IsNullOrWhiteSpace(Input.WorkspaceNamePrefix)
? $"LoadTest-{DateTimeOffset.UtcNow:yyyy-MM-dd}-{Guid.CreateVersion7():N}"
: $"{Input.WorkspaceNamePrefix}-{DateTimeOffset.UtcNow:yyyy-MM-dd}-{Guid.CreateVersion7():N}";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in arktronic@978a027 — capped WorkspaceNamePrefix to 100 - 12 - 32 = 56 chars (reserving room for the -yyyy-MM-dd- + 32-char GUID suffix) so the combined name can never exceed the DB's 100-char limit.

Comment thread SAMA.Web/Pages/Dev/LoadTest.cshtml.cs Outdated
Comment on lines +141 to +142
var lastStatus = "Up";
var lastResponseTime = random.Next(20, 500);

@atniptw atniptw Jul 1, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in arktronic@1ac985c — replaced the hard-coded "Up"/"Warn"/"Down" strings with CheckStatuses constants throughout.

Comment on lines +150 to +165
if (random.NextDouble() < 0.05)
{
status = "Down";
responseTime = random.Next(1000, 5000);
}
else if (random.NextDouble() < 0.1)
{
status = "Warn";
responseTime = random.Next(500, 2000);
}
else
{
status = "Up";
responseTime = random.Next(20, 500);
}

@atniptw atniptw Jul 1, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in arktronic@1ac985c — this line now uses CheckStatuses.Up.

Comment thread SAMA.Web/Pages/Dev/LoadTest.cshtml.cs Outdated
Comment on lines +166 to +170
if (status == "Down" && random.NextDouble() < 0.6)
{
status = "Warn";
responseTime = random.Next(500, 1500);
}

@atniptw atniptw Jul 1, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in arktronic@1ac985c — all status literals in this method now use CheckStatuses.

Comment thread SAMA.Web/Pages/Dev/LoadTest.cshtml.cs Outdated
Comment on lines +175 to +178
Status = status,
ResponseTimeMs = responseTime,
StatusCode = status == "Up" ? 200 : (status == "Warn" ? 200 : 0),
ErrorMessage = status == "Down" ? "Connection failed" : null,

@atniptw atniptw Jul 1, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in arktronic@cfa6210 — replaced the nested ternaries with a switch expression over CheckStatuses for the StatusCode/ErrorMessage mapping.

current = current.AddSeconds(intervalSeconds);
}

await dbContext.SaveChangesAsync();

@atniptw atniptw Jul 1, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in arktronic@c8a136c — after seeding each check's historical results, we now look up the tracked Check entity and set LatestStatus/LatestCheckedAt/LatestResponseTimeMs from the loop's final values before saving.

Comment thread SAMA.Web/Pages/Dev/LoadTest.cshtml.cs Outdated
Comment on lines +192 to +194
StatusMessage = $"Created workspace '{workspace.Name}' with {checks.Count} checks and {totalResults} historical results.";
return RedirectToPage("/Dashboard/Index", new { workspaceId = workspace.Id });
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in arktronic@e64778c — switched to TempData["SuccessMessage"], which the shared layout already renders after a redirect (same pattern as Workspaces/Create), and removed the dead StatusMessage property/alert block.

atniptw and others added 5 commits July 1, 2026 13:38
Workspace.Name is limited to 100 chars, but the load test page appended
a date + GUID suffix to an unbounded 100-char prefix, which could exceed
the limit and cause SaveChangesAsync to throw.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Replaces hard-coded "Up"/"Warn"/"Down" strings with the existing
CheckStatuses constants to avoid typos and stay consistent with the
rest of the codebase.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Replaces nested ternaries with a switch on CheckStatuses so the
StatusCode/ErrorMessage mapping stays clear and easy to extend if
statuses ever change.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
CheckResults were being inserted without updating the owning Check's
LatestStatus/LatestCheckedAt/LatestResponseTimeMs, so the dashboard and
check list (which read those fields directly) showed load-test checks
as pending until the scheduler ran them for real. Also puts the
previously-unused lastCheckedAt value to use.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
StatusMessage was set right before redirecting to /Dashboard/Index, so
it never rendered. Switch to TempData["SuccessMessage"], which the
shared layout already displays after a redirect, matching the pattern
used by other create pages (e.g. Workspaces/Create). Removes the
now-dead StatusMessage property and its alert block.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@arktronic-sep
arktronic-sep merged commit bcbdd41 into sep:main Jul 3, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants