Skip to content

Commit

Permalink
fix primary shards count and replica validation
Browse files Browse the repository at this point in the history
Signed-off-by: Shenoy Pratik <[email protected]>
  • Loading branch information
ps48 committed Oct 4, 2023
1 parent bd0e593 commit 72bec36
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ describe('validatePrimaryShardCount', () => {

describe('validateReplicaCount', () => {
it('should return an array with an error message when replicaCount is less than 1', () => {
expect(validateReplicaCount(0)).toEqual(['Replica count should be greater than 0']);
expect(validateReplicaCount(-1)).toEqual(['Replica count should be greater than 0']); // form throws validation error, doesn't allow user to proceed
expect(validateReplicaCount(-1)).toEqual(['Replica count should be equal or greater than 0']); // form throws validation error, doesn't allow user to proceed
});

it('should return an empty array when replicaCount is greater than or equal to 1', () => {
expect(validateReplicaCount(0)).toEqual([]);
expect(validateReplicaCount(1)).toEqual([]);
expect(validateReplicaCount(5)).toEqual([]);
expect(validateReplicaCount(100)).toEqual([]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const CreateAcceleration = ({
},
},
accelerationIndexName: ACCELERATION_DEFUALT_SKIPPING_INDEX_NAME,
primaryShardsCount: 5,
primaryShardsCount: 1,
replicaShardsCount: 1,
refreshType: 'auto',
checkpointLocation: undefined,
Expand Down
2 changes: 1 addition & 1 deletion public/components/acceleration/create/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const validatePrimaryShardCount = (primaryShardCount: number) => {
};

export const validateReplicaCount = (replicaCount: number) => {
return replicaCount < 1 ? ['Replica count should be greater than 0'] : [];
return replicaCount < 0 ? ['Replica count should be equal or greater than 0'] : [];
};

export const validateRefreshInterval = (refreshType: string, refreshWindow: number) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const IndexSettingOptions = ({
},
];

const [primaryShards, setPrimaryShards] = useState(5);
const [primaryShards, setPrimaryShards] = useState(1);
const [replicaCount, setReplicaCount] = useState(1);
const [refreshTypeSelected, setRefreshTypeSelected] = useState(autoRefreshId);
const [refreshWindow, setRefreshWindow] = useState(1);
Expand Down Expand Up @@ -116,7 +116,7 @@ export const IndexSettingOptions = ({
/>
<EuiFormRow
label="Number of primary shards"
helpText="Specify the number of primary shards for the index. Default is 5. The number of primary shards cannot be changed after the index is created."
helpText="Specify the number of primary shards for the index. Default is 1. The number of primary shards cannot be changed after the index is created."
isInvalid={hasError(accelerationFormData.formErrors, 'primaryShardsError')}
error={accelerationFormData.formErrors.primaryShardsError}
>
Expand Down

0 comments on commit 72bec36

Please sign in to comment.