This is an automated email from the ASF dual-hosted git repository.
lizhimins pushed a commit to branch rocketmq-studio
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git
The following commit(s) were added to refs/heads/rocketmq-studio by this push:
new f6a8aaa87 fix(consumer): scope mock progress to its instance (#7253)
f6a8aaa87 is described below
commit f6a8aaa87b2b83c20ea3642584344d9d194d1850
Author: Loyal-Young <[email protected]>
AuthorDate: Mon Oct 26 23:22:21 2026 +0800
fix(consumer): scope mock progress to its instance (#7253)
* fix(consumer): scope mock progress to its instance
---
web/src/services/consumerService.test.ts | 23 +++++++++++++++++++++++
web/src/services/consumerService.ts | 20 +++++++++++++++++---
2 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/web/src/services/consumerService.test.ts
b/web/src/services/consumerService.test.ts
index ae9eff14c..bfec41bfc 100644
--- a/web/src/services/consumerService.test.ts
+++ b/web/src/services/consumerService.test.ts
@@ -371,6 +371,29 @@ describe('consumer service mock data', () => {
expect(secondSubscriptions[0]).not.toBe(firstSubscriptions[0]);
});
+ it('does not show another instance fixture for a same-named mock group',
async () => {
+ const name = 'cg-order-notify';
+ const otherInstance = 'instance-proxy-2';
+ expect((await getConsumerProgress(name,
'instance-proxy-1')).length).toBeGreaterThan(0);
+ expect((await getConsumerSubscriptions(name,
'instance-proxy-1')).length).toBeGreaterThan(0);
+
+ await createConsumerGroup({ name, instanceId: otherInstance });
+ try {
+ expect(await getConsumerProgress(name, otherInstance)).toEqual([]);
+ expect(await getConsumerSubscriptions(name, otherInstance)).toEqual([]);
+ const preview = await previewConsumerOffsetReset({
+ name,
+ instanceId: otherInstance,
+ topic: 'order-create',
+ timestamp: 1784246400000,
+ });
+ expect(preview.queueCount).toBe(0);
+ expect(preview.allowReset).toBe(false);
+ } finally {
+ await deleteConsumerGroup(name, otherInstance);
+ }
+ });
+
it('builds copied reset offset previews in mock mode', async () => {
const firstPreview = await previewConsumerOffsetReset({
name: 'cg-order-notify',
diff --git a/web/src/services/consumerService.ts
b/web/src/services/consumerService.ts
index cd6a3edc0..8381f33a9 100644
--- a/web/src/services/consumerService.ts
+++ b/web/src/services/consumerService.ts
@@ -27,6 +27,16 @@ const consumerGroupsState = mockConsumerGroups as unknown as
(ConsumerGroup & {
consumeMessageOrderly?: boolean;
consumeBroadcastEnable?: boolean;
})[];
+const fixtureGroupsByName = new Map(mockConsumerGroups.map((group) =>
[group.name, group]));
+
+function hasActiveFixtureGroup(name: string, instanceId?: string): boolean {
+ const fixture = fixtureGroupsByName.get(name);
+ return (
+ fixture !== undefined &&
+ mockConsumerGroups.includes(fixture) &&
+ (!instanceId || fixture.instanceId === instanceId)
+ );
+}
const EXPORT_PAGE_SIZE = 100;
const MAX_EXPORT_PAGES = 100;
const GROUP_EXPORT_COLUMNS: CsvColumn<ConsumerGroup>[] = [
@@ -182,6 +192,7 @@ export async function getConsumerProgress(
instanceId?: string,
): Promise<QueueProgress[]> {
if (isMockMode()) {
+ if (!hasActiveFixtureGroup(name, instanceId)) return [];
return ((mockQueueProgress[name] as unknown as QueueProgress[]) ??
[]).map(copyQueueProgress);
}
return metadataApi.getConsumerProgress(name, instanceId);
@@ -267,6 +278,7 @@ export async function getConsumerSubscriptions(
instanceId?: string,
): Promise<SubscriptionEntry[]> {
if (isMockMode()) {
+ if (!hasActiveFixtureGroup(name, instanceId)) return [];
return ((mockSubscriptions[name] as unknown as SubscriptionEntry[]) ??
[]).map(
copySubscription,
);
@@ -382,9 +394,11 @@ export async function previewConsumerOffsetReset(
}
function buildMockResetOffsetPreview(data: ResetConsumerOffsetRequest):
ResetConsumerOffsetPreview {
- const progressRows = ((mockQueueProgress[data.name] as unknown as
QueueProgress[]) ?? []).filter(
- (progress) => !progress.topic || progress.topic === data.topic,
- );
+ const progressRows = hasActiveFixtureGroup(data.name, data.instanceId)
+ ? ((mockQueueProgress[data.name] as unknown as QueueProgress[]) ??
[]).filter(
+ (progress) => !progress.topic || progress.topic === data.topic,
+ )
+ : [];
const queues = progressRows.map((progress) =>
buildMockResetOffsetQueuePreview(data.topic, progress),
);