Copilot commented on code in PR #10968:
URL: https://github.com/apache/ozone/pull/10968#discussion_r3737987935


##########
hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/v2/components/tables/bucketsTable.tsx:
##########
@@ -78,6 +79,27 @@ function renderBucketLayout(bucketLayout: BucketLayout) {
   return <Tag color={color}>{bucketLayout}</Tag>;
 };
 
+const REPLICATION_TYPE_LABELS: Record<string, string> = {
+  RATIS: 'Ratis',
+  STAND_ALONE: 'Standalone'
+};

Review Comment:
   `formatReplicationType` maps `STAND_ALONE` to `Standalone`, but 
StandaloneReplicationConfig can serialize `replicationType` as `STANDALONE` (no 
underscore). In that case the column would currently render `STANDALONE-1` 
instead of `Standalone-1`.



##########
hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/__tests__/buckets/BucketsTable.test.tsx:
##########
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { vi } from 'vitest';
+import { render, screen } from '@testing-library/react';
+
+import BucketsTable from '@/v2/components/tables/bucketsTable';
+import { Bucket, BucketsTableProps } from '@/v2/types/bucket.types';
+
+function getBucketWith(
+  name: string,
+  replicationConfigInfo: Bucket['replicationConfigInfo']
+): Bucket {
+  return {
+    volumeName: 'vol1',
+    name,
+    versioning: false,
+    storageType: 'DISK',
+    creationTime: 1728280581608,
+    modificationTime: 1728280581608,
+    usedBytes: 0,
+    usedNamespace: 0,
+    quotaInBytes: -1,
+    quotaInNamespace: -1,
+    owner: 'om',
+    acls: [],
+    bucketLayout: 'FILE_SYSTEM_OPTIMIZED',
+    replicationConfigInfo
+  };
+}
+
+const defaultProps: BucketsTableProps = {
+  loading: false,
+  data: [],
+  handleAclClick: vi.fn(),
+  searchColumn: 'name',
+  searchTerm: '',
+  selectedColumns: [
+    { label: 'Bucket',
+      value: 'name' },
+    { label: 'Volume',
+      value: 'volumeName' },
+    { label: 'Replication Type',
+      value: 'replicationType' }
+  ]
+};
+
+describe('BucketsTable Replication Type column', () => {
+  test('renders the Ratis variant for a Ratis bucket', () => {
+    render(
+      <BucketsTable
+        {...defaultProps}
+        data={[getBucketWith('ratis-bucket', {
+          type: 'RATIS',
+          replicationConfig: {
+            replicationType: 'RATIS',
+            replicationFactor: 'THREE',
+            requiredNodes: 3
+          }
+        })]}
+      />
+    );
+
+    expect(screen.getByText('Ratis-3')).toBeInTheDocument();
+  });
+
+  test('renders the EC variant for an Erasure Coded bucket', () => {
+    render(
+      <BucketsTable
+        {...defaultProps}
+        data={[getBucketWith('ec-bucket', {
+          type: 'EC',
+          replicationConfig: {
+            replicationType: 'EC',
+            codec: 'RS',
+            data: 6,
+            parity: 3,
+            ecChunkSize: 1048576,
+            requiredNodes: 9
+          }
+        })]}
+      />
+    );
+
+    expect(screen.getByText('RS-6-3-1024k')).toBeInTheDocument();
+  });
+
+  test('renders the Standalone variant for a single replica bucket', () => {
+    render(
+      <BucketsTable
+        {...defaultProps}
+        data={[getBucketWith('standalone-bucket', {
+          type: 'STAND_ALONE',
+          replicationConfig: {
+            replicationType: 'STAND_ALONE',
+            replicationFactor: 'ONE',
+            requiredNodes: 1
+          }
+        })]}
+      />
+    );
+
+    expect(screen.getByText('Standalone-1')).toBeInTheDocument();
+  });

Review Comment:
   The backend can emit Standalone buckets with nested `replicationType: 
"STANDALONE"` (no underscore). This test currently only covers the 
`STAND_ALONE` spelling, so it won't catch regressions where the UI displays 
`STANDALONE-1`.



##########
hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/v2/types/bucket.types.ts:
##########
@@ -37,6 +37,35 @@ export const BucketLayoutTypeList = [
 export type BucketLayout = typeof BucketLayoutTypeList[number];
 
 
+// Corresponds to the serialized 
org.apache.hadoop.hdds.client.RatisReplicationConfig
+// and StandaloneReplicationConfig
+type BucketRatisReplicationConfig = {
+  replicationType: 'RATIS' | 'STAND_ALONE';
+  replicationFactor: string;
+  requiredNodes: number;
+}

Review Comment:
   StandaloneReplicationConfig serializes the nested `replicationType` as 
`"STANDALONE"` (see 
org.apache.hadoop.hdds.client.StandaloneReplicationConfig#replicationType()), 
but this type only allows `STAND_ALONE`. That mismatch can cause the UI to 
render `STANDALONE-1` (or fail type-checking when adding fixtures) instead of 
the intended `Standalone-1`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to