Compare commits

...

229 Commits

Author SHA1 Message Date
zhuyijun
7d9f4b5234 fix:处理脚本编码问题 2024-09-04 17:09:50 +08:00
zhuyijun
b6b58ad584 新增DM的TrustedDmFunctionEnum枚举 2024-08-22 18:14:44 +08:00
zhuyijun
528c33a9fb 适配2.4.1达梦 2024-08-21 16:37:53 +08:00
杨翊 SionYang
106a1d57dd
Upgrade to 2.4.1 (#12493) 2024-08-15 17:58:58 +08:00
杨翊 SionYang
bbed5a4eb7
[Refactor] Remove KvStorage and ConsistencyService. (#12489)
* Remove KvStorage and ConsistencyService.

* Fix switch manager dead lock until timeout.

* Ignore env vote leader effect in IT.

* Wait leader voted before start do test case.
2024-08-15 17:10:05 +08:00
杨翊 SionYang
7133411bc2
Enhance derby sql to support limit sql. (#12490) 2024-08-15 16:05:47 +08:00
若念莫念
c56c4153eb
[ISSUE #12466] serviceMetadata environment variables config (#12477)
* FIX [ISSUE #12446] macInstance 补充日志

* UPDATE [ISSUE #12466] serviceMetadata environment variables config

* fixed DefaultParamChecker and DefaultParamCheckerTest codeStyle
2024-08-12 09:59:37 +08:00
杨翊 SionYang
bcbdb863ba
Try to fix codecov lose for PR. (#12465)
* Try to fix codecov lose for PR.

* Try to fix codecov lose for PR.

* Try to fix codecov lose for PR.

* Try to fix codecov lose for PR.

* Try to fix codecov lose for PR.

* Try to fix codecov lose for PR.

* Try to fix codecov lose for PR.
2024-08-09 11:20:03 +08:00
gongycn
5d8d81aae4
Resolve the Hessian package conflict issue. (#12449) 2024-08-05 10:01:09 +08:00
若念莫念
4e42fe6bad
FIX [ISSUE #12446] macInstance 补充日志 (#12447) 2024-08-01 14:59:07 +08:00
kangzhao
3967c91d1a
修复mem计算逻辑 (#12401)
* 修复mem计算逻辑

* 修复mem计算逻辑单测

* fix ci
2024-07-31 14:29:25 +08:00
chaos
cfa3312582
fix: 关闭控制台登录时请求的Authorization为null (#12442) 2024-07-31 14:04:10 +08:00
chen10038
525f3bf43f
修改: Fix 12301。 (#12310) 2024-07-31 13:47:59 +08:00
laokou
48a0f8b0fb
删除console多余的@EnableScheduling (#12386)
* 删除console多余的@EnableScheduling

* 删除console多余的@EnableScheduling
2024-07-29 10:46:35 +08:00
Plato
927fbfd110
[ISSUE #11887] add some tips for upgrade (#12434) 2024-07-29 10:34:40 +08:00
Sitosoym
3e28b586bb
fix default sql in the comment to be consistent with the implementation (#12324) 2024-07-24 16:11:01 +08:00
阿魁
631babe1e2
[IT]Adjust config module base and auth ITs for Checkstyle compliance. (#12376)
* [IT]Adjust core module auth integration tests to meet checkstyle requirements.

* [IT]Adjust config module base integration tests to meet checkstyle requirements.
2024-07-24 16:10:16 +08:00
阿魁
c00d863242
[IT]Adjust config module config integration tests to meet checkstyle requirements. (#12377) 2024-07-24 16:09:51 +08:00
阿魁
0f023a270f
[IT]Refactor naming module base ITs for Checkstyle compliance. (#12378) 2024-07-24 16:09:34 +08:00
Sunrisea
6122a9afc4
Fix the bug of ConnectionControlManager (#12399) 2024-07-24 16:05:34 +08:00
Ikko Eltociear Ashimine
6c6a22b4cc
Update README.md (#12392)
Github -> GitHub
2024-07-24 14:59:12 +08:00
blake.qiu
96a93189c3
feat(#12405): The LDAP default password is a fixed value 'nacos' and cannot be customized. (#12406) 2024-07-24 14:50:49 +08:00
徐晓伟
fbfa39d06d
🔧 fix pom.xml version (#12417)
https://github.com/alibaba/nacos/issues/12416
2024-07-24 14:42:14 +08:00
July
f4a4ab2eb5
fix beta publish (#12411) 2024-07-24 14:30:33 +08:00
Sunrisea
7e577811a7
[ISSUE#12359]Refactoring the historical configuration cleanup strategy with SPI (#12367)
* 历史配置清理逻辑SPI改造

* 添加单元测试

* 单元测试fix

* 单元测试fix

* 优化spi实现

* 优化日志打印
2024-07-23 16:42:29 +08:00
杨翊 SionYang
197795a854
Fix #12395, use request context replace session depend. (#12398) 2024-07-22 13:32:41 +08:00
杨翊 SionYang
298f36f145
Revert "Add an id primary key column to both the roles and permissions tables.(mysql-schema.sql) (#12206)" (#12396)
This reverts commit 5d871967ea.
2024-07-22 12:10:17 +08:00
杨翊 SionYang
4e776256eb
Upgrade to 2.4.0 (#12384) 2024-07-19 13:46:19 +08:00
杨翊 SionYang
ad83ff0c75
Develop support ram info switch (#12382)
* add new property to support agent situation.

* for checkstyle.

* Upgrade cheery pick ut to junit5.

* add ignored lefthook.yml.

* add ignored lefthook.yml.
2024-07-19 11:22:35 +08:00
杨翊 SionYang
ed7bd03d4c
Close derby ops api default. (#12372)
* Close derby ops api default.

* Fix unit test.
2024-07-18 15:30:15 +08:00
杨翊 SionYang
fc5e502243
Upgrade grpc to 1.64.2 (#12369)
* Upgrade grpc to 1.64.1

* add grpc-util compile scope.

* add grpc-testing
2024-07-18 11:31:58 +08:00
blake.qiu
1879c81edd
fix(#12333): fixed auth Plugin resource parser can't parser v2 config openAPI namespaceId. (#12336)
fix(#12333): fixed auth Plugin resource parser can't parser v2 config openAPI namespaceId.
2024-07-18 11:17:42 +08:00
阿魁
4f827ca0d9
Adjust integration tests for common modules in the core module to comply with checkstyle. (#12349)
* Fix exception code error.(#10925)

* [IT]Adjust integration tests for ability, base, and client modules in the core module to comply with checkstyle.

* [IT]Optimize the class naming.

* [IT]Adjust integration tests for common modules in the core module to comply with checkstyle.
2024-07-18 11:15:38 +08:00
阿魁
c717538bd7
[IT]Adjust integration tests for cluster,code,smoke modules in the core module to comply with checkstyle. (#12350) 2024-07-18 11:12:14 +08:00
dingjs
8664a1aec6
fix [ISSUE #12323] , using the project's logback packagingData configuration instead of logback-nacos.xml's packagingData configuration (#12360) 2024-07-18 11:10:09 +08:00
HMYDK
a6047fae45
Remove the accessToken from the URL. (#12353) 2024-07-18 09:41:12 +08:00
blake.qiu
47d913de05
feat(#12355): Record the cost of ConfigDump in Prometheus. (#12356) 2024-07-18 09:40:12 +08:00
阿魁
9d0a48d54f
[IT]Adjust core module auth integration tests to meet checkstyle requirements. (#12368) 2024-07-18 09:30:26 +08:00
HMYDK
6c05ad5497
[ISSUE #12282]Fix the issue where monitoring data cannot be found through the IP dimension in the ListeningQuery (#12315) 2024-07-15 14:13:43 +08:00
阿魁
de5ade75c8
Adjust integration tests for ability, base, and client modules in the core module to comply with checkstyle. (#12335)
* Fix exception code error.(#10925)

* [IT]Adjust integration tests for ability, base, and client modules in the core module to comply with checkstyle.

* [IT]Optimize the class naming.
2024-07-15 11:17:48 +08:00
杨翊 SionYang
2233e6556c
Develop refactor request context (#12331)
* Add RequestContext and RequestContextHolder.

* build RequestContext when request start.

* Refactor ClientAttributesFilter with RequestContext.

* InstanceController get client ip from request context.

* SubscribeServiceRequestHandler get app from requestcontext.

* config http api support use request context get user, app and source ip.

* Rename nacos request context filter.

* Unified naming request get source ip by request context.

* For checkstyle.
2024-07-10 16:54:19 +08:00
shalk(xiao kun)
2aa9fc51bc
fix unexpect exception from NetworkInterface.ifUp (#12325) 2024-07-10 16:52:23 +08:00
blake.qiu
8aba80d3c1
fix(#12231): When inserting and updating configurations in the database, the time-related field values need to be set using the time obtained from the database's built-in time function. (#12244) 2024-07-09 11:19:22 +08:00
hth
e8e8cd29c0
add some UT for default auth plugin (#12318) 2024-07-08 10:48:51 +08:00
misakacoder
97162438f7
[ISSUE #12219] 修复nacos-client中config的ServerListManager解析endpoint失败问题 (#12220)
* [ISSUE #12219] 修复nacos-client中config的ServerListManager解析endpoint失败问题

* [ISSUE #12219] 修复nacos-client中config的ServerListManager解析endpoint失败问题
2024-07-01 13:53:59 +08:00
Thomas Lee
92a3d17681
[ISSUE #12196] FIX prometheus http sd invalid label names (#12239)
* prometheus http sd: fix invalid label names

* Update PrometheusUtils.java
2024-07-01 13:53:32 +08:00
shalk(xiao kun)
b8d13e0557
[ISSUE #12207] fix disk failover datasource not keep status (#12188)
* fix disk failover datasource not keep status

* fix style

* fix DiskFailoverDataSource
2024-06-26 17:50:45 +08:00
shalk(xiao kun)
8034da88e5
[ISSUE #12016] upgrade to junit5 and remove junit4 (#12280)
* clean junit4

* clean junit4

* clean some test dep; fix scope

* fix test compile
2024-06-26 17:39:08 +08:00
阿魁
108f51083f
Add RpcServerSslContextRefresherHolder unit tests. (#12281)
* Fix exception code error.(#10925)

* [Unit test]Add RpcServerSslContextRefresherHolder unit tests.

* [Unit test]Fix bug.
2024-06-26 17:37:51 +08:00
shalk(xiao kun)
8575e84ee4
fix nacos client dependencies tree without grpc package (#12266) 2024-06-24 13:50:29 +08:00
misakacoder
29c28bd01e
[ISSUE #12246] 配置列表和服务列表的总数显示国际化 (#12276) 2024-06-24 13:49:43 +08:00
HMYDK
27da090b7c
[#12235]Fix the incorrect logging format in the ResponseExceptionHandler of the naming module. (#12236) 2024-06-24 09:41:25 +08:00
shalk(xiao kun)
3b2f787d61
[ISSUE #12227] upgrade module test from junit4 to junit5 (#12251)
* upgrade module naocs-test from junit4 to junit5

* fix test/core-test

* fix some test

* fix ci
2024-06-24 09:38:38 +08:00
nov.lzf
63dc87a30c
add endpoint cluster name for config & naming server list manager (#12253) 2024-06-24 09:37:41 +08:00
HMYDK
5d871967ea
Add an id primary key column to both the roles and permissions tables.(mysql-schema.sql) (#12206) 2024-06-17 15:42:37 +08:00
HMYDK
e192e25d9d
Add total record count display in pagination (TotalRender). (#12203) 2024-06-17 14:26:13 +08:00
shalk(xiao kun)
cd8e8583d8
upgrade module naocs-persistence from junit4 to junit5 (#12228) 2024-06-17 14:18:32 +08:00
shalk(xiao kun)
21bfac76e7
upgrade module naocs-plugin from junit4 to junit5 (#12229) 2024-06-17 14:08:09 +08:00
shalk(xiao kun)
ab6591ac83
upgrade module naocs-plugin-impl from junit4 to junit5 (#12230) 2024-06-17 14:07:37 +08:00
misakacoder
833e6ca59a
[ISSUE #12180] 修复克隆和导入配置没有记录操作人 (#12181) 2024-06-12 09:27:48 +08:00
shalk(xiao kun)
7590a4eb12
fix: use nacos properties in CacheDirUtil (#12186) 2024-06-12 09:26:59 +08:00
杨翊 SionYang
d68b904f93
Update console header link to new nacos.io. (#12177) 2024-06-05 10:45:24 +08:00
misakacoder
8a03485fa8
[ISSUE #12168] 修复系统语言切换至英文后,权限控制-角色管理页面的查询条件的label还显示的是中文 (#12169)
* [ISSUE #12146] 修复当对操作类型为删除的配置进行回滚时,操作类型不显示问题

* [ISSUE #12168] 修复系统语言切换至英文后,权限控制-角色管理页面的查询条件的label还显示的是中文
2024-06-03 17:56:08 +08:00
杨翊 SionYang
07d92ffb3e
Do some refactor for naming notify event. (#12167) 2024-06-03 15:55:46 +08:00
杨翊 SionYang
7cdf224157
Enhance nacos client init properties logger. (#12166) 2024-06-03 13:32:08 +08:00
Kurok1
da78aeea0d
[ISSUE #12130] add metadata as labels in prometheus http sd (#12144)
* add metadata as labels in prometheus http sd

* fix style
2024-06-03 10:41:10 +08:00
misakacoder
d1bd44625f
[ISSUE #12146] 修复当对操作类型为删除的配置进行回滚时,操作类型不显示问题 (#12164) 2024-06-03 10:40:32 +08:00
Leo Han
19c3adcbb6
[ISSUE#12074] Add Python sample for nacos (#12127)
* Add Python sample for nacos

* Delete example/src/main/python directory

Remove python sample

* Update for nacos show python  codeing
2024-06-03 10:13:22 +08:00
杨翊 SionYang
d212a52bc9
Merge pull request #12165 from alibaba/summer-ospp#10374
Summer ospp#10374
2024-06-03 10:11:53 +08:00
KomachiSion
0d8b04b470 For checkstyle. 2024-06-03 09:35:35 +08:00
KomachiSion
96ee0f37e6 Fix UT after sync newest branch 2024-05-31 16:59:43 +08:00
KomachiSion
5f7801b341 Merge branch 'refs/heads/upstream-develop' into summer-ospp#10374
# Conflicts:
#	client/src/main/java/com/alibaba/nacos/client/naming/NacosNamingService.java
#	client/src/main/java/com/alibaba/nacos/client/naming/cache/ServiceInfoHolder.java
#	client/src/test/java/com/alibaba/nacos/client/naming/NacosNamingServiceTest.java
#	client/src/test/java/com/alibaba/nacos/client/naming/event/InstancesChangeEventTest.java
#	client/src/test/java/com/alibaba/nacos/client/naming/event/InstancesChangeNotifierTest.java
2024-05-31 15:21:48 +08:00
shalk(xiao kun)
04f9b86e45
upgrade module naocs-core from junit4 to junit5 (#12134) 2024-05-31 13:42:53 +08:00
杨翊 SionYang
79a5aa5eb6
Support aliyun ram v4 signature method. (#12162)
* Nacos client ram plugin support aliyun v4 signature.

* Add V4 sign UT

* For checkstyle.
2024-05-31 13:30:55 +08:00
shalk(xiao kun)
67da6d1b5f
upgrade module naocs-log from junit4 to junit5 (#12156) 2024-05-31 11:50:03 +08:00
shalk(xiao kun)
25155e480a
[ISSUE #12158] module naming upgrade to junit5 (#12159)
* upgrade module naocs-naming from junit4 to junit5

* upgrade module naocs-naming from junit4 to junit5
2024-05-31 11:49:42 +08:00
杨翊 SionYang
857e6113c4
No need init password when auth disabled. (#12153) 2024-05-31 09:24:21 +08:00
xpy01xpy
47786e6c0b
[ISSUE#11957] Fix init password for nacos username en-us (#12150)
* fix:add en

* build code

* fix:all state

* build code

* feat:register / request
2024-05-30 18:04:41 +08:00
杨翊 SionYang
98edf22e8c
Change duplicate create admin user api return code to 4xx. (#12149) 2024-05-30 15:28:29 +08:00
xpy01xpy
0a797223c0
[ISSUE#11957] Console support init password for nacos username (#12148)
* feat:add register pagg

* fix:i18n

* console-ui build

* fix

* fix
2024-05-30 14:53:41 +08:00
shalk(xiao kun)
bc039bc125
upgrade module naocs-console from junit4 to junit5 (#12136) 2024-05-29 10:43:13 +08:00
shalk(xiao kun)
6fa3069b7e
[issue #12043] module client refact unit test to junit5 (#12044)
* refact(client): remove junit4 to junit5

* fix code style

* format with code style

* fix code style

* fix codestyle
2024-05-24 10:15:17 +08:00
hth
992f10a1d6
[ISSUE #11957] AuthModule add admin exist (#12066)
* AuthModule add admin exist

* test fix

* fix state

* add state cache

* rename to auth_admin_request

* test fix

* auth_admin_request default value fix

* fix admin request
2024-05-24 10:14:40 +08:00
杨翊 SionYang
6bee5c47a9
update codecov token. (#12121) 2024-05-20 14:32:43 +08:00
shalk(xiao kun)
366c88e4d6
[issue #12081] module api upgrade junit4 to junit5 (#12082)
* refact(api): remove junit4 to junit5

* format with code style
2024-05-20 11:14:33 +08:00
Zachary
9363a088f0
[ISSUE #12060] fix too large ttl when auth disabled (#12090)
* [ISSUE #12060]  fix too large ttl when auth disabled

fix issue #12060

1. fix too large ttl when auth disabled
2. generate a valid token when key is valid even if auth disabled

* [ISSUE #12060]  add unit test

* [ISSUE alibaba#12060] fix style issue
2024-05-20 11:12:24 +08:00
shalk(xiao kun)
35e3994bcb
[ISSUE #12113] upgrade module naocs-common from junit4 to junit5 (#12116)
* upgrade module naocs-common from junit4 to junit5

* fix checkstyle
2024-05-20 11:10:23 +08:00
shalk(xiao kun)
94bf8661ad
[ISSUE #12114] upgrade module naocs-config from junit4 to junit5 (#12117)
* upgrade module naocs-config from junit4 to junit5

* fix checkstyle
2024-05-20 10:59:47 +08:00
shalk(xiao kun)
26176ddb3c
upgrade module naocs-consistency from junit4 to junit5 (#12118) 2024-05-20 10:46:53 +08:00
shalk(xiao kun)
dc0e46e9f9
upgrade module naocs-auth from junit4 to junit5 (#12105) 2024-05-16 09:41:05 +08:00
shalk(xiao kun)
67b672251e
upgrade module naocs-sys from junit4 to junit5 (#12107) 2024-05-16 09:40:12 +08:00
阿魁
5169f06654
Support TLS Grpc communication between clusters. (#11549)
* Fix exception code error.(#10925)

* [ISSUE #11456]Add RpcClusterClientTlsConfig.java.

* [ISSUE #11456]Add cluster rpc tls config.

* [ISSUE #11456]Add RpcClusterClientTlsConfig UT.

* [ISSUE #11456]Add cluster server tls.

* [ISSUE #11456]Remove supportCommunicationTypes.

* [ISSUE #11456]Fix unit testing and indentation handling

* [ISSUE #11456]Indentation handling

* [ISSUE #11456]Fix unit test and rpc constants.

* [ISSUE #11456]Fix unit test.

* [ISSUE #11456]Optimize code.

* [ISSUE #11456]Fix check style.

* [ISSUE #11456]Add unit test.

* [ISSUE #11456]Fix check style.

* [ISSUE #11456]Update unit test.

* [ISSUE #11456]Fix unit test.

* [ISSUE #11456]Add License.

* [ISSUE #11456]Fix unit test.

* [ISSUE #11456]Fix unit test.

* [ISSUE #11456]Rename class.

* [ISSUE #11456]Optimize code.

* [ISSUE #11456]Handling indentation issues.

* [ISSUE #11456]Handling indentation issues.

* [ISSUE #11456]Handling indentation issues.

* [ISSUE #11456]Optimize code.

* [ISSUE #11456]Fix unit test.

* [ISSUE #11456]Fix unit testing and compatibility handling.

* [ISSUE #11456]Support TLS GRPC communication between clusters.

* [ISSUE #11456] Fix bugs.

* [ISSUE #11456]Fix bugs.

* [ISSUE #11456]Adjusting parameter names (compatibility considerations).

* [ISSUE #11456]Resolve conflict.

* [ISSUE #11456]Remove ProtocolNegotiatorBuilderManager and abstract ProtocolNegotiatorBuilderSingleton.

* [ISSUE #11456]Remove CommunicationType.java.

* [ISSUE #11456]Optimize code.

* [ISSUE #11456]Revert author.

* Splitting RpcTlsConfigFactory.

* Split RpcConstants.

* Divided RpcTlsConfigFactory, adjusted cluster parameters to "nacos.remote.peer.rpc.tls".

* check style.

* check style.

* unit test.
2024-05-15 11:13:29 +08:00
shenyao
6fe43637c0
[ISSUE #11967] Can not aquire the specific config (#12025)
* [ISSUE #11967] Can not aquire the specific config

* [ISSUE #11967] Can not aquire the specific config

* [ISSUE #11967] Can not aquire the specific config

* [ISSUE #11967] Can not aquire the specific config

* [ISSUE #11967] Can not aquire the specific config
2024-05-15 11:04:32 +08:00
mikolls
9a6ec0ca3d
[ISSUE#12022] Fix nacos datasource plugin ClassCastException bug (#12… (#12031)
* [ISSUE#12022] Fix nacos datasource plugin ClassCastException bug (#12022)

* [ISSUE#12022] Fix nacos datasource plugin ClassCastException bug (#12022)

* [ISSUE#12022] Fix nacos datasource plugin ClassCastException bug (#12022)

* [ISSUE#12022] Fix nacos datasource plugin ClassCastException bug (#12022)

* [ISSUE#12022] Fix MapperManagerTest test (#12022)

* [ISSUE#12022] Fix MapperManagerTest test (#12022)
2024-05-15 10:56:54 +08:00
Happy-26
15c9663d31
[ISSUE #12072] Add logic that does not impose any limit when totalCountLimit is less than 0. (#12073)
* Fixed an issue where the maximum number of anti-fragile plug-ins implemented by default in Nacos is one more than the actual number of connections.

* bug fix : 修改删除空服务实例时,服务名和分组名没有正确解析的问题

* Update ConfigChangeAspect.java

修改configChangeRequest.setArg()的key为serviceType

* Update ConfigChangeAspect.java

* Update ConfigChangeRequest.java

* Update NacosConnectionControlManager.java

Add logic to not impose any limit when totalCountLimit equals -1.

* Update NacosConnectionControlManager.java

* Update NacosConnectionControlManagerTest.java

Add unit test cases when LimitCount is less than 0

* Update NacosConnectionControlManager.java

Modify comment
2024-05-15 10:39:26 +08:00
shalk(xiao kun)
4e2bcb9277
module address upgrade junit4 to junit5 (#12084) 2024-05-15 10:37:53 +08:00
JianweiWang
47dd078545
fix #11984 (#12091) 2024-05-14 13:37:08 +08:00
Zac
b047a90fba
[issue 12062]bugfix (#12086) 2024-05-11 13:38:45 +08:00
xYohn
7c461fdf67
[ISSUE #12046] fix console-ui bug when using encryption-plugin (#12061)
* #12046 console-ui should not offer encryptedDataKey field to API

* #12046 when containing encryptedDataKey,it should not execute encryption in v2 API (same as the v1 API)
2024-05-07 16:18:36 +08:00
杨翊 SionYang
ed64d1f055
Depend nacos logback adapter directly. (#12059) 2024-05-06 14:15:10 +08:00
caoyanan666
99807358df
feat(develop): [ISSUES #12013] startup.sh support environment CUSTOM_NACOS_MEMORY (#12014)
* use DISABLE_NACOS_DEFAULT_MEMORY_SETTING

* use CUSTOM_NACOS_MEMORY

* Code optimization

* remove unuse

* startup.cmd support CUSTOM_NACOS_MEMORY environment variable

---------

Co-authored-by: caoyanan <caoyanan@growingio.com>
2024-05-06 11:49:19 +08:00
shenyao
8d6f87eda6
[ISSUE #11926] The abnormal exit mechanism does not take effect (#12045) 2024-05-06 11:44:28 +08:00
hth
70ad2eb991
[ISSUE #11957] Remove default password (#11991)
* Remove default password

* admin role check fix

* remove tmp admin
2024-04-29 10:04:00 +08:00
shalk(xiao kun)
b2e506d7fe
[WIP] add junit jupiter (#12024)
* add junit5 in compatible mode

* add junit5 jupiter and mockito jupiter
2024-04-29 09:51:28 +08:00
shalk(xiao kun)
b016e79dfe
fix client log config (#12040) 2024-04-29 09:34:53 +08:00
杨翊 SionYang
da3e88b3d4
[ISSUE#11956] Fix logging module old bugs (#12011)
* Remove log4j dependencies from nacos-client.

* Fix logback listener don't add to context.

* Fix can't adapter low version logback below 1.1.10.

* For checkstyle.
2024-04-24 18:07:34 +08:00
shalk(xiao kun)
de10c07146
clean code remove unused dependency javatuple (#11976) 2024-04-24 15:51:58 +08:00
cxhello
17dea53d20
fix: CVE-2024-22262 Upgrade Spring to 5.3.34 (#11980) (#12003) 2024-04-24 15:44:30 +08:00
杨翊 SionYang
4d30b042ee
[ISSUE #11956] Move logback 12 and log4j2 adapter to single module. (#11996)
* Move some basic logging classes into common module.

* Move logback 12 version adapter to single module.

* For checkstyle.

* Enhance logger adapter pom.

* Refactor the adapter initialization logic to avoid spi loader error.

* Move log4j2 logger adapter to single module.

* Fix the ut cover and create useless dir.
2024-04-23 10:24:38 +08:00
cx
720519b1dc
[ISSUE #11994]修复HttpRequestInstanceBuilderTest出现的空指针问题,优化SnowFlakeInstanceIdGenerator初始化流程 (#11995)
* [ISSUE #11994] fix: Initialize EnvUtil's variable environment in HttpRequestInstanceBuilderTest

* refactor: Optimize the initialization process of SnowFlakeInstanceIdGenerator

* refactor: optimize the initialization process of SnowFlakeInstanceIdGenerator.
2024-04-23 09:31:11 +08:00
Happy-26
96814ff00d
[ISSUE #11968] Buf fix: Use put() instead of putIfAbsent() for setArg() in ConfigChangeRequest (#11971)
* Fixed an issue where the maximum number of anti-fragile plug-ins implemented by default in Nacos is one more than the actual number of connections.

* bug fix : 修改删除空服务实例时,服务名和分组名没有正确解析的问题

* Update ConfigChangeAspect.java

修改configChangeRequest.setArg()的key为serviceType

* Update ConfigChangeAspect.java

* Update ConfigChangeRequest.java
2024-04-22 10:53:11 +08:00
温安适
2bb7193d1b
Bug fix:10639 (#11972)
* Update LocalSimpleCountRateCounter.java

fixbug

* Update LocalSimpleCountRateCounter.java

bugfix

* fix:默认的nacos反脆弱插件的问题

* fix:默认的nacos反脆弱插件的问题

* fix:默认的nacos反脆弱插件的问题

* fix:默认的nacos反脆弱插件的问题

* fix:默认的nacos反脆弱插件的问题,调整为tryAdd

* fix:默认的nacos反脆弱插件的问题,调整为tryAdd

* 调整测试方式,保障流水线成功

* 重构PageHandlerAdapterFactory,这里将handlerAdapters,handlerAdapterMap设置为unmodifiable

* 重构PageHandlerAdapterFactory,这里将handlerAdapters,handlerAdapterMap设置为unmodifiable

* fix: 10639, 调整encrypted_data_key 为varchar(1024)
2024-04-22 10:49:08 +08:00
杨翊 SionYang
5c19ac12ad
[#11956] Refactor nacos client logging module, use SPI load current logger adapter. (#11964)
* Add NacosLoggingAdapter

* Refactor Logback Logging adapter to Nacos logging adapter.

* Refactor log4j2 Logging adapter to Nacos logging adapter.

* Remove useless abstract class

* Add and Adapt log4j2 impl to SPI.

* Remove useless method in NacosLogbackConfigurator

* Fix IT ClassNotFound problem
2024-04-16 13:52:28 +08:00
Happy-26
2005ca6f90
[ISSUE #11951] Fix the problem that the servicename and groupname are not resolved correctly when deleting an empty service instance (#11955)
* Fixed an issue where the maximum number of anti-fragile plug-ins implemented by default in Nacos is one more than the actual number of connections.

* bug fix : 修改删除空服务实例时,服务名和分组名没有正确解析的问题
2024-04-15 15:20:02 +08:00
hnyyghk
9b2cc662ec
[ISSUE #11902] Fix request and response reflect-config.json (#11940)
* Update request reflect-config.json

add deletion graalvm reflect config

* Update response reflect-config.json

add deletion graalvm reflect config
2024-04-11 15:30:10 +08:00
hnyyghk
fb597084c5
fix Navigator clipboard api needs a secure context (https) (#11942) 2024-04-11 15:29:09 +08:00
bajiejump
5c141593d8
issue:11943(保存导入用户) (#11945) 2024-04-11 15:28:54 +08:00
cxhello
d179e47df4
fix: vulnerability (#11914)
- CVE-2024-22257 Upgrade Spring Security to 5.7.12.
- Use spring-framework-bom as dependencyManagement.

Closes #11904
2024-04-08 10:43:18 +08:00
zhanghong
d4126ba2bd
[ISSUE #11847] Feature: add console-ui publish config cas (#11927)
* 修复openApi publishConfigCas失效

* 修复openApi publishConfigCas失效

* fix unit test

* add publish cas
2024-04-08 10:36:36 +08:00
杨翊 SionYang
8af8519c6d
Bump console ui dependencies to solve security problem with audit fix. (#11913) 2024-04-02 17:06:24 +08:00
blake.qiu
c09ee2da04
fix(#11895): grpc 服务注册失败时返回了成功 (#11909) 2024-04-02 14:13:46 +08:00
tangmingyao
facf4c8270
fix:add param for ConfigInfoMapperByMySql#findAllConfigInfoBaseFetchRows (#11883)
* fix:add param for ConfigInfoMapperByMySql#findAllConfigInfoBaseFetchRows

* fix:code style modify

* fix:code style modify

* fix:code style modify

---------

Co-authored-by: zhangyang <1445621702@qq.com>
2024-04-02 11:36:29 +08:00
cxhello
19a857b701
fix: CVE-2024-22243 & CVE-2024-22259 Upgrade Spring Web to 5.3.33 (#11833) 2024-04-01 16:48:33 +08:00
zhanghong
25585d65dd
[ISSUE #11847] fix OpenApi publish Cas fail (#11850)
* 修复openApi publishConfigCas失效

* 修复openApi publishConfigCas失效

* fix unit test
2024-04-01 15:32:33 +08:00
nov.lzf
5fcef225be
format check on client labels (#11903)
* format check on client labels

* log optimize

* testcase fix
2024-04-01 14:55:44 +08:00
publicize-y
2df335d57e
Response wrong status code for some situation for openAPI (#11864)
* fix:Response wrong status code for some situation for openAPI

* fix:Response wrong status code for some situation for openAPI for PrometheusApiExceptionHandler

* fix:PrometheusApiExceptionHandler status modify

* fix:add unit test

* fix:modify the unit test description

* fix:the code style modify

* fix:the UT modify
2024-04-01 14:11:16 +08:00
shalk(xiao kun)
6461aeb719
fix 11892 keep ErrorResponse result code the same with errorcode (#11893) 2024-04-01 12:02:46 +08:00
阿魁
3a1f0c297e
[ISSUE #11880]Fixed the issue of duplicate notifications of configuration changes. (#11881) 2024-03-26 17:16:56 +08:00
lmm1990
ec4f21540e
Update reflect-config.json (#11860)
add deletion graalvm reflect config
2024-03-26 16:23:39 +08:00
徐晓伟
08edb4fbd6
⬆️ upgrade mysql-connector-java from 8.0.28 to 8.0.33 (#11875)
https://github.com/alibaba/nacos/issues/11874
2024-03-26 16:22:06 +08:00
chenyiqin
a7d9ef2fe8
Fix get batch service instances error (#11845)
* fix get batch service instances error

* fix checkstyle

* fix get wrong res when batch instance

* add the clientId to return data
2024-03-25 18:03:48 +08:00
shalk(xiao kun)
082c5073bb
fix #11871 remove reflection from client pom.xml (#11872) 2024-03-25 17:25:03 +08:00
nov.lzf
6dc0a2109f
simplify nacos app labels collector and log fix. (#11867)
* remove batch

* simplify label collector ,optimize log

* simplify label collector ,optimize log

* testcase fix
2024-03-22 17:13:20 +08:00
hth
9db51e58ed
add UT for NamespacePersist (#11852)
* UT for NamespacePersist

* NamespacePersistTest fix
2024-03-22 09:36:22 +08:00
brother-戎
9fd6ff6a04
feature: add client labels collect and attach labels to conn (#11844)
* add client labels collect and attach labels to conn

* remove some constants

* fixup test case
2024-03-21 14:33:57 +08:00
JianweiWang
b79d585f97
fix #11835 (#11838) 2024-03-18 09:36:31 +08:00
linqiuping
038420c69f
Add ParamCheckerFilter ut (#11834)
* remove unused exception

* Add ReuseHttpServletRequest ut

* fix ut description

* fix code style

* fix code style

* fix code style

* Add ReuseUploadFileHttpServletRequest ut

* fix code style

* fix ut with unapproved license

* fix code style

* Add CheckConfiguration ut

* Add ParamCheckerFilter ut

* fix code style

* fix License

* fix code style
2024-03-15 15:32:20 +08:00
不务正业
c86147b6ab
🐛 Uncontrolled data used in path expression (#11822)
https://github.com/alibaba/nacos/issues/11821
2024-03-15 14:05:20 +08:00
linqiuping
0d7fcff261
Add CheckConfiguration ut (#11829)
* remove unused exception

* Add ReuseHttpServletRequest ut

* fix ut description

* fix code style

* fix code style

* fix code style

* Add ReuseUploadFileHttpServletRequest ut

* fix code style

* fix ut with unapproved license

* fix code style

* Add CheckConfiguration ut
2024-03-15 14:00:34 +08:00
linqiuping
d26ed3623e
Add ReuseUploadFileHttpServletRequest ut (#11827)
* remove unused exception

* Add ReuseHttpServletRequest ut

* fix ut description

* fix code style

* fix code style

* fix code style

* Add ReuseUploadFileHttpServletRequest ut

* fix code style

* fix ut with unapproved license

* fix code style
2024-03-14 15:45:00 +08:00
linqiuping
3b319502a1
Add ReuseHttpServletRequest ut (#11826)
* remove unused exception

* Add ReuseHttpServletRequest ut

* fix ut description

* fix code style

* fix code style

* fix code style
2024-03-14 13:41:14 +08:00
linqiuping
5a5473bdbd
remove unused exception (#11824) 2024-03-13 17:21:14 +08:00
heihei180
15fbf92b15
modify the log file path. (#11794) 2024-03-07 13:50:32 +08:00
Peter Zhu
2f2fc1b12b
failover triggered mistakenly (#11536)
* Fix failover switch triggered mistakenly and optimise metrics

* format code

* Fix checkstyle

* Fix unit test
2024-03-07 11:40:41 +08:00
blake.qiu
4397e8d275
feat(11752): The contentPath of AddressServerUrl is not flexible. (#11754) 2024-03-07 11:39:52 +08:00
温安适
c2aa515f1e
PageHandlerAdapterFactory, handlerAdapters,handlerAdapterMap should unmodifiable (#11801)
* Update LocalSimpleCountRateCounter.java

fixbug

* Update LocalSimpleCountRateCounter.java

bugfix

* fix:默认的nacos反脆弱插件的问题

* fix:默认的nacos反脆弱插件的问题

* fix:默认的nacos反脆弱插件的问题

* fix:默认的nacos反脆弱插件的问题

* fix:默认的nacos反脆弱插件的问题,调整为tryAdd

* fix:默认的nacos反脆弱插件的问题,调整为tryAdd

* 调整测试方式,保障流水线成功

* 重构PageHandlerAdapterFactory,这里将handlerAdapters,handlerAdapterMap设置为unmodifiable

* 重构PageHandlerAdapterFactory,这里将handlerAdapters,handlerAdapterMap设置为unmodifiable
2024-03-07 10:48:49 +08:00
杨翊 SionYang
b7c3905976
Upgrade to 2.4.0-SNAPSHOT. (#11795) 2024-03-04 16:55:45 +08:00
杨翊 SionYang
92dda945a0
Upgrade to 2.3.1 (#11791) 2024-03-04 11:23:41 +08:00
杨翊 SionYang
64b9e8d3f7
Make findMapper log to debug level to avoid nacos.log print much log. (#11786) 2024-03-01 13:35:30 +08:00
zhanghong
8f1cb59370
[ISSUE #11782] Optimized the use of map (#11783)
* Optimized the use of map

* Optimized the use of map
2024-03-01 10:05:33 +08:00
杨翊 SionYang
961d56ccce
use npm audit fix to solve some ui security dependencies. (#11777) 2024-03-01 09:58:31 +08:00
dingjiefei
fdbc99dd99
Update the sofa-jraft version to resolve the issue of the server cannot connect to the client (#11721)
* update sofa-jraft version

* fix JRaftServerTest.testRefreshRouteTable

* remove unnecessary Mockito stubbings
2024-02-27 14:40:28 +08:00
lcmarvin
889a78a82b
[ISSUE #11706] Fix the Chinese description in announcement under English console. (#11729) 2024-02-27 10:28:58 +08:00
publicize-y
a275356c10
fix:Use the article an before instance (#11759)
* fix:Use the article an before instance

* fix:The modal verb 'will' requires the verb's base form.
2024-02-27 09:24:02 +08:00
xxc
7f4c7f8297
Update README.md (#11775)
update community information and official website download channel
2024-02-27 09:21:46 +08:00
黄科铭
4f279bf110
fix issues/11723 PageHandlerAdapterFactory 集合容量不够大 (#11763) 2024-02-22 14:59:49 +08:00
黄科铭
c2f8463e12
The test case pass (#11764) 2024-02-22 14:59:26 +08:00
杨翊 SionYang
fde996d2a6
Enhance nacos example (#11761)
* example stable.

* example stable.

* Update copyright
2024-02-22 14:58:57 +08:00
温安适
1710fa32a2
[ISSUES #11626] 优化Nacos的默认反脆弱插件 (#11625)
* Update LocalSimpleCountRateCounter.java

fixbug

* Update LocalSimpleCountRateCounter.java

bugfix

* fix:默认的nacos反脆弱插件的问题

* fix:默认的nacos反脆弱插件的问题

* fix:默认的nacos反脆弱插件的问题

* fix:默认的nacos反脆弱插件的问题

* fix:默认的nacos反脆弱插件的问题,调整为tryAdd

* fix:默认的nacos反脆弱插件的问题,调整为tryAdd

* 调整测试方式,保障流水线成功
2024-02-22 11:32:04 +08:00
梁天语
1d3f1bb492
[ISSUE #11718] Fix ErrorCode have the same code (#11747)
* [ISSUE #11718] Fix ErrorCode have the same code

* Fix code style.
2024-02-20 14:07:58 +08:00
blake.qiu
7d085a8846
build(11749): upgrade spring boot version. (#11755) 2024-02-20 13:35:55 +08:00
chenyiqin
0ee724ee7f
Fix class cast error when distro sync batch service data (#11702)
* fix class cast error when distro sync batch service data

* check for logic

* simplify logic

* add ut for distro data process

* rm redundant mock
2024-02-20 10:51:51 +08:00
jimin
3c278edba9
optimize: support get java cmd from which java (#11720) 2024-02-20 10:51:16 +08:00
zhanghong
e6eb636aed
fix dark mode bugs (#11740) 2024-02-20 10:46:20 +08:00
hth
21f8065073
log improvement (#11753) 2024-02-20 10:42:58 +08:00
杨翊 SionYang
139f4f2377
Add client module ut. (#11739)
* Add client module ut.

* Fix naming ut possible failed.
2024-02-06 16:11:25 +08:00
nov.lzf
3da1240f3a
config module coverage (#11738)
* testcase fix

* checkstyle

* testcase coverage

* testcase coverage

* testcase coverage

* testcase coverage

* testcase fixed
2024-02-06 14:53:14 +08:00
李云飞
2bb93982df
[ISSUE #11655]fix invalid usage of ProporityQueue in ConfigChangePluginManger (#11668)
* [ISSUE #11655]fix invalid usage of ProporityQueue in ConfigChangePluginManager

* add UT for config change plugin

* for checkstyle

* for checkstyle
2024-02-02 15:57:21 +08:00
blake.qiu
9fcc4c0dbe
fix(11127): Fix ClientWork removeListener and addListener concurrency issue. (#11681) 2024-02-02 15:55:52 +08:00
peachisai
1b9a22c1a8
Fix when push fail the totalPush variable count cannot increase (#11704) 2024-01-31 10:27:01 +08:00
Qishang Zhong
9d473ef60c
[ISSUE #11618] Add the config of max thread count for client worker & naming polling (#11693)
* [ISSUE #11618] Add the config of max thread count for client worker & naming polling

* Fix
2024-01-31 09:43:46 +08:00
blake.qiu
8f2150892a
build(11606): Make sql-schema consistent. (#11703) 2024-01-31 09:32:19 +08:00
hth
817eb58597
[ISSUE#11695] fix PreviousConfigHistory encryption (#11707)
* fix PreviousConfigHistory encryption

* UT fix
2024-01-31 09:30:46 +08:00
Qishang Zhong
bd5caa64a6
Clean up system property after running the test case (#11711) 2024-01-31 09:30:01 +08:00
nov.lzf
849393c4a1
optimize dump all logic and optimize dump change interface (#11658)
* optimize config dump all,do not select content in page query,single query config on md5 and ts updated.

* 1.optimize config dump all,do not select content in page query,single query config on md5 and ts updated.
2. remove convertDeleteConfig and convertConfigConfig ,use standard RowMapper instead.

* remove unecessary code

* use context param instead of adding plugin method params

* bug and test fix
2024-01-19 15:26:28 +08:00
hth
9722ad8dd5
Auth check fix (#11672) 2024-01-19 15:24:18 +08:00
wuyfee
dd385294f5
Multi Language CI (#11674)
* feat: add multi language test

* fix: replace dockerhub
2024-01-19 15:23:52 +08:00
nov.lzf
5f9c848d7e
remove direct read (#11670)
* remove isDirectRead

* check style

* coverage makeup

* coverage makeup

* coverage makeup
2024-01-17 19:20:48 +08:00
Happy-26
30a5014e5d
Fixed an issue where the maximum number of anti-fragile plug-ins implemented by default in Nacos is one more than the actual number of connections. (#11636) 2024-01-17 16:19:41 +08:00
杨翊 SionYang
f5d72a3455
Revert "[ISSUES #11601]Auth check fix" (#11671) 2024-01-17 16:10:23 +08:00
hth
51fa941df7
Auth check fix (#11649) 2024-01-17 16:07:55 +08:00
Qishang Zhong
07168099db
[ISSUE #11612] Unified use of NameThreadFactory to create thread pools. (#11613) 2024-01-17 15:47:19 +08:00
hth
bdbc356ce4
fix RaftConfig is always {} (#11648) 2024-01-17 15:27:49 +08:00
chenyiqin
1943825e4d
server don't send its abilities when client don't send its abilities (#11661) 2024-01-17 15:19:36 +08:00
hth
a7d1c35f85
fix user update permission (#11603) 2024-01-11 17:16:00 +08:00
hth
207505735c
add UT for control plugin (#11611)
* add ut for control plugin

* control plugin fix LocalDiskRuleStorage mkdirs
2024-01-11 17:11:47 +08:00
hth
b4a380f15b
control plugin fix LocalDiskRuleStorage mkdirs (#11620) 2024-01-11 17:08:55 +08:00
brother-戎
84900756d1
[add unit test case] Add unit test for capacity management aspect (#11622)
* add_unit_test_capacity_management_aspect

* remove some code

* some tiny fix

* some tiny fix

* some tiny fix

* some tiny fix
2024-01-11 17:08:13 +08:00
CZJCC
c98b8c4111
修复client register事件跟clientManager addClient异步并行问题 (#11634) 2024-01-10 19:06:37 +08:00
杨翊 SionYang
f3fb60ebf3
打开config模块覆盖率 (#11628) 2024-01-10 14:37:40 +08:00
nov.lzf
c70a86820d
config module coverage (#11592)
* coverage

* coverage

* coverage up tp 80% ,fix checkstyle pmd

* coverage up tp 80% ,fix checkstyle pmd

* fix checkstyle

* optmize grpc connection push

* testcase

* grp connection coverage
2024-01-08 14:25:15 +08:00
MajorHe1
dbb1b65fcb
[ISSUE #11526] Update ServiceInfoHolder.java, add log output in processServiceInfo (#11527)
* Update ServiceInfoHolder.java, add log output in processServiceInfo

* Update ServiceInfoHolder.java, add log output in processServiceInfo
2024-01-05 17:56:08 +08:00
hth
ea94095f74
[ISSUES #9001]spi instanceIdGenerator and snowFlakeInstanceIdGenerator (#11561)
* spi instanceIdGenerator and snowFlakeInstanceIdGenerator

* Test fix

* fix InstanceId set

* Copyright fix
2024-01-05 17:53:56 +08:00
hth
2296125d41
add UT for control default plugin (#11572)
* add control default plugin Test

* Copyright fix
2024-01-05 17:48:41 +08:00
hth
8a69c9e8ac
fix default tps control plugin (#11579) 2024-01-05 17:47:59 +08:00
Karson
97104b2445
[ISSUE #11586]Remove deprecated api of spring security (#11587)
* remove deprecated config

* style fix
2024-01-05 17:02:39 +08:00
chenyiqin
6b0636dd5d
support metric for grpc server request (#11427)
* support metric for grpc server request

* change way to judge field

* optimize record
2023-12-29 14:08:50 +08:00
nov.lzf
d4e2ccda82
config module coverage up to 60% (#11560)
* fix test case

* test case coverage

* open config module testcases

* config module testcases coverage

* test case coverage up to 55%

* test case coverage up to 55%

* test case coverage up to 60%

* fix test case

* fix test case

* fix test case

* fix test case

* fix test case

* fix test case

* coverage makeup

* coverage makeup

* coverage makeup

* coverage makeup
2023-12-29 11:46:54 +08:00
blake.qiu
526227c77b
fix(#11498): fix CheckDbHealthTask. (#11500) 2023-12-28 11:37:29 +08:00
喻世文
6587029851
[ISSUE #11544] Supplementary single test, when the prefix of dataId is cipher. (#11546)
* [ISSUE #11544] Supplementary single test, when the prefix of dataId is cipher.

* [ISSUE #11544] Supplementary single test, when the prefix of dataId is cipher. Adjusting code format.

* [ISSUE #11544] Supplementary single test, when the prefix of dataId is cipher. Change static code block to @Before annotation.

* [ISSUE #11544] Supplementary single test, when the prefix of dataId is cipher. run ci.
2023-12-27 11:08:23 +08:00
杨翊 SionYang
9e48e8cb3b
Develop client ut (#11557)
* Add UT for client module logging package.

* Add UT for client module utils package.

* Add UT for client module naming package.

* For checkstyle.

* For PMD.
2023-12-26 11:53:26 +08:00
hth
41222ee99a
service name check fix (#11553) 2023-12-26 10:46:13 +08:00
realJackSun
4d76eb7c31
Add unit tests for package com.alibaba.nacos.config.server.service.dump (#11532)
* Add unit test for DumpAllProcessor

* [#11531] Add unit tests for package com.alibaba.nacos.config.server.service.dump ———— Add unit test for DumpAllProcessor
2023-12-22 14:26:00 +08:00
毛文超
d40190ee24
[ISSUES #11499] fix address server health check error (#11508)
* [ISSUES #11499] fix address server health check error

Close #11499

* [ISSUES #11499] add some unit tests for HealthController
2023-12-19 14:25:54 +08:00
nov.lzf
ca9d55e264
fix config test case and remove useless code (#11521)
* 修复客户端cmsgc导致服务端推送积压直接内存oom问题

* 修复ut及bug

* 修复ut及bug,checkstyle

* 修复ut及bug

* 修复ut

* 修复覆盖率

* 修复测试用例

* 修复测试用例,覆盖率

* 修复测试用例,覆盖率,删除无用代码

* 修复测试用例,覆盖率,pmd&checkstyle

* fix test case
2023-12-18 13:42:28 +08:00
nov.lzf
790bb197cf
优化增量对账,减少开销 (#11248)
* 优化增量dump,减少开销

* check style fix

* pmd fix

* testcase fix

* testcase fix

* checkstyle fix
2023-12-18 13:41:27 +08:00
杨翊 SionYang
ab2ddac06f
Develop client ut (#11516)
* Add ut for client module auth package.

* Add ut for client module env package.

* Add ut for client module env package.

* For copyright

* Fix UT might failed problem.
2023-12-18 10:20:55 +08:00
zhanghong
d84a566235
fix proxy mapper bug (#11507) 2023-12-15 15:42:01 +08:00
nov.lzf
06edd123f9
check server stream ready state to avoid bytebuffer back up in flow control pending write queue. (#11514)
* 修复客户端cmsgc导致服务端推送积压直接内存oom问题

* 修复ut及bug

* 修复ut及bug,checkstyle

* 修复ut

* 修复覆盖率

* checkstyle
2023-12-15 15:40:45 +08:00
杨翊 SionYang
58803687c8
client don't judge token content invalid. (#11496) 2023-12-12 16:24:47 +08:00
杨翊 SionYang
a3420b733b
[ISSUE#11494] Fix frequently request login api when using 2.X client with username. (#11495)
* Fix frequently request login api when using 2.X client with username.

* Fix frequently request login api when using 2.X client with username.
2023-12-12 14:13:56 +08:00
虢豳
26d045ca49
fix(#11489): PageHandlerAdapterFactory initHandlerAdapters error (#11490) 2023-12-12 11:59:35 +08:00
Karson
327ebaf36e
[ISSUE #10752] Fix Prometheus sd api security is not compatiable with nacos original security configs (#11470)
* fix issue #10752

* fix issue #10752
2023-12-06 13:13:15 +08:00
chenyiqin
01a28ee3cd
Support metric for grpc server executor (#11428)
* support metric for grpc server executor

* remove unused field

* add copyright

* add ut
2023-12-06 13:12:20 +08:00
dependabot[bot]
92f36b1d30
Bump ch.qos.logback:logback-classic from 1.2.9 to 1.2.13 (#11473)
Bumps [ch.qos.logback:logback-classic](https://github.com/qos-ch/logback) from 1.2.9 to 1.2.13.
- [Commits](https://github.com/qos-ch/logback/compare/v_1.2.9...v_1.2.13)

---
updated-dependencies:
- dependency-name: ch.qos.logback:logback-classic
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-06 13:11:35 +08:00
dependabot[bot]
cd2d4149b5
Bump ch.qos.logback:logback-core from 1.2.9 to 1.2.13 (#11472)
Bumps [ch.qos.logback:logback-core](https://github.com/qos-ch/logback) from 1.2.9 to 1.2.13.
- [Commits](https://github.com/qos-ch/logback/compare/v_1.2.9...v_1.2.13)

---
updated-dependencies:
- dependency-name: ch.qos.logback:logback-core
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-06 13:11:14 +08:00
阿魁
3058f9f8ff
[ISSUE #11325]Fix logging for Config pull events. (#11326)
* [ISSUE #11325]Fix logging for Config pull events.

* Update style.
2023-12-06 13:10:17 +08:00
杨翊 SionYang
319ec8c257
Upgrade to 2.3.1-SNAPSHOT (#11469) 2023-12-06 13:09:46 +08:00
guozongkang
380c019fdd
Nacos客户端磁盘降级需求 issues:11053 (#11207)
* 使用磁盘实现Nacos客户端版本降级

* 使用磁盘实现Nacos客户端版本降级

* 使用磁盘实现Nacos客户端版本降级

* 使用磁盘实现Nacos客户端版本降级

* 创建对象时去除cachedir,去除磁盘定时保存任务

* 创建对象时去除cachedir,去除磁盘定时保存任务

* 删除saveFailoverData方法

* 移除getServiceInfo方法中的容灾逻辑

* 移除getServiceInfo方法中的容灾逻辑

* 删除掉注释的方法

* 使用serviceMap对比

* 使用serviceMap对比

* failoverSwith去除serviceNameSet集合

* failoverSwith去除serviceNameSet集合

* failoverSwith去除serviceNameSet集合

* 特殊情况下增补日志

* 格式化checkstyle

* 对UtilAndComs  checkstyle

* 对test类  checkstyle

* 去除无效变量

* 去除无效变量

* 修改serviceInfo对象被重新覆盖的问题

* 优化getServiceInfo方法

* 降级开关初次开启时发送通知

* 降级开关开启时,也发送通知

* 当降级开启时,不再订阅服务信息。去除多余的init方法

* 本地修复CI报错

* 本地修复CI报错

* 本地修复CI报错

* 监控指标优化内部版本同步

* 监控指标优化内部版本同步

* serviceName字段去除""
2023-12-05 10:21:52 +08:00
chenyiqin
18a4672dd9
Support metric for module connection (#11426)
* support metric for module connection

* fix pmd

* add ut
2023-12-05 10:16:41 +08:00
chenyiqin
2fd002c8d1
fix: connection count of current node is not accurate (#11417) 2023-12-05 09:41:03 +08:00
zhanghong
de739e9b9c
[ISSUE #11441] Add console-ui Dark mode (#11445)
* fix NPE

* fix NPE

* add console-ui dark mode

* merge

* merge
2023-12-05 09:33:33 +08:00
blake.qiu
33cb6e26c7
fix(#11306): change the length of the field named resource from 255 to 128. (#11453) 2023-12-05 09:32:38 +08:00
毛文超
f8b3d35e88
[ISSUES #11459] fix CONFIG_INFO_STATE_WRAPPER_ROW_MAPPER missing (#11465)
- register CONFIG_INFO_STATE_WRAPPER_ROW_MAPPER to RowMapperManager

Close #11459
2023-12-05 09:28:56 +08:00
Dale Lee
7fdbc63390
For #10374, format code using Nacos Style (#11438) 2023-11-28 10:19:42 +08:00
Dale Lee
263e223d94
[ISSUE #10374] Add default selectors (#11142)
* Add default selectors

* add tests

* Update SubscribeSelector_ITCase

* add unsubscribe test

* Removes some methods for NamingSelectorFactor

* Update SelectorManager
2023-09-22 13:55:46 +08:00
Dale Lee
4ad98d837d
[ISSUE #10374] Select clusters using the selector (#10995)
* Select clusters using the selector

* Add Event Cache

* Update NacosNamingService,InstancesChangeNotifier
2023-09-06 17:18:18 +08:00
Dale Lee
cc34b6ca0d
[ISSUE #10374] Define selectors and related components (#10954)
* For #10374, Define selectors and related components

* Add unit test

* Update NamingSelectorWrapperTest

* Update selectors and related components

* Update NamingSelectorWrapper
2023-08-17 10:48:24 +08:00
Dale Lee
c026d2f3ac
[ISSUE #10374] Support listener to get changed instances (#10905)
* For #10374, Support listener to get changed instances

* Update AbstractNamingChangeListener,NamingChaneEventTest

* Update InstancesDiffTest

* Rename NamingChangeEventTest
2023-08-07 09:29:05 +08:00
1340 changed files with 60099 additions and 38084 deletions

View File

@ -6,11 +6,10 @@ name: "Continuous Integration"
on:
push:
branches: [ master, develop, v1.x-develop, v1.X ]
pull_request:
pull_request_target:
branches: [ develop, v1.x-develop ]
permissions:
contents: read # to fetch code (actions/checkout)
permissions: read-all
jobs:
ci:
@ -21,16 +20,16 @@ jobs:
java: [8]
steps:
- name: "Cache Maven Repos"
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: "Checkout"
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: "Set up JDK ${{ matrix.java }}"
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'zulu'
@ -44,6 +43,11 @@ jobs:
- name: "Test With Maven"
run: mvn -Prelease-nacos clean test -DtrimStackTrace=false -e -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
- name: "Codecov"
uses: codecov/codecov-action@v3.1.0
uses: codecov/codecov-action@v4.2.0
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: ./address/target/site/jacoco/jacoco.xml,./api/target/site/jacoco/jacoco.xml,./auth/target/site/jacoco/jacoco.xml,./client/target/site/jacoco/jacoco.xml,./common/target/site/jacoco/jacoco.xml,./consistency/target/site/jacoco/jacoco.xml,./console/target/site/jacoco/jacoco.xml,./core/target/site/jacoco/jacoco.xml,./naming/target/site/jacoco/jacoco.xml,./persistence/target/site/jacoco/jacoco.xml,./plugin-default-impl/nacos-default-auth-plugin/target/site/jacoco/jacoco.xml,./plugin/auth/target/site/jacoco/jacoco.xml,./plugin/config/target/site/jacoco/jacoco.xml,./plugin/control/target/site/jacoco/jacoco.xml,./plugin/datasource/target/site/jacoco/jacoco.xml,./plugin/encryption/target/site/jacoco/jacoco.xml,./plugin/environment/target/site/jacoco/jacoco.xml,./plugin/trace/target/site/jacoco/jacoco.xml,./prometheus/target/site/jacoco/jacoco.xml,./sys/target/site/jacoco/jacoco.xml
verbose: true
fail_ci_if_error: true
files: ./address/target/site/jacoco/jacoco.xml,./api/target/site/jacoco/jacoco.xml,./auth/target/site/jacoco/jacoco.xml,./client/target/site/jacoco/jacoco.xml,./common/target/site/jacoco/jacoco.xml,./config/target/site/jacoco/jacoco.xml,./consistency/target/site/jacoco/jacoco.xml,./console/target/site/jacoco/jacoco.xml,./core/target/site/jacoco/jacoco.xml,./logger-adapter-impl/log4j2-adapter/target/site/jacoco/jacoco.xml,./logger-adapter-impl/logback-adapter-12/target/site/jacoco/jacoco.xml,./naming/target/site/jacoco/jacoco.xml,./persistence/target/site/jacoco/jacoco.xml,./plugin-default-impl/nacos-default-auth-plugin/target/site/jacoco/jacoco.xml,./plugin-default-impl/nacos-default-control-plugin/target/site/jacoco/jacoco.xml,./plugin/auth/target/site/jacoco/jacoco.xml,./plugin/config/target/site/jacoco/jacoco.xml,./plugin/control/target/site/jacoco/jacoco.xml,./plugin/datasource/target/site/jacoco/jacoco.xml,./plugin/encryption/target/site/jacoco/jacoco.xml,./plugin/environment/target/site/jacoco/jacoco.xml,./plugin/trace/target/site/jacoco/jacoco.xml,./prometheus/target/site/jacoco/jacoco.xml,./sys/target/site/jacoco/jacoco.xml
token: ${{ secrets.CODECOV_TOKEN }}

View File

@ -6,10 +6,11 @@ on:
workflows: ["PR-CI"]
types:
- completed
env:
DOCKER_REPO: wuyfeedocker/nacos-ci
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
DOCKER_REPO_B: wuyfeehub/nacos-ci
TEST_REPO_NAME: nacos-group/nacos-e2e
jobs:
docker:
@ -22,6 +23,8 @@ jobs:
matrix:
base-image: ["ubuntu"]
java-version: ["8"]
outputs:
version-json: ${{ steps.show_versions.outputs.version-json }}
steps:
- name: 'Download artifact'
uses: actions/github-script@v3.1.0
@ -33,7 +36,7 @@ jobs:
run_id: ${{ github.event.workflow_run.id }},
});
var matchArtifactNacos = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "nacos"
return artifact.name == "nacos"
})[0];
var download = await github.actions.downloadArtifact({
owner: context.repo.owner,
@ -47,19 +50,12 @@ jobs:
unzip nacos.zip
mkdir nacos
cp -r nacos-* nacos/
ls
- uses: actions/checkout@v3
with:
repository: nacos-group/nacos-e2e.git
ref: main
path: nacos-e2e
- name: docker-login
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and save docker images
- name: Generate image tag
id: build-images
run: |
mv nacos-server-*.tar.gz nacos-e2e/cicd/build
@ -68,43 +64,44 @@ jobs:
mkdir versionlist
touch versionlist/"${version}-`echo ${{ matrix.java-version }} | sed -e "s/:/-/g"`"
ls versionlist/
tag=${version}-$(echo ${{ matrix.java-version }} | sed -e "s/:/-/g")
echo $tag
docker build --no-cache -f Dockerfile -t ${DOCKER_REPO}:${tag} .
docker push ${DOCKER_REPO}:${tag}
- uses: actions/upload-artifact@v3
name: Upload distribution tar
echo TAG=${version}-$(echo ${{ matrix.java-version }} | sed -e "s/:/-/g") >> $GITHUB_ENV
- name: docker-login-1
uses: docker/login-action@v2
with:
name: versionlist
path: nacos-e2e/cicd/build/versionlist/*
list-version:
if: always()
name: List version
needs: [docker]
runs-on: ubuntu-latest
timeout-minutes: 30
outputs:
version-json: ${{ steps.show_versions.outputs.version-json }}
steps:
- uses: actions/download-artifact@v3
name: Download versionlist
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: save docker_1 images
run: |
mkdir build_backup
cp -rf nacos-e2e/cicd/build/* ./build_backup/
cd nacos-e2e/cicd/build
docker build --no-cache -f Dockerfile -t ${DOCKER_REPO}:${{ env.TAG }} .
docker push ${DOCKER_REPO}:${{ env.TAG }}
- name: docker-login-2
uses: docker/login-action@v2
with:
name: versionlist
path: versionlist
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKERHUB_USER_B }}
password: ${{ secrets.DOCKERHUB_TOKEN_B }}
- name: save docker_2 images
run: |
rm -rf nacos-e2e/cicd/build/*
mv ./build_backup/* nacos-e2e/cicd/build/
cd nacos-e2e/cicd/build
docker build --no-cache -f Dockerfile -t ${DOCKER_REPO_B}:${{ env.TAG }} .
docker push ${DOCKER_REPO_B}:${{ env.TAG }}
- name: Show versions
id: show_versions
run: |
a=(`ls versionlist`)
run: |
a=(`ls nacos-e2e/cicd/build/versionlist`)
printf '%s\n' "${a[@]}" | jq -R . | jq -s .
echo version-json=`printf '%s\n' "${a[@]}" | jq -R . | jq -s .` >> $GITHUB_OUTPUT
deploy:
if: ${{ success() }}
name: Deploy nacos
needs: [list-version,docker]
needs: [docker]
runs-on: ubuntu-latest
timeout-minutes: 60
env:
@ -112,99 +109,392 @@ jobs:
DATABASE: mysql
NODE_PORT: 30000
strategy:
fail-fast: false
matrix:
mode: ["cluster","standalone"]
version: ${{ fromJSON(needs.list-version.outputs.version-json) }}
version: ${{ fromJSON(needs.docker.outputs.version-json) }}
steps:
- name: set nodeport
run: |
echo "::set-env name=NODE_PORT::$(expr $(expr $(expr $(expr 1 * $(expr ${{ github.run_number }} - 1)) + ${{ strategy.job-index }}) % 30000) + 30000)"
echo "NODE_PORT=$(expr $(expr $(expr $(expr ${{ strategy.job-index }} + 1) * ${{ github.run_number }}) % 30000) + 30000)" >> $GITHUB_ENV
- name: set cluster params
if: ${{ matrix.mode == 'standalone' }}
run: |
echo "::set-env name=REPLICA_COUNT::1"
echo "::set-env name=DATABASE::embedded"
- uses: apache/rocketmq-test-tool@136205caa6e97f81744e30adea114dd2f09cc55e
echo "REPLICA_COUNT=1" >> $GITHUB_ENV
echo "DATABASE=embedded" >> $GITHUB_ENV
- name: allocate docker repo
run: |
if [[ $(expr $(expr ${{ github.run_id }} + ${{ strategy.job-index }} ) % 2 ) -eq 1 ]]; then
echo "DOCKER_REPO_ACTUAL=${{ env.DOCKER_REPO }}" >> $GITHUB_ENV
else
echo "DOCKER_REPO_ACTUAL=${{ env.DOCKER_REPO_B }}" >> $GITHUB_ENV
fi
- uses: apache/rocketmq-test-tool@java-dev
name: Deploy nacos
with:
action: "deploy"
ask-config: "${{ secrets.ASK_CONFIG_VIRGINA }}"
test-version: "${{ matrix.version }}"
chart-git: "https://ghproxy.com/https://github.com/nacos-group/nacos-e2e.git"
chart-branch: "main"
chart-path: "./cicd/helm"
job-id: ${{ strategy.job-index }}
helm-values: |
yamlString: |
action: deploy
namespace: nacos-${{ github.run_id }}-${{ strategy.job-index }}
global:
mode: ${{ matrix.mode }}
nacos:
replicaCount: ${{ env.REPLICA_COUNT }}
image:
repository: ${{ env.DOCKER_REPO }}
tag: ${{ matrix.version }}
storage:
type: ${{ env.DATABASE }}
db:
port: 3306
username: nacos
password: nacos
param: characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false
service:
nodePort: ${{ env.NODE_PORT }}
type: ClusterIP
e2e-test:
askConfig: ${{ secrets.ASK_CONFIG_VIRGINA }}
waitTimes: 2000
velaAppDescription: nacos-${{ env.GITHUB_WORKFLOW }}-${{ github.run_id }}@${{ matrix.version }}
repoName: nacos
helm:
chart: ./cicd/helm
git:
branch: main
repoType: git
retries: 3
url: https://ghproxy.com/https://github.com/nacos-group/nacos-e2e.git
values:
namespace: nacos-${{ github.run_id }}-${{ strategy.job-index }}
global:
mode: ${{ matrix.mode }}
nacos:
replicaCount: ${{ env.REPLICA_COUNT }}
image:
repository: ${{ env.DOCKER_REPO_ACTUAL }}
tag: ${{ matrix.version }}
storage:
type: ${{ env.DATABASE }}
db:
port: 3306
username: nacos
password: nacos
param: characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false
service:
nodePort: ${{ env.NODE_PORT }}
type: ClusterIP
e2e-java-test:
if: ${{ success() }}
name: E2E Test
needs: [list-version, deploy]
name: Java e2e Test
needs: [docker, deploy]
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
mode: ["cluster","standalone"]
version: ${{ fromJSON(needs.list-version.outputs.version-json) }}
version: ${{ fromJSON(needs.docker.outputs.version-json) }}
steps:
- uses: apache/rocketmq-test-tool@136205caa6e97f81744e30adea114dd2f09cc55e
name: e2e test
- uses: apache/rocketmq-test-tool@java-dev
name: java e2e test
with:
action: "test"
ask-config: "${{ secrets.ASK_CONFIG_VIRGINA }}"
test-version: "${{ matrix.version }}"
test-code-git: "https://github.com/nacos-group/nacos-e2e.git"
test-code-branch: "main"
test-code-path: "java/nacos-2X"
test-cmd: 'mvn clean test -B'
job-id: ${{ strategy.job-index }}
- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
if: always() # always run even if the previous step fails
with:
report_paths: '**/test_report/TEST-*.xml'
annotate_only: true
include_passed: true
detailed_summary: true
yamlString: |
action: test
namespace: nacos-${{ github.run_id }}-${{ strategy.job-index }}
askConfig: ${{ secrets.ASK_CONFIG_VIRGINA }}
API_VERSION: v1
KIND: Pod
RESTART_POLICY: Never
ENV:
WAIT_TIME: 900
REPO_NAME: ${{ env.TEST_REPO_NAME }}
CODE: https://github.com/${{ env.TEST_REPO_NAME }}
BRANCH: main
CODE_PATH: java/nacos-2X
CMD: mvn clean test -B
ALL_IP: null
CONTAINER:
IMAGE: cloudnativeofalibabacloud/test-runner:v0.0.4
RESOURCE_LIMITS:
cpu: 2
memory: 2Gi
RESOURCE_REQUIRE:
cpu: 2
memory: 2Gi
- uses: actions/upload-artifact@v3
if: always()
name: Upload test log
with:
name: testlog.txt ${{ matrix.mode }}
name: testlog-${{ matrix.mode }}-java.txt
path: testlog.txt
- name: add markdown
if: always()
run: |
cat result.md >> $GITHUB_STEP_SUMMARY
e2e-go-test:
if: ${{ success() }}
name: GO E2E Test
needs: [docker, deploy]
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
mode: ["cluster","standalone"]
version: ${{ fromJSON(needs.docker.outputs.version-json) }}
steps:
- uses: apache/rocketmq-test-tool@java-dev
name: go e2e test
with:
yamlString: |
action: test
namespace: nacos-${{ github.run_id }}-${{ strategy.job-index }}
askConfig: ${{ secrets.ASK_CONFIG_VIRGINA }}
API_VERSION: v1
KIND: Pod
RESTART_POLICY: Never
ENV:
WAIT_TIME: 900
REPO_NAME: ${{ env.TEST_REPO_NAME }}
CODE: https://github.com/${{ env.TEST_REPO_NAME }}
BRANCH: main
CODE_PATH: golang
CMD: |
cd /root/code/golang && go mod init nacos_go_test && go mod tidy
gotestsum --junitfile ./target/surefire-reports/TEST-report.xml ./nacosgotest
ALL_IP: null
CONTAINER:
IMAGE: cloudnativeofalibabacloud/test-runner:v0.0.4
RESOURCE_LIMITS:
cpu: 2
memory: 2Gi
RESOURCE_REQUIRE:
cpu: 2
memory: 2Gi
- uses: actions/upload-artifact@v3
if: always()
name: Upload test log
with:
name: testlog-${{ matrix.mode }}-go.txt
path: testlog.txt
- name: add markdown
if: always()
run: |
cat result.md >> $GITHUB_STEP_SUMMARY
e2e-cpp-test:
if: ${{ success() }}
name: Cpp E2E Test
needs: [docker, deploy]
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
mode: ["cluster","standalone"]
version: ${{ fromJSON(needs.docker.outputs.version-json) }}
steps:
- uses: apache/rocketmq-test-tool@java-dev
name: cpp e2e test
with:
yamlString: |
action: test
namespace: nacos-${{ github.run_id }}-${{ strategy.job-index }}
askConfig: ${{ secrets.ASK_CONFIG_VIRGINA }}
API_VERSION: v1
KIND: Pod
RESTART_POLICY: Never
ENV:
WAIT_TIME: 900
REPO_NAME: ${{ env.TEST_REPO_NAME }}
CODE: https://github.com/${{ env.TEST_REPO_NAME }}
BRANCH: main
CODE_PATH: cpp
CMD: |
cd /root/code/cpp && make install
echo "export LD_LIBRARY_PATH=/usr/local/lib" >> ~/.bashrc && source ~/.bashrc
cd /root/code/cpp/nacoscpptest
g++ nacos_test.cpp -o nacos_test -lgtest -lpthread -I/usr/local/include/nacos/ -L/usr/local/lib/ -lnacos-cli
chmod 777 nacos_test && ./nacos_test --gtest_output="xml:../target/surefire-reports/TEST-gtestresults.xml"
ALL_IP: null
CONTAINER:
IMAGE: cloudnativeofalibabacloud/test-runner:v0.0.4
RESOURCE_LIMITS:
cpu: 2
memory: 2Gi
RESOURCE_REQUIRE:
cpu: 2
memory: 2Gi
- uses: actions/upload-artifact@v3
if: always()
name: Upload test log
with:
name: testlog-${{ matrix.mode }}-cpp.txt
path: testlog.txt
- name: add markdown
if: always()
run: |
cat result.md >> $GITHUB_STEP_SUMMARY
e2e-csharp-test:
if: ${{ success() }}
name: Csharp E2E Test
needs: [docker, deploy]
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
mode: ["cluster","standalone"]
version: ${{ fromJSON(needs.docker.outputs.version-json) }}
steps:
- uses: apache/rocketmq-test-tool@java-dev
name: csharp e2e test
with:
yamlString: |
action: test
namespace: nacos-${{ github.run_id }}-${{ strategy.job-index }}
askConfig: ${{ secrets.ASK_CONFIG_VIRGINA }}
API_VERSION: v1
KIND: Pod
RESTART_POLICY: Never
ENV:
WAIT_TIME: 900
REPO_NAME: ${{ env.TEST_REPO_NAME }}
CODE: https://github.com/${{ env.TEST_REPO_NAME }}
BRANCH: main
CODE_PATH: csharp
CMD: |
rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
yum -y install dotnet-sdk-3.1 && yum -y install aspnetcore-runtime-7.0
cd /root/code/csharp/nacos-csharp-sdk-test && dotnet restore
dotnet test --logger:"junit;LogFilePath=../target/surefire-reports/TEST-result.xml"
ALL_IP: null
CONTAINER:
IMAGE: cloudnativeofalibabacloud/test-runner:v0.0.4
RESOURCE_LIMITS:
cpu: 2
memory: 2Gi
RESOURCE_REQUIRE:
cpu: 2
memory: 2Gi
- uses: actions/upload-artifact@v3
if: always()
name: Upload test log
with:
name: testlog-${{ matrix.mode }}-csharp.txt
path: testlog.txt
- name: add markdown
if: always()
run: |
cat result.md >> $GITHUB_STEP_SUMMARY
e2e-nodejs-test:
if: ${{ success() }}
name: Nodejs E2E Test
needs: [docker, deploy]
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
mode: ["cluster","standalone"]
version: ${{ fromJSON(needs.docker.outputs.version-json) }}
steps:
- uses: apache/rocketmq-test-tool@java-dev
name: nodejs e2e test
with:
yamlString: |
action: test
namespace: nacos-${{ github.run_id }}-${{ strategy.job-index }}
askConfig: ${{ secrets.ASK_CONFIG_VIRGINA }}
API_VERSION: v1
KIND: Pod
RESTART_POLICY: Never
ENV:
WAIT_TIME: 900
REPO_NAME: ${{ env.TEST_REPO_NAME }}
CODE: https://github.com/${{ env.TEST_REPO_NAME }}
BRANCH: main
CODE_PATH: nodejs
CMD: |
cd /root/code/nodejs/nacosnodejstest && npm install
mocha test --reporter mocha-junit-reporter --reporter-options mochaFile=../target/surefire-reports/TEST-report.xml
ALL_IP: null
CONTAINER:
IMAGE: cloudnativeofalibabacloud/test-runner:v0.0.4
RESOURCE_LIMITS:
cpu: 2
memory: 2Gi
RESOURCE_REQUIRE:
cpu: 2
memory: 2Gi
- uses: actions/upload-artifact@v3
if: always()
name: Upload test log
with:
name: testlog-${{ matrix.mode }}-nodejs.txt
path: testlog.txt
- name: add markdown
if: always()
run: |
cat result.md >> $GITHUB_STEP_SUMMARY
e2e-python-test:
if: ${{ success() }}
name: Python E2E Test
needs: [docker, deploy]
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
mode: ["cluster","standalone"]
version: ${{ fromJSON(needs.docker.outputs.version-json) }}
steps:
- uses: apache/rocketmq-test-tool@java-dev
name: python e2e test
with:
yamlString: |
action: test
namespace: nacos-${{ github.run_id }}-${{ strategy.job-index }}
askConfig: ${{ secrets.ASK_CONFIG_VIRGINA }}
API_VERSION: v1
KIND: Pod
RESTART_POLICY: Never
ENV:
WAIT_TIME: 900
REPO_NAME: ${{ env.TEST_REPO_NAME }}
CODE: https://github.com/${{ env.TEST_REPO_NAME }}
BRANCH: main
CODE_PATH: python
CMD: |
cd /root/code/python
pip3 install -r requirements.txt
source ~/.bashrc
cd nacospythontest && pytest --junitxml ../target/surefire-reports/TEST-report.xml test/*_test.py --log-cli-level=DEBUG
ALL_IP: null
CONTAINER:
IMAGE: cloudnativeofalibabacloud/test-runner:v0.0.4
RESOURCE_LIMITS:
cpu: 2
memory: 2Gi
RESOURCE_REQUIRE:
cpu: 2
memory: 2Gi
- uses: actions/upload-artifact@v3
if: always()
name: Upload test log
with:
name: testlog-${{ matrix.mode }}-python.txt
path: testlog.txt
- name: add markdown
if: always()
run: |
cat result.md >> $GITHUB_STEP_SUMMARY
clean:
if: always()
name: Clean
needs: [list-version, e2e-test]
needs: [docker, e2e-java-test, e2e-go-test, e2e-cpp-test, e2e-csharp-test, e2e-nodejs-test, e2e-python-test]
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
mode: ["cluster","standalone"]
version: ${{ fromJSON(needs.list-version.outputs.version-json) }}
version: ${{ fromJSON(needs.docker.outputs.version-json) }}
steps:
- uses: apache/rocketmq-test-tool@136205caa6e97f81744e30adea114dd2f09cc55e
- uses: apache/rocketmq-test-tool@java-dev
name: clean
with:
action: "clean"
ask-config: "${{ secrets.ASK_CONFIG_VIRGINA }}"
test-version: "${{ matrix.version }}"
job-id: ${{ strategy.job-index }}
yamlString: |
action: clean
namespace: nacos-${{ github.run_id }}-${{ strategy.job-index }}
askConfig: ${{ secrets.ASK_CONFIG_VIRGINA }}

View File

@ -5,15 +5,15 @@ on:
branches: [master, develop, v1.x-develop, v1.X]
permissions:
contents: read # to fetch code (actions/checkout)
contents: read
concurrency:
group: nacos-${{ github.ref }}
env:
DOCKER_REPO: wuyfeedocker/nacos-ci
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
DOCKER_REPO_B: wuyfeehub/nacos-ci
TEST_REPO_NAME: nacos-group/nacos-e2e
jobs:
dist-tar:
@ -50,10 +50,15 @@ jobs:
needs: [dist-tar]
runs-on: ubuntu-latest
timeout-minutes: 30
env:
DOCKERHUB_USER_ACTUAL: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_TOKEN_ACTUAL: ${{ secrets.DOCKERHUB_TOKEN }}
strategy:
matrix:
base-image: ["centos"]
java-version: ["8"]
outputs:
version-json: ${{ steps.show_versions.outputs.version-json }}
steps:
- uses: actions/checkout@v3
with:
@ -65,13 +70,7 @@ jobs:
with:
name: nacos
path: ./
- name: docker-login
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and save docker images
- name: Generate image tag
id: build-images
run: |
mv nacos-server-*.tar.gz nacos-e2e/cicd/build/
@ -80,42 +79,44 @@ jobs:
mkdir versionlist
touch versionlist/"${version}-`echo ${{ matrix.java-version }} | sed -e "s/:/-/g"`"
ls versionlist/
tag=${version}-$(echo ${{ matrix.java-version }} | sed -e "s/:/-/g")
echo $tag
docker build --no-cache -f Dockerfile -t ${DOCKER_REPO}:${tag} .
docker push ${DOCKER_REPO}:${tag}
- uses: actions/upload-artifact@v3
name: Upload distribution tar
echo TAG=${version}-$(echo ${{ matrix.java-version }} | sed -e "s/:/-/g") >> $GITHUB_ENV
- name: docker-login-1
uses: docker/login-action@v2
with:
name: versionlist
path: nacos-e2e/cicd/build/versionlist/*
list-version:
if: always()
name: List version
needs: [docker]
runs-on: ubuntu-latest
timeout-minutes: 30
outputs:
version-json: ${{ steps.show_versions.outputs.version-json }}
steps:
- uses: actions/download-artifact@v3
name: Download versionlist
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: save docker_1 images
run: |
mkdir build_backup
cp -rf nacos-e2e/cicd/build/* ./build_backup/
cd nacos-e2e/cicd/build
docker build --no-cache -f Dockerfile -t ${DOCKER_REPO}:${{ env.TAG }} .
docker push ${DOCKER_REPO}:${{ env.TAG }}
- name: docker-login-2
uses: docker/login-action@v2
with:
name: versionlist
path: versionlist
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKERHUB_USER_B }}
password: ${{ secrets.DOCKERHUB_TOKEN_B }}
- name: save docker_2 images
run: |
rm -rf nacos-e2e/cicd/build/*
mv ./build_backup/* nacos-e2e/cicd/build/
cd nacos-e2e/cicd/build
docker build --no-cache -f Dockerfile -t ${DOCKER_REPO_B}:${{ env.TAG }} .
docker push ${DOCKER_REPO_B}:${{ env.TAG }}
- name: Show versions
id: show_versions
run: |
a=(`ls versionlist`)
a=(`ls nacos-e2e/cicd/build/versionlist`)
printf '%s\n' "${a[@]}" | jq -R . | jq -s .
echo version-json=`printf '%s\n' "${a[@]}" | jq -R . | jq -s .` >> $GITHUB_OUTPUT
deploy:
if: ${{ success() }}
name: Deploy nacos
needs: [list-version,docker]
needs: [docker]
runs-on: ubuntu-latest
timeout-minutes: 60
env:
@ -123,99 +124,390 @@ jobs:
DATABASE: mysql
NODE_PORT: 30000
strategy:
fail-fast: false
matrix:
mode: ["cluster","standalone"]
version: ${{ fromJSON(needs.list-version.outputs.version-json) }}
version: ${{ fromJSON(needs.docker.outputs.version-json) }}
steps:
- name: set nodeport
run: |
echo "::set-env name=NODE_PORT::$(expr $(expr $(expr $(expr 1 * $(expr ${{ github.run_number }} - 1)) + ${{ strategy.job-index }}) % 30000) + 30000)"
echo "NODE_PORT=$(expr $(expr $(expr $(expr ${{ strategy.job-index }} + 1) * ${{ github.run_number }}) % 30000) + 30000)" >> $GITHUB_ENV
- name: set cluster params
if: ${{ matrix.mode == 'standalone' }}
run: |
echo "::set-env name=REPLICA_COUNT::1"
echo "::set-env name=DATABASE::embedded"
- uses: apache/rocketmq-test-tool@136205caa6e97f81744e30adea114dd2f09cc55e
echo "REPLICA_COUNT=1" >> $GITHUB_ENV
echo "DATABASE=embedded" >> $GITHUB_ENV
- name: allocate docker repo
run: |
if [[ $(expr $(expr ${{ github.run_id }} + ${{ strategy.job-index }} ) % 2 ) -eq 1 ]]; then
echo "DOCKER_REPO_ACTUAL=${{ env.DOCKER_REPO }}" >> $GITHUB_ENV
else
echo "DOCKER_REPO_ACTUAL=${{ env.DOCKER_REPO_B }}" >> $GITHUB_ENV
fi
- uses: apache/rocketmq-test-tool@java-dev
name: Deploy nacos
with:
action: "deploy"
ask-config: "${{ secrets.ASK_CONFIG_VIRGINA }}"
test-version: "${{ matrix.version }}"
chart-git: "https://ghproxy.com/https://github.com/nacos-group/nacos-e2e.git"
chart-branch: "main"
chart-path: "./cicd/helm"
job-id: ${{ strategy.job-index }}
helm-values: |
yamlString: |
action: deploy
namespace: nacos-${{ github.run_id }}-${{ strategy.job-index }}
global:
mode: ${{ matrix.mode }}
nacos:
replicaCount: ${{ env.REPLICA_COUNT }}
image:
repository: ${{ env.DOCKER_REPO }}
tag: ${{ matrix.version }}
storage:
type: ${{ env.DATABASE }}
db:
port: 3306
username: nacos
password: nacos
param: characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false
service:
nodePort: ${{ env.NODE_PORT }}
type: ClusterIP
e2e-test:
askConfig: ${{ secrets.ASK_CONFIG_VIRGINA }}
waitTimes: 2000
velaAppDescription: nacos-${{ env.GITHUB_WORKFLOW }}-${{ github.run_id }}@${{ matrix.version }}
repoName: nacos
helm:
chart: ./cicd/helm
git:
branch: main
repoType: git
retries: 3
url: https://ghproxy.com/https://github.com/nacos-group/nacos-e2e.git
values:
namespace: nacos-${{ github.run_id }}-${{ strategy.job-index }}
global:
mode: ${{ matrix.mode }}
nacos:
replicaCount: ${{ env.REPLICA_COUNT }}
image:
repository: ${{ env.DOCKER_REPO_ACTUAL }}
tag: ${{ matrix.version }}
storage:
type: ${{ env.DATABASE }}
db:
port: 3306
username: nacos
password: nacos
param: characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false
service:
nodePort: ${{ env.NODE_PORT }}
type: ClusterIP
e2e-java-test:
if: ${{ success() }}
name: E2E Test
needs: [list-version, deploy]
name: Java e2e Test
needs: [docker, deploy]
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
mode: ["cluster","standalone"]
version: ${{ fromJSON(needs.list-version.outputs.version-json) }}
version: ${{ fromJSON(needs.docker.outputs.version-json) }}
steps:
- uses: apache/rocketmq-test-tool@136205caa6e97f81744e30adea114dd2f09cc55e
name: e2e test
- uses: apache/rocketmq-test-tool@java-dev
name: java e2e test
with:
action: "test"
ask-config: "${{ secrets.ASK_CONFIG_VIRGINA }}"
test-version: "${{ matrix.version }}"
test-code-git: "https://github.com/nacos-group/nacos-e2e.git"
test-code-branch: "main"
test-code-path: "java/nacos-2X"
test-cmd: 'mvn clean test -B'
job-id: ${{ strategy.job-index }}
- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
if: always() # always run even if the previous step fails
with:
report_paths: '**/test_report/TEST-*.xml'
annotate_only: true
include_passed: true
detailed_summary: true
yamlString: |
action: test
namespace: nacos-${{ github.run_id }}-${{ strategy.job-index }}
askConfig: ${{ secrets.ASK_CONFIG_VIRGINA }}
API_VERSION: v1
KIND: Pod
RESTART_POLICY: Never
ENV:
WAIT_TIME: 900
REPO_NAME: ${{ env.TEST_REPO_NAME }}
CODE: https://github.com/${{ env.TEST_REPO_NAME }}
BRANCH: main
CODE_PATH: java/nacos-2X
CMD: mvn clean test -B
ALL_IP: null
CONTAINER:
IMAGE: cloudnativeofalibabacloud/test-runner:v0.0.4
RESOURCE_LIMITS:
cpu: 2
memory: 2Gi
RESOURCE_REQUIRE:
cpu: 2
memory: 2Gi
- uses: actions/upload-artifact@v3
if: always()
name: Upload test log
with:
name: testlog.txt ${{ matrix.mode }}
name: testlog-${{ matrix.mode }}-java.txt
path: testlog.txt
- name: add markdown
if: always()
run: |
cat result.md >> $GITHUB_STEP_SUMMARY
e2e-go-test:
if: ${{ success() }}
name: GO E2E Test
needs: [docker, deploy]
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
mode: ["cluster","standalone"]
version: ${{ fromJSON(needs.docker.outputs.version-json) }}
steps:
- uses: apache/rocketmq-test-tool@java-dev
name: go e2e test
with:
yamlString: |
action: test
namespace: nacos-${{ github.run_id }}-${{ strategy.job-index }}
askConfig: ${{ secrets.ASK_CONFIG_VIRGINA }}
API_VERSION: v1
KIND: Pod
RESTART_POLICY: Never
ENV:
WAIT_TIME: 900
REPO_NAME: ${{ env.TEST_REPO_NAME }}
CODE: https://github.com/${{ env.TEST_REPO_NAME }}
BRANCH: main
CODE_PATH: golang
CMD: |
cd /root/code/golang && go mod init nacos_go_test && go mod tidy
gotestsum --junitfile ./target/surefire-reports/TEST-report.xml ./nacosgotest
ALL_IP: null
CONTAINER:
IMAGE: cloudnativeofalibabacloud/test-runner:v0.0.4
RESOURCE_LIMITS:
cpu: 2
memory: 2Gi
RESOURCE_REQUIRE:
cpu: 2
memory: 2Gi
- uses: actions/upload-artifact@v3
if: always()
name: Upload test log
with:
name: testlog-${{ matrix.mode }}-go.txt
path: testlog.txt
- name: add markdown
if: always()
run: |
cat result.md >> $GITHUB_STEP_SUMMARY
e2e-cpp-test:
if: ${{ success() }}
name: Cpp E2E Test
needs: [docker, deploy]
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
mode: ["cluster","standalone"]
version: ${{ fromJSON(needs.docker.outputs.version-json) }}
steps:
- uses: apache/rocketmq-test-tool@java-dev
name: cpp e2e test
with:
yamlString: |
action: test
namespace: nacos-${{ github.run_id }}-${{ strategy.job-index }}
askConfig: ${{ secrets.ASK_CONFIG_VIRGINA }}
API_VERSION: v1
KIND: Pod
RESTART_POLICY: Never
ENV:
WAIT_TIME: 900
REPO_NAME: ${{ env.TEST_REPO_NAME }}
CODE: https://github.com/${{ env.TEST_REPO_NAME }}
BRANCH: main
CODE_PATH: cpp
CMD: |
cd /root/code/cpp && make install
echo "export LD_LIBRARY_PATH=/usr/local/lib" >> ~/.bashrc && source ~/.bashrc
cd /root/code/cpp/nacoscpptest
g++ nacos_test.cpp -o nacos_test -lgtest -lpthread -I/usr/local/include/nacos/ -L/usr/local/lib/ -lnacos-cli
chmod 777 nacos_test && ./nacos_test --gtest_output="xml:../target/surefire-reports/TEST-gtestresults.xml"
ALL_IP: null
CONTAINER:
IMAGE: cloudnativeofalibabacloud/test-runner:v0.0.4
RESOURCE_LIMITS:
cpu: 2
memory: 2Gi
RESOURCE_REQUIRE:
cpu: 2
memory: 2Gi
- uses: actions/upload-artifact@v3
if: always()
name: Upload test log
with:
name: testlog-${{ matrix.mode }}-cpp.txt
path: testlog.txt
- name: add markdown
if: always()
run: |
cat result.md >> $GITHUB_STEP_SUMMARY
e2e-csharp-test:
if: ${{ success() }}
name: Csharp E2E Test
needs: [docker, deploy]
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
mode: ["cluster","standalone"]
version: ${{ fromJSON(needs.docker.outputs.version-json) }}
steps:
- uses: apache/rocketmq-test-tool@java-dev
name: csharp e2e test
with:
yamlString: |
action: test
namespace: nacos-${{ github.run_id }}-${{ strategy.job-index }}
askConfig: ${{ secrets.ASK_CONFIG_VIRGINA }}
API_VERSION: v1
KIND: Pod
RESTART_POLICY: Never
ENV:
WAIT_TIME: 900
REPO_NAME: ${{ env.TEST_REPO_NAME }}
CODE: https://github.com/${{ env.TEST_REPO_NAME }}
BRANCH: main
CODE_PATH: csharp
CMD: |
rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
yum -y install dotnet-sdk-3.1 && yum -y install aspnetcore-runtime-7.0
cd /root/code/csharp/nacos-csharp-sdk-test && dotnet restore
dotnet test --logger:"junit;LogFilePath=../target/surefire-reports/TEST-result.xml"
ALL_IP: null
CONTAINER:
IMAGE: cloudnativeofalibabacloud/test-runner:v0.0.4
RESOURCE_LIMITS:
cpu: 2
memory: 2Gi
RESOURCE_REQUIRE:
cpu: 2
memory: 2Gi
- uses: actions/upload-artifact@v3
if: always()
name: Upload test log
with:
name: testlog-${{ matrix.mode }}-csharp.txt
path: testlog.txt
- name: add markdown
if: always()
run: |
cat result.md >> $GITHUB_STEP_SUMMARY
e2e-nodejs-test:
if: ${{ success() }}
name: Nodejs E2E Test
needs: [docker, deploy]
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
mode: ["cluster","standalone"]
version: ${{ fromJSON(needs.docker.outputs.version-json) }}
steps:
- uses: apache/rocketmq-test-tool@java-dev
name: nodejs e2e test
with:
yamlString: |
action: test
namespace: nacos-${{ github.run_id }}-${{ strategy.job-index }}
askConfig: ${{ secrets.ASK_CONFIG_VIRGINA }}
API_VERSION: v1
KIND: Pod
RESTART_POLICY: Never
ENV:
WAIT_TIME: 900
REPO_NAME: ${{ env.TEST_REPO_NAME }}
CODE: https://github.com/${{ env.TEST_REPO_NAME }}
BRANCH: main
CODE_PATH: nodejs
CMD: |
cd /root/code/nodejs/nacosnodejstest && npm install
mocha test --reporter mocha-junit-reporter --reporter-options mochaFile=../target/surefire-reports/TEST-report.xml
ALL_IP: null
CONTAINER:
IMAGE: cloudnativeofalibabacloud/test-runner:v0.0.4
RESOURCE_LIMITS:
cpu: 2
memory: 2Gi
RESOURCE_REQUIRE:
cpu: 2
memory: 2Gi
- uses: actions/upload-artifact@v3
if: always()
name: Upload test log
with:
name: testlog-${{ matrix.mode }}-nodejs.txt
path: testlog.txt
- name: add markdown
if: always()
run: |
cat result.md >> $GITHUB_STEP_SUMMARY
e2e-python-test:
if: ${{ success() }}
name: Python E2E Test
needs: [docker, deploy]
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
mode: ["cluster","standalone"]
version: ${{ fromJSON(needs.docker.outputs.version-json) }}
steps:
- uses: apache/rocketmq-test-tool@java-dev
name: python e2e test
with:
yamlString: |
action: test
namespace: nacos-${{ github.run_id }}-${{ strategy.job-index }}
askConfig: ${{ secrets.ASK_CONFIG_VIRGINA }}
API_VERSION: v1
KIND: Pod
RESTART_POLICY: Never
ENV:
WAIT_TIME: 900
REPO_NAME: ${{ env.TEST_REPO_NAME }}
CODE: https://github.com/${{ env.TEST_REPO_NAME }}
BRANCH: main
CODE_PATH: python
CMD: |
cd /root/code/python && pip3 install -r requirements.txt && source ~/.bashrc
cd nacospythontest && pytest --junitxml ../target/surefire-reports/TEST-report.xml test/*_test.py --log-cli-level=DEBUG
ALL_IP: null
CONTAINER:
IMAGE: cloudnativeofalibabacloud/test-runner:v0.0.4
RESOURCE_LIMITS:
cpu: 2
memory: 2Gi
RESOURCE_REQUIRE:
cpu: 2
memory: 2Gi
- uses: actions/upload-artifact@v3
if: always()
name: Upload test log
with:
name: testlog-${{ matrix.mode }}-python.txt
path: testlog.txt
- name: add markdown
if: always()
run: |
cat result.md >> $GITHUB_STEP_SUMMARY
clean:
if: always()
name: Clean
needs: [list-version, e2e-test]
needs: [docker, e2e-java-test, e2e-go-test, e2e-cpp-test, e2e-csharp-test, e2e-nodejs-test, e2e-python-test]
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
mode: ["cluster","standalone"]
version: ${{ fromJSON(needs.list-version.outputs.version-json) }}
version: ${{ fromJSON(needs.docker.outputs.version-json) }}
steps:
- uses: apache/rocketmq-test-tool@136205caa6e97f81744e30adea114dd2f09cc55e
- uses: apache/rocketmq-test-tool@java-dev
name: clean
with:
action: "clean"
ask-config: "${{ secrets.ASK_CONFIG_VIRGINA }}"
test-version: "${{ matrix.version }}"
job-id: ${{ strategy.job-index }}
yamlString: |
action: clean
namespace: nacos-${{ github.run_id }}-${{ strategy.job-index }}
askConfig: ${{ secrets.ASK_CONFIG_VIRGINA }}

1
.gitignore vendored
View File

@ -18,3 +18,4 @@ test/logs
derby.log
yarn.lock
.flattened-pom.xml
lefthook.yml

View File

@ -116,7 +116,7 @@
* [#175] Support deregistering instance automatically.
* [#176] Naming client query instance method should bypass local cache at client start.
* [#177] Console supports registering new empty service and delete empty service.
* [#181] NPE when adding a instance if no leader in the raft cluster.
* [#181] NPE when adding an instance if no leader in the raft cluster.
* [#193] Configure host domain name cause nacos server cluster is unavailable.
* [#209] Disable service and cluster level customization in client registerInstance method.
* [#214] Please support Java 11.

View File

@ -86,7 +86,7 @@ You can view the full documentation from the [Nacos website](https://nacos.io/en
You can also read this online eBook from the [NACOS ARCHITECTURE & PRINCIPLES](https://www.yuque.com/nacos/ebook/kbyo6n).
All the latest and long-term notice can also be found here from [Github notice issue](https://github.com/alibaba/nacos/labels/notice).
All the latest and long-term notice can also be found here from [GitHub notice issue](https://github.com/alibaba/nacos/labels/notice).
## Contributing
@ -121,19 +121,21 @@ Contributors are welcomed to join Nacos project. Please check [CONTRIBUTING](./C
* commits-nacos@googlegroups.com: Commits notice, very high frequency.
* Join us from DingDing(Group 1: 21708933(full), Group 2: 30438813(full), Group 3: 31222241(full), Group 4: 12810027056).
![Nacos](https://img.alicdn.com/imgextra/i1/O1CN01ULSVXu1DRbANwVC6r_!!6000000000213-2-tps-666-884.png)
<img src="https://img.alicdn.com/imgextra/i4/O1CN01MI7re41xTrZNdB7Yv_!!6000000006445-0-tps-974-1228.jpg" width="500">
## Enterprise Service
If you need Nacos enterprise service support, or purchase cloud product services, you can join the discussion by scanning the following DingTalk group. It can also be directly activated and used through the microservice engine (MSE) provided by Alibaba Cloud.
https://cn.aliyun.com/product/aliware/mse?spm=nacos-website.topbar.0.0.0
![image](https://user-images.githubusercontent.com/17695352/128659442-65b030b8-c5f4-4bb7-baa2-e5b3ef0cbc15.png)
<img src="https://img.alicdn.com/imgextra/i3/O1CN01RTfN7q1KUzX4TcH08_!!6000000001168-2-tps-864-814.png" width="500">
## Download
- [Github Release](https://github.com/alibaba/nacos/releases)
- [Baidu Netdisk](https://pan.baidu.com/s/1186nmlqPGows9gUZKAx8Zw) Fetch Code : `rest`
- [Nacos Official Website](https://nacos.io/download/nacos-server)
- [GitHub Release](https://github.com/alibaba/nacos/releases)
## Who is using
These are only part of the companies using Nacos, for reference only. If you are using Nacos, please [add your company here](https://github.com/alibaba/nacos/issues/273) to tell us your scenario to make Nacos better.

View File

@ -41,8 +41,8 @@
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

View File

@ -96,7 +96,7 @@ public class AddressServerGeneratorManager {
/**
* Generate response ips.
*
* @param instanceList a instance set will generate string response to client.
* @param instanceList an instance set will generate string response to client.
* @return the result of response to client
*/
public String generateResponseIps(List<com.alibaba.nacos.api.naming.pojo.Instance> instanceList) {
@ -113,7 +113,7 @@ public class AddressServerGeneratorManager {
/**
* Generate nacos service name.
*
* @param rawServiceName the raw service name will not contains the {@link Constants#DEFAULT_GROUP}.
* @param rawServiceName the raw service name will not contain the {@link Constants#DEFAULT_GROUP}.
* @return the nacos service name
*/
public String generateNacosServiceName(String rawServiceName) {

View File

@ -16,22 +16,26 @@
package com.alibaba.nacos.address.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.SecurityFilterChain;
/**
* nacos web security configuration.
*
* @author onewe
*/
@Configuration
@Order(99)
public class AddressServerSecurityConfiguration extends WebSecurityConfigurerAdapter {
public class AddressServerSecurityConfiguration {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeHttpRequests(requestMatcherRegistry -> requestMatcherRegistry.mvcMatchers("/nacos/v1/as/**").authenticated())
.csrf().disable().httpBasic();
@Bean
@Order(99)
public SecurityFilterChain addressServerSecurityFilterChain(HttpSecurity http) throws Exception {
http.authorizeHttpRequests(
requestMatcherRegistry -> requestMatcherRegistry.mvcMatchers("/nacos/v1/as/**").authenticated()).csrf()
.disable().httpBasic();
return http.build();
}
}

View File

@ -18,55 +18,59 @@ package com.alibaba.nacos.address.component;
import com.alibaba.nacos.address.constant.AddressServerConstants;
import com.alibaba.nacos.api.naming.pojo.Instance;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
public class AddressServerGeneratorManagerTest {
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
class AddressServerGeneratorManagerTest {
@Test
public void testGenerateProductName() {
void testGenerateProductName() {
AddressServerGeneratorManager manager = new AddressServerGeneratorManager();
final String blankName = manager.generateProductName("");
Assert.assertEquals(AddressServerConstants.ALIWARE_NACOS_DEFAULT_PRODUCT_NAME, blankName);
assertEquals(AddressServerConstants.ALIWARE_NACOS_DEFAULT_PRODUCT_NAME, blankName);
final String defaultName = manager.generateProductName(AddressServerConstants.DEFAULT_PRODUCT);
Assert.assertEquals(AddressServerConstants.ALIWARE_NACOS_DEFAULT_PRODUCT_NAME, defaultName);
assertEquals(AddressServerConstants.ALIWARE_NACOS_DEFAULT_PRODUCT_NAME, defaultName);
final String testName = manager.generateProductName("test");
Assert.assertEquals("nacos.as.test", testName);
assertEquals("nacos.as.test", testName);
}
@Test
public void testGenerateInstancesByIps() {
void testGenerateInstancesByIps() {
AddressServerGeneratorManager manager = new AddressServerGeneratorManager();
final List<Instance> empty = manager.generateInstancesByIps(null, null, null, null);
Assert.assertNotNull(empty);
Assert.assertTrue(empty.isEmpty());
assertNotNull(empty);
assertTrue(empty.isEmpty());
String[] ipArray = new String[]{"192.168.3.1:8848", "192.168.3.2:8848", "192.168.3.3:8848"};
final List<Instance> instanceList = manager.generateInstancesByIps("DEFAULT_GROUP@@nacos.as.test", "test", "test",
ipArray);
Assert.assertNotNull(instanceList);
Assert.assertFalse(instanceList.isEmpty());
Assert.assertEquals(3, instanceList.size());
assertNotNull(instanceList);
assertFalse(instanceList.isEmpty());
assertEquals(3, instanceList.size());
final Instance instance1 = instanceList.get(0);
Assert.assertEquals("192.168.3.1", instance1.getIp());
assertEquals("192.168.3.1", instance1.getIp());
final Instance instance2 = instanceList.get(1);
Assert.assertEquals("192.168.3.2", instance2.getIp());
assertEquals("192.168.3.2", instance2.getIp());
final Instance instance3 = instanceList.get(2);
Assert.assertEquals("192.168.3.3", instance3.getIp());
assertEquals("192.168.3.3", instance3.getIp());
}
@Test
public void testGenerateResponseIps() {
void testGenerateResponseIps() {
final List<com.alibaba.nacos.api.naming.pojo.Instance> instanceList = new ArrayList<>();
Instance instance1 = new Instance();
instance1.setIp("192.168.3.1");
@ -92,19 +96,19 @@ public class AddressServerGeneratorManagerTest {
.append("192.168.3.1:8848").append('\n')
.append("192.168.3.2:8848").append('\n')
.append("192.168.3.3:8848").append('\n');
Assert.assertEquals(ret.toString(), ipListStr);
assertEquals(ret.toString(), ipListStr);
}
@Test
public void testGenerateNacosServiceName() {
void testGenerateNacosServiceName() {
AddressServerGeneratorManager manager = new AddressServerGeneratorManager();
final String containDefault = manager.generateNacosServiceName("DEFAULT_GROUP@@test");
Assert.assertEquals("DEFAULT_GROUP@@test", containDefault);
assertEquals("DEFAULT_GROUP@@test", containDefault);
final String product = manager.generateNacosServiceName("product");
Assert.assertEquals("DEFAULT_GROUP@@product", product);
assertEquals("DEFAULT_GROUP@@product", product);
}
}

View File

@ -17,38 +17,38 @@
package com.alibaba.nacos.address.component;
import com.alibaba.nacos.address.constant.AddressServerConstants;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class AddressServerManagerTests {
class AddressServerManagerTests {
private static final AddressServerManager ADDRESS_SERVER_MANAGER = new AddressServerManager();
@Test
public void getRawProductName() {
void getRawProductName() {
assertEquals(AddressServerConstants.DEFAULT_PRODUCT, ADDRESS_SERVER_MANAGER.getRawProductName(""));
assertEquals(AddressServerConstants.DEFAULT_PRODUCT,
ADDRESS_SERVER_MANAGER.getRawProductName(AddressServerConstants.DEFAULT_PRODUCT));
assertEquals("otherProduct", ADDRESS_SERVER_MANAGER.getRawProductName("otherProduct"));
}
@Test
public void getDefaultClusterNameIfEmpty() {
void getDefaultClusterNameIfEmpty() {
assertEquals(AddressServerConstants.DEFAULT_GET_CLUSTER, ADDRESS_SERVER_MANAGER.getDefaultClusterNameIfEmpty(""));
assertEquals(AddressServerConstants.DEFAULT_GET_CLUSTER,
ADDRESS_SERVER_MANAGER.getDefaultClusterNameIfEmpty(AddressServerConstants.DEFAULT_GET_CLUSTER));
assertEquals("otherServerList", ADDRESS_SERVER_MANAGER.getDefaultClusterNameIfEmpty("otherServerList"));
}
@Test
public void testGetRawClusterName() {
void testGetRawClusterName() {
assertEquals("serverList", ADDRESS_SERVER_MANAGER.getRawClusterName("serverList"));
assertEquals(AddressServerConstants.DEFAULT_GET_CLUSTER, ADDRESS_SERVER_MANAGER.getRawClusterName(""));
}
@Test
public void testSplitIps() {
void testSplitIps() {
final String[] emptyArr = ADDRESS_SERVER_MANAGER.splitIps("");
assertEquals(0, emptyArr.length);
final String[] one = ADDRESS_SERVER_MANAGER.splitIps("192.168.1.12:8848");

View File

@ -26,13 +26,13 @@ import com.alibaba.nacos.naming.core.InstanceOperator;
import com.alibaba.nacos.naming.core.v2.ServiceManager;
import com.alibaba.nacos.naming.core.v2.metadata.NamingMetadataManager;
import com.alibaba.nacos.naming.core.v2.pojo.Service;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
@ -40,8 +40,8 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@RunWith(MockitoJUnitRunner.class)
public class AddressServerClusterControllerTest {
@ExtendWith(MockitoExtension.class)
class AddressServerClusterControllerTest {
@Mock
private InstanceOperator instanceOperator;
@ -53,9 +53,9 @@ public class AddressServerClusterControllerTest {
private ClusterOperator clusterOperator;
private MockMvc mockMvc;
@Before
public void before() {
@BeforeEach
void before() {
mockMvc = MockMvcBuilders.standaloneSetup(
new AddressServerClusterController(instanceOperator, metadataManager, clusterOperator,
new AddressServerManager(), new AddressServerGeneratorManager())).build();
@ -63,30 +63,30 @@ public class AddressServerClusterControllerTest {
.newService(Constants.DEFAULT_NAMESPACE_ID, Constants.DEFAULT_GROUP, "nacos.as.default", false);
ServiceManager.getInstance().getSingleton(service);
}
@After
public void tearDown() {
@AfterEach
void tearDown() {
Service service = Service
.newService(Constants.DEFAULT_NAMESPACE_ID, Constants.DEFAULT_GROUP, "nacos.as.default", false);
ServiceManager.getInstance().removeSingleton(service);
}
@Test
public void testPostCluster() throws Exception {
void testPostCluster() throws Exception {
mockMvc.perform(post("/nacos/v1/as/nodes").param("product", "default").param("cluster", "serverList")
.param("ips", "192.168.3.1,192.168.3.2")).andExpect(status().isOk());
}
@Test
public void testPostClusterWithErrorIps() throws Exception {
void testPostClusterWithErrorIps() throws Exception {
mockMvc.perform(post("/nacos/v1/as/nodes").param("product", "default").param("cluster", "serverList")
.param("ips", "192.168.1")).andExpect(status().isBadRequest());
}
@Test
public void testPostClusterThrowException() throws Exception {
void testPostClusterThrowException() throws Exception {
Mockito.doThrow(new NacosException(500, "create service error")).when(clusterOperator)
.updateClusterMetadata(Mockito.eq(Constants.DEFAULT_NAMESPACE_ID), Mockito.eq(
@ -97,34 +97,34 @@ public class AddressServerClusterControllerTest {
.param("ips", "192.168.1")).andExpect(status().isInternalServerError());
}
@Test
public void testDeleteCluster() throws Exception {
void testDeleteCluster() throws Exception {
mockMvc.perform(delete("/nacos/v1/as/nodes").param("product", "default").param("cluster", "serverList")
.param("ips", "192.168.3.1,192.168.3.2")).andExpect(status().isOk());
}
@Test
public void testDeleteClusterCannotFindService() throws Exception {
void testDeleteClusterCannotFindService() throws Exception {
tearDown();
mockMvc.perform(delete("/nacos/v1/as/nodes").param("product", "default").param("cluster", "serverList")
.param("ips", "192.168.3.1,192.168.3.2")).andExpect(status().isNotFound());
}
@Test
public void testDeleteClusterEmptyIps() throws Exception {
void testDeleteClusterEmptyIps() throws Exception {
mockMvc.perform(delete("/nacos/v1/as/nodes").param("product", "default").param("cluster", "serverList")
.param("ips", "")).andExpect(status().isBadRequest());
}
@Test
public void testDeleteClusterErrorIps() throws Exception {
void testDeleteClusterErrorIps() throws Exception {
mockMvc.perform(delete("/nacos/v1/as/nodes").param("product", "default").param("cluster", "serverList")
.param("ips", "192.168.1")).andExpect(status().isBadRequest());
}
@Test
public void testDeleteClusterThrowException() throws Exception {
void testDeleteClusterThrowException() throws Exception {
Mockito.doThrow(new NacosException(500, "remove service error")).when(instanceOperator)
.removeInstance(Mockito.eq(Constants.DEFAULT_NAMESPACE_ID), Mockito.eq(
Constants.DEFAULT_GROUP + AddressServerConstants.GROUP_SERVICE_NAME_SEP + "nacos.as.default"),

View File

@ -26,12 +26,12 @@ import com.alibaba.nacos.naming.core.v2.metadata.ClusterMetadata;
import com.alibaba.nacos.naming.core.v2.metadata.NamingMetadataManager;
import com.alibaba.nacos.naming.core.v2.metadata.ServiceMetadata;
import com.alibaba.nacos.naming.core.v2.pojo.Service;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
@ -43,8 +43,8 @@ import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@RunWith(MockitoJUnitRunner.class)
public class ServerListControllerTest {
@ExtendWith(MockitoExtension.class)
class ServerListControllerTest {
@Mock
private NamingMetadataManager metadataManager;
@ -55,23 +55,23 @@ public class ServerListControllerTest {
private Service service;
private MockMvc mockMvc;
@Before
public void before() {
@BeforeEach
void before() {
this.mockMvc = MockMvcBuilders.standaloneSetup(
new ServerListController(new AddressServerGeneratorManager(), metadataManager, serviceStorage)).build();
service = Service
.newService(Constants.DEFAULT_NAMESPACE_ID, Constants.DEFAULT_GROUP, "nacos.as.default", false);
ServiceManager.getInstance().getSingleton(service);
}
@After
public void tearDown() {
@AfterEach
void tearDown() {
ServiceManager.getInstance().removeSingleton(service);
}
@Test
public void testGetCluster() throws Exception {
void testGetCluster() throws Exception {
final Service service = Service
.newService(Constants.DEFAULT_NAMESPACE_ID, Constants.DEFAULT_GROUP, "nacos.as.default", false);
@ -86,16 +86,16 @@ public class ServerListControllerTest {
when(serviceStorage.getData(service)).thenReturn(serviceInfo);
mockMvc.perform(get("/nacos/serverList")).andExpect(status().isOk());
}
@Test
public void testGetClusterCannotFindService() throws Exception {
void testGetClusterCannotFindService() throws Exception {
tearDown();
mockMvc.perform(get("/default/serverList")).andExpect(status().isNotFound());
}
@Test
public void testGetClusterCannotFindCluster() throws Exception {
void testGetClusterCannotFindCluster() throws Exception {
mockMvc.perform(get("/nacos/serverList")).andExpect(status().isNotFound());
}

View File

@ -63,11 +63,6 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
@ -85,6 +80,10 @@
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-util</artifactId>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-common-protos</artifactId>

View File

@ -33,6 +33,10 @@ public class PropertyKeyConst {
public static final String ENDPOINT_PORT = "endpointPort";
public static final String ENDPOINT_CONTEXT_PATH = "endpointContextPath";
public static final String ENDPOINT_CLUSTER_NAME = "endpointClusterName";
public static final String SERVER_NAME = "serverName";
public static final String NAMESPACE = "namespace";
@ -59,6 +63,10 @@ public class PropertyKeyConst {
public static final String CONFIG_RETRY_TIME = "configRetryTime";
public static final String CLIENT_WORKER_MAX_THREAD_COUNT = "clientWorkerMaxThreadCount";
public static final String CLIENT_WORKER_THREAD_COUNT = "clientWorkerThreadCount";
public static final String MAX_RETRY = "maxRetry";
public static final String ENABLE_REMOTE_SYNC_CONFIG = "enableRemoteSyncConfig";
@ -69,6 +77,8 @@ public class PropertyKeyConst {
public static final String NAMING_CLIENT_BEAT_THREAD_COUNT = "namingClientBeatThreadCount";
public static final String NAMING_POLLING_MAX_THREAD_COUNT = "namingPollingMaxThreadCount";
public static final String NAMING_POLLING_THREAD_COUNT = "namingPollingThreadCount";
public static final String NAMING_REQUEST_DOMAIN_RETRY_COUNT = "namingRequestDomainMaxRetryCount";
@ -81,6 +91,15 @@ public class PropertyKeyConst {
public static final String REDO_DELAY_THREAD_COUNT = "redoDelayThreadCount";
public static final String SIGNATURE_REGION_ID = "signatureRegionId";
public static final String LOG_ALL_PROPERTIES = "logAllProperties";
/**
* Since 2.3.3, For some situation like java agent using nacos-client which can't use env ram info.
*/
public static final String IS_USE_RAM_INFO_PARSING = "isUseRamInfoParsing";
/**
* Get the key value of some variable value from the system property.
*/
@ -88,6 +107,8 @@ public class PropertyKeyConst {
public static final String ALIBABA_ALIWARE_ENDPOINT_PORT = "ALIBABA_ALIWARE_ENDPOINT_PORT";
public static final String ALIBABA_ALIWARE_ENDPOINT_CONTEXT_PATH = "ALIBABA_ALIWARE_ENDPOINT_CONTEXT_PATH";
public static final String ALIBABA_ALIWARE_NAMESPACE = "ALIBABA_ALIWARE_NAMESPACE";
public static final String ALIBABA_ALIWARE_ENDPOINT_URL = "ALIBABA_ALIWARE_ENDPOINT_URL";

View File

@ -46,4 +46,9 @@ public interface SystemPropertyKeyConst {
* It is also supported by the -D parameter.
*/
String IS_USE_ENDPOINT_PARSING_RULE = "nacos.use.endpoint.parsing.rule";
/**
* Since 2.3.3, For some situation like java agent using nacos-client which can't use env ram info.
*/
String IS_USE_RAM_INFO_PARSING = "nacos.use.ram.info.parsing";
}

View File

@ -33,6 +33,8 @@ public class Constants {
public static final String APPNAME = "AppName";
public static final String CLIENT_VERSION_KEY = "ClientVersion";
public static final String UNKNOWN_APP = "UnknownApp";
public static final String DEFAULT_DOMAINNAME = "commonconfig.config-host.taobao.com";
@ -41,10 +43,14 @@ public class Constants {
public static final String NULL = "";
public static final String DATAID = "dataId";
public static final String DATA_ID = "dataId";
public static final String TENANT = "tenant";
public static final String GROUP = "group";
public static final String NAMESPACE_ID = "namespaceId";
public static final String LAST_MODIFIED = "Last-Modified";
public static final String ACCEPT_ENCODING = "Accept-Encoding";
@ -223,6 +229,29 @@ public class Constants {
public static final int DEFAULT_REDO_THREAD_COUNT = 1;
public static final String APP_CONN_LABELS_KEY = "nacos.app.conn.labels";
public static final String DOT = ".";
public static final String WEIGHT = "weight";
public static final String PROPERTIES_KEY = "properties";
public static final String JVM_KEY = "jvm";
public static final String ENV_KEY = "env";
public static final String APP_CONN_LABELS_PREFERRED = "nacos_app_conn_labels_preferred";
public static final String APP_CONN_PREFIX = "app_";
public static final String CONFIG_GRAY_LABEL = "nacos.config.gray.label";
/**
* Since 2.3.3, For some situation like java agent using nacos-client which can't use env ram info.
*/
public static final String DEFAULT_USE_RAM_INFO_PARSING = "true";
/**
* The constants in config directory.
*/
@ -237,9 +266,9 @@ public class Constants {
* The constants in naming directory.
*/
public static class Naming {
public static final String NAMING_MODULE = "naming";
public static final String CMDB_CONTEXT_TYPE = "CMDB";
}
@ -247,7 +276,7 @@ public class Constants {
* The constants in remote directory.
*/
public static class Remote {
public static final String INTERNAL_MODULE = "internal";
}
@ -259,9 +288,9 @@ public class Constants {
public static final int SERIALIZE_ERROR_CODE = 100;
public static final int DESERIALIZE_ERROR_CODE = 101;
public static final int FIND_DATASOURCE_ERROR_CODE = 102;
public static final int FIND_TABLE_ERROR_CODE = 103;
}
}

View File

@ -178,7 +178,7 @@ public enum ErrorCode {
/**
* node down failure.
*/
NODE_DOWN_FAILURE(23001, "node down failure"),
NODE_DOWN_FAILURE(23002, "node down failure"),
/**
* server error.

View File

@ -21,6 +21,7 @@ import com.alibaba.nacos.api.naming.listener.EventListener;
import com.alibaba.nacos.api.naming.pojo.Instance;
import com.alibaba.nacos.api.naming.pojo.ListView;
import com.alibaba.nacos.api.naming.pojo.ServiceInfo;
import com.alibaba.nacos.api.naming.selector.NamingSelector;
import com.alibaba.nacos.api.selector.AbstractSelector;
import java.util.List;
@ -33,7 +34,7 @@ import java.util.List;
public interface NamingService {
/**
* register a instance to service.
* register an instance to service.
*
* @param serviceName name of service
* @param ip instance ip
@ -43,7 +44,7 @@ public interface NamingService {
void registerInstance(String serviceName, String ip, int port) throws NacosException;
/**
* register a instance to service.
* register an instance to service.
*
* @param serviceName name of service
* @param groupName group of service
@ -54,7 +55,7 @@ public interface NamingService {
void registerInstance(String serviceName, String groupName, String ip, int port) throws NacosException;
/**
* register a instance to service with specified cluster name.
* register an instance to service with specified cluster name.
*
* @param serviceName name of service
* @param ip instance ip
@ -65,7 +66,7 @@ public interface NamingService {
void registerInstance(String serviceName, String ip, int port, String clusterName) throws NacosException;
/**
* register a instance to service with specified cluster name.
* register an instance to service with specified cluster name.
*
* @param serviceName name of service
* @param groupName group of service
@ -78,7 +79,7 @@ public interface NamingService {
throws NacosException;
/**
* register a instance to service with specified instance properties.
* register an instance to service with specified instance properties.
*
* @param serviceName name of service
* @param instance instance to register
@ -87,7 +88,7 @@ public interface NamingService {
void registerInstance(String serviceName, Instance instance) throws NacosException;
/**
* register a instance to service with specified instance properties.
* register an instance to service with specified instance properties.
*
* @param serviceName name of service
* @param groupName group of service
@ -491,6 +492,28 @@ public interface NamingService {
void subscribe(String serviceName, String groupName, List<String> clusters, EventListener listener)
throws NacosException;
/**
* Subscribe service to receive events of instances alteration.
*
* @param serviceName name of service
* @param selector selector of instances
* @param listener event listener
* @throws NacosException nacos exception
*/
void subscribe(String serviceName, NamingSelector selector, EventListener listener) throws NacosException;
/**
* Subscribe service to receive events of instances alteration.
*
* @param serviceName name of service
* @param groupName group of service
* @param selector selector of instances
* @param listener event listener
* @throws NacosException nacos exception
*/
void subscribe(String serviceName, String groupName, NamingSelector selector, EventListener listener)
throws NacosException;
/**
* Unsubscribe event listener of service.
*
@ -532,6 +555,28 @@ public interface NamingService {
void unsubscribe(String serviceName, String groupName, List<String> clusters, EventListener listener)
throws NacosException;
/**
* Unsubscribe event listener of service.
*
* @param serviceName name of service
* @param selector selector of instances
* @param listener event listener
* @throws NacosException nacos exception
*/
void unsubscribe(String serviceName, NamingSelector selector, EventListener listener) throws NacosException;
/**
* Unsubscribe event listener of service.
*
* @param serviceName name of service
* @param groupName group of service
* @param selector selector of instances
* @param listener event listener
* @throws NacosException nacos exception
*/
void unsubscribe(String serviceName, String groupName, NamingSelector selector, EventListener listener)
throws NacosException;
/**
* Get all service names from server.
*

View File

@ -69,7 +69,7 @@ public class HealthCheckerFactory {
}
/**
* Deserialize and create a instance of health checker.
* Deserialize and create an instance of health checker.
*
* @param jsonString json string of health checker
* @return new instance
@ -83,7 +83,7 @@ public class HealthCheckerFactory {
}
/**
* Serialize a instance of health checker to json.
* Serialize an instance of health checker to json.
*
* @param healthChecker health checker instance
* @return son string after serializing

View File

@ -0,0 +1,57 @@
/*
* Copyright 1999-2023 Alibaba Group Holding Ltd.
*
* Licensed 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.
*/
package com.alibaba.nacos.api.naming.selector;
import com.alibaba.nacos.api.naming.pojo.Instance;
import java.util.List;
/**
* Naming selector context.
*
* @author lideyou
*/
public interface NamingContext {
/**
* Get service name.
*
* @return service name
*/
String getServiceName();
/**
* Get group name.
*
* @return group name
*/
String getGroupName();
/**
* Get clusters.
*
* @return clusters
*/
String getClusters();
/**
* Get current instances.
*
* @return current instances
*/
List<Instance> getInstances();
}

View File

@ -0,0 +1,31 @@
/*
* Copyright 1999-2023 Alibaba Group Holding Ltd.
*
* Licensed 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.
*/
package com.alibaba.nacos.api.naming.selector;
import com.alibaba.nacos.api.naming.pojo.Instance;
import com.alibaba.nacos.api.selector.client.SelectResult;
import java.util.List;
/**
* Naming select result.
*
* @author lideyou
*/
public interface NamingResult extends SelectResult<List<Instance>> {
}

View File

@ -0,0 +1,28 @@
/*
* Copyright 1999-2023 Alibaba Group Holding Ltd.
*
* Licensed 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.
*/
package com.alibaba.nacos.api.naming.selector;
import com.alibaba.nacos.api.selector.client.Selector;
/**
* Naming selector.
*
* @author lideyou
*/
public interface NamingSelector extends Selector<NamingContext, NamingResult> {
}

View File

@ -16,17 +16,27 @@
package com.alibaba.nacos.api.naming.spi.generator;
import com.alibaba.nacos.api.naming.pojo.Instance;
/**
* Generator SPI for Instance Id.
*
* @author xiweng.yy
*/
public interface IdGenerator {
public interface InstanceIdGenerator {
/**
* Generate instance id.
*
* @param instance instance
* @return instance id
*/
String generateInstanceId();
String generateInstanceId(Instance instance);
/**
* Generator type.
*
* @return type
*/
String type();
}

View File

@ -87,6 +87,16 @@ public class NamingUtils {
return serviceNameWithGroup.split(Constants.SERVICE_INFO_SPLITER)[0];
}
/**
* Check serviceName is compatibility mode or not.
*
* @param serviceName serviceName
* @return if serviceName is compatibility mode, return true
*/
public static boolean isServiceNameCompatibilityMode(final String serviceName) {
return !StringUtils.isBlank(serviceName) && serviceName.contains(Constants.SERVICE_INFO_SPLITER);
}
/**
* check combineServiceName format. the serviceName can't be blank.
* <pre>

View File

@ -57,6 +57,7 @@ public class ErrorResponse extends Response {
}
ErrorResponse response = new ErrorResponse();
response.setErrorInfo(errorCode, exception.getMessage());
response.setResultCode(errorCode);
return response;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 1999-2022 Alibaba Group Holding Ltd.
* Copyright 1999-2023 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -14,19 +14,20 @@
* limitations under the License.
*/
package com.alibaba.nacos.common.log;
package com.alibaba.nacos.api.selector.client;
/**
* nacos logback properties.
* @author hujun
* Select result.
*
* @param <T> the type of result
* @author lideyou
*/
public interface NacosLogbackProperties {
public interface SelectResult<T> {
/**
* get value.
* Get select result.
*
* @param source source
* @param defaultValue defaultValue
* @return value
* @return select result
*/
String getValue(String source, String defaultValue);
T getResult();
}

View File

@ -0,0 +1,35 @@
/*
* Copyright 1999-2023 Alibaba Group Holding Ltd.
*
* Licensed 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.
*/
package com.alibaba.nacos.api.selector.client;
/**
* Client selector.
*
* @param <C> the type of selector context
* @param <E> the type of select result
* @author lideyou
*/
public interface Selector<C, E> {
/**
* select the target result.
*
* @param context selector context
* @return select result
*/
E select(C context);
}

View File

@ -20,25 +20,25 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ClientAbilitiesTest {
class ClientAbilitiesTest {
private static ObjectMapper mapper;
@BeforeClass
public static void setUp() throws Exception {
@BeforeAll
static void setUp() throws Exception {
mapper = new ObjectMapper();
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
}
@Test
public void testSerialize() throws JsonProcessingException {
void testSerialize() throws JsonProcessingException {
ClientAbilities abilities = new ClientAbilities();
String json = mapper.writeValueAsString(abilities);
assertTrue(json.contains("\"remoteAbility\":{"));
@ -47,7 +47,7 @@ public class ClientAbilitiesTest {
}
@Test
public void testDeserialize() throws JsonProcessingException {
void testDeserialize() throws JsonProcessingException {
String json = "{\"remoteAbility\":{\"supportRemoteConnection\":false},"
+ "\"configAbility\":{\"supportRemoteMetrics\":false},\"namingAbility\":{\"supportDeltaPush\":false,"
+ "\"supportRemoteMetric\":false}}";

View File

@ -20,35 +20,35 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ServerAbilitiesTest {
class ServerAbilitiesTest {
private static ObjectMapper mapper;
private ServerAbilities serverAbilities;
@BeforeClass
public static void setUpBeforeClass() throws Exception {
@BeforeAll
static void setUpBeforeClass() throws Exception {
mapper = new ObjectMapper();
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
}
@Before
public void setUp() throws Exception {
@BeforeEach
void setUp() throws Exception {
serverAbilities = new ServerAbilities();
}
@Test
public void testSerialize() throws JsonProcessingException {
void testSerialize() throws JsonProcessingException {
serverAbilities = new ServerAbilities();
String json = mapper.writeValueAsString(serverAbilities);
assertTrue(json.contains("\"remoteAbility\":{"));
@ -57,7 +57,7 @@ public class ServerAbilitiesTest {
}
@Test
public void testDeserialize() throws JsonProcessingException {
void testDeserialize() throws JsonProcessingException {
String json = "{\"remoteAbility\":{\"supportRemoteConnection\":false},"
+ "\"configAbility\":{\"supportRemoteMetrics\":false},\"namingAbility\":{\"supportDeltaPush\":false,"
+ "\"supportRemoteMetric\":false}}";
@ -68,10 +68,10 @@ public class ServerAbilitiesTest {
}
@Test
public void testEqualsAndHashCode() {
void testEqualsAndHashCode() {
assertEquals(serverAbilities, serverAbilities);
assertEquals(serverAbilities.hashCode(), serverAbilities.hashCode());
assertNotEquals(serverAbilities, null);
assertNotEquals(null, serverAbilities);
assertNotEquals(serverAbilities, new ClientAbilities());
ServerAbilities test = new ServerAbilities();
assertEquals(serverAbilities, test);

View File

@ -16,14 +16,14 @@
package com.alibaba.nacos.api.ability.register.impl;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ClusterClientAbilitiesTest {
class ClusterClientAbilitiesTest {
@Test
public void testGetStaticAbilities() {
void testGetStaticAbilities() {
// TODO add the cluster client abilities.
assertTrue(ClusterClientAbilities.getStaticAbilities().isEmpty());
}

View File

@ -16,14 +16,14 @@
package com.alibaba.nacos.api.ability.register.impl;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class SdkClientAbilitiesTest {
class SdkClientAbilitiesTest {
@Test
public void testGetStaticAbilities() {
void testGetStaticAbilities() {
// TODO add the sdk client abilities.
assertTrue(SdkClientAbilities.getStaticAbilities().isEmpty());
}

View File

@ -17,20 +17,20 @@
package com.alibaba.nacos.api.ability.register.impl;
import com.alibaba.nacos.api.ability.constant.AbilityKey;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ServerAbilitiesTest {
class ServerAbilitiesTest {
@Test
public void testGetStaticAbilities() {
void testGetStaticAbilities() {
assertFalse(ServerAbilities.getStaticAbilities().isEmpty());
}
@Test
public void testSupportPersistentInstanceByGrpcAbilities() {
void testSupportPersistentInstanceByGrpcAbilities() {
assertTrue(ServerAbilities.getStaticAbilities().get(AbilityKey.SERVER_SUPPORT_PERSISTENT_INSTANCE_BY_GRPC));
}
}

View File

@ -16,8 +16,7 @@
package com.alibaba.nacos.api.annotation;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.mock.env.MockEnvironment;
import static com.alibaba.nacos.api.annotation.NacosProperties.ACCESS_KEY_PLACEHOLDER;
@ -28,23 +27,24 @@ import static com.alibaba.nacos.api.annotation.NacosProperties.ENDPOINT_PLACEHOL
import static com.alibaba.nacos.api.annotation.NacosProperties.NAMESPACE_PLACEHOLDER;
import static com.alibaba.nacos.api.annotation.NacosProperties.SECRET_KEY_PLACEHOLDER;
import static com.alibaba.nacos.api.annotation.NacosProperties.SERVER_ADDR_PLACEHOLDER;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class NacosPropertiesTest {
class NacosPropertiesTest {
@Test
public void testPlaceholders() {
Assert.assertEquals("${nacos.endpoint:}", ENDPOINT_PLACEHOLDER);
Assert.assertEquals("${nacos.namespace:}", NAMESPACE_PLACEHOLDER);
Assert.assertEquals("${nacos.access-key:}", ACCESS_KEY_PLACEHOLDER);
Assert.assertEquals("${nacos.secret-key:}", SECRET_KEY_PLACEHOLDER);
Assert.assertEquals("${nacos.server-addr:}", SERVER_ADDR_PLACEHOLDER);
Assert.assertEquals("${nacos.context-path:}", CONTEXT_PATH_PLACEHOLDER);
Assert.assertEquals("${nacos.cluster-name:}", CLUSTER_NAME_PLACEHOLDER);
Assert.assertEquals("${nacos.encode:UTF-8}", ENCODE_PLACEHOLDER);
void testPlaceholders() {
assertEquals("${nacos.endpoint:}", ENDPOINT_PLACEHOLDER);
assertEquals("${nacos.namespace:}", NAMESPACE_PLACEHOLDER);
assertEquals("${nacos.access-key:}", ACCESS_KEY_PLACEHOLDER);
assertEquals("${nacos.secret-key:}", SECRET_KEY_PLACEHOLDER);
assertEquals("${nacos.server-addr:}", SERVER_ADDR_PLACEHOLDER);
assertEquals("${nacos.context-path:}", CONTEXT_PATH_PLACEHOLDER);
assertEquals("${nacos.cluster-name:}", CLUSTER_NAME_PLACEHOLDER);
assertEquals("${nacos.encode:UTF-8}", ENCODE_PLACEHOLDER);
}
@Test
public void testResolvePlaceholders() {
void testResolvePlaceholders() {
testResolvePlaceholder(ENDPOINT_PLACEHOLDER, "nacos.endpoint", "test-value", "test-value");
testResolvePlaceholder(ENDPOINT_PLACEHOLDER, "", "test-value", "");
@ -75,11 +75,11 @@ public class NacosPropertiesTest {
MockEnvironment environment = new MockEnvironment();
environment.setProperty(propertyName, propertyValue);
String resolvedValue = environment.resolvePlaceholders(placeholder);
Assert.assertEquals(expectValue, resolvedValue);
assertEquals(expectValue, resolvedValue);
}
@Test
public void testSort() {
void testSort() {
}
}

View File

@ -20,24 +20,24 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class EntityEventTest {
class EntityEventTest {
ObjectMapper mapper = new ObjectMapper();
@Before
public void setUp() throws Exception {
@BeforeEach
void setUp() throws Exception {
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
}
@Test
public void testSerialization() throws JsonProcessingException {
void testSerialization() throws JsonProcessingException {
EntityEvent entity = new EntityEvent();
entity.setEntityName("test-entity");
entity.setEntityType("CMDB");
@ -50,7 +50,7 @@ public class EntityEventTest {
}
@Test
public void testDeserialization() throws JsonProcessingException {
void testDeserialization() throws JsonProcessingException {
String json = "{\"type\":\"ENTITY_REMOVE\",\"entityName\":\"test-entity\",\"entityType\":\"CMDB\"}";
EntityEvent entity = mapper.readValue(json, EntityEvent.class);
assertEquals("test-entity", entity.getEntityName());

View File

@ -20,26 +20,26 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.Collections;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class EntityTest {
class EntityTest {
ObjectMapper mapper = new ObjectMapper();
@Before
public void setUp() throws Exception {
@BeforeEach
void setUp() throws Exception {
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
}
@Test
public void testSerialization() throws JsonProcessingException {
void testSerialization() throws JsonProcessingException {
Entity entity = new Entity();
entity.setName("test-entity");
entity.setType(PreservedEntityTypes.ip.name());
@ -51,7 +51,7 @@ public class EntityTest {
}
@Test
public void testDeserialization() throws JsonProcessingException {
void testDeserialization() throws JsonProcessingException {
String json = "{\"type\":\"service\",\"name\":\"test-entity\",\"labels\":{\"test-label-key\":\"test-label-value\"}}";
Entity entity = mapper.readValue(json, Entity.class);
assertEquals("test-entity", entity.getName());

View File

@ -20,26 +20,26 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.Collections;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class LabelTest {
class LabelTest {
ObjectMapper mapper = new ObjectMapper();
@Before
public void setUp() throws Exception {
@BeforeEach
void setUp() throws Exception {
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
}
@Test
public void testSerialization() throws JsonProcessingException {
void testSerialization() throws JsonProcessingException {
Label label = new Label();
label.setName("test-label");
label.setDescription("CMDB description");
@ -52,7 +52,7 @@ public class LabelTest {
}
@Test
public void testDeserialization() throws JsonProcessingException {
void testDeserialization() throws JsonProcessingException {
String json = "{\"values\":[\"test-value\"],\"name\":\"test-label\",\"description\":\"CMDB description\"}";
Label label = mapper.readValue(json, Label.class);
assertEquals("test-label", label.getName());

View File

@ -16,18 +16,18 @@
package com.alibaba.nacos.api.config;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
public class ConfigChangeEventTest {
class ConfigChangeEventTest {
@Test
public void testConstructor() {
void testConstructor() {
Map<String, ConfigChangeItem> mockData = new HashMap<>();
mockData.put("test", new ConfigChangeItem("testKey", null, "testValue"));
ConfigChangeEvent event = new ConfigChangeEvent(mockData);

View File

@ -16,15 +16,15 @@
package com.alibaba.nacos.api.config;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
public class ConfigChangeItemTest {
class ConfigChangeItemTest {
@Test
public void testSetNewValue() {
void testSetNewValue() {
ConfigChangeItem item = new ConfigChangeItem("testKey", null, "testValue");
item.setType(PropertyChangeType.ADDED);
assertEquals("testKey", item.getKey());
@ -46,7 +46,7 @@ public class ConfigChangeItemTest {
}
@Test
public void testToString() {
void testToString() {
ConfigChangeItem item = new ConfigChangeItem("testKey", null, "testValue");
item.setType(PropertyChangeType.ADDED);
assertEquals("ConfigChangeItem{key='testKey', oldValue='null', newValue='testValue', type=ADDED}",

View File

@ -16,16 +16,16 @@
package com.alibaba.nacos.api.config;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ConfigTypeTest {
class ConfigTypeTest {
@Test
public void isValidType() {
void isValidType() {
assertTrue(ConfigType.isValidType("xml"));
assertTrue(ConfigType.isValidType("properties"));
assertTrue(ConfigType.isValidType("json"));
@ -38,7 +38,7 @@ public class ConfigTypeTest {
}
@Test
public void testGetDefaultType() {
void testGetDefaultType() {
assertEquals("text", ConfigType.getDefaultType().getType());
}
}

View File

@ -21,32 +21,32 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ClientRemoteAbilityTest {
class ClientRemoteAbilityTest {
private static ObjectMapper mapper;
@BeforeClass
public static void setUp() throws Exception {
@BeforeAll
static void setUp() throws Exception {
mapper = new ObjectMapper();
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
}
@Test
public void testSerialize() throws JsonProcessingException {
void testSerialize() throws JsonProcessingException {
ClientRemoteAbility abilities = new ClientRemoteAbility();
String json = mapper.writeValueAsString(abilities);
assertEquals("{\"supportRemoteConnection\":false}", json);
}
@Test
public void testDeserialize() throws JsonProcessingException {
void testDeserialize() throws JsonProcessingException {
String json = "{\"supportRemoteConnection\":true}";
ClientRemoteAbility abilities = mapper.readValue(json, ClientRemoteAbility.class);
assertTrue(abilities.isSupportRemoteConnection());

View File

@ -16,21 +16,20 @@
package com.alibaba.nacos.api.config.ability;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
public class ServerConfigAbilityTest {
class ServerConfigAbilityTest {
@Test
public void testEquals() {
void testEquals() {
ServerConfigAbility ability = new ServerConfigAbility();
ability.setSupportRemoteMetrics(true);
assertEquals(ability, ability);
assertFalse(ability.equals(null));
assertFalse(ability.equals(new ClientConfigAbility()));
assertNotEquals(null, ability);
assertNotEquals(ability, new ClientConfigAbility());
ServerConfigAbility newOne = new ServerConfigAbility();
assertNotEquals(ability, newOne);
newOne.setSupportRemoteMetrics(true);

View File

@ -23,35 +23,35 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ServerRemoteAbilityTest {
class ServerRemoteAbilityTest {
private static ObjectMapper mapper;
private ServerRemoteAbility serverAbilities;
@BeforeClass
public static void setUpBeforeClass() throws Exception {
@BeforeAll
static void setUpBeforeClass() throws Exception {
mapper = new ObjectMapper();
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.enable(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY);
}
@Before
public void setUp() throws Exception {
@BeforeEach
void setUp() throws Exception {
serverAbilities = new ServerRemoteAbility();
}
@Test
public void testSerialize() throws JsonProcessingException {
void testSerialize() throws JsonProcessingException {
serverAbilities = new ServerRemoteAbility();
String json = mapper.writeValueAsString(serverAbilities);
assertTrue(json.contains("\"supportRemoteConnection\":false"));
@ -59,7 +59,7 @@ public class ServerRemoteAbilityTest {
}
@Test
public void testDeserialize() throws JsonProcessingException {
void testDeserialize() throws JsonProcessingException {
String json = "{\"supportRemoteConnection\":true,\"grpcReportEnabled\":true}";
ServerRemoteAbility abilities = mapper.readValue(json, ServerRemoteAbility.class);
assertTrue(abilities.isSupportRemoteConnection());
@ -67,10 +67,10 @@ public class ServerRemoteAbilityTest {
}
@Test
public void testEqualsAndHashCode() {
void testEqualsAndHashCode() {
assertEquals(serverAbilities, serverAbilities);
assertEquals(serverAbilities.hashCode(), serverAbilities.hashCode());
assertNotEquals(serverAbilities, null);
assertNotEquals(null, serverAbilities);
assertNotEquals(serverAbilities, new ClientAbilities());
ServerRemoteAbility test = new ServerRemoteAbility();
assertEquals(serverAbilities, test);

View File

@ -16,14 +16,14 @@
package com.alibaba.nacos.api.config.listener;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertNull;
public class AbstractListenerTest {
class AbstractListenerTest {
@Test
public void testGetExecutor() {
void testGetExecutor() {
// Default listener executor is null.
assertNull(new AbstractListener() {
@Override

View File

@ -16,28 +16,28 @@
package com.alibaba.nacos.api.config.listener;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
public class AbstractSharedListenerTest {
class AbstractSharedListenerTest {
private static final String CONFIG_CONTENT = "test";
private static Map<String, String> receivedMap;
@Before
public void setUp() {
@BeforeEach
void setUp() {
receivedMap = new HashMap<>();
}
@Test
public void testFillContext() {
void testFillContext() {
assertEquals(0, receivedMap.size());
MockShardListener listener = new MockShardListener();
listener.receiveConfigInfo(CONFIG_CONTENT);
@ -52,7 +52,7 @@ public class AbstractSharedListenerTest {
}
@Test
public void getExecutor() {
void getExecutor() {
// Default listener executor is null.
assertNull(new MockShardListener().getExecutor());
}

View File

@ -22,7 +22,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.BeforeClass;
import org.junit.jupiter.api.BeforeAll;
import java.util.HashMap;
import java.util.Map;
@ -30,8 +30,6 @@ import java.util.UUID;
public abstract class BasedConfigRequestTest {
protected static ObjectMapper mapper;
protected static final String DATA_ID = "test_data";
protected static final String GROUP = "group";
@ -52,11 +50,13 @@ public abstract class BasedConfigRequestTest {
protected static final String CONTENT = "content";
protected static ObjectMapper mapper;
static {
HEADERS.put(HEADER_KEY, HEADER_VALUE);
}
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
mapper = new ObjectMapper();
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);

View File

@ -18,18 +18,17 @@ package com.alibaba.nacos.api.config.remote.request;
import com.alibaba.nacos.api.common.Constants;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.Objects;
import static com.alibaba.nacos.api.config.remote.request.ClientConfigMetricRequest.MetricsKey.CACHE_DATA;
import static com.alibaba.nacos.api.config.remote.request.ClientConfigMetricRequest.MetricsKey.SNAPSHOT_DATA;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ClientConfigMetricRequestTest extends BasedConfigRequestTest {
class ClientConfigMetricRequestTest extends BasedConfigRequestTest {
@Override
@Test
@ -57,35 +56,36 @@ public class ClientConfigMetricRequestTest extends BasedConfigRequestTest {
+ "\"test_data+group+test_tenant\"},{\"type\":\"snapshotData\","
+ "\"key\":\"test_data+group+test_tenant\"}],\"module\":\"config\"}";
ClientConfigMetricRequest actual = mapper.readValue(json, ClientConfigMetricRequest.class);
assertEquals(actual.getMetricsKeys().size(), 2);
assertEquals(actual.getModule(), Constants.Config.CONFIG_MODULE);
assertEquals(actual.getHeader(HEADER_KEY), HEADER_VALUE);
assertEquals(2, actual.getMetricsKeys().size());
assertEquals(Constants.Config.CONFIG_MODULE, actual.getModule());
assertEquals(HEADER_VALUE, actual.getHeader(HEADER_KEY));
}
@Test
public void testMetricsKeysEquals() {
void testMetricsKeysEquals() {
String dataKey = String.join("+", KEY);
ClientConfigMetricRequest.MetricsKey key = ClientConfigMetricRequest.MetricsKey.build(CACHE_DATA, dataKey);
assertEquals(key, key);
assertFalse(key.equals(null));
assertFalse(key.equals(new ClientConfigMetricRequest()));
ClientConfigMetricRequest.MetricsKey newOne = ClientConfigMetricRequest.MetricsKey
.build(SNAPSHOT_DATA, dataKey);
assertNotEquals(null, key);
assertNotEquals(key, new ClientConfigMetricRequest());
ClientConfigMetricRequest.MetricsKey newOne = ClientConfigMetricRequest.MetricsKey.build(SNAPSHOT_DATA,
dataKey);
assertNotEquals(key, newOne);
newOne.setType(CACHE_DATA);
assertEquals(key, newOne);
}
@Test
public void testMetricsHashCode() {
void testMetricsHashCode() {
String dataKey = String.join("+", KEY);
ClientConfigMetricRequest.MetricsKey key = ClientConfigMetricRequest.MetricsKey.build(CACHE_DATA, dataKey);
assertEquals(Objects.hash(CACHE_DATA, dataKey), key.hashCode());
}
@Test
public void testMetricsToString() {
ClientConfigMetricRequest.MetricsKey key = ClientConfigMetricRequest.MetricsKey.build(CACHE_DATA, String.join("+", KEY));
void testMetricsToString() {
ClientConfigMetricRequest.MetricsKey key = ClientConfigMetricRequest.MetricsKey.build(CACHE_DATA,
String.join("+", KEY));
assertEquals("MetricsKey{type='cacheData', key='test_data+group+test_tenant'}", key.toString());
}
}

View File

@ -18,12 +18,12 @@ package com.alibaba.nacos.api.config.remote.request;
import com.alibaba.nacos.api.common.Constants;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ConfigBatchListenRequestTest extends BasedConfigRequestTest {
class ConfigBatchListenRequestTest extends BasedConfigRequestTest {
@Override
@Test
@ -47,14 +47,14 @@ public class ConfigBatchListenRequestTest extends BasedConfigRequestTest {
+ "\"configListenContexts\":[{\"group\":\"group\",\"md5\":\"test_MD5\","
+ "\"dataId\":\"test_data\",\"tenant\":\"test_tenant\"}],\"module\":\"config\"}";
ConfigBatchListenRequest actual = mapper.readValue(json, ConfigBatchListenRequest.class);
assertEquals(actual.isListen(), true);
assertEquals(actual.getModule(), Constants.Config.CONFIG_MODULE);
assertEquals(actual.getHeader(HEADER_KEY), HEADER_VALUE);
assertEquals(actual.getConfigListenContexts().size(), 1);
assertEquals(true, actual.isListen());
assertEquals(Constants.Config.CONFIG_MODULE, actual.getModule());
assertEquals(HEADER_VALUE, actual.getHeader(HEADER_KEY));
assertEquals(1, actual.getConfigListenContexts().size());
}
@Test
public void testConfigListenContextToString() {
void testConfigListenContextToString() {
ConfigBatchListenRequest configBatchListenRequest = new ConfigBatchListenRequest();
configBatchListenRequest.addConfigListenContext(GROUP, DATA_ID, TENANT, MD5);
assertEquals("ConfigListenContext{group='group', md5='test_MD5', dataId='test_data', tenant='test_tenant'}",

View File

@ -18,20 +18,20 @@ package com.alibaba.nacos.api.config.remote.request;
import com.alibaba.nacos.api.common.Constants;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ConfigChangeNotifyRequestTest extends BasedConfigRequestTest {
class ConfigChangeNotifyRequestTest extends BasedConfigRequestTest {
ConfigChangeNotifyRequest configChangeNotifyRequest;
String requestId;
@Before
public void before() {
@BeforeEach
void before() {
configChangeNotifyRequest = ConfigChangeNotifyRequest.build(DATA_ID, GROUP, TENANT);
configChangeNotifyRequest.putAllHeader(HEADERS);
requestId = injectRequestUuId(configChangeNotifyRequest);
@ -54,10 +54,10 @@ public class ConfigChangeNotifyRequestTest extends BasedConfigRequestTest {
String json = "{\"headers\":{\"header1\":\"test_header1\"},\"dataId\":\"test_data\",\"group\":"
+ "\"group\",\"tenant\":\"test_tenant\",\"module\":\"config\"}";
ConfigChangeNotifyRequest actual = mapper.readValue(json, ConfigChangeNotifyRequest.class);
assertEquals(actual.getDataId(), DATA_ID);
assertEquals(actual.getGroup(), GROUP);
assertEquals(actual.getTenant(), TENANT);
assertEquals(actual.getModule(), Constants.Config.CONFIG_MODULE);
assertEquals(actual.getHeader(HEADER_KEY), HEADER_VALUE);
assertEquals(DATA_ID, actual.getDataId());
assertEquals(GROUP, actual.getGroup());
assertEquals(TENANT, actual.getTenant());
assertEquals(Constants.Config.CONFIG_MODULE, actual.getModule());
assertEquals(HEADER_VALUE, actual.getHeader(HEADER_KEY));
}
}

View File

@ -18,24 +18,24 @@ package com.alibaba.nacos.api.config.remote.request;
import com.alibaba.nacos.api.common.Constants;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ConfigPublishRequestTest extends BasedConfigRequestTest {
ConfigPublishRequest configPublishRequest;
class ConfigPublishRequestTest extends BasedConfigRequestTest {
private static final String TAG_PARAM = "tag";
private static final String APP_NAME_PARAM = "appName";
ConfigPublishRequest configPublishRequest;
String requestId;
@Before
public void before() {
@BeforeEach
void before() {
configPublishRequest = new ConfigPublishRequest(DATA_ID, GROUP, TENANT, CONTENT);
configPublishRequest.putAdditionalParam(TAG_PARAM, TAG_PARAM);
configPublishRequest.putAdditionalParam(APP_NAME_PARAM, APP_NAME_PARAM);
@ -64,13 +64,13 @@ public class ConfigPublishRequestTest extends BasedConfigRequestTest {
+ "\"tenant\":\"test_tenant\",\"content\":\"content\",\"casMd5\":\"test_MD5\","
+ "\"additionMap\":{\"appName\":\"appName\",\"tag\":\"tag\"},\"module\":\"config\"}";
ConfigPublishRequest actual = mapper.readValue(json, ConfigPublishRequest.class);
assertEquals(actual.getDataId(), DATA_ID);
assertEquals(actual.getGroup(), GROUP);
assertEquals(actual.getTenant(), TENANT);
assertEquals(actual.getModule(), Constants.Config.CONFIG_MODULE);
assertEquals(actual.getContent(), CONTENT);
assertEquals(actual.getCasMd5(), MD5);
assertEquals(actual.getAdditionParam(TAG_PARAM), TAG_PARAM);
assertEquals(actual.getAdditionParam(APP_NAME_PARAM), APP_NAME_PARAM);
assertEquals(DATA_ID, actual.getDataId());
assertEquals(GROUP, actual.getGroup());
assertEquals(TENANT, actual.getTenant());
assertEquals(Constants.Config.CONFIG_MODULE, actual.getModule());
assertEquals(CONTENT, actual.getContent());
assertEquals(MD5, actual.getCasMd5());
assertEquals(TAG_PARAM, actual.getAdditionParam(TAG_PARAM));
assertEquals(APP_NAME_PARAM, actual.getAdditionParam(APP_NAME_PARAM));
}
}

View File

@ -18,16 +18,16 @@ package com.alibaba.nacos.api.config.remote.request;
import com.alibaba.nacos.api.common.Constants;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ConfigQueryRequestTest extends BasedConfigRequestTest {
class ConfigQueryRequestTest extends BasedConfigRequestTest {
ConfigQueryRequest configQueryRequest;
@ -35,8 +35,8 @@ public class ConfigQueryRequestTest extends BasedConfigRequestTest {
String requestId;
@Before
public void before() {
@BeforeEach
void before() {
headers.put(Constants.Config.NOTIFY_HEADER, Boolean.TRUE.toString());
configQueryRequest = ConfigQueryRequest.build(DATA_ID, GROUP, TENANT);
configQueryRequest.putAllHeader(headers);
@ -45,7 +45,7 @@ public class ConfigQueryRequestTest extends BasedConfigRequestTest {
}
@Test
public void testIsNotify() {
void testIsNotify() {
assertTrue(configQueryRequest.isNotify());
}
@ -67,10 +67,10 @@ public class ConfigQueryRequestTest extends BasedConfigRequestTest {
String json = "{\"headers\":{\"notify\":\"true\"},\"dataId\":\"test_data\",\"group\":\"group\","
+ "\"tenant\":\"test_tenant\",\"notify\":true,\"module\":\"config\",\"tag\":\"tag\"}";
ConfigQueryRequest actual = mapper.readValue(json, ConfigQueryRequest.class);
assertEquals(actual.getDataId(), DATA_ID);
assertEquals(actual.getGroup(), GROUP);
assertEquals(actual.getTenant(), TENANT);
assertEquals(actual.getTag(), TAG);
assertEquals(actual.getModule(), Constants.Config.CONFIG_MODULE);
assertEquals(DATA_ID, actual.getDataId());
assertEquals(GROUP, actual.getGroup());
assertEquals(TENANT, actual.getTenant());
assertEquals(TAG, actual.getTag());
assertEquals(Constants.Config.CONFIG_MODULE, actual.getModule());
}
}

View File

@ -18,20 +18,20 @@ package com.alibaba.nacos.api.config.remote.request;
import com.alibaba.nacos.api.common.Constants;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ConfigRemoveRequestTest extends BasedConfigRequestTest {
class ConfigRemoveRequestTest extends BasedConfigRequestTest {
ConfigRemoveRequest configRemoveRequest;
String requestId;
@Before
public void before() {
@BeforeEach
void before() {
configRemoveRequest = new ConfigRemoveRequest(DATA_ID, GROUP, TENANT, TAG);
requestId = injectRequestUuId(configRemoveRequest);
@ -56,10 +56,10 @@ public class ConfigRemoveRequestTest extends BasedConfigRequestTest {
String json = "{\"headers\":{},\"dataId\":\"test_data\",\"group\":\"group\",\"tenant\":\"test_tenant\""
+ ",\"tag\":\"tag\",\"module\":\"config\"}";
ConfigRemoveRequest actual = mapper.readValue(json, ConfigRemoveRequest.class);
assertEquals(actual.getDataId(), DATA_ID);
assertEquals(actual.getGroup(), GROUP);
assertEquals(actual.getTenant(), TENANT);
assertEquals(actual.getModule(), Constants.Config.CONFIG_MODULE);
assertEquals(actual.getTag(), TAG);
assertEquals(DATA_ID, actual.getDataId());
assertEquals(GROUP, actual.getGroup());
assertEquals(TENANT, actual.getTenant());
assertEquals(Constants.Config.CONFIG_MODULE, actual.getModule());
assertEquals(TAG, actual.getTag());
}
}

View File

@ -19,20 +19,20 @@ package com.alibaba.nacos.api.config.remote.request.cluster;
import com.alibaba.nacos.api.common.Constants;
import com.alibaba.nacos.api.config.remote.request.BasedConfigRequestTest;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ConfigChangeClusterSyncRequestTest extends BasedConfigRequestTest {
class ConfigChangeClusterSyncRequestTest extends BasedConfigRequestTest {
ConfigChangeClusterSyncRequest configChangeClusterSyncRequest;
String requestId;
@Before
public void before() {
@BeforeEach
void before() {
configChangeClusterSyncRequest = new ConfigChangeClusterSyncRequest();
configChangeClusterSyncRequest.setDataId(DATA_ID);
configChangeClusterSyncRequest.setGroup(GROUP);
@ -64,15 +64,16 @@ public class ConfigChangeClusterSyncRequestTest extends BasedConfigRequestTest {
@Override
@Test
public void testDeserialize() throws JsonProcessingException {
String json = "{\"headers\":{\"header1\":\"test_header1\"},\"requestId\":\"ece89111-3c42-4055-aca4-c95e16ec564b\",\"dataId\":\"test_data\","
+ "\"group\":\"group\",\"tenant\":\"test_tenant\","
+ "\"tag\":\"tag\",\"lastModified\":0,\"beta\":true,\"module\":\"config\"}";
String json =
"{\"headers\":{\"header1\":\"test_header1\"},\"requestId\":\"ece89111-3c42-4055-aca4-c95e16ec564b\",\"dataId\":\"test_data\","
+ "\"group\":\"group\",\"tenant\":\"test_tenant\","
+ "\"tag\":\"tag\",\"lastModified\":0,\"beta\":true,\"module\":\"config\"}";
ConfigChangeClusterSyncRequest actual = mapper.readValue(json, ConfigChangeClusterSyncRequest.class);
assertEquals(actual.getDataId(), DATA_ID);
assertEquals(actual.getGroup(), GROUP);
assertEquals(actual.getTenant(), TENANT);
assertEquals(actual.getModule(), Constants.Config.CONFIG_MODULE);
assertEquals(actual.getLastModified(), 0L);
assertEquals(DATA_ID, actual.getDataId());
assertEquals(GROUP, actual.getGroup());
assertEquals(TENANT, actual.getTenant());
assertEquals(Constants.Config.CONFIG_MODULE, actual.getModule());
assertEquals(0L, actual.getLastModified());
assertTrue(actual.isBeta());
}
}

View File

@ -18,14 +18,14 @@ package com.alibaba.nacos.api.config.remote.response;
import com.alibaba.nacos.api.remote.response.ResponseCode;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ClientConfigMetricResponseTest extends BasedConfigResponseTest {
@ -33,8 +33,8 @@ public class ClientConfigMetricResponseTest extends BasedConfigResponseTest {
Map<String, Object> metric = new HashMap<>(16);
@Before
public void before() {
@BeforeEach
void before() {
metric.put("m1", "v1");
clientConfigMetricResponse = new ClientConfigMetricResponse();
clientConfigMetricResponse.setMetrics(metric);

View File

@ -18,18 +18,18 @@ package com.alibaba.nacos.api.config.remote.response;
import com.alibaba.nacos.api.remote.response.ResponseCode;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ConfigChangeBatchListenResponseTest extends BasedConfigResponseTest {
class ConfigChangeBatchListenResponseTest extends BasedConfigResponseTest {
ConfigChangeBatchListenResponse configChangeBatchListenResponse;
@Before
public void before() {
@BeforeEach
void before() {
configChangeBatchListenResponse = new ConfigChangeBatchListenResponse();
requestId = injectResponseUuId(configChangeBatchListenResponse);
configChangeBatchListenResponse.addChangeConfig(DATA_ID, GROUP, TENANT);
@ -50,8 +50,8 @@ public class ConfigChangeBatchListenResponseTest extends BasedConfigResponseTest
@Override
@Test
public void testSerializeFailResponse() throws JsonProcessingException {
ConfigChangeBatchListenResponse configChangeBatchListenResponse = ConfigChangeBatchListenResponse
.buildFailResponse("Fail");
ConfigChangeBatchListenResponse configChangeBatchListenResponse = ConfigChangeBatchListenResponse.buildFailResponse(
"Fail");
String json = mapper.writeValueAsString(configChangeBatchListenResponse);
assertTrue(json.contains("\"resultCode\":" + ResponseCode.FAIL.getCode()));
assertTrue(json.contains("\"errorCode\":0"));

View File

@ -18,17 +18,17 @@ package com.alibaba.nacos.api.config.remote.response;
import com.alibaba.nacos.api.remote.response.ResponseCode;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ConfigChangeNotifyResponseTest extends BasedConfigResponseTest {
ConfigChangeNotifyResponse configChangeNotifyResponse;
@Before
public void before() {
@BeforeEach
void before() {
configChangeNotifyResponse = new ConfigChangeNotifyResponse();
requestId = injectResponseUuId(configChangeNotifyResponse);
}
@ -41,7 +41,7 @@ public class ConfigChangeNotifyResponseTest extends BasedConfigResponseTest {
assertTrue(json.contains("\"requestId\":\"" + requestId));
assertTrue(json.contains("\"resultCode\":" + ResponseCode.SUCCESS.getCode()));
assertTrue(json.contains("\"errorCode\":0"));
}
@Override

View File

@ -18,17 +18,17 @@ package com.alibaba.nacos.api.config.remote.response;
import com.alibaba.nacos.api.remote.response.ResponseCode;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ConfigPublishResponseTest extends BasedConfigResponseTest {
class ConfigPublishResponseTest extends BasedConfigResponseTest {
ConfigPublishResponse configPublishResponse;
@Before
public void before() {
@BeforeEach
void before() {
configPublishResponse = ConfigPublishResponse.buildSuccessResponse();
requestId = injectResponseUuId(configPublishResponse);
}

View File

@ -18,18 +18,18 @@ package com.alibaba.nacos.api.config.remote.response;
import com.alibaba.nacos.api.remote.response.ResponseCode;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ConfigQueryResponseTest extends BasedConfigResponseTest {
class ConfigQueryResponseTest extends BasedConfigResponseTest {
ConfigQueryResponse configQueryResponse;
@Before
public void before() {
@BeforeEach
void before() {
configQueryResponse = ConfigQueryResponse.buildSuccessResponse("success");
configQueryResponse.setContentType("text");
configQueryResponse.setEncryptedDataKey("encryptedKey");

View File

@ -18,17 +18,17 @@ package com.alibaba.nacos.api.config.remote.response;
import com.alibaba.nacos.api.remote.response.ResponseCode;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ConfigRemoveResponseTest extends BasedConfigResponseTest {
class ConfigRemoveResponseTest extends BasedConfigResponseTest {
ConfigRemoveResponse configRemoveResponse;
@Before
public void before() {
@BeforeEach
void before() {
configRemoveResponse = ConfigRemoveResponse.buildSuccessResponse();
requestId = injectResponseUuId(configRemoveResponse);
}

View File

@ -19,17 +19,17 @@ package com.alibaba.nacos.api.config.remote.response.cluster;
import com.alibaba.nacos.api.config.remote.response.BasedConfigResponseTest;
import com.alibaba.nacos.api.remote.response.ResponseCode;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ConfigChangeClusterSyncResponseTest extends BasedConfigResponseTest {
ConfigChangeClusterSyncResponse configChangeClusterSyncResponse;
@Before
public void before() {
@BeforeEach
void before() {
configChangeClusterSyncResponse = new ConfigChangeClusterSyncResponse();
requestId = injectResponseUuId(configChangeClusterSyncResponse);
}

View File

@ -17,14 +17,14 @@
package com.alibaba.nacos.api.exception;
import com.alibaba.nacos.api.common.Constants;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class NacosExceptionTest {
class NacosExceptionTest {
@Test
public void testEmptyConstructor() {
void testEmptyConstructor() {
NacosException exception = new NacosException();
assertEquals(0, exception.getErrCode());
assertEquals(Constants.NULL, exception.getErrMsg());
@ -35,7 +35,7 @@ public class NacosExceptionTest {
}
@Test
public void testConstructorWithErrMsg() {
void testConstructorWithErrMsg() {
NacosException exception = new NacosException(NacosException.SERVER_ERROR, "test");
assertEquals(NacosException.SERVER_ERROR, exception.getErrCode());
assertEquals("test", exception.getErrMsg());
@ -43,7 +43,7 @@ public class NacosExceptionTest {
}
@Test
public void testConstructorWithCause() {
void testConstructorWithCause() {
NacosException exception = new NacosException(NacosException.SERVER_ERROR, new RuntimeException("cause test"));
assertEquals(NacosException.SERVER_ERROR, exception.getErrCode());
assertEquals("cause test", exception.getErrMsg());
@ -51,7 +51,7 @@ public class NacosExceptionTest {
}
@Test
public void testConstructorWithMultiCauses() {
void testConstructorWithMultiCauses() {
NacosException exception = new NacosException(NacosException.SERVER_ERROR,
new RuntimeException("cause test", new RuntimeException("multi")));
assertEquals(NacosException.SERVER_ERROR, exception.getErrCode());
@ -60,7 +60,7 @@ public class NacosExceptionTest {
}
@Test
public void testConstructorWithFull() {
void testConstructorWithFull() {
NacosException exception = new NacosException(NacosException.SERVER_ERROR, "test",
new RuntimeException("cause test"));
assertEquals(NacosException.SERVER_ERROR, exception.getErrCode());

View File

@ -18,14 +18,14 @@ package com.alibaba.nacos.api.exception.api;
import com.alibaba.nacos.api.common.Constants;
import com.alibaba.nacos.api.model.v2.ErrorCode;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class NacosApiExceptionTest {
class NacosApiExceptionTest {
@Test
public void testEmptyConstructor() {
void testEmptyConstructor() {
NacosApiException exception = new NacosApiException();
assertEquals(0, exception.getErrCode());
assertEquals(0, exception.getDetailErrCode());
@ -34,7 +34,7 @@ public class NacosApiExceptionTest {
}
@Test
public void testConstructorWithoutCause() {
void testConstructorWithoutCause() {
NacosApiException exception = new NacosApiException(500, ErrorCode.SERVER_ERROR, "test");
assertEquals(500, exception.getErrCode());
assertEquals(ErrorCode.SERVER_ERROR.getCode().intValue(), exception.getDetailErrCode());
@ -43,7 +43,7 @@ public class NacosApiExceptionTest {
}
@Test
public void testConstructorWithCause() {
void testConstructorWithCause() {
NacosApiException exception = new NacosApiException(500, ErrorCode.SERVER_ERROR,
new RuntimeException("cause test"), "test");
assertEquals(500, exception.getErrCode());

View File

@ -18,17 +18,17 @@ package com.alibaba.nacos.api.exception.runtime;
import com.alibaba.nacos.api.common.Constants;
import com.fasterxml.jackson.databind.type.SimpleType;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.lang.reflect.Type;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
public class NacosDeserializationExceptionTest {
class NacosDeserializationExceptionTest {
@Test
public void testEmptyConstructor() {
void testEmptyConstructor() {
NacosDeserializationException exception = new NacosDeserializationException();
assertEquals(Constants.Exception.DESERIALIZE_ERROR_CODE, exception.getErrCode());
assertNull(exception.getMessage());
@ -36,7 +36,7 @@ public class NacosDeserializationExceptionTest {
}
@Test
public void testConstructorWithTargetClass() {
void testConstructorWithTargetClass() {
NacosDeserializationException exception = new NacosDeserializationException(
NacosDeserializationExceptionTest.class);
assertEquals(Constants.Exception.DESERIALIZE_ERROR_CODE, exception.getErrCode());
@ -46,7 +46,7 @@ public class NacosDeserializationExceptionTest {
}
@Test
public void testConstructorWithTargetType() {
void testConstructorWithTargetType() {
Type type = SimpleType.constructUnsafe(NacosDeserializationExceptionTest.class);
NacosDeserializationException exception = new NacosDeserializationException(type);
assertEquals(Constants.Exception.DESERIALIZE_ERROR_CODE, exception.getErrCode());
@ -57,7 +57,7 @@ public class NacosDeserializationExceptionTest {
}
@Test
public void testConstructorWithCause() {
void testConstructorWithCause() {
NacosDeserializationException exception = new NacosDeserializationException(new RuntimeException("test"));
assertEquals(Constants.Exception.DESERIALIZE_ERROR_CODE, exception.getErrCode());
assertEquals("errCode: 101, errMsg: Nacos deserialize failed. ", exception.getMessage());
@ -65,7 +65,7 @@ public class NacosDeserializationExceptionTest {
}
@Test
public void testConstructorWithTargetClassAndCause() {
void testConstructorWithTargetClassAndCause() {
NacosDeserializationException exception = new NacosDeserializationException(
NacosDeserializationExceptionTest.class, new RuntimeException("test"));
assertEquals(Constants.Exception.DESERIALIZE_ERROR_CODE, exception.getErrCode());
@ -75,7 +75,7 @@ public class NacosDeserializationExceptionTest {
}
@Test
public void testConstructorWithTargetTypeAndCause() {
void testConstructorWithTargetTypeAndCause() {
Type type = SimpleType.constructUnsafe(NacosDeserializationExceptionTest.class);
NacosDeserializationException exception = new NacosDeserializationException(type, new RuntimeException("test"));
assertEquals(Constants.Exception.DESERIALIZE_ERROR_CODE, exception.getErrCode());

View File

@ -16,15 +16,15 @@
package com.alibaba.nacos.api.exception.runtime;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
public class NacosLoadExceptionTest {
class NacosLoadExceptionTest {
@Test
public void testConstructor() {
void testConstructor() {
NacosLoadException exception = new NacosLoadException("test");
assertEquals("test", exception.getMessage());
assertNull(exception.getCause());

View File

@ -17,16 +17,16 @@
package com.alibaba.nacos.api.exception.runtime;
import com.alibaba.nacos.api.exception.NacosException;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class NacosRuntimeExceptionTest {
class NacosRuntimeExceptionTest {
@Test
public void testConstructorWithErrorCode() {
void testConstructorWithErrorCode() {
NacosRuntimeException exception = new NacosRuntimeException(NacosException.INVALID_PARAM);
assertEquals(NacosException.INVALID_PARAM, exception.getErrCode());
assertNull(exception.getMessage());
@ -34,7 +34,7 @@ public class NacosRuntimeExceptionTest {
}
@Test
public void testConstructorWithErrorCodeAndMsg() {
void testConstructorWithErrorCodeAndMsg() {
NacosRuntimeException exception = new NacosRuntimeException(NacosException.INVALID_PARAM, "test");
assertEquals(NacosException.INVALID_PARAM, exception.getErrCode());
assertEquals("errCode: 400, errMsg: test ", exception.getMessage());
@ -42,7 +42,7 @@ public class NacosRuntimeExceptionTest {
}
@Test
public void testConstructorWithErrorCodeAndCause() {
void testConstructorWithErrorCodeAndCause() {
NacosRuntimeException exception = new NacosRuntimeException(NacosException.INVALID_PARAM,
new RuntimeException("test"));
assertEquals(NacosException.INVALID_PARAM, exception.getErrCode());
@ -51,9 +51,9 @@ public class NacosRuntimeExceptionTest {
}
@Test
public void testConstructorWithFull() {
NacosRuntimeException exception = new NacosRuntimeException(NacosException.INVALID_PARAM,
"test", new RuntimeException("cause test"));
void testConstructorWithFull() {
NacosRuntimeException exception = new NacosRuntimeException(NacosException.INVALID_PARAM, "test",
new RuntimeException("cause test"));
assertEquals(NacosException.INVALID_PARAM, exception.getErrCode());
assertEquals("errCode: 400, errMsg: test ", exception.getMessage());
assertTrue(exception.getCause() instanceof RuntimeException);

View File

@ -17,15 +17,15 @@
package com.alibaba.nacos.api.exception.runtime;
import com.alibaba.nacos.api.common.Constants;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
public class NacosSerializationExceptionTest {
class NacosSerializationExceptionTest {
@Test
public void testEmptyConstructor() {
void testEmptyConstructor() {
NacosSerializationException exception = new NacosSerializationException();
assertEquals(Constants.Exception.SERIALIZE_ERROR_CODE, exception.getErrCode());
assertNull(exception.getMessage());
@ -33,7 +33,7 @@ public class NacosSerializationExceptionTest {
}
@Test
public void testConstructorWithSerializedClass() {
void testConstructorWithSerializedClass() {
NacosSerializationException exception = new NacosSerializationException(NacosSerializationExceptionTest.class);
assertEquals(Constants.Exception.SERIALIZE_ERROR_CODE, exception.getErrCode());
assertEquals(String.format("errCode: 100, errMsg: Nacos serialize for class [%s] failed. ",
@ -42,7 +42,7 @@ public class NacosSerializationExceptionTest {
}
@Test
public void testConstructorWithCause() {
void testConstructorWithCause() {
NacosSerializationException exception = new NacosSerializationException(new RuntimeException("test"));
assertEquals(Constants.Exception.SERIALIZE_ERROR_CODE, exception.getErrCode());
assertEquals("errCode: 100, errMsg: Nacos serialize failed. ", exception.getMessage());
@ -50,7 +50,7 @@ public class NacosSerializationExceptionTest {
}
@Test
public void testConstructorWithSerializedClassAndCause() {
void testConstructorWithSerializedClassAndCause() {
NacosSerializationException exception = new NacosSerializationException(NacosSerializationExceptionTest.class,
new RuntimeException("test"));
assertEquals(Constants.Exception.SERIALIZE_ERROR_CODE, exception.getErrCode());

View File

@ -0,0 +1,41 @@
/*
* Copyright 1999-2021 Alibaba Group Holding Ltd.
*
* Licensed 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.
*/
package com.alibaba.nacos.api.model.v2;
import org.junit.jupiter.api.Test;
import java.util.HashSet;
import java.util.Set;
import static org.junit.jupiter.api.Assertions.assertEquals;
class ErrorCodeTest {
@Test
void testCodeNotSame() {
Class<ErrorCode> errorCodeClass = ErrorCode.class;
ErrorCode[] errorCodes = errorCodeClass.getEnumConstants();
Set<Integer> codeSet = new HashSet<Integer>(errorCodes.length);
for (ErrorCode errorCode : errorCodes) {
codeSet.add(errorCode.getCode());
}
assertEquals(errorCodes.length, codeSet.size());
}
}

View File

@ -16,15 +16,15 @@
package com.alibaba.nacos.api.model.v2;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
public class ResultTest {
class ResultTest {
@Test
public void testSuccessEmptyResult() {
void testSuccessEmptyResult() {
Result<String> result = Result.success();
assertNull(result.getData());
assertEquals(ErrorCode.SUCCESS.getCode(), result.getCode());
@ -32,7 +32,7 @@ public class ResultTest {
}
@Test
public void testSuccessWithData() {
void testSuccessWithData() {
Result<String> result = Result.success("test");
assertEquals("test", result.getData());
assertEquals(ErrorCode.SUCCESS.getCode(), result.getCode());
@ -40,7 +40,7 @@ public class ResultTest {
}
@Test
public void testFailureMessageResult() {
void testFailureMessageResult() {
Result<String> result = Result.failure("test");
assertNull(result.getData());
assertEquals(ErrorCode.SERVER_ERROR.getCode(), result.getCode());
@ -48,7 +48,7 @@ public class ResultTest {
}
@Test
public void testFailureWithoutData() {
void testFailureWithoutData() {
Result<String> result = Result.failure(ErrorCode.DATA_ACCESS_ERROR);
assertNull(result.getData());
assertEquals(ErrorCode.DATA_ACCESS_ERROR.getCode(), result.getCode());
@ -56,7 +56,7 @@ public class ResultTest {
}
@Test
public void testFailureWithData() {
void testFailureWithData() {
Result<String> result = Result.failure(ErrorCode.DATA_ACCESS_ERROR, "error");
assertEquals("error", result.getData());
assertEquals(ErrorCode.DATA_ACCESS_ERROR.getCode(), result.getCode());
@ -64,7 +64,7 @@ public class ResultTest {
}
@Test
public void testToString() {
void testToString() {
Result<String> result = Result.success("test");
assertEquals("Result{errorCode=0, message='success', data=test}", result.toString());
}

View File

@ -16,15 +16,15 @@
package com.alibaba.nacos.api.naming.ability;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ClientNamingAbilityTest {
class ClientNamingAbilityTest {
@Test
public void testGetAndSet() {
void testGetAndSet() {
ClientNamingAbility ability = new ClientNamingAbility();
assertFalse(ability.isSupportDeltaPush());
assertFalse(ability.isSupportRemoteMetric());

View File

@ -20,34 +20,33 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
public class ServerNamingAbilityTest {
class ServerNamingAbilityTest {
private static ObjectMapper jacksonMapper;
@BeforeClass
public static void setUpClass() throws Exception {
@BeforeAll
static void setUpClass() throws Exception {
jacksonMapper = new ObjectMapper();
jacksonMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
jacksonMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
}
@Test
public void testDeserializeServerNamingAbilityForNonExistItem() throws JsonProcessingException {
void testDeserializeServerNamingAbilityForNonExistItem() throws JsonProcessingException {
String nonExistItemJson = "{\"exampleAbility\":false}";
ServerNamingAbility actual = jacksonMapper.readValue(nonExistItemJson, ServerNamingAbility.class);
assertFalse(actual.isSupportJraft());
}
@Test
public void testEquals() throws JsonProcessingException {
void testEquals() throws JsonProcessingException {
ServerNamingAbility expected = new ServerNamingAbility();
expected.setSupportJraft(true);
String serializeJson = jacksonMapper.writeValueAsString(expected);
@ -60,19 +59,19 @@ public class ServerNamingAbilityTest {
}
@Test
public void testEqualsForOneObject() {
void testEqualsForOneObject() {
ServerNamingAbility ability = new ServerNamingAbility();
assertTrue(ability.equals(ability));
assertEquals(ability, ability);
}
@Test
public void testEqualsForOtherAbility() {
void testEqualsForOtherAbility() {
ServerNamingAbility ability = new ServerNamingAbility();
assertFalse(ability.equals(new ClientNamingAbility()));
assertNotEquals(ability, new ClientNamingAbility());
}
@Test
public void testHashCode() throws JsonProcessingException {
void testHashCode() throws JsonProcessingException {
ServerNamingAbility expected = new ServerNamingAbility();
expected.setSupportJraft(true);
String serializeJson = jacksonMapper.writeValueAsString(expected);

View File

@ -16,26 +16,26 @@
package com.alibaba.nacos.api.naming.listener;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.Collections;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class NamingEventTest {
class NamingEventTest {
private MockNamingEventListener eventListener;
@Before
public void setUp() throws Exception {
@BeforeEach
void setUp() throws Exception {
eventListener = new MockNamingEventListener();
}
@Test
public void testNamingEventWithSimpleConstructor() {
void testNamingEventWithSimpleConstructor() {
NamingEvent event = new NamingEvent("serviceName", Collections.EMPTY_LIST);
assertEquals("serviceName", event.getServiceName());
assertNull(event.getGroupName());
@ -49,7 +49,7 @@ public class NamingEventTest {
}
@Test
public void testNamingEventWithFullConstructor() {
void testNamingEventWithFullConstructor() {
NamingEvent event = new NamingEvent("serviceName", "group", "clusters", Collections.EMPTY_LIST);
assertEquals("serviceName", event.getServiceName());
assertEquals("group", event.getGroupName());

View File

@ -22,29 +22,29 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.util.Collections;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ClusterTest {
class ClusterTest {
private static ObjectMapper mapper;
@BeforeClass
public static void setUp() throws Exception {
@BeforeAll
static void setUp() throws Exception {
mapper = new ObjectMapper();
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
}
@Test
public void testSetAndGet() {
void testSetAndGet() {
Cluster actual = new Cluster();
assertNull(actual.getName());
assertNull(actual.getServiceName());
@ -72,7 +72,7 @@ public class ClusterTest {
}
@Test
public void testJsonSerialize() throws JsonProcessingException {
void testJsonSerialize() throws JsonProcessingException {
Cluster actual = new Cluster("cluster");
actual.setServiceName("group@@service");
actual.setHealthChecker(new Http());
@ -91,7 +91,7 @@ public class ClusterTest {
}
@Test
public void testJsonDeserialize() throws JsonProcessingException {
void testJsonDeserialize() throws JsonProcessingException {
String json = "{\"serviceName\":\"group@@service\",\"name\":\"cluster\","
+ "\"healthChecker\":{\"type\":\"HTTP\",\"path\":\"\",\"headers\":\"\",\"expectedResponseCode\":200},"
+ "\"defaultPort\":81,\"defaultCheckPort\":82,\"useIPPort4Check\":false,\"metadata\":{\"a\":\"a\"}}";

View File

@ -22,30 +22,31 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.HashMap;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class InstanceTest {
class InstanceTest {
private static ObjectMapper mapper;
@BeforeClass
public static void setUp() throws Exception {
@BeforeAll
static void setUp() throws Exception {
mapper = new ObjectMapper();
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
}
@Test
public void testSetAndGet() {
void testSetAndGet() {
Instance instance = new Instance();
assertNull(instance.getInstanceId());
assertNull(instance.getIp());
@ -62,7 +63,7 @@ public class InstanceTest {
}
@Test
public void testJsonSerialize() throws JsonProcessingException {
void testJsonSerialize() throws JsonProcessingException {
Instance instance = new Instance();
setInstance(instance);
String actual = mapper.writeValueAsString(instance);
@ -82,7 +83,7 @@ public class InstanceTest {
}
@Test
public void testJsonDeserialize() throws JsonProcessingException {
void testJsonDeserialize() throws JsonProcessingException {
String json = "{\"instanceId\":\"id\",\"ip\":\"1.1.1.1\",\"port\":1000,\"weight\":100.0,\"healthy\":false,"
+ "\"enabled\":false,\"ephemeral\":false,\"clusterName\":\"cluster\","
+ "\"serviceName\":\"group@@serviceName\",\"metadata\":{\"a\":\"b\"},\"instanceHeartBeatInterval\":5000,"
@ -92,21 +93,21 @@ public class InstanceTest {
}
@Test
public void testCheckClusterNameFormat() {
void testCheckClusterNameFormat() {
Instance instance = new Instance();
instance.setClusterName("demo");
assertEquals("demo", instance.getClusterName());
}
@Test
public void testToInetAddr() {
void testToInetAddr() {
Instance instance = new Instance();
setInstance(instance);
assertEquals("1.1.1.1:1000", instance.toInetAddr());
}
@Test
public void testContainsMetadata() {
void testContainsMetadata() {
Instance instance = new Instance();
assertFalse(instance.containsMetadata("a"));
instance.setMetadata(null);
@ -116,7 +117,7 @@ public class InstanceTest {
}
@Test
public void testGetInstanceIdGenerator() {
void testGetInstanceIdGenerator() {
Instance instance = new Instance();
assertEquals(Constants.DEFAULT_INSTANCE_ID_GENERATOR, instance.getInstanceIdGenerator());
instance.addMetadata(PreservedMetadataKeys.INSTANCE_ID_GENERATOR, "test");
@ -124,19 +125,19 @@ public class InstanceTest {
}
@Test
public void testEquals() {
void testEquals() {
Instance actual = new Instance();
setInstance(actual);
actual.setMetadata(new HashMap<>());
actual.addMetadata("a", "b");
assertFalse(actual.equals(new Object()));
assertNotEquals(actual, new Object());
Instance expected = new Instance();
setInstance(expected);
expected.setMetadata(new HashMap<>());
expected.addMetadata("a", "b");
assertTrue(actual.equals(expected));
assertEquals(actual, expected);
expected.addMetadata("a", "c");
assertFalse(actual.equals(expected));
assertNotEquals(actual, expected);
}
private void setInstance(Instance instance) {

View File

@ -16,19 +16,19 @@
package com.alibaba.nacos.api.naming.pojo;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
public class ListViewTest {
class ListViewTest {
@Test
public void testToString() {
void testToString() {
List<String> data = new LinkedList<>();
data.add("1");
data.add("2");
@ -41,7 +41,7 @@ public class ListViewTest {
}
@Test
public void testSetAndGet() {
void testSetAndGet() {
ListView<String> listView = new ListView<>();
assertEquals(0, listView.getCount());
assertNull(listView.getData());

View File

@ -20,8 +20,8 @@ import com.alibaba.nacos.api.utils.StringUtils;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
@ -30,25 +30,26 @@ import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ServiceInfoTest {
class ServiceInfoTest {
private ObjectMapper mapper;
private ServiceInfo serviceInfo;
@Before
public void setUp() throws Exception {
@BeforeEach
void setUp() throws Exception {
mapper = new ObjectMapper();
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
serviceInfo = new ServiceInfo("G@@testName", "testClusters");
}
@Test
public void testSerialize() throws JsonProcessingException {
void testSerialize() throws JsonProcessingException {
String actual = mapper.writeValueAsString(serviceInfo);
assertTrue(actual.contains("\"name\":\"G@@testName\""));
assertTrue(actual.contains("\"clusters\":\"testClusters\""));
@ -64,7 +65,7 @@ public class ServiceInfoTest {
}
@Test
public void testDeserialize() throws IOException {
void testDeserialize() throws IOException {
String example = "{\"name\":\"G@@testName\",\"clusters\":\"testClusters\",\"cacheMillis\":1000,\"hosts\":[],"
+ "\"lastRefTime\":0,\"checksum\":\"\",\"allIPs\":false,\"valid\":true,\"groupName\":\"\"}";
ServiceInfo actual = mapper.readValue(example, ServiceInfo.class);
@ -82,14 +83,14 @@ public class ServiceInfoTest {
}
@Test
public void testGetKey() {
void testGetKey() {
String key = serviceInfo.getKey();
assertEquals("G@@testName@@testClusters", key);
assertEquals("G@@testName@@testClusters", serviceInfo.toString());
}
@Test
public void testGetKeyEncode() {
void testGetKeyEncode() {
String key = serviceInfo.getKeyEncoded();
String encodeName = null;
try {
@ -101,7 +102,7 @@ public class ServiceInfoTest {
}
@Test
public void testServiceInfoConstructor() {
void testServiceInfoConstructor() {
String key1 = "group@@name";
String key2 = "group@@name@@c2";
ServiceInfo s1 = new ServiceInfo(key1);
@ -110,32 +111,34 @@ public class ServiceInfoTest {
assertEquals(key2, s2.getKey());
}
@Test(expected = IllegalArgumentException.class)
public void testServiceInfoConstructorWithError() {
String key1 = "name";
ServiceInfo s1 = new ServiceInfo(key1);
@Test
void testServiceInfoConstructorWithError() {
assertThrows(IllegalArgumentException.class, () -> {
String key1 = "name";
ServiceInfo s1 = new ServiceInfo(key1);
});
}
@Test
public void testValidateForAllIps() {
void testValidateForAllIps() {
serviceInfo.setAllIPs(true);
assertTrue(serviceInfo.validate());
}
@Test
public void testValidateForNullHosts() {
void testValidateForNullHosts() {
serviceInfo.setHosts(null);
assertFalse(serviceInfo.validate());
}
@Test
public void testValidateForEmptyHosts() {
void testValidateForEmptyHosts() {
serviceInfo.setHosts(Collections.EMPTY_LIST);
assertFalse(serviceInfo.validate());
}
@Test
public void testValidateForUnhealthyHosts() {
void testValidateForUnhealthyHosts() {
Instance instance = new Instance();
instance.setHealthy(false);
serviceInfo.addHost(instance);
@ -143,7 +146,7 @@ public class ServiceInfoTest {
}
@Test
public void testValidateForBothUnhealthyAndHealthyHosts() {
void testValidateForBothUnhealthyAndHealthyHosts() {
List<Instance> instanceList = new LinkedList<>();
Instance instance = new Instance();
instanceList.add(instance);
@ -155,7 +158,7 @@ public class ServiceInfoTest {
}
@Test
public void testFromKey() {
void testFromKey() {
String key1 = "group@@name";
String key2 = "group@@name@@c2";
ServiceInfo s1 = ServiceInfo.fromKey(key1);
@ -165,7 +168,7 @@ public class ServiceInfoTest {
}
@Test
public void testSetAndGet() throws JsonProcessingException {
void testSetAndGet() throws JsonProcessingException {
serviceInfo.setReachProtectionThreshold(true);
serviceInfo.setJsonFromServer(mapper.writeValueAsString(serviceInfo));
ServiceInfo actual = mapper.readValue(serviceInfo.getJsonFromServer(), ServiceInfo.class);

View File

@ -16,19 +16,19 @@
package com.alibaba.nacos.api.naming.pojo;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.HashMap;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ServiceTest {
class ServiceTest {
@Test
public void testSetAndGet() {
void testSetAndGet() {
Service service = new Service();
assertNull(service.getName());
assertNull(service.getAppName());
@ -51,12 +51,13 @@ public class ServiceTest {
}
@Test
public void testToString() {
void testToString() {
Service service = new Service("service");
service.setGroupName("group");
service.setAppName("app");
service.setProtectThreshold(1.0f);
service.setMetadata(Collections.singletonMap("a", "b"));
assertEquals("Service{name='service', protectThreshold=1.0, appName='app', groupName='group', metadata={a=b}}", service.toString());
assertEquals("Service{name='service', protectThreshold=1.0, appName='app', groupName='group', metadata={a=b}}",
service.toString());
}
}

View File

@ -17,18 +17,16 @@
package com.alibaba.nacos.api.naming.pojo.builder;
import com.alibaba.nacos.api.naming.pojo.Instance;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.Map;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class InstanceBuilderTest {
class InstanceBuilderTest {
private static final String SERVICE_NAME = "testService";
@ -53,26 +51,26 @@ public class InstanceBuilderTest {
private static final String META_VALUE = "value";
@Test
public void testBuildFullInstance() {
void testBuildFullInstance() {
InstanceBuilder builder = InstanceBuilder.newBuilder();
Instance actual = builder.setServiceName(SERVICE_NAME).setClusterName(CLUSTER_NAME).setInstanceId(INSTANCE_ID)
.setIp(IP).setPort(PORT).setWeight(WEIGHT).setHealthy(HEALTHY).setEnabled(ENABLED)
.setEphemeral(EPHEMERAL).addMetadata(META_KEY, META_VALUE).build();
assertThat(actual.getServiceName(), is(SERVICE_NAME));
assertThat(actual.getClusterName(), is(CLUSTER_NAME));
assertThat(actual.getInstanceId(), is(INSTANCE_ID));
assertThat(actual.getIp(), is(IP));
assertThat(actual.getPort(), is(PORT));
assertThat(actual.getWeight(), is(WEIGHT));
assertThat(actual.isHealthy(), is(HEALTHY));
assertThat(actual.isEnabled(), is(ENABLED));
assertThat(actual.isEphemeral(), is(EPHEMERAL));
assertThat(actual.getMetadata().size(), is(1));
assertThat(actual.getMetadata().get(META_KEY), is(META_VALUE));
Instance actual = builder.setServiceName(SERVICE_NAME).setClusterName(CLUSTER_NAME).setInstanceId(INSTANCE_ID).setIp(IP)
.setPort(PORT).setWeight(WEIGHT).setHealthy(HEALTHY).setEnabled(ENABLED).setEphemeral(EPHEMERAL)
.addMetadata(META_KEY, META_VALUE).build();
assertEquals(actual.getServiceName(), SERVICE_NAME);
assertEquals(actual.getClusterName(), CLUSTER_NAME);
assertEquals(actual.getInstanceId(), INSTANCE_ID);
assertEquals(actual.getIp(), IP);
assertEquals(actual.getPort(), PORT);
assertEquals(actual.getWeight(), WEIGHT);
assertEquals(actual.isHealthy(), HEALTHY);
assertEquals(actual.isEnabled(), ENABLED);
assertEquals(actual.isEphemeral(), EPHEMERAL);
assertEquals(actual.getMetadata().size(), 1);
assertEquals(actual.getMetadata().get(META_KEY), META_VALUE);
}
@Test
public void testBuildInstanceWithoutNewMetadata() {
void testBuildInstanceWithoutNewMetadata() {
InstanceBuilder builder = InstanceBuilder.newBuilder();
Map<String, String> metadata = new HashMap<>();
metadata.put("test", "test");
@ -81,8 +79,8 @@ public class InstanceBuilderTest {
assertNull(actual.getClusterName());
assertNull(actual.getInstanceId());
assertNull(actual.getIp());
assertThat(actual.getPort(), is(0));
assertThat(actual.getWeight(), is(1.0));
assertEquals(actual.getPort(), 0);
assertEquals(actual.getWeight(), 1.0);
assertTrue(actual.isHealthy());
assertTrue(actual.isEnabled());
assertTrue(actual.isEphemeral());
@ -90,15 +88,15 @@ public class InstanceBuilderTest {
}
@Test
public void testBuildEmptyInstance() {
void testBuildEmptyInstance() {
InstanceBuilder builder = InstanceBuilder.newBuilder();
Instance actual = builder.build();
assertNull(actual.getServiceName());
assertNull(actual.getClusterName());
assertNull(actual.getInstanceId());
assertNull(actual.getIp());
assertThat(actual.getPort(), is(0));
assertThat(actual.getWeight(), is(1.0));
assertEquals(actual.getPort(), 0);
assertEquals(actual.getWeight(), 1.0);
assertTrue(actual.isHealthy());
assertTrue(actual.isEnabled());
assertTrue(actual.isEphemeral());

View File

@ -20,26 +20,26 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.jsontype.NamedType;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class AbstractHealthCheckerTest {
class AbstractHealthCheckerTest {
private final ObjectMapper objectMapper = new ObjectMapper();
@Before
public void setUp() {
@BeforeEach
void setUp() {
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
objectMapper.registerSubtypes(new NamedType(TestChecker.class, TestChecker.TYPE));
}
@Test
public void testSerialize() throws JsonProcessingException {
void testSerialize() throws JsonProcessingException {
TestChecker testChecker = new TestChecker();
testChecker.setTestValue("");
String actual = objectMapper.writeValueAsString(testChecker);
@ -48,7 +48,7 @@ public class AbstractHealthCheckerTest {
}
@Test
public void testDeserialize() throws IOException {
void testDeserialize() throws IOException {
String testChecker = "{\"type\":\"TEST\",\"testValue\":\"\"}";
TestChecker actual = objectMapper.readValue(testChecker, TestChecker.class);
assertEquals("", actual.getTestValue());
@ -56,7 +56,7 @@ public class AbstractHealthCheckerTest {
}
@Test
public void testClone() throws CloneNotSupportedException {
void testClone() throws CloneNotSupportedException {
AbstractHealthChecker none = new AbstractHealthChecker.None().clone();
assertEquals(AbstractHealthChecker.None.class, none.getClass());
}

View File

@ -19,17 +19,17 @@ package com.alibaba.nacos.api.naming.pojo.healthcheck;
import com.alibaba.nacos.api.naming.pojo.healthcheck.impl.Http;
import com.alibaba.nacos.api.naming.pojo.healthcheck.impl.Mysql;
import com.alibaba.nacos.api.naming.pojo.healthcheck.impl.Tcp;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
public class HealthCheckTypeTest {
class HealthCheckTypeTest {
@Test
public void testOfHealthCheckerClassForBuildInType() {
void testOfHealthCheckerClassForBuildInType() {
assertEquals(Tcp.class, HealthCheckType.ofHealthCheckerClass("TCP"));
assertEquals(Http.class, HealthCheckType.ofHealthCheckerClass("HTTP"));
assertEquals(Mysql.class, HealthCheckType.ofHealthCheckerClass("MYSQL"));
@ -37,18 +37,18 @@ public class HealthCheckTypeTest {
}
@Test
public void testOfHealthCheckerClassForExtendType() {
void testOfHealthCheckerClassForExtendType() {
HealthCheckType.registerHealthChecker(TestChecker.TYPE, TestChecker.class);
assertEquals(TestChecker.class, HealthCheckType.ofHealthCheckerClass(TestChecker.TYPE));
}
@Test
public void testOfHealthCheckerClassForNonExistType() {
void testOfHealthCheckerClassForNonExistType() {
assertNull(HealthCheckType.ofHealthCheckerClass("non-exist"));
}
@Test
public void testGetLoadedHealthCheckerClasses() {
void testGetLoadedHealthCheckerClasses() {
HealthCheckType.registerHealthChecker(TestChecker.TYPE, TestChecker.class);
List<Class<? extends AbstractHealthChecker>> actual = HealthCheckType.getLoadedHealthCheckerClasses();
assertEquals(5, actual.size());

View File

@ -19,75 +19,80 @@ package com.alibaba.nacos.api.naming.pojo.healthcheck;
import com.alibaba.nacos.api.exception.runtime.NacosDeserializationException;
import com.alibaba.nacos.api.exception.runtime.NacosSerializationException;
import com.alibaba.nacos.api.naming.pojo.healthcheck.impl.Tcp;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class HealthCheckerFactoryTest {
class HealthCheckerFactoryTest {
@BeforeClass
public static void beforeClass() {
@BeforeAll
static void beforeClass() {
HealthCheckerFactory.registerSubType(new TestChecker());
}
@Test
public void testSerialize() {
void testSerialize() {
Tcp tcp = new Tcp();
String actual = HealthCheckerFactory.serialize(tcp);
assertTrue(actual.contains("\"type\":\"TCP\""));
}
@Test
public void testSerializeExtend() {
void testSerializeExtend() {
TestChecker testChecker = new TestChecker();
String actual = HealthCheckerFactory.serialize(testChecker);
assertTrue(actual.contains("\"type\":\"TEST\""));
}
@Test
public void testDeserialize() {
void testDeserialize() {
String tcpString = "{\"type\":\"TCP\"}";
AbstractHealthChecker actual = HealthCheckerFactory.deserialize(tcpString);
assertEquals(Tcp.class, actual.getClass());
}
@Test
public void testDeserializeExtend() {
void testDeserializeExtend() {
String tcpString = "{\"type\":\"TEST\",\"testValue\":null}";
AbstractHealthChecker actual = HealthCheckerFactory.deserialize(tcpString);
assertEquals(TestChecker.class, actual.getClass());
}
@Test
public void testSerializeNoRegister() {
void testSerializeNoRegister() {
NoRegisterHealthChecker noRegister = new NoRegisterHealthChecker();
assertFalse(HealthCheckerFactory.serialize(noRegister).contains("no register"));
}
@Test
public void testDeserializeNoRegister() {
void testDeserializeNoRegister() {
String tcpString = "{\"type\":\"no register\",\"testValue\":null}";
AbstractHealthChecker actual = HealthCheckerFactory.deserialize(tcpString);
assertEquals(AbstractHealthChecker.None.class, actual.getClass());
}
@Test(expected = NacosSerializationException.class)
public void testSerializeFailure() {
SelfDependHealthChecker selfDependHealthChecker = new SelfDependHealthChecker();
System.out.println(HealthCheckerFactory.serialize(selfDependHealthChecker));
}
@Test(expected = NacosDeserializationException.class)
public void testDeserializeFailure() {
String errorString = "{\"type\"=\"TCP\"}";
System.out.println(HealthCheckerFactory.deserialize(errorString));
@Test
void testSerializeFailure() {
assertThrows(NacosSerializationException.class, () -> {
SelfDependHealthChecker selfDependHealthChecker = new SelfDependHealthChecker();
System.out.println(HealthCheckerFactory.serialize(selfDependHealthChecker));
});
}
@Test
public void testCreateNoneHealthChecker() {
void testDeserializeFailure() {
assertThrows(NacosDeserializationException.class, () -> {
String errorString = "{\"type\"=\"TCP\"}";
System.out.println(HealthCheckerFactory.deserialize(errorString));
});
}
@Test
void testCreateNoneHealthChecker() {
assertEquals(AbstractHealthChecker.None.class, HealthCheckerFactory.createNoneHealthChecker().getClass());
}

View File

@ -28,6 +28,10 @@ public class TestChecker extends AbstractHealthChecker {
private String testValue;
public TestChecker() {
super(TYPE);
}
public String getTestValue() {
return testValue;
}
@ -36,10 +40,6 @@ public class TestChecker extends AbstractHealthChecker {
this.testValue = testValue;
}
public TestChecker() {
super(TYPE);
}
@Override
public AbstractHealthChecker clone() throws CloneNotSupportedException {
return null;

View File

@ -18,36 +18,37 @@ package com.alibaba.nacos.api.naming.pojo.healthcheck.impl;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class HttpTest {
class HttpTest {
private ObjectMapper objectMapper;
private Http http;
@Before
public void setUp() {
@BeforeEach
void setUp() {
objectMapper = new ObjectMapper();
http = new Http();
}
@Test
public void testGetExpectedResponseCodeWithEmpty() {
void testGetExpectedResponseCodeWithEmpty() {
http.setHeaders("");
assertTrue(http.getCustomHeaders().isEmpty());
}
@Test
public void testGetExpectedResponseCodeWithoutEmpty() {
void testGetExpectedResponseCodeWithoutEmpty() {
http.setHeaders("x:a|y:");
Map<String, String> actual = http.getCustomHeaders();
assertFalse(actual.isEmpty());
@ -56,7 +57,7 @@ public class HttpTest {
}
@Test
public void testSerialize() throws JsonProcessingException {
void testSerialize() throws JsonProcessingException {
http.setHeaders("x:a|y:");
http.setPath("/x");
String actual = objectMapper.writeValueAsString(http);
@ -67,7 +68,7 @@ public class HttpTest {
}
@Test
public void testDeserialize() throws IOException {
void testDeserialize() throws IOException {
String testChecker = "{\"type\":\"HTTP\",\"path\":\"/x\",\"headers\":\"x:a|y:\",\"expectedResponseCode\":200}";
Http actual = objectMapper.readValue(testChecker, Http.class);
assertEquals("x:a|y:", actual.getHeaders());
@ -78,23 +79,23 @@ public class HttpTest {
}
@Test
public void testClone() throws CloneNotSupportedException {
void testClone() throws CloneNotSupportedException {
Http cloned = http.clone();
assertEquals(http.hashCode(), cloned.hashCode());
assertTrue(http.equals(cloned));
assertEquals(http, cloned);
}
@Test
public void testNotEquals() throws CloneNotSupportedException {
assertFalse(http.equals(new Tcp()));
void testNotEquals() throws CloneNotSupportedException {
assertNotEquals(http, new Tcp());
Http cloned = http.clone();
cloned.setPath("aaa");
assertFalse(http.equals(cloned));
assertNotEquals(http, cloned);
cloned = http.clone();
cloned.setHeaders("aaa");
assertFalse(http.equals(cloned));
assertNotEquals(http, cloned);
cloned = http.clone();
cloned.setExpectedResponseCode(500);
assertFalse(http.equals(cloned));
assertNotEquals(http, cloned);
}
}

View File

@ -18,23 +18,23 @@ package com.alibaba.nacos.api.naming.pojo.healthcheck.impl;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class MysqlTest {
class MysqlTest {
private ObjectMapper objectMapper;
private Mysql mysql;
@Before
public void setUp() throws Exception {
@BeforeEach
void setUp() throws Exception {
mysql = new Mysql();
mysql.setUser("user");
mysql.setPwd("pwd");
@ -43,7 +43,7 @@ public class MysqlTest {
}
@Test
public void testSerialize() throws JsonProcessingException {
void testSerialize() throws JsonProcessingException {
String actual = objectMapper.writeValueAsString(mysql);
assertTrue(actual.contains("\"user\":\"user\""));
assertTrue(actual.contains("\"type\":\"MYSQL\""));
@ -52,7 +52,7 @@ public class MysqlTest {
}
@Test
public void testDeserialize() throws IOException {
void testDeserialize() throws IOException {
String testChecker = "{\"type\":\"MYSQL\",\"user\":\"user\",\"pwd\":\"pwd\",\"cmd\":\"cmd\"}";
Mysql actual = objectMapper.readValue(testChecker, Mysql.class);
assertEquals("cmd", actual.getCmd());
@ -62,23 +62,23 @@ public class MysqlTest {
}
@Test
public void testClone() throws CloneNotSupportedException {
void testClone() throws CloneNotSupportedException {
Mysql cloned = mysql.clone();
assertEquals(mysql.hashCode(), cloned.hashCode());
assertTrue(mysql.equals(cloned));
assertEquals(mysql, cloned);
}
@Test
public void testNotEquals() throws CloneNotSupportedException {
assertFalse(mysql.equals(new Tcp()));
void testNotEquals() throws CloneNotSupportedException {
assertNotEquals(mysql, new Tcp());
Mysql cloned = mysql.clone();
cloned.setUser("aaa");
assertFalse(mysql.equals(cloned));
assertNotEquals(mysql, cloned);
cloned = mysql.clone();
cloned.setPwd("aaa");
assertFalse(mysql.equals(cloned));
assertNotEquals(mysql, cloned);
cloned = mysql.clone();
cloned.setCmd("aaa");
assertFalse(mysql.equals(cloned));
assertNotEquals(mysql, cloned);
}
}

View File

@ -16,18 +16,17 @@
package com.alibaba.nacos.api.naming.pojo.healthcheck.impl;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class TcpTest {
class TcpTest {
@Test
public void testClone() throws CloneNotSupportedException {
void testClone() throws CloneNotSupportedException {
Tcp original = new Tcp();
Tcp cloned = original.clone();
assertEquals(original.hashCode(), cloned.hashCode());
assertTrue(original.equals(cloned));
assertEquals(original, cloned);
}
}

View File

@ -19,11 +19,11 @@ package com.alibaba.nacos.api.naming.remote.request;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.BeforeClass;
import org.junit.jupiter.api.BeforeAll;
import static com.alibaba.nacos.api.common.Constants.Naming.NAMING_MODULE;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public abstract class BasedNamingRequestTest {
@ -35,7 +35,7 @@ public abstract class BasedNamingRequestTest {
protected static ObjectMapper mapper;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
mapper = new ObjectMapper();
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);

View File

@ -19,17 +19,17 @@ package com.alibaba.nacos.api.naming.remote.request;
import com.alibaba.nacos.api.naming.pojo.Instance;
import com.alibaba.nacos.api.naming.remote.NamingRemoteConstants;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.Collections;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class BatchInstanceRequestTest extends BasedNamingRequestTest {
class BatchInstanceRequestTest extends BasedNamingRequestTest {
@Test
public void testSerialize() throws JsonProcessingException {
void testSerialize() throws JsonProcessingException {
BatchInstanceRequest request = new BatchInstanceRequest(NAMESPACE, SERVICE, GROUP,
NamingRemoteConstants.BATCH_REGISTER_INSTANCE, Collections.singletonList(new Instance()));
String json = mapper.writeValueAsString(request);
@ -39,7 +39,7 @@ public class BatchInstanceRequestTest extends BasedNamingRequestTest {
}
@Test
public void testDeserialize() throws JsonProcessingException {
void testDeserialize() throws JsonProcessingException {
String json = "{\"headers\":{},\"namespace\":\"namespace\",\"serviceName\":\"service\",\"groupName\":\"group\","
+ "\"type\":\"batchRegisterInstance\",\"instances\":[{\"port\":0,\"weight\":1.0,\"healthy\":true,"
+ "\"enabled\":true,\"ephemeral\":true,\"metadata\":{},\"instanceIdGenerator\":\"simple\","

View File

@ -19,15 +19,15 @@ package com.alibaba.nacos.api.naming.remote.request;
import com.alibaba.nacos.api.naming.pojo.Instance;
import com.alibaba.nacos.api.naming.remote.NamingRemoteConstants;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class InstanceRequestTest extends BasedNamingRequestTest {
class InstanceRequestTest extends BasedNamingRequestTest {
@Test
public void testSerialize() throws JsonProcessingException {
void testSerialize() throws JsonProcessingException {
InstanceRequest request = new InstanceRequest(NAMESPACE, SERVICE, GROUP,
NamingRemoteConstants.REGISTER_INSTANCE, new Instance());
String json = mapper.writeValueAsString(request);
@ -37,7 +37,7 @@ public class InstanceRequestTest extends BasedNamingRequestTest {
}
@Test
public void testDeserialize() throws JsonProcessingException {
void testDeserialize() throws JsonProcessingException {
String json = "{\"headers\":{},\"namespace\":\"namespace\",\"serviceName\":\"service\",\"groupName\":\"group\","
+ "\"type\":\"deregisterInstance\",\"instance\":{\"port\":0,\"weight\":1.0,\"healthy\":true,"
+ "\"enabled\":true,\"ephemeral\":true,\"metadata\":{},\"instanceIdGenerator\":\"simple\","

View File

@ -21,14 +21,14 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static com.alibaba.nacos.api.common.Constants.Naming.NAMING_MODULE;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class NotifySubscriberRequestTest {
class NotifySubscriberRequestTest {
private static final String SERVICE = "service";
@ -38,15 +38,15 @@ public class NotifySubscriberRequestTest {
private static ObjectMapper mapper;
@BeforeClass
public static void setUp() throws Exception {
@BeforeAll
static void setUp() throws Exception {
mapper = new ObjectMapper();
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
}
@Test
public void testSerialize() throws JsonProcessingException {
void testSerialize() throws JsonProcessingException {
ServiceInfo serviceInfo = new ServiceInfo(GROUP + "@@" + SERVICE);
NotifySubscriberRequest request = NotifySubscriberRequest.buildNotifySubscriberRequest(serviceInfo);
request.setServiceName(SERVICE);
@ -58,7 +58,7 @@ public class NotifySubscriberRequestTest {
}
@Test
public void testDeserialize() throws JsonProcessingException {
void testDeserialize() throws JsonProcessingException {
String json = "{\"headers\":{},\"namespace\":\"namespace\",\"serviceName\":\"service\",\"groupName\":\"group\","
+ "\"serviceInfo\":{\"name\":\"service\",\"groupName\":\"group\",\"cacheMillis\":1000,\"hosts\":[],"
+ "\"lastRefTime\":0,\"checksum\":\"\",\"allIPs\":false,\"reachProtectionThreshold\":false,"

View File

@ -19,15 +19,15 @@ package com.alibaba.nacos.api.naming.remote.request;
import com.alibaba.nacos.api.naming.pojo.Instance;
import com.alibaba.nacos.api.naming.remote.NamingRemoteConstants;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class PersistentInstanceRequestTest extends BasedNamingRequestTest {
class PersistentInstanceRequestTest extends BasedNamingRequestTest {
@Test
public void testSerialize() throws JsonProcessingException {
void testSerialize() throws JsonProcessingException {
PersistentInstanceRequest request = new PersistentInstanceRequest(NAMESPACE, SERVICE, GROUP,
NamingRemoteConstants.REGISTER_INSTANCE, new Instance());
String json = mapper.writeValueAsString(request);
@ -37,7 +37,7 @@ public class PersistentInstanceRequestTest extends BasedNamingRequestTest {
}
@Test
public void testDeserialize() throws JsonProcessingException {
void testDeserialize() throws JsonProcessingException {
String json = "{\"headers\":{},\"namespace\":\"namespace\",\"serviceName\":\"service\",\"groupName\":\"group\","
+ "\"type\":\"deregisterInstance\",\"instance\":{\"port\":0,\"weight\":1.0,\"healthy\":true,"
+ "\"enabled\":true,\"ephemeral\":true,\"metadata\":{},\"instanceIdGenerator\":\"simple\","

View File

@ -17,16 +17,16 @@
package com.alibaba.nacos.api.naming.remote.request;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static com.alibaba.nacos.api.common.Constants.Naming.NAMING_MODULE;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ServiceListRequestTest extends BasedNamingRequestTest {
class ServiceListRequestTest extends BasedNamingRequestTest {
@Test
public void testSerialize() throws JsonProcessingException {
void testSerialize() throws JsonProcessingException {
ServiceListRequest request = new ServiceListRequest(NAMESPACE, GROUP, 1, 10);
request.setSelector("label");
String json = mapper.writeValueAsString(request);
@ -39,7 +39,7 @@ public class ServiceListRequestTest extends BasedNamingRequestTest {
}
@Test
public void testDeserialize() throws JsonProcessingException {
void testDeserialize() throws JsonProcessingException {
String json = "{\"headers\":{},\"namespace\":\"namespace\",\"serviceName\":\"\",\"groupName\":\"group\","
+ "\"pageNo\":1,\"pageSize\":10,\"selector\":\"label\",\"module\":\"naming\"}";
ServiceListRequest actual = mapper.readValue(json, ServiceListRequest.class);

View File

@ -18,15 +18,15 @@ package com.alibaba.nacos.api.naming.remote.request;
import com.alibaba.nacos.api.common.Constants;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ServiceQueryRequestTest extends BasedNamingRequestTest {
class ServiceQueryRequestTest extends BasedNamingRequestTest {
@Test
public void testSerialize() throws JsonProcessingException {
void testSerialize() throws JsonProcessingException {
ServiceQueryRequest request = new ServiceQueryRequest(NAMESPACE, SERVICE, GROUP);
request.setCluster(Constants.DEFAULT_CLUSTER_NAME);
String json = mapper.writeValueAsString(request);
@ -37,7 +37,7 @@ public class ServiceQueryRequestTest extends BasedNamingRequestTest {
}
@Test
public void testDeserialize() throws JsonProcessingException {
void testDeserialize() throws JsonProcessingException {
String json = "{\"headers\":{},\"namespace\":\"namespace\",\"serviceName\":\"service\",\"groupName\":\"group\","
+ "\"cluster\":\"DEFAULT\",\"healthyOnly\":true,\"udpPort\":0,\"module\":\"naming\"}";
ServiceQueryRequest actual = mapper.readValue(json, ServiceQueryRequest.class);

View File

@ -17,16 +17,16 @@
package com.alibaba.nacos.api.naming.remote.request;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class SubscribeServiceRequestTest extends BasedNamingRequestTest {
class SubscribeServiceRequestTest extends BasedNamingRequestTest {
@Test
public void testSerialize() throws JsonProcessingException {
void testSerialize() throws JsonProcessingException {
SubscribeServiceRequest request = new SubscribeServiceRequest(NAMESPACE, GROUP, SERVICE, "", true);
String json = mapper.writeValueAsString(request);
checkSerializeBasedInfo(json);
@ -35,7 +35,7 @@ public class SubscribeServiceRequestTest extends BasedNamingRequestTest {
}
@Test
public void testDeserialize() throws JsonProcessingException {
void testDeserialize() throws JsonProcessingException {
String json = "{\"headers\":{},\"namespace\":\"namespace\",\"serviceName\":\"service\",\"groupName\":\"group\","
+ "\"subscribe\":false,\"clusters\":\"aa,bb\",\"module\":\"naming\"}";
SubscribeServiceRequest actual = mapper.readValue(json, SubscribeServiceRequest.class);

View File

@ -21,32 +21,32 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class BatchInstanceResponseTest {
class BatchInstanceResponseTest {
protected static ObjectMapper mapper;
@BeforeClass
public static void setUp() throws Exception {
@BeforeAll
static void setUp() throws Exception {
mapper = new ObjectMapper();
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
}
@Test
public void testSerialize() throws JsonProcessingException {
void testSerialize() throws JsonProcessingException {
BatchInstanceResponse response = new BatchInstanceResponse(NamingRemoteConstants.REGISTER_INSTANCE);
String json = mapper.writeValueAsString(response);
assertTrue(json.contains("\"type\":\"" + NamingRemoteConstants.REGISTER_INSTANCE + "\""));
}
@Test
public void testDeserialize() throws JsonProcessingException {
void testDeserialize() throws JsonProcessingException {
String json = "{\"resultCode\":200,\"errorCode\":0,\"type\":\"registerInstance\",\"success\":true}";
BatchInstanceResponse response = mapper.readValue(json, BatchInstanceResponse.class);
assertEquals(NamingRemoteConstants.REGISTER_INSTANCE, response.getType());

View File

@ -21,32 +21,32 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class InstanceResponseTest {
class InstanceResponseTest {
protected static ObjectMapper mapper;
@BeforeClass
public static void setUp() throws Exception {
@BeforeAll
static void setUp() throws Exception {
mapper = new ObjectMapper();
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
}
@Test
public void testSerialize() throws JsonProcessingException {
void testSerialize() throws JsonProcessingException {
InstanceResponse response = new InstanceResponse(NamingRemoteConstants.REGISTER_INSTANCE);
String json = mapper.writeValueAsString(response);
assertTrue(json.contains("\"type\":\"" + NamingRemoteConstants.REGISTER_INSTANCE + "\""));
}
@Test
public void testDeserialize() throws JsonProcessingException {
void testDeserialize() throws JsonProcessingException {
String json = "{\"resultCode\":200,\"errorCode\":0,\"type\":\"deregisterInstance\",\"success\":true}";
InstanceResponse response = mapper.readValue(json, InstanceResponse.class);
assertEquals(NamingRemoteConstants.DE_REGISTER_INSTANCE, response.getType());

View File

@ -21,25 +21,25 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class QueryServiceResponseTest {
class QueryServiceResponseTest {
protected static ObjectMapper mapper;
@BeforeClass
public static void setUp() throws Exception {
@BeforeAll
static void setUp() throws Exception {
mapper = new ObjectMapper();
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
}
@Test
public void testSerializeSuccessResponse() throws JsonProcessingException {
void testSerializeSuccessResponse() throws JsonProcessingException {
QueryServiceResponse response = QueryServiceResponse.buildSuccessResponse(new ServiceInfo());
String json = mapper.writeValueAsString(response);
assertTrue(json.contains("\"serviceInfo\":{"));
@ -49,7 +49,7 @@ public class QueryServiceResponseTest {
}
@Test
public void testSerializeFailResponse() throws JsonProcessingException {
void testSerializeFailResponse() throws JsonProcessingException {
QueryServiceResponse response = QueryServiceResponse.buildFailResponse("test");
String json = mapper.writeValueAsString(response);
assertTrue(json.contains("\"resultCode\":500"));
@ -59,7 +59,7 @@ public class QueryServiceResponseTest {
}
@Test
public void testDeserialize() throws JsonProcessingException {
void testDeserialize() throws JsonProcessingException {
String json = "{\"resultCode\":200,\"errorCode\":0,\"serviceInfo\":{\"cacheMillis\":1000,\"hosts\":[],"
+ "\"lastRefTime\":0,\"checksum\":\"\",\"allIPs\":false,\"reachProtectionThreshold\":false,"
+ "\"valid\":true},\"success\":true}";

View File

@ -20,27 +20,27 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.util.Collections;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ServiceListResponseTest {
class ServiceListResponseTest {
protected static ObjectMapper mapper;
@BeforeClass
public static void setUp() throws Exception {
@BeforeAll
static void setUp() throws Exception {
mapper = new ObjectMapper();
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
}
@Test
public void testSerializeSuccessResponse() throws JsonProcessingException {
void testSerializeSuccessResponse() throws JsonProcessingException {
ServiceListResponse response = ServiceListResponse.buildSuccessResponse(10, Collections.singletonList("a"));
String json = mapper.writeValueAsString(response);
assertTrue(json.contains("\"count\":10"));
@ -51,7 +51,7 @@ public class ServiceListResponseTest {
}
@Test
public void testSerializeFailResponse() throws JsonProcessingException {
void testSerializeFailResponse() throws JsonProcessingException {
ServiceListResponse response = ServiceListResponse.buildFailResponse("test");
String json = mapper.writeValueAsString(response);
assertTrue(json.contains("\"resultCode\":500"));
@ -61,7 +61,7 @@ public class ServiceListResponseTest {
}
@Test
public void testDeserialize() throws JsonProcessingException {
void testDeserialize() throws JsonProcessingException {
String json = "{\"resultCode\":200,\"errorCode\":0,\"count\":10,\"serviceNames\":[\"a\"],\"success\":true}";
ServiceListResponse response = mapper.readValue(json, ServiceListResponse.class);
assertEquals(10, response.getCount());

View File

@ -21,25 +21,25 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class SubscribeServiceResponseTest {
class SubscribeServiceResponseTest {
protected static ObjectMapper mapper;
@BeforeClass
public static void setUp() throws Exception {
@BeforeAll
static void setUp() throws Exception {
mapper = new ObjectMapper();
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
}
@Test
public void testSerializeSuccessResponse() throws JsonProcessingException {
void testSerializeSuccessResponse() throws JsonProcessingException {
SubscribeServiceResponse response = new SubscribeServiceResponse(200, null, new ServiceInfo());
String json = mapper.writeValueAsString(response);
assertTrue(json.contains("\"serviceInfo\":{"));
@ -49,7 +49,7 @@ public class SubscribeServiceResponseTest {
}
@Test
public void testSerializeFailResponse() throws JsonProcessingException {
void testSerializeFailResponse() throws JsonProcessingException {
SubscribeServiceResponse response = new SubscribeServiceResponse(500, "test", null);
String json = mapper.writeValueAsString(response);
assertTrue(json.contains("\"resultCode\":500"));
@ -59,7 +59,7 @@ public class SubscribeServiceResponseTest {
}
@Test
public void testDeserialize() throws JsonProcessingException {
void testDeserialize() throws JsonProcessingException {
String json = "{\"resultCode\":200,\"errorCode\":0,\"serviceInfo\":{\"cacheMillis\":1000,\"hosts\":[],"
+ "\"lastRefTime\":0,\"checksum\":\"\",\"allIPs\":false,\"reachProtectionThreshold\":false,"
+ "\"valid\":true},\"success\":true}";

View File

@ -21,94 +21,117 @@ import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.naming.PreservedMetadataKeys;
import com.alibaba.nacos.api.naming.pojo.Instance;
import com.alibaba.nacos.api.utils.StringUtils;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class NamingUtilsTest {
class NamingUtilsTest {
@Test
public void testGetGroupedName() {
void testGetGroupedName() {
assertEquals("group@@serviceName", NamingUtils.getGroupedName("serviceName", "group"));
}
@Test(expected = IllegalArgumentException.class)
public void testGetGroupedNameWithoutGroup() {
NamingUtils.getGroupedName("serviceName", "");
}
@Test(expected = IllegalArgumentException.class)
public void testGetGroupedNameWithoutServiceName() {
NamingUtils.getGroupedName("", "group");
@Test
void testGetGroupedNameWithoutGroup() {
assertThrows(IllegalArgumentException.class, () -> {
NamingUtils.getGroupedName("serviceName", "");
});
}
@Test
public void testGetServiceName() {
void testGetGroupedNameWithoutServiceName() {
assertThrows(IllegalArgumentException.class, () -> {
NamingUtils.getGroupedName("", "group");
});
}
@Test
void testGetServiceName() {
String validServiceName = "group@@serviceName";
assertEquals("serviceName", NamingUtils.getServiceName(validServiceName));
}
@Test
public void testGetServiceNameWithoutGroup() {
void testGetServiceNameWithoutGroup() {
String serviceName = "serviceName";
assertEquals(serviceName, NamingUtils.getServiceName(serviceName));
}
@Test
public void testGetServiceNameWithEmpty() {
void testGetServiceNameWithEmpty() {
assertEquals(StringUtils.EMPTY, NamingUtils.getServiceName(null));
}
@Test
public void testGetGroupName() {
void testGetGroupName() {
String validServiceName = "group@@serviceName";
assertEquals("group", NamingUtils.getGroupName(validServiceName));
}
@Test
public void testGetGroupNameWithoutGroup() {
void testGetGroupNameWithoutGroup() {
String serviceName = "serviceName";
assertEquals(Constants.DEFAULT_GROUP, NamingUtils.getGroupName(serviceName));
}
@Test
public void testGetGroupNameWithEmpty() {
void testGetGroupNameWithEmpty() {
assertEquals(StringUtils.EMPTY, NamingUtils.getGroupName(null));
}
@Test
public void testCheckServiceNameFormat() {
void testIsServiceNameCompatibilityMode() {
String serviceName1 = "group@@serviceName";
assertTrue(NamingUtils.isServiceNameCompatibilityMode(serviceName1));
String serviceName2 = "serviceName";
assertFalse(NamingUtils.isServiceNameCompatibilityMode(serviceName2));
String serviceName3 = null;
assertFalse(NamingUtils.isServiceNameCompatibilityMode(serviceName3));
}
@Test
void testCheckServiceNameFormat() {
String validServiceName = "group@@serviceName";
NamingUtils.checkServiceNameFormat(validServiceName);
}
@Test(expected = IllegalArgumentException.class)
public void testCheckServiceNameFormatWithoutGroupAndService() {
String validServiceName = "@@";
NamingUtils.checkServiceNameFormat(validServiceName);
}
@Test(expected = IllegalArgumentException.class)
public void testCheckServiceNameFormatWithoutGroup() {
String validServiceName = "@@service";
NamingUtils.checkServiceNameFormat(validServiceName);
}
@Test(expected = IllegalArgumentException.class)
public void testCheckServiceNameFormatWithoutService() {
String validServiceName = "group@@";
NamingUtils.checkServiceNameFormat(validServiceName);
@Test
void testCheckServiceNameFormatWithoutGroupAndService() {
assertThrows(IllegalArgumentException.class, () -> {
String validServiceName = "@@";
NamingUtils.checkServiceNameFormat(validServiceName);
});
}
@Test
public void testGetGroupedNameOptional() {
void testCheckServiceNameFormatWithoutGroup() {
assertThrows(IllegalArgumentException.class, () -> {
String validServiceName = "@@service";
NamingUtils.checkServiceNameFormat(validServiceName);
});
}
@Test
void testCheckServiceNameFormatWithoutService() {
assertThrows(IllegalArgumentException.class, () -> {
String validServiceName = "group@@";
NamingUtils.checkServiceNameFormat(validServiceName);
});
}
@Test
void testGetGroupedNameOptional() {
String onlyGroupName = NamingUtils.getGroupedNameOptional(StringUtils.EMPTY, "groupA");
assertEquals("groupA@@", onlyGroupName);
@ -120,7 +143,7 @@ public class NamingUtilsTest {
}
@Test
public void testCheckInstanceIsLegal() throws NacosException {
void testCheckInstanceIsLegal() throws NacosException {
// check invalid clusterName
Instance instance = new Instance();
instance.setClusterName("cluster1,cluster2");
@ -138,7 +161,7 @@ public class NamingUtilsTest {
instance.setClusterName("cluster1");
NamingUtils.checkInstanceIsLegal(instance);
assertTrue(true);
// check heartBeatTimeout, heartBeatInterval, ipDeleteTimeout
Map<String, String> meta = new HashMap<>();
meta.put(PreservedMetadataKeys.HEART_BEAT_TIMEOUT, "1");
@ -150,8 +173,7 @@ public class NamingUtilsTest {
assertTrue(false);
} catch (Exception e) {
assertTrue(e instanceof NacosException);
assertEquals(
"Instance 'heart beat interval' must less than 'heart beat timeout' and 'ip delete timeout'.",
assertEquals("Instance 'heart beat interval' must less than 'heart beat timeout' and 'ip delete timeout'.",
e.getMessage());
}
meta.put(PreservedMetadataKeys.HEART_BEAT_TIMEOUT, "3");
@ -162,7 +184,7 @@ public class NamingUtilsTest {
}
@Test
public void testBatchCheckInstanceIsLegal() throws NacosException {
void testBatchCheckInstanceIsLegal() throws NacosException {
// check invalid clusterName
Instance instance = new Instance();
instance.setClusterName("cluster1,cluster2");
@ -199,8 +221,7 @@ public class NamingUtilsTest {
assertTrue(false);
} catch (Exception e) {
assertTrue(e instanceof NacosException);
assertEquals(
"Instance 'heart beat interval' must less than 'heart beat timeout' and 'ip delete timeout'.",
assertEquals("Instance 'heart beat interval' must less than 'heart beat timeout' and 'ip delete timeout'.",
e.getMessage());
}
instanceList.remove(instance);
@ -215,7 +236,7 @@ public class NamingUtilsTest {
}
@Test
public void testCheckInstanceIsEphemeral() throws NacosException {
void testCheckInstanceIsEphemeral() throws NacosException {
Instance instance = new Instance();
instance.setIp("127.0.0.1");
instance.setPort(9089);
@ -228,12 +249,12 @@ public class NamingUtilsTest {
instance.setEphemeral(false);
NamingUtils.checkInstanceIsEphemeral(instance);
} catch (NacosException e) {
Assert.assertEquals(e.getErrCode(), NacosException.INVALID_PARAM);
assertEquals(NacosException.INVALID_PARAM, e.getErrCode());
}
}
@Test
public void testCheckInstanceIsNull() throws NacosException {
void testCheckInstanceIsNull() throws NacosException {
Instance instance = new Instance();
instance.setIp("127.0.0.1");
instance.setPort(9089);
@ -241,15 +262,15 @@ public class NamingUtilsTest {
try {
NamingUtils.checkInstanceIsLegal(null);
} catch (NacosException e) {
Assert.assertEquals(e.getErrCode(), NacosException.INVALID_PARAM);
assertEquals(NacosException.INVALID_PARAM, e.getErrCode());
}
}
@Test
public void testIsNumber() {
void testIsNumber() {
String str1 = "abc";
assertTrue(!NamingUtils.isNumber(str1));
assertFalse(NamingUtils.isNumber(str1));
String str2 = "123456";
assertTrue(NamingUtils.isNumber(str2));
}

View File

@ -16,18 +16,18 @@
package com.alibaba.nacos.api.remote;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class AbstractPushCallBackTest {
class AbstractPushCallBackTest {
boolean testValue;
@Test
public void testAbstractPushCallBack() {
void testAbstractPushCallBack() {
AbstractPushCallBack callBack = new AbstractPushCallBack(2000) {
@Override

View File

@ -18,20 +18,20 @@ package com.alibaba.nacos.api.remote;
import com.alibaba.nacos.api.remote.response.ErrorResponse;
import com.alibaba.nacos.api.remote.response.Response;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.concurrent.Executor;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class AbstractRequestCallBackTest {
class AbstractRequestCallBackTest {
boolean testValue;
@Test
public void testAbstractPushCallBack() {
void testAbstractPushCallBack() {
AbstractRequestCallBack callBack = new AbstractRequestCallBack() {
@Override
public Executor getExecutor() {

Some files were not shown because too many files have changed in this diff Show More