mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-02-19 17:03:31 +00:00
Compare commits
4 Commits
users/saks
...
fix_duplic
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1a1aca5bd5 | ||
|
|
e03de89bf3 | ||
|
|
cc26e2800e | ||
|
|
39ac7cf3f2 |
@@ -6,7 +6,7 @@ import { MinimalQueryIterator, nextPage } from "../IteratorUtilities";
|
||||
|
||||
// Redact sensitive information from BadRequest errors with specific codes
|
||||
export const redactSyntaxErrorMessage = (error: unknown): unknown => {
|
||||
const codesToRedact = ["SC1001", "SC2001"];
|
||||
const codesToRedact = ["SC1001", "SC2001", "SC1010"];
|
||||
|
||||
try {
|
||||
// Handle error objects with a message property
|
||||
|
||||
@@ -543,9 +543,6 @@ export class ThroughputInputAutoPilotV3Component extends React.Component<
|
||||
<span style={{ float: "left", transform: "translateX(-50%)" }}>
|
||||
{this.props.instantMaximumThroughput.toLocaleString(ThroughputInputAutoPilotV3Component.LOCALE_EN_US)}
|
||||
</span>
|
||||
<span style={{ float: "right" }}>
|
||||
{this.props.softAllowedMaximumThroughput.toLocaleString(ThroughputInputAutoPilotV3Component.LOCALE_EN_US)}
|
||||
</span>
|
||||
<span style={{ float: "right" }} data-test="soft-allowed-maximum-throughput">
|
||||
{this.props.softAllowedMaximumThroughput.toLocaleString(ThroughputInputAutoPilotV3Component.LOCALE_EN_US)}
|
||||
</span>
|
||||
|
||||
@@ -426,15 +426,6 @@ exports[`ThroughputInputAutoPilotV3Component autopilot input visible 1`] = `
|
||||
>
|
||||
5,000
|
||||
</span>
|
||||
<span
|
||||
style={
|
||||
{
|
||||
"float": "right",
|
||||
}
|
||||
}
|
||||
>
|
||||
1,000,000
|
||||
</span>
|
||||
<span
|
||||
data-test="soft-allowed-maximum-throughput"
|
||||
style={
|
||||
@@ -1034,15 +1025,6 @@ exports[`ThroughputInputAutoPilotV3Component spendAck checkbox visible 1`] = `
|
||||
>
|
||||
5,000
|
||||
</span>
|
||||
<span
|
||||
style={
|
||||
{
|
||||
"float": "right",
|
||||
}
|
||||
}
|
||||
>
|
||||
1,000,000
|
||||
</span>
|
||||
<span
|
||||
data-test="soft-allowed-maximum-throughput"
|
||||
style={
|
||||
@@ -1620,15 +1602,6 @@ exports[`ThroughputInputAutoPilotV3Component throughput input visible 1`] = `
|
||||
>
|
||||
5,000
|
||||
</span>
|
||||
<span
|
||||
style={
|
||||
{
|
||||
"float": "right",
|
||||
}
|
||||
}
|
||||
>
|
||||
1,000,000
|
||||
</span>
|
||||
<span
|
||||
data-test="soft-allowed-maximum-throughput"
|
||||
style={
|
||||
|
||||
@@ -120,7 +120,7 @@ const App = (): JSX.Element => {
|
||||
}, [explorer]);
|
||||
|
||||
// Track interactive phase for both ContainerCopyPanel and DivExplorer paths
|
||||
useInteractive(MetricScenario.ApplicationLoad);
|
||||
useInteractive(MetricScenario.ApplicationLoad, !!config);
|
||||
|
||||
if (!explorer) {
|
||||
return <LoadingExplorer />;
|
||||
|
||||
@@ -56,6 +56,13 @@ class ScenarioMonitor {
|
||||
});
|
||||
}
|
||||
|
||||
private devLog(msg: string) {
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`[Metrics] ${msg}`);
|
||||
}
|
||||
}
|
||||
|
||||
start(scenario: MetricScenario) {
|
||||
if (this.contexts.has(scenario)) {
|
||||
return;
|
||||
@@ -86,6 +93,10 @@ class ScenarioMonitor {
|
||||
ctx.phases.set(phase, { startMarkName: phaseStartMarkName });
|
||||
});
|
||||
|
||||
this.devLog(
|
||||
`scenario_start: ${scenario} | phases=${config.requiredPhases.join(", ")} | timeout=${config.timeoutMs}ms`,
|
||||
);
|
||||
|
||||
traceMark(Action.MetricsScenario, {
|
||||
event: "scenario_start",
|
||||
scenario,
|
||||
@@ -136,6 +147,12 @@ class ScenarioMonitor {
|
||||
const endTimeISO = endEntry ? new Date(navigationStart + endEntry.startTime).toISOString() : undefined;
|
||||
const durationMs = startEntry && endEntry ? endEntry.startTime - startEntry.startTime : undefined;
|
||||
|
||||
this.devLog(
|
||||
`phase_complete: ${scenario}.${phase} | ${
|
||||
durationMs !== null && durationMs !== undefined ? `${Math.round(durationMs)}ms` : "?"
|
||||
} | ${ctx.completed.size}/${ctx.config.requiredPhases.length} phases`,
|
||||
);
|
||||
|
||||
traceSuccess(Action.MetricsScenario, {
|
||||
event: "phase_complete",
|
||||
scenario,
|
||||
@@ -155,6 +172,13 @@ class ScenarioMonitor {
|
||||
return;
|
||||
}
|
||||
|
||||
// If an expected failure was flagged (auth, firewall, etc.), treat as success.
|
||||
if (ctx.hasExpectedFailure) {
|
||||
this.devLog(`phase_fail: ${scenario}.${phase} — expected failure, completing as healthy`);
|
||||
this.completePhase(scenario, phase);
|
||||
return;
|
||||
}
|
||||
|
||||
// Mark the explicitly failed phase
|
||||
performance.mark(`scenario_${scenario}_${phase}_failed`);
|
||||
ctx.failed.add(phase);
|
||||
@@ -169,6 +193,12 @@ class ScenarioMonitor {
|
||||
// Build a snapshot with failure info
|
||||
const failureSnapshot = this.buildSnapshot(ctx, { final: false, timedOut: false });
|
||||
|
||||
this.devLog(
|
||||
`phase_fail: ${scenario}.${phase} | failed=[${Array.from(ctx.failed).join(", ")}] | completed=[${Array.from(
|
||||
ctx.completed,
|
||||
).join(", ")}]`,
|
||||
);
|
||||
|
||||
traceFailure(Action.MetricsScenario, {
|
||||
event: "phase_fail",
|
||||
scenario,
|
||||
@@ -177,7 +207,7 @@ class ScenarioMonitor {
|
||||
completedPhases: Array.from(ctx.completed).join(","),
|
||||
});
|
||||
|
||||
// Emit unhealthy immediately
|
||||
// Emit unhealthy immediately for unexpected failures
|
||||
this.emit(ctx, false, false, failureSnapshot);
|
||||
}
|
||||
|
||||
@@ -270,6 +300,19 @@ class ScenarioMonitor {
|
||||
ttfb: finalSnapshot.vitals?.ttfb,
|
||||
});
|
||||
|
||||
this.devLog(
|
||||
`scenario_end: ${ctx.scenario} | ${healthy ? "healthy" : "unhealthy"} | ${
|
||||
timedOut ? "timed out" : `${Math.round(finalSnapshot.durationMs)}ms`
|
||||
} | ${JSON.stringify({
|
||||
completedPhases: finalSnapshot.completed.join(", "),
|
||||
failedPhases: finalSnapshot.failedPhases?.join(", ") || "none",
|
||||
platform,
|
||||
api,
|
||||
phaseTimings: finalSnapshot.phaseTimings,
|
||||
vitals: finalSnapshot.vitals,
|
||||
})}`,
|
||||
);
|
||||
|
||||
// Call portal backend health metrics endpoint
|
||||
// If healthy is true (either completed successfully or timeout with expected failure), report healthy
|
||||
if (healthy) {
|
||||
|
||||
@@ -7,14 +7,18 @@ import { ApplicationMetricPhase, CommonMetricPhase } from "./ScenarioConfig";
|
||||
* Hook to automatically complete the Interactive phase when the component becomes interactive.
|
||||
* Uses requestAnimationFrame to complete after the browser has painted.
|
||||
*/
|
||||
export function useInteractive(scenario: MetricScenario) {
|
||||
export function useInteractive(scenario: MetricScenario, enabled = true) {
|
||||
const { completePhase } = useMetricScenario();
|
||||
|
||||
React.useEffect(() => {
|
||||
requestAnimationFrame(() => {
|
||||
if (!enabled) {
|
||||
return undefined;
|
||||
}
|
||||
const id = requestAnimationFrame(() => {
|
||||
completePhase(scenario, CommonMetricPhase.Interactive);
|
||||
});
|
||||
}, [scenario, completePhase]);
|
||||
return () => cancelAnimationFrame(id);
|
||||
}, [scenario, completePhase, enabled]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,157 +0,0 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
import { CommandBarButton, DataExplorer, Editor, ONE_MINUTE_MS, TestAccount } from "../../fx";
|
||||
import { createTestSQLContainer, TestContainerContext } from "../../testData";
|
||||
|
||||
test.describe("Indexing Policy under Scale & Settings", () => {
|
||||
let context: TestContainerContext = null!;
|
||||
let explorer: DataExplorer = null!;
|
||||
|
||||
// Helper function to get the indexing policy editor
|
||||
const getIndexingPolicyEditor = (): Editor => {
|
||||
const editorContainer = explorer.frame.locator(".settingsV2Editor");
|
||||
return new Editor(explorer.frame, editorContainer);
|
||||
};
|
||||
|
||||
test.beforeAll("Create Test Database & Open Indexing Policy tab", async ({ browser }) => {
|
||||
context = await createTestSQLContainer();
|
||||
const page = await browser.newPage();
|
||||
explorer = await DataExplorer.open(page, TestAccount.SQL);
|
||||
|
||||
// Click Scale & Settings and open Indexing Policy tab
|
||||
await explorer.openScaleAndSettings(context);
|
||||
const indexingPolicyTab = explorer.frame.getByTestId("settings-tab-header/IndexingPolicyTab");
|
||||
await indexingPolicyTab.click();
|
||||
});
|
||||
|
||||
test.afterAll("Delete Test Database", async () => {
|
||||
await context?.dispose();
|
||||
});
|
||||
|
||||
test("Verify Indexing Policy tab is visible", async () => {
|
||||
const indexingPolicyTab = explorer.frame.getByTestId("settings-tab-header/IndexingPolicyTab");
|
||||
await expect(indexingPolicyTab).toBeVisible();
|
||||
});
|
||||
|
||||
test("Verify Indexing Policy editor is present", async () => {
|
||||
// The Monaco editor is rendered in a div with class settingsV2Editor
|
||||
const editorContainer = explorer.frame.locator(".settingsV2Editor");
|
||||
await expect(editorContainer).toBeVisible();
|
||||
|
||||
// Verify the editor has content (default indexing policy) using Editor helper
|
||||
const editor = getIndexingPolicyEditor();
|
||||
const editorContent = await editor.text();
|
||||
expect(editorContent).toBeTruthy();
|
||||
});
|
||||
|
||||
test("Update Indexing Policy - Change automatic to false", async () => {
|
||||
// Use helper function to get editor instance
|
||||
const editor = getIndexingPolicyEditor();
|
||||
|
||||
// Verify the Monaco editor is visible
|
||||
const editorElement = explorer.frame.locator(".settingsV2Editor").locator(".monaco-editor");
|
||||
await expect(editorElement).toBeVisible();
|
||||
|
||||
// Get current indexing policy content
|
||||
const currentContent = await editor.text();
|
||||
expect(currentContent).toBeTruthy();
|
||||
const indexingPolicy = JSON.parse(currentContent as string);
|
||||
|
||||
// Verify default policy structure
|
||||
expect(indexingPolicy).toHaveProperty("automatic");
|
||||
expect(indexingPolicy).toHaveProperty("indexingMode");
|
||||
|
||||
// Modify the indexing policy - change automatic to false
|
||||
indexingPolicy.automatic = false;
|
||||
const updatedContent = JSON.stringify(indexingPolicy, null, 4);
|
||||
|
||||
// Set the new content in the editor
|
||||
await editor.setText(updatedContent);
|
||||
|
||||
// Verify the warning message appears for unsaved changes
|
||||
const warningMessage = explorer.frame.locator(".ms-MessageBar--warning");
|
||||
await expect(warningMessage).toBeVisible({ timeout: 5000 });
|
||||
|
||||
// Save the changes
|
||||
await explorer.commandBarButton(CommandBarButton.Save).click();
|
||||
|
||||
// Verify success message
|
||||
await expect(explorer.getConsoleHeaderStatus()).toContainText(
|
||||
`Successfully updated container ${context.container.id}`,
|
||||
{
|
||||
timeout: 2 * ONE_MINUTE_MS,
|
||||
},
|
||||
);
|
||||
|
||||
// Verify warning message is no longer visible after save
|
||||
await expect(warningMessage).not.toBeVisible({ timeout: 5000 });
|
||||
});
|
||||
|
||||
test("Update Indexing Policy - Change indexingMode to lazy", async () => {
|
||||
// Use helper function to get editor instance
|
||||
const editor = getIndexingPolicyEditor();
|
||||
|
||||
// Verify the Monaco editor is visible
|
||||
const editorElement = explorer.frame.locator(".settingsV2Editor").locator(".monaco-editor");
|
||||
await expect(editorElement).toBeVisible();
|
||||
|
||||
// Get current indexing policy content
|
||||
const currentContent = await editor.text();
|
||||
expect(currentContent).toBeTruthy();
|
||||
const indexingPolicy = JSON.parse(currentContent as string);
|
||||
|
||||
// Modify the indexing policy - change indexingMode to lazy
|
||||
indexingPolicy.indexingMode = "lazy";
|
||||
const updatedContent = JSON.stringify(indexingPolicy, null, 4);
|
||||
|
||||
// Set the new content in the editor
|
||||
await editor.setText(updatedContent);
|
||||
|
||||
// Verify the warning message appears
|
||||
const warningMessage = explorer.frame.locator(".ms-MessageBar--warning");
|
||||
await expect(warningMessage).toBeVisible({ timeout: 5000 });
|
||||
|
||||
// Save the changes
|
||||
await explorer.commandBarButton(CommandBarButton.Save).click();
|
||||
|
||||
// Verify success message
|
||||
await expect(explorer.getConsoleHeaderStatus()).toContainText(
|
||||
`Successfully updated container ${context.container.id}`,
|
||||
{
|
||||
timeout: 2 * ONE_MINUTE_MS,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
test("Update Indexing Policy - Revert automatic to true", async () => {
|
||||
// Use helper function to get editor instance
|
||||
const editor = getIndexingPolicyEditor();
|
||||
|
||||
// Verify the Monaco editor is visible
|
||||
const editorElement = explorer.frame.locator(".settingsV2Editor").locator(".monaco-editor");
|
||||
await expect(editorElement).toBeVisible();
|
||||
|
||||
// Get current indexing policy content
|
||||
const currentContent = await editor.text();
|
||||
expect(currentContent).toBeTruthy();
|
||||
const indexingPolicy = JSON.parse(currentContent as string);
|
||||
|
||||
// Revert the changes - set automatic back to true and indexingMode to consistent
|
||||
indexingPolicy.automatic = true;
|
||||
indexingPolicy.indexingMode = "consistent";
|
||||
const updatedContent = JSON.stringify(indexingPolicy, null, 4);
|
||||
|
||||
// Set the new content in the editor
|
||||
await editor.setText(updatedContent);
|
||||
|
||||
// Save the changes
|
||||
await explorer.commandBarButton(CommandBarButton.Save).click();
|
||||
|
||||
// Verify success message
|
||||
await expect(explorer.getConsoleHeaderStatus()).toContainText(
|
||||
`Successfully updated container ${context.container.id}`,
|
||||
{
|
||||
timeout: 2 * ONE_MINUTE_MS,
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user