Skip to content

Commit a648d5a

Browse files
committed
fix:Optimize CHANGES.md、unit tests、usage documentation
1 parent 597242a commit a648d5a

6 files changed

Lines changed: 11 additions & 20 deletions

File tree

CHANGES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Apollo 2.4.0
1111
* [Fix: Resolve issues with duplicate comments and blank lines in configuration management](https://github.com/apolloconfig/apollo/pull/5232)
1212
* [Fix link namespace published items show missing some items](https://github.com/apolloconfig/apollo/pull/5240)
1313
* [Feature: Add limit and whitelist for namespace count per appid+cluster](https://github.com/apolloconfig/apollo/pull/5228)
14-
* [Feature added limit the number of items under a single namespace](https://github.com/apolloconfig/apollo/pull/5228)
14+
* [Feature add limit for items count per namespace](https://github.com/apolloconfig/apollo/pull/5227)
1515

1616
------------------
1717
All issues and pull requests are [here](https://github.com/apolloconfig/apollo/milestone/15?closed=1)

apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ItemController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public ItemDTO create(@PathVariable("appId") String appId,
8484
if (bizConfig.isItemNumLimitEnabled()) {
8585
int itemCount = itemService.findNonEmptyItemCount(entity.getNamespaceId());
8686
if (itemCount >= bizConfig.itemNumLimit()) {
87-
throw new BadRequestException("current namespace item count=[" + itemCount + "], single namespace max allow count=[ " + bizConfig.itemNumLimit() + "]");
87+
throw new BadRequestException("The maximum number of items (" + bizConfig.itemNumLimit() + ") for this namespace has been reached. Current item count is " + itemCount + ".");
8888
}
8989
}
9090

apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ItemSetService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public ItemChangeSets updateSet(String appId, String clusterName,
7575
int deleteItemCount = (int) changeSet.getDeleteItems().stream().filter(item -> !StringUtils.isEmpty(item.getKey())).count();
7676
itemCount = itemCount + createItemCount - deleteItemCount;
7777
if (itemCount > bizConfig.itemNumLimit()) {
78-
throw new BadRequestException("current namespace item count=[" + itemCount + "], single namespace max allow count=[ " + bizConfig.itemNumLimit() + "]");
78+
throw new BadRequestException("The maximum number of items (" + bizConfig.itemNumLimit() + ") for this namespace has been reached. Current item count is " + itemCount + ".");
7979
}
8080
}
8181

apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/ItemSetServiceTest.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,13 @@
2727
import com.ctrip.framework.apollo.common.exception.BadRequestException;
2828
import org.junit.Assert;
2929
import org.junit.Test;
30-
import org.mockito.Mock;
3130
import org.springframework.beans.factory.annotation.Autowired;
31+
import org.springframework.boot.test.mock.mockito.MockBean;
3232
import org.springframework.test.context.jdbc.Sql;
33-
import org.springframework.test.util.ReflectionTestUtils;
3433

3534
public class ItemSetServiceTest extends AbstractIntegrationTest {
3635

37-
@Mock
36+
@MockBean
3837
private BizConfig bizConfig;
3938

4039
@Autowired
@@ -50,7 +49,6 @@ public class ItemSetServiceTest extends AbstractIntegrationTest {
5049
@Sql(scripts = "/sql/clean.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
5150
public void testUpdateSetWithoutItemNumLimit() {
5251

53-
ReflectionTestUtils.setField(itemSetService, "bizConfig", bizConfig);
5452
when(bizConfig.isItemNumLimitEnabled()).thenReturn(false);
5553
when(bizConfig.itemNumLimit()).thenReturn(5);
5654

@@ -76,7 +74,6 @@ public void testUpdateSetWithoutItemNumLimit() {
7674
@Sql(scripts = "/sql/clean.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
7775
public void testUpdateSetWithItemNumLimit() {
7876

79-
ReflectionTestUtils.setField(itemSetService, "bizConfig", bizConfig);
8077
when(bizConfig.isItemNumLimitEnabled()).thenReturn(true);
8178
when(bizConfig.itemNumLimit()).thenReturn(5);
8279

@@ -107,7 +104,6 @@ public void testUpdateSetWithItemNumLimit() {
107104
@Sql(scripts = "/sql/clean.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
108105
public void testUpdateSetWithItemNumLimit2() {
109106

110-
ReflectionTestUtils.setField(itemSetService, "bizConfig", bizConfig);
111107
when(bizConfig.isItemNumLimitEnabled()).thenReturn(true);
112108
when(bizConfig.itemNumLimit()).thenReturn(5);
113109

docs/en/portal/apollo-user-guide.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -531,21 +531,17 @@ Starting from version 2.4.0, apollo-portal provides the function of checking the
531531
![item-num-limit](https://cdn.jsdelivr.net/gh/apolloconfig/apollo@master/doc/images/namespace-num-limit-white.png)
532532

533533

534-
535-
## 6.4 单个命名空间下的配置项数量限制
534+
## 6.5 Limitation on the number of configuration items in a single namespace
536535
Starting from version 2.4.0, apollo-portal provides the function of limiting the number of configuration items in a single namespace. This function is disabled by default and needs to be enabled by configuring the system `item.num.limit.enabled`. At the same time, the system parameter `item.num.limit` is provided to dynamically configure the upper limit of the number of items in a single Namespace.
537536

538537
**Setting method:**
539538
1. Log in to the Apollo Configuration Center interface with a super administrator account
540539
2. Go to the `Administrator Tools - System Parameters - ConfigDB Configuration Management` page and add or modify the `item.num.limit.enabled` configuration item to true/false to enable/disable this function.
541540

542-
[//]: # ( ![item-num-limit-enabled](https://cdn.jsdelivr.net/gh/apolloconfig/apollo@master/doc/images/item-num-limit-enabled.png))
543-
![item-num-limit-enabled](../../../doc/images/item-num-limit-enabled.png)
541+
![item-num-limit-enabled](https://cdn.jsdelivr.net/gh/apolloconfig/apollo@master/doc/images/item-num-limit-enabled.png)
544542
3. Go to the `Admin Tools - System Parameters - ConfigDB Configuration Management` page and add or modify the `item.num.limit` configuration item to configure the upper limit of the number of items under a single Namespace.
545543

546-
[//]: # ( ![item-num-limit](https://cdn.jsdelivr.net/gh/apolloconfig/apollo@master/doc/images/item-num-limit.png))
547-
![item-num-limit](../../../doc/images/item-num-limit.png)
548-
544+
![item-num-limit](https://cdn.jsdelivr.net/gh/apolloconfig/apollo@master/doc/images/item-num-limit.png)
549545

550546

551547
# VII. Best practices

docs/zh/portal/apollo-user-guide.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -509,12 +509,11 @@ Apollo从1.6.0版本开始增加访问密钥机制,从而只有经过身份验
509509
1. 用超级管理员账号登录到Apollo配置中心的界面
510510
2. 进入`管理员工具 - 系统参数 - ConfigDB 配置管理`页面新增或修改`item.num.limit.enabled`配置项为true/false 即可开启/关闭此功能
511511

512-
[//]: # ( ![item-num-limit-enabled](https://cdn.jsdelivr.net/gh/apolloconfig/apollo@master/doc/images/item-num-limit-enabled.png))
513-
![item-num-limit-enabled](../../../doc/images/item-num-limit-enabled.png)
512+
![item-num-limit-enabled](https://cdn.jsdelivr.net/gh/apolloconfig/apollo@master/doc/images/item-num-limit-enabled.png)
513+
514514
3. 进入`管理员工具 - 系统参数 - ConfigDB 配置管理`页面新增或修改`item.num.limit`配置项来配置单个Namespace下的item数量上限值
515515

516-
[//]: # ( ![item-num-limit](https://cdn.jsdelivr.net/gh/apolloconfig/apollo@master/doc/images/item-num-limit.png))
517-
![item-num-limit](../../../doc/images/item-num-limit.png)
516+
![item-num-limit](https://cdn.jsdelivr.net/gh/apolloconfig/apollo@master/doc/images/item-num-limit.png)
518517

519518

520519

0 commit comments

Comments
 (0)