This is an automated email from the ASF dual-hosted git repository.

lizhimins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git


The following commit(s) were added to refs/heads/master by this push:
     new 37b539f75 fix(cluster): mirror the NameServer comparison scope in the 
mock config diff (#6780)
37b539f75 is described below

commit 37b539f75a2aa2879f69c3142407fe2828577834
Author: Apulupie <[email protected]>
AuthorDate: Fri Nov 27 12:48:14 2026 +0800

    fix(cluster): mirror the NameServer comparison scope in the mock config 
diff (#6780)
---
 web/src/services/clusterService.test.ts | 37 +++++++++++++++++++++++++++++++++
 web/src/services/clusterService.ts      | 33 ++++++++++++++++++++++++++++-
 2 files changed, 69 insertions(+), 1 deletion(-)

diff --git a/web/src/services/clusterService.test.ts 
b/web/src/services/clusterService.test.ts
index cb3c1092f..39bda838e 100644
--- a/web/src/services/clusterService.test.ts
+++ b/web/src/services/clusterService.test.ts
@@ -22,6 +22,32 @@ vi.mock('../config', () => ({
   API_BASE_URL: '/api',
 }));
 
+// @types/node is deliberately not a dependency of the web package, so node:fs 
is reached through a
+// dynamic import with an opaque specifier and `declare const` types the 
__dirname vitest injects.
+declare const __dirname: string;
+
+interface NodeFs {
+  readFileSync(path: string, encoding: string): string;
+}
+
+/**
+ * The comparison scope of NameServerConfigDiffService lives in this server 
resource and nowhere
+ * else: the service loads SAFE_CONFIG_KEYS from it and returns those names as 
comparedKeys, and the
+ * resource itself documents that adding or removing a key there is the only 
change needed.
+ * web/src/services -> repo root is three levels up.
+ */
+const NAMESERVER_SAFE_CONFIG_KEYS_PATH = 
`${__dirname}/../../../server/src/main/resources/cluster/nameserver-safe-config-keys.yml`;
+
+async function readNameserverSafeConfigKeys(): Promise<string[]> {
+  const fs = (await import('node:fs' as string)) as unknown as NodeFs;
+  return fs
+    .readFileSync(NAMESERVER_SAFE_CONFIG_KEYS_PATH, 'utf8')
+    .split('\n')
+    .map((line) => line.trim())
+    .filter((line) => line.startsWith('- '))
+    .map((line) => line.slice(2).trim());
+}
+
 import {
   createNameServer,
   createK8sCert,
@@ -106,6 +132,17 @@ describe('clusterService mock clusters', () => {
     ]);
   });
 
+  it('advertises the NameServer comparison scope the endpoint reports', async 
() => {
+    const safeConfigKeys = await readNameserverSafeConfigKeys();
+
+    // A short list here is not harmless: the drift panel renders comparedKeys 
as chips next to the
+    // differences, so a mock list the service never compares claims a 
comparison the product does
+    // not perform. This pins the mock to the server resource instead of a 
hand-copied subset.
+    expect(safeConfigKeys.length).toBeGreaterThan(2);
+    const result = await getNameServerConfigDiff('cluster-prod');
+    expect(result.comparedKeys).toEqual(safeConfigKeys);
+  });
+
   it('previews mock config updates without mutating the cluster', async () => {
     const before = await getCluster('cluster-prod');
 
diff --git a/web/src/services/clusterService.ts 
b/web/src/services/clusterService.ts
index aa640791f..f4202dd5a 100644
--- a/web/src/services/clusterService.ts
+++ b/web/src/services/clusterService.ts
@@ -126,6 +126,37 @@ export async function getCluster(id: string, instanceId?: 
string): Promise<Clust
   return clusterApi.getCluster(id, instanceId);
 }
 
+/**
+ * The comparison scope of a NameServer drift result. 
NameServerConfigDiffService loads its compared
+ * keys from server/src/main/resources/cluster/nameserver-safe-config-keys.yml 
and returns them as
+ * comparedKeys; the drift panel then renders them as chips, so a mock list 
that names a key the
+ * service never compares - or omits the ones it does - advertises a 
comparison the product does not
+ * perform. Keep this list identical to that resource (clusterService.test.ts 
pins the two together).
+ */
+function nameserverComparedKeys(): string[] {
+  return [
+    'listenPort',
+    'serverWorkerThreads',
+    'serverCallbackExecutorThreads',
+    'serverSelectorThreads',
+    'serverOnewaySemaphoreValue',
+    'serverAsyncSemaphoreValue',
+    'serverChannelMaxIdleTimeSeconds',
+    'serverSocketSndBufSize',
+    'serverSocketRcvBufSize',
+    'serverPooledByteBufAllocatorEnable',
+    'useEpollNativeSelector',
+    'orderMessageEnable',
+    'returnOrderTopicConfigToBroker',
+    'enableControllerInNamesrv',
+    'enableUncleanMasterElection',
+    'notifyMinBrokerIdChanged',
+    'supportActingMaster',
+    'scanNotActiveBrokerInterval',
+    'unRegisterBrokerQueueCapacity',
+  ];
+}
+
 export async function getNameServerConfigDiff(
   clusterId: string,
   instanceId?: string,
@@ -146,7 +177,7 @@ export async function getNameServerConfigDiff(
     driftDetected,
     nodeCount: nodes.length,
     reachableNodeCount: reachableAddresses.length,
-    comparedKeys: ['listenPort', 'serverWorkerThreads', 
'clientRequestThreadPoolNums'],
+    comparedKeys: nameserverComparedKeys(),
     nodes,
     differences: driftDetected
       ? [

Reply via email to