feat(mq): implement Apache Pulsar message queue admin
* feat(mq): implement Apache Pulsar message queue admin - Add complete MQ admin adapter layer with version detection * Pulsar adapter with multi-version API support * OAuth2 token caching and authentication * JWT token signing for Pulsar clients * Transport layer (SSH/Proxy) integration - Implement comprehensive admin operations * Tenant, namespace, topic management * Subscription and consumer/producer monitoring * Rate limits, backlog quotas, retention policies * Permissions and role-based access control * Raw admin API for advanced operations - Add desktop UI components * MQ admin console with tabbed interface * Tenant, namespace, topic panels * Subscription management and cursor operations * Monitoring panel with stats visualization * Policy configuration UI - Add web routes for MQ admin operations - Add secret store support for MQ auth credentials - Add comprehensive test coverage * fix: del local test files * fix(mq): mark message queue as unsupported mcpMode in driver manifest MQ admin connections do not use the MCP query bridge - they use a separate REST admin API. Mark mcpMode as 'unsupported' to align with the test expectations and reflect the actual architecture. Fixes CI test: driver-manifest.test.ts * fix(mq): fix TypeScript errors in MQ components - Fix typo in SubscriptionsPanel.vue: messagformatError(e)Id -> message.messageId - Use formatError() helper in RawApiPanel.vue instead of accessing e?.message - Fix undefined 'tab' reference in ConnectionTree.vue: use config.db_type instead Fixes frontend CI TypeScript check errors. * fix(mcp): add 'mq' to MCP server connection type description The MCP server's connection type description must include all database types from the driver manifest. Add 'mq' to the list to fix the test: 'add connection database type description includes every manifest database type' Fixes: packages/mcp-server/tests/driver-manifest.test.ts * fix(mq): add missing ConnectionConfig fields for Rust compilation - Add gbase_server and keepalive_interval_secs fields to all ConnectionConfig test constructors in mq/config.rs, mq/service.rs, and storage.rs - Import uses_bare_mysql_pool in connection.rs tests module Fixes compilation errors from upstream ConnectionConfig changes. * chore(ui): simplify Pulsar icon to logo-only version Remove text from Pulsar icon (127x30 -> 35x30), keeping only the wave logo symbol for a cleaner, more consistent appearance with other database icons. * fix(mq): return removed pools from drain_connection_pools --------- Co-authored-by: t8y2 <1156263951@qq.com>
This commit is contained in:
1 parent
8339d23df5
commit
2a59d3143e
83 files changed
+15979
-37
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { quickConnectionOpenTarget } from "@/lib/connectionOpenTarget";
|
||||
import type { ConnectionConfig } from "@/types/database";
|
||||
|
||||
function connection(dbType: ConnectionConfig["db_type"]): ConnectionConfig {
|
||||
return {
|
||||
id: "conn",
|
||||
name: "conn",
|
||||
db_type: dbType,
|
||||
host: "127.0.0.1",
|
||||
port: 0,
|
||||
user: "",
|
||||
password: "",
|
||||
database: "",
|
||||
readonly: false,
|
||||
read_only: false,
|
||||
ssl_mode: "disabled",
|
||||
color: "#888",
|
||||
} as ConnectionConfig;
|
||||
}
|
||||
|
||||
describe("quickConnectionOpenTarget", () => {
|
||||
it("opens message queue connections in the MQ admin console", () => {
|
||||
expect(quickConnectionOpenTarget(connection("mq"))).toEqual({ kind: "mq-admin" });
|
||||
});
|
||||
|
||||
it("opens regular connections in a query tab", () => {
|
||||
expect(quickConnectionOpenTarget({ ...connection("postgresql"), database: "app" })).toEqual({
|
||||
kind: "query",
|
||||
database: "app",
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,45 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
function componentSource(name: string): string {
|
||||
return readFileSync(new URL(`../../components/mq/${name}`, import.meta.url), "utf8");
|
||||
}
|
||||
|
||||
describe("MQ list panels", () => {
|
||||
it("does not issue per-tenant detail requests from the tenant list UI", () => {
|
||||
const source = componentSource("TenantsPanel.vue");
|
||||
|
||||
expect(source).not.toContain("mqGetTenant");
|
||||
});
|
||||
|
||||
it("does not issue per-namespace permission requests from the namespace list UI", () => {
|
||||
const source = componentSource("NamespacesPanel.vue");
|
||||
|
||||
expect(source).not.toContain("mqListPermissions");
|
||||
});
|
||||
|
||||
it("refreshing policies hydrates missing fields from defaults instead of dirty form values", () => {
|
||||
const source = componentSource("PoliciesPanel.vue");
|
||||
|
||||
expect(source).not.toContain("policyFormsFromEffectivePolicies(loaded, currentPolicyForms())");
|
||||
expect(source).toContain("policyFormsFromEffectivePolicies(loaded, defaultMqPolicyForms())");
|
||||
});
|
||||
|
||||
it("raw api panel includes common endpoint presets that use the selected mq context", () => {
|
||||
const rawSource = componentSource("RawApiPanel.vue");
|
||||
const consoleSource = componentSource("MqAdminConsole.vue");
|
||||
|
||||
expect(rawSource).toContain("const presets = computed<RawApiPreset[]>");
|
||||
expect(rawSource).toContain("/admin/v2/brokers/version");
|
||||
expect(rawSource).toContain("/internalStats");
|
||||
expect(rawSource).toContain("/partitioned-stats");
|
||||
expect(rawSource).toContain("/schema");
|
||||
expect(rawSource).toContain("presetsCollapsed");
|
||||
expect(rawSource).toContain("formatJsonBody");
|
||||
expect(rawSource).toContain("bodyTextareaRows");
|
||||
expect(rawSource).toContain("body: isReadMethod.value ? undefined : parseBody()");
|
||||
expect(consoleSource).toContain(':tenant="selectedTenant"');
|
||||
expect(consoleSource).toContain(':namespace="selectedNamespace"');
|
||||
expect(consoleSource).toContain(':topic="selectedTopic"');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,22 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { MQ_PINNED_VERSION_AUTO, MQ_PINNED_VERSION_OPTIONS, pinnedVersionToSelection, selectionToPinnedVersion } from "@/lib/mqPinnedVersionOptions";
|
||||
|
||||
describe("mqPinnedVersionOptions", () => {
|
||||
it("offers auto-detection and the supported Pulsar 3.x profile", () => {
|
||||
expect(MQ_PINNED_VERSION_OPTIONS.map((option) => option.value)).toEqual([MQ_PINNED_VERSION_AUTO, "3.1.x"]);
|
||||
});
|
||||
|
||||
it("normalizes existing Pulsar 3.x pinned values to the supported profile option", () => {
|
||||
expect(pinnedVersionToSelection(undefined)).toBe(MQ_PINNED_VERSION_AUTO);
|
||||
expect(pinnedVersionToSelection("")).toBe(MQ_PINNED_VERSION_AUTO);
|
||||
expect(pinnedVersionToSelection("3.0.7")).toBe("3.1.x");
|
||||
expect(pinnedVersionToSelection("3.1.2")).toBe("3.1.x");
|
||||
expect(pinnedVersionToSelection("3.1.x")).toBe("3.1.x");
|
||||
});
|
||||
|
||||
it("only persists an explicit version when a supported profile is selected", () => {
|
||||
expect(selectionToPinnedVersion(MQ_PINNED_VERSION_AUTO)).toBeUndefined();
|
||||
expect(selectionToPinnedVersion("3.1.x")).toBe("3.1.x");
|
||||
expect(selectionToPinnedVersion("4.0.x")).toBeUndefined();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,72 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { defaultMqPolicyForms, policyFormsFromEffectivePolicies } from "@/lib/mqPolicyForms";
|
||||
|
||||
describe("mqPolicyForms", () => {
|
||||
it("hydrates forms from topic effective policies", () => {
|
||||
const forms = policyFormsFromEffectivePolicies(
|
||||
{
|
||||
level: "topic",
|
||||
topicPolicies: {
|
||||
publishRate: {
|
||||
publishThrottlingRateInMsg: 100,
|
||||
publishThrottlingRateInByte: 2048,
|
||||
},
|
||||
dispatchRate: {
|
||||
dispatchThrottlingRateInMsg: 50,
|
||||
dispatchThrottlingRateInByte: 1024,
|
||||
ratePeriodInSecond: 5,
|
||||
},
|
||||
backlogQuota: {
|
||||
limitSize: 4096,
|
||||
limitTime: 60,
|
||||
policy: "producer_exception",
|
||||
quotaType: "message_age",
|
||||
},
|
||||
retention: {
|
||||
retentionTimeInMinutes: 120,
|
||||
retentionSizeInMB: 512,
|
||||
},
|
||||
},
|
||||
},
|
||||
defaultMqPolicyForms(),
|
||||
);
|
||||
|
||||
expect(forms.publishForm.publishThrottlingRateInMsg).toBe(100);
|
||||
expect(forms.dispatchForm.ratePeriodInSecond).toBe(5);
|
||||
expect(forms.backlogForm.quotaType).toBe("message_age");
|
||||
expect(forms.retentionForm.retentionSizeInMb).toBe(512);
|
||||
});
|
||||
|
||||
it("hydrates forms from namespace Pulsar policies shape", () => {
|
||||
const forms = policyFormsFromEffectivePolicies(
|
||||
{
|
||||
publishRate: {
|
||||
publishThrottlingRateInMsg: 20,
|
||||
publishThrottlingRateInByte: 3000,
|
||||
},
|
||||
subscribeRate: {
|
||||
subscribeThrottlingRatePerConsumer: 12,
|
||||
ratePeriodInSecond: 3,
|
||||
},
|
||||
backlog_quota_map: {
|
||||
destination_storage: {
|
||||
limitSize: 999,
|
||||
limitTime: 10,
|
||||
policy: "consumer_backlog_eviction",
|
||||
},
|
||||
},
|
||||
retention_policies: {
|
||||
retentionTimeInMinutes: 30,
|
||||
retentionSizeInMB: 64,
|
||||
},
|
||||
},
|
||||
defaultMqPolicyForms(),
|
||||
);
|
||||
|
||||
expect(forms.publishForm.publishThrottlingRateInByte).toBe(3000);
|
||||
expect(forms.subscribeForm.ratePeriodInSecond).toBe(3);
|
||||
expect(forms.backlogForm.limitSize).toBe(999);
|
||||
expect(forms.backlogForm.quotaType).toBe("destination_storage");
|
||||
expect(forms.retentionForm.retentionTimeInMinutes).toBe(30);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,25 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { defaultTenantConfig, mqClusterOptionsFromExtra, validateTenantForm } from "@/lib/mqTenantForm";
|
||||
|
||||
describe("mqTenantForm", () => {
|
||||
it("extracts selectable cluster names from Pulsar cluster info extras", () => {
|
||||
expect(mqClusterOptionsFromExtra({ clusters: ["standalone", "ec-pulsar", "standalone", "", 42] })).toEqual(["standalone", "ec-pulsar"]);
|
||||
expect(mqClusterOptionsFromExtra({ clusters: "standalone" })).toEqual([]);
|
||||
expect(mqClusterOptionsFromExtra(undefined)).toEqual([]);
|
||||
});
|
||||
|
||||
it("prefills a new tenant with detected clusters", () => {
|
||||
const config = defaultTenantConfig(["standalone", "ec-pulsar"]);
|
||||
|
||||
expect(config).toEqual({
|
||||
adminRoles: [],
|
||||
allowedClusters: ["standalone", "ec-pulsar"],
|
||||
});
|
||||
});
|
||||
|
||||
it("requires both a tenant name and at least one allowed cluster", () => {
|
||||
expect(validateTenantForm("", { adminRoles: [], allowedClusters: ["standalone"] })).toBe("Tenant name is required");
|
||||
expect(validateTenantForm("tenant-a", { adminRoles: [], allowedClusters: [] })).toBe("Allowed clusters are required");
|
||||
expect(validateTenantForm("tenant-a", { adminRoles: [], allowedClusters: ["standalone"] })).toBeUndefined();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { formatMqTokenIssueError } from "../mqTokenErrors";
|
||||
|
||||
describe("MQ token errors", () => {
|
||||
it("turns missing signing configuration backend errors into actionable Chinese copy", () => {
|
||||
const result = formatMqTokenIssueError("/api/mq/tokens/issue returned 500: Token signing is not configured for this MQ connection");
|
||||
|
||||
expect(result.kind).toBe("missingSigningKey");
|
||||
expect(result.title).toBe("未配置 Token 签发密钥");
|
||||
expect(result.message).toContain("无法生成客户端 Token");
|
||||
expect(result.detail).toContain("Broker Token 签发");
|
||||
});
|
||||
|
||||
it("keeps unrelated errors as ordinary messages", () => {
|
||||
const result = formatMqTokenIssueError("network failed");
|
||||
|
||||
expect(result.kind).toBe("generic");
|
||||
expect(result.title).toBeUndefined();
|
||||
expect(result.message).toBe("network failed");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user