fix(rabbitmq): add bounded paging for queue and exchange management lists
Closes #8879
This commit is contained in:
1 parent
33f212a452
commit
725b1ee252
22 files changed
+1445
-67
No files matched your search
@@ -9,6 +9,7 @@ vi.mock("@tauri-apps/api/core", () => ({
|
||||
}));
|
||||
|
||||
const NS = { tenant: "_rabbitmq", namespace: "/" };
|
||||
const PAGINATION = { page: 2, pageSize: 100, search: "orders", sort: "name" as const, sortDescending: false };
|
||||
|
||||
describe("mq exchanges/bindings tauri API", () => {
|
||||
beforeEach(() => {
|
||||
@@ -27,6 +28,18 @@ describe("mq exchanges/bindings tauri API", () => {
|
||||
expect(result[0]?.name).toBe("dbx-events");
|
||||
});
|
||||
|
||||
it("invokes the bounded exchange and topic list commands with pagination", async () => {
|
||||
const { mqListExchangesPage, mqListTopicsPage } = await import("@/lib/backend/mq-tauri");
|
||||
mocks.invoke.mockResolvedValue({ items: [], page: 2, pageSize: 100, totalCount: 125, hasMore: false });
|
||||
|
||||
await mqListExchangesPage("conn-1", NS, PAGINATION);
|
||||
expect(mocks.invoke).toHaveBeenCalledWith("mq_list_exchanges_page", { connectionId: "conn-1", ns: NS, pagination: PAGINATION });
|
||||
|
||||
const opts = { includeNonPersistent: false };
|
||||
await mqListTopicsPage("conn-1", NS, opts, PAGINATION);
|
||||
expect(mocks.invoke).toHaveBeenCalledWith("mq_list_topics_page", { connectionId: "conn-1", ns: NS, opts, pagination: PAGINATION });
|
||||
});
|
||||
|
||||
it("invokes mq_create_exchange with flattened fields", async () => {
|
||||
const { mqCreateExchange } = await import("@/lib/backend/mq-tauri");
|
||||
mocks.invoke.mockResolvedValue(undefined);
|
||||
@@ -113,6 +126,18 @@ describe("mq exchanges/bindings HTTP API", () => {
|
||||
expect(lastCall(fetchMock)).toEqual({ url: "/api/mq/exchanges/delete", body: { connectionId: "conn-1", ns: NS, name: "dbx-events" } });
|
||||
});
|
||||
|
||||
it("posts bounded exchange and topic list requests", async () => {
|
||||
const fetchMock = stubFetch();
|
||||
const { mqListExchangesPage, mqListTopicsPage } = await import("@/lib/backend/mq-http");
|
||||
|
||||
await mqListExchangesPage("conn-1", NS, PAGINATION);
|
||||
expect(lastCall(fetchMock)).toEqual({ url: "/api/mq/exchanges/list-page", body: { connectionId: "conn-1", ns: NS, pagination: PAGINATION } });
|
||||
|
||||
const opts = { includeNonPersistent: false };
|
||||
await mqListTopicsPage("conn-1", NS, opts, PAGINATION);
|
||||
expect(lastCall(fetchMock)).toEqual({ url: "/api/mq/topics/list-page", body: { connectionId: "conn-1", ns: NS, opts, pagination: PAGINATION } });
|
||||
});
|
||||
|
||||
it("posts to the bindings endpoints", async () => {
|
||||
const fetchMock = stubFetch();
|
||||
const { mqListBindings, mqBind, mqUnbind } = await import("@/lib/backend/mq-http");
|
||||
|
||||
@@ -766,12 +766,14 @@ export const mqCreateNamespace = forward("mqCreateNamespace");
|
||||
export const mqDeleteNamespace = forward("mqDeleteNamespace");
|
||||
export const mqGetNamespacePolicies = forward("mqGetNamespacePolicies");
|
||||
export const mqListTopics = forward("mqListTopics");
|
||||
export const mqListTopicsPage = forward("mqListTopicsPage");
|
||||
export const mqCreateTopic = forward("mqCreateTopic");
|
||||
export const mqDeleteTopic = forward("mqDeleteTopic");
|
||||
export const mqUpdatePartitions = forward("mqUpdatePartitions");
|
||||
export const mqGetTopicStats = forward("mqGetTopicStats");
|
||||
export const mqGetTopicInternalStats = forward("mqGetTopicInternalStats");
|
||||
export const mqListExchanges = forward("mqListExchanges");
|
||||
export const mqListExchangesPage = forward("mqListExchangesPage");
|
||||
export const mqCreateExchange = forward("mqCreateExchange");
|
||||
export const mqDeleteExchange = forward("mqDeleteExchange");
|
||||
export const mqListBindings = forward("mqListBindings");
|
||||
|
||||
@@ -11,6 +11,8 @@ import type {
|
||||
TopicRef,
|
||||
TopicInfo,
|
||||
ListTopicsOpts,
|
||||
MqListPage,
|
||||
MqListPageRequest,
|
||||
TopicStats,
|
||||
SubscriptionInfo,
|
||||
KafkaConsumerGroupSnapshot,
|
||||
@@ -75,6 +77,10 @@ export async function mqListExchanges(connectionId: string, ns: NamespaceRef): P
|
||||
return post("/api/mq/exchanges/list", { connectionId, ns });
|
||||
}
|
||||
|
||||
export async function mqListExchangesPage(connectionId: string, ns: NamespaceRef, pagination: MqListPageRequest): Promise<MqListPage<MqExchangeInfo>> {
|
||||
return post("/api/mq/exchanges/list-page", { connectionId, ns, pagination });
|
||||
}
|
||||
|
||||
export async function mqCreateExchange(connectionId: string, ns: NamespaceRef, exchange: MqExchangeCreateRequest): Promise<void> {
|
||||
return post("/api/mq/exchanges/create", { connectionId, ns, name: exchange.name, exchangeType: exchange.type, durable: exchange.durable, autoDelete: exchange.autoDelete });
|
||||
}
|
||||
@@ -194,6 +200,10 @@ export async function mqListTopics(connectionId: string, ns: NamespaceRef, opts:
|
||||
return post("/api/mq/topics/list", { connectionId, ns, opts });
|
||||
}
|
||||
|
||||
export async function mqListTopicsPage(connectionId: string, ns: NamespaceRef, opts: ListTopicsOpts, pagination: MqListPageRequest): Promise<MqListPage<TopicInfo>> {
|
||||
return post("/api/mq/topics/list-page", { connectionId, ns, opts, pagination });
|
||||
}
|
||||
|
||||
export async function mqCreateTopic(connectionId: string, topic: TopicRef, partitions?: number): Promise<void> {
|
||||
return post("/api/mq/topics/create", { connectionId, topic, partitions });
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ import type {
|
||||
TopicRef,
|
||||
TopicInfo,
|
||||
ListTopicsOpts,
|
||||
MqListPage,
|
||||
MqListPageRequest,
|
||||
TopicStats,
|
||||
SubscriptionInfo,
|
||||
KafkaConsumerGroupSnapshot,
|
||||
@@ -64,6 +66,10 @@ export async function mqListExchanges(connectionId: string, ns: NamespaceRef): P
|
||||
return invoke("mq_list_exchanges", { connectionId, ns });
|
||||
}
|
||||
|
||||
export async function mqListExchangesPage(connectionId: string, ns: NamespaceRef, pagination: MqListPageRequest): Promise<MqListPage<MqExchangeInfo>> {
|
||||
return invoke("mq_list_exchanges_page", { connectionId, ns, pagination });
|
||||
}
|
||||
|
||||
export async function mqCreateExchange(connectionId: string, ns: NamespaceRef, exchange: MqExchangeCreateRequest): Promise<void> {
|
||||
return invoke("mq_create_exchange", { connectionId, ns, name: exchange.name, exchangeType: exchange.type, durable: exchange.durable, autoDelete: exchange.autoDelete });
|
||||
}
|
||||
@@ -187,6 +193,10 @@ export async function mqListTopics(connectionId: string, ns: NamespaceRef, opts:
|
||||
return invoke("mq_list_topics", { connectionId, ns, opts });
|
||||
}
|
||||
|
||||
export async function mqListTopicsPage(connectionId: string, ns: NamespaceRef, opts: ListTopicsOpts, pagination: MqListPageRequest): Promise<MqListPage<TopicInfo>> {
|
||||
return invoke("mq_list_topics_page", { connectionId, ns, opts, pagination });
|
||||
}
|
||||
|
||||
export async function mqCreateTopic(connectionId: string, topic: TopicRef, partitions?: number): Promise<void> {
|
||||
return invoke("mq_create_topic", { connectionId, topic, partitions });
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user