From 74ba1b93df16b28112e17c5f287b91622e52188e Mon Sep 17 00:00:00 2001 From: "blake.qiu" Date: Sun, 16 Jun 2024 02:03:26 +0800 Subject: [PATCH] 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. --- .../embedded/EmbeddedConfigInfoBetaPersistServiceImpl.java | 4 +--- .../embedded/EmbeddedConfigInfoPersistServiceImpl.java | 2 -- .../embedded/EmbeddedConfigInfoTagPersistServiceImpl.java | 5 +---- .../extrnal/ExternalConfigInfoBetaPersistServiceImpl.java | 6 +----- .../extrnal/ExternalConfigInfoPersistServiceImpl.java | 3 --- .../extrnal/ExternalConfigInfoTagPersistServiceImpl.java | 3 --- .../embedded/EmbeddedConfigInfoPersistServiceImplTest.java | 2 +- .../extrnal/ExternalConfigInfoPersistServiceImplTest.java | 5 ++--- .../plugin/datasource/mapper/ConfigInfoBetaMapper.java | 3 +-- .../nacos/plugin/datasource/mapper/ConfigInfoMapper.java | 3 +-- .../plugin/datasource/mapper/ConfigInfoTagMapper.java | 5 ++--- .../impl/derby/ConfigInfoBetaMapperByDerbyTest.java | 7 ++----- .../datasource/impl/derby/ConfigInfoMapperByDerbyTest.java | 6 ++---- .../impl/derby/ConfigInfoTagMapperByDerbyTest.java | 7 ++----- .../impl/mysql/ConfigInfoBetaMapperByMySqlTest.java | 7 ++----- .../impl/mysql/ConfigInfoTagMapperByMySqlTest.java | 7 ++----- 16 files changed, 20 insertions(+), 55 deletions(-) diff --git a/config/src/main/java/com/alibaba/nacos/config/server/service/repository/embedded/EmbeddedConfigInfoBetaPersistServiceImpl.java b/config/src/main/java/com/alibaba/nacos/config/server/service/repository/embedded/EmbeddedConfigInfoBetaPersistServiceImpl.java index 646c42d51ed..28f3d7b33a1 100644 --- a/config/src/main/java/com/alibaba/nacos/config/server/service/repository/embedded/EmbeddedConfigInfoBetaPersistServiceImpl.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/service/repository/embedded/EmbeddedConfigInfoBetaPersistServiceImpl.java @@ -250,14 +250,12 @@ public ConfigOperateResult updateConfigInfo4BetaCas(ConfigInfo configInfo, Strin ConfigInfoBetaMapper configInfoBetaMapper = mapperManager.findMapper(dataSourceService.getDataSourceType(), TableConstant.CONFIG_INFO_BETA); - Timestamp time = new Timestamp(System.currentTimeMillis()); MapperContext context = new MapperContext(); context.putUpdateParameter(FieldConstant.CONTENT, configInfo.getContent()); context.putUpdateParameter(FieldConstant.MD5, md5); context.putUpdateParameter(FieldConstant.BETA_IPS, betaIps); context.putUpdateParameter(FieldConstant.SRC_IP, srcIp); context.putUpdateParameter(FieldConstant.SRC_USER, srcUser); - context.putUpdateParameter(FieldConstant.GMT_MODIFIED, time); context.putUpdateParameter(FieldConstant.APP_NAME, appNameTmp); context.putWhereParameter(FieldConstant.DATA_ID, configInfo.getDataId()); @@ -269,7 +267,7 @@ public ConfigOperateResult updateConfigInfo4BetaCas(ConfigInfo configInfo, Strin final String sql = mapperResult.getSql(); List paramList = mapperResult.getParamList(); final Object[] args = paramList.toArray(); - + Timestamp time = new Timestamp(System.currentTimeMillis()); EmbeddedStorageContextUtils.onModifyConfigBetaInfo(configInfo, betaIps, srcIp, time); EmbeddedStorageContextHolder.addSqlContext(sql, args); diff --git a/config/src/main/java/com/alibaba/nacos/config/server/service/repository/embedded/EmbeddedConfigInfoPersistServiceImpl.java b/config/src/main/java/com/alibaba/nacos/config/server/service/repository/embedded/EmbeddedConfigInfoPersistServiceImpl.java index a008946a373..b86592893d0 100644 --- a/config/src/main/java/com/alibaba/nacos/config/server/service/repository/embedded/EmbeddedConfigInfoPersistServiceImpl.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/service/repository/embedded/EmbeddedConfigInfoPersistServiceImpl.java @@ -614,13 +614,11 @@ private ConfigOperateResult updateConfigInfoAtomicCas(final ConfigInfo configInf configInfo.getEncryptedDataKey() == null ? StringUtils.EMPTY : configInfo.getEncryptedDataKey(); ConfigInfoMapper configInfoMapper = mapperManager.findMapper(dataSourceService.getDataSourceType(), TableConstant.CONFIG_INFO); - Timestamp time = new Timestamp(System.currentTimeMillis()); MapperContext context = new MapperContext(); context.putUpdateParameter(FieldConstant.CONTENT, configInfo.getContent()); context.putUpdateParameter(FieldConstant.MD5, md5Tmp); context.putUpdateParameter(FieldConstant.SRC_IP, srcIp); context.putUpdateParameter(FieldConstant.SRC_USER, srcUser); - context.putUpdateParameter(FieldConstant.GMT_MODIFIED, time); context.putUpdateParameter(FieldConstant.APP_NAME, appNameTmp); context.putUpdateParameter(FieldConstant.C_DESC, desc); context.putUpdateParameter(FieldConstant.C_USE, use); diff --git a/config/src/main/java/com/alibaba/nacos/config/server/service/repository/embedded/EmbeddedConfigInfoTagPersistServiceImpl.java b/config/src/main/java/com/alibaba/nacos/config/server/service/repository/embedded/EmbeddedConfigInfoTagPersistServiceImpl.java index 0e57f09aa0e..4ac42636ea4 100644 --- a/config/src/main/java/com/alibaba/nacos/config/server/service/repository/embedded/EmbeddedConfigInfoTagPersistServiceImpl.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/service/repository/embedded/EmbeddedConfigInfoTagPersistServiceImpl.java @@ -234,14 +234,11 @@ public ConfigOperateResult updateConfigInfo4TagCas(ConfigInfo configInfo, String String md5 = MD5Utils.md5Hex(configInfo.getContent(), Constants.ENCODE); ConfigInfoTagMapper configInfoTagMapper = mapperManager.findMapper(dataSourceService.getDataSourceType(), TableConstant.CONFIG_INFO_TAG); - Timestamp time = new Timestamp(System.currentTimeMillis()); - MapperContext context = new MapperContext(); context.putUpdateParameter(FieldConstant.CONTENT, configInfo.getContent()); context.putUpdateParameter(FieldConstant.MD5, md5); context.putUpdateParameter(FieldConstant.SRC_IP, srcIp); context.putUpdateParameter(FieldConstant.SRC_USER, srcUser); - context.putUpdateParameter(FieldConstant.GMT_MODIFIED, time); context.putUpdateParameter(FieldConstant.APP_NAME, appNameTmp); context.putWhereParameter(FieldConstant.DATA_ID, configInfo.getDataId()); @@ -251,7 +248,7 @@ public ConfigOperateResult updateConfigInfo4TagCas(ConfigInfo configInfo, String context.putWhereParameter(FieldConstant.MD5, configInfo.getMd5()); final MapperResult mapperResult = configInfoTagMapper.updateConfigInfo4TagCas(context); - + Timestamp time = new Timestamp(System.currentTimeMillis()); EmbeddedStorageContextUtils.onModifyConfigTagInfo(configInfo, tagTmp, srcIp, time); EmbeddedStorageContextHolder.addSqlContext(mapperResult.getSql(), mapperResult.getParamList().toArray()); diff --git a/config/src/main/java/com/alibaba/nacos/config/server/service/repository/extrnal/ExternalConfigInfoBetaPersistServiceImpl.java b/config/src/main/java/com/alibaba/nacos/config/server/service/repository/extrnal/ExternalConfigInfoBetaPersistServiceImpl.java index 3fb3b20cce9..602a2c09b02 100644 --- a/config/src/main/java/com/alibaba/nacos/config/server/service/repository/extrnal/ExternalConfigInfoBetaPersistServiceImpl.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/service/repository/extrnal/ExternalConfigInfoBetaPersistServiceImpl.java @@ -48,7 +48,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.support.TransactionTemplate; -import java.sql.Timestamp; import java.util.Arrays; import java.util.List; @@ -127,7 +126,6 @@ public ConfigOperateResult insertOrUpdateBeta(final ConfigInfo configInfo, final configInfo.getGroup(), configInfo.getTenant()); if (configInfo4BetaState == null) { return addConfigInfo4Beta(configInfo, betaIps, srcIp, srcUser); - } else { return updateConfigInfo4Beta(configInfo, betaIps, srcIp, srcUser); } @@ -229,15 +227,13 @@ public ConfigOperateResult updateConfigInfo4BetaCas(ConfigInfo configInfo, Strin try { ConfigInfoBetaMapper configInfoBetaMapper = mapperManager.findMapper(dataSourceService.getDataSourceType(), TableConstant.CONFIG_INFO_BETA); - Timestamp time = new Timestamp(System.currentTimeMillis()); - + MapperContext context = new MapperContext(); context.putUpdateParameter(FieldConstant.CONTENT, configInfo.getContent()); context.putUpdateParameter(FieldConstant.MD5, md5); context.putUpdateParameter(FieldConstant.BETA_IPS, betaIps); context.putUpdateParameter(FieldConstant.SRC_IP, srcIp); context.putUpdateParameter(FieldConstant.SRC_USER, srcUser); - context.putUpdateParameter(FieldConstant.GMT_MODIFIED, time); context.putUpdateParameter(FieldConstant.APP_NAME, appNameTmp); context.putWhereParameter(FieldConstant.DATA_ID, configInfo.getDataId()); diff --git a/config/src/main/java/com/alibaba/nacos/config/server/service/repository/extrnal/ExternalConfigInfoPersistServiceImpl.java b/config/src/main/java/com/alibaba/nacos/config/server/service/repository/extrnal/ExternalConfigInfoPersistServiceImpl.java index d1fcbd4d950..6638c9a993b 100644 --- a/config/src/main/java/com/alibaba/nacos/config/server/service/repository/extrnal/ExternalConfigInfoPersistServiceImpl.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/service/repository/extrnal/ExternalConfigInfoPersistServiceImpl.java @@ -629,14 +629,11 @@ private int updateConfigInfoAtomicCas(final ConfigInfo configInfo, final String try { ConfigInfoMapper configInfoMapper = mapperManager.findMapper(dataSourceService.getDataSourceType(), TableConstant.CONFIG_INFO); - Timestamp now = new Timestamp(System.currentTimeMillis()); - MapperContext context = new MapperContext(); context.putUpdateParameter(FieldConstant.CONTENT, configInfo.getContent()); context.putUpdateParameter(FieldConstant.MD5, md5Tmp); context.putUpdateParameter(FieldConstant.SRC_IP, srcIp); context.putUpdateParameter(FieldConstant.SRC_USER, srcUser); - context.putUpdateParameter(FieldConstant.GMT_MODIFIED, now); context.putUpdateParameter(FieldConstant.APP_NAME, appNameTmp); context.putUpdateParameter(FieldConstant.C_DESC, desc); context.putUpdateParameter(FieldConstant.C_USE, use); diff --git a/config/src/main/java/com/alibaba/nacos/config/server/service/repository/extrnal/ExternalConfigInfoTagPersistServiceImpl.java b/config/src/main/java/com/alibaba/nacos/config/server/service/repository/extrnal/ExternalConfigInfoTagPersistServiceImpl.java index 9194f1f8176..5016f5ffd1d 100644 --- a/config/src/main/java/com/alibaba/nacos/config/server/service/repository/extrnal/ExternalConfigInfoTagPersistServiceImpl.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/service/repository/extrnal/ExternalConfigInfoTagPersistServiceImpl.java @@ -219,14 +219,11 @@ public ConfigOperateResult updateConfigInfo4TagCas(ConfigInfo configInfo, String String md5 = MD5Utils.md5Hex(configInfo.getContent(), Constants.ENCODE); ConfigInfoTagMapper configInfoTagMapper = mapperManager.findMapper(dataSourceService.getDataSourceType(), TableConstant.CONFIG_INFO_TAG); - Timestamp time = new Timestamp(System.currentTimeMillis()); - MapperContext context = new MapperContext(); context.putUpdateParameter(FieldConstant.CONTENT, configInfo.getContent()); context.putUpdateParameter(FieldConstant.MD5, md5); context.putUpdateParameter(FieldConstant.SRC_IP, srcIp); context.putUpdateParameter(FieldConstant.SRC_USER, srcUser); - context.putUpdateParameter(FieldConstant.GMT_MODIFIED, time); context.putUpdateParameter(FieldConstant.APP_NAME, appNameTmp); context.putWhereParameter(FieldConstant.DATA_ID, configInfo.getDataId()); diff --git a/config/src/test/java/com/alibaba/nacos/config/server/service/repository/embedded/EmbeddedConfigInfoPersistServiceImplTest.java b/config/src/test/java/com/alibaba/nacos/config/server/service/repository/embedded/EmbeddedConfigInfoPersistServiceImplTest.java index e60d4bb124f..0d42ca15c31 100644 --- a/config/src/test/java/com/alibaba/nacos/config/server/service/repository/embedded/EmbeddedConfigInfoPersistServiceImplTest.java +++ b/config/src/test/java/com/alibaba/nacos/config/server/service/repository/embedded/EmbeddedConfigInfoPersistServiceImplTest.java @@ -347,7 +347,7 @@ void testInsertOrUpdateCasOfUpdateConfigSuccess() { //expect update config info invoked. embeddedStorageContextHolderMockedStatic.verify( () -> EmbeddedStorageContextHolder.addSqlContext(eq(Boolean.TRUE), anyString(), eq(content), - eq(MD5Utils.md5Hex(content, Constants.PERSIST_ENCODE)), eq(srcIp), eq(srcUser), any(Timestamp.class), eq(appName), + eq(MD5Utils.md5Hex(content, Constants.PERSIST_ENCODE)), eq(srcIp), eq(srcUser), eq(appName), eq(desc), eq(use), eq(effect), eq(type), eq(schema), eq(encryptedDataKey), eq(dataId), eq(group), eq(tenant), eq(casMd5)), times(1)); diff --git a/config/src/test/java/com/alibaba/nacos/config/server/service/repository/extrnal/ExternalConfigInfoPersistServiceImplTest.java b/config/src/test/java/com/alibaba/nacos/config/server/service/repository/extrnal/ExternalConfigInfoPersistServiceImplTest.java index 84634817285..99f57d438e8 100644 --- a/config/src/test/java/com/alibaba/nacos/config/server/service/repository/extrnal/ExternalConfigInfoPersistServiceImplTest.java +++ b/config/src/test/java/com/alibaba/nacos/config/server/service/repository/extrnal/ExternalConfigInfoPersistServiceImplTest.java @@ -422,7 +422,6 @@ void testInsertOrUpdateOfUpdateConfigSuccess() { @Test void testInsertOrUpdateCasOfUpdateConfigSuccess() { - Map configAdvanceInfo = new HashMap<>(); configAdvanceInfo.put("config_tags", "tag1,tag2"); configAdvanceInfo.put("desc", "desc11"); @@ -458,7 +457,7 @@ void testInsertOrUpdateCasOfUpdateConfigSuccess() { String srcUser = "srcUser"; //mock update config info cas Mockito.when(jdbcTemplate.update(anyString(), eq(content), eq(MD5Utils.md5Hex(content, Constants.PERSIST_ENCODE)), eq(srcIp), - eq(srcUser), any(Timestamp.class), eq(configInfoWrapperOld.getAppName()), eq(configAdvanceInfo.get("desc")), + eq(srcUser), eq(configInfoWrapperOld.getAppName()), eq(configAdvanceInfo.get("desc")), eq(configAdvanceInfo.get("use")), eq(configAdvanceInfo.get("effect")), eq(configAdvanceInfo.get("type")), eq(configAdvanceInfo.get("schema")), eq(encryptedDataKey), eq(dataId), eq(group), eq(tenant), eq(casMd5))).thenReturn(1); @@ -483,7 +482,7 @@ void testInsertOrUpdateCasOfUpdateConfigSuccess() { //expect update config cas Mockito.verify(jdbcTemplate, times(1)) .update(anyString(), eq(content), eq(MD5Utils.md5Hex(content, Constants.PERSIST_ENCODE)), eq(srcIp), eq(srcUser), - any(Timestamp.class), eq(configInfoWrapperOld.getAppName()), eq(configAdvanceInfo.get("desc")), + eq(configInfoWrapperOld.getAppName()), eq(configAdvanceInfo.get("desc")), eq(configAdvanceInfo.get("use")), eq(configAdvanceInfo.get("effect")), eq(configAdvanceInfo.get("type")), eq(configAdvanceInfo.get("schema")), eq(encryptedDataKey), eq(dataId), eq(group), eq(tenant), eq(casMd5)); diff --git a/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/mapper/ConfigInfoBetaMapper.java b/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/mapper/ConfigInfoBetaMapper.java index 511ca2bf57b..e6cf972e2bc 100644 --- a/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/mapper/ConfigInfoBetaMapper.java +++ b/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/mapper/ConfigInfoBetaMapper.java @@ -42,7 +42,7 @@ public interface ConfigInfoBetaMapper extends Mapper { * @return The result of updating beta configuration information. */ default MapperResult updateConfigInfo4BetaCas(MapperContext context) { - final String sql = "UPDATE config_info_beta SET content = ?,md5 = ?,beta_ips = ?,src_ip = ?,src_user = ?,gmt_modified = ?,app_name = ? " + final String sql = "UPDATE config_info_beta SET content = ?,md5 = ?,beta_ips = ?,src_ip = ?,src_user = ?,gmt_modified = CURRENT_TIMESTAMP,app_name = ? " + "WHERE data_id = ? AND group_id = ? AND tenant_id = ? AND (md5 = ? OR md5 is null OR md5 = '')"; List paramList = new ArrayList<>(); @@ -52,7 +52,6 @@ default MapperResult updateConfigInfo4BetaCas(MapperContext context) { paramList.add(context.getUpdateParameter(FieldConstant.BETA_IPS)); paramList.add(context.getUpdateParameter(FieldConstant.SRC_IP)); paramList.add(context.getUpdateParameter(FieldConstant.SRC_USER)); - paramList.add(context.getUpdateParameter(FieldConstant.GMT_MODIFIED)); paramList.add(context.getUpdateParameter(FieldConstant.APP_NAME)); paramList.add(context.getWhereParameter(FieldConstant.DATA_ID)); diff --git a/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/mapper/ConfigInfoMapper.java b/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/mapper/ConfigInfoMapper.java index ba7f7a521d2..914b124a5d7 100644 --- a/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/mapper/ConfigInfoMapper.java +++ b/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/mapper/ConfigInfoMapper.java @@ -492,7 +492,6 @@ default MapperResult updateConfigInfoAtomicCas(MapperContext context) { paramList.add(context.getUpdateParameter(FieldConstant.MD5)); paramList.add(context.getUpdateParameter(FieldConstant.SRC_IP)); paramList.add(context.getUpdateParameter(FieldConstant.SRC_USER)); - paramList.add(context.getUpdateParameter(FieldConstant.GMT_MODIFIED)); paramList.add(context.getUpdateParameter(FieldConstant.APP_NAME)); paramList.add(context.getUpdateParameter(FieldConstant.C_DESC)); paramList.add(context.getUpdateParameter(FieldConstant.C_USE)); @@ -504,7 +503,7 @@ default MapperResult updateConfigInfoAtomicCas(MapperContext context) { paramList.add(context.getWhereParameter(FieldConstant.GROUP_ID)); paramList.add(context.getWhereParameter(FieldConstant.TENANT_ID)); paramList.add(context.getWhereParameter(FieldConstant.MD5)); - String sql = "UPDATE config_info SET " + "content=?, md5 = ?, src_ip=?,src_user=?,gmt_modified=?," + String sql = "UPDATE config_info SET " + "content=?, md5 = ?, src_ip=?,src_user=?,gmt_modified=CURRENT_TIMESTAMP," + " app_name=?,c_desc=?,c_use=?,effect=?,type=?,c_schema=?,encrypted_data_key=? " + "WHERE data_id=? AND group_id=? AND tenant_id=? AND (md5=? OR md5 IS NULL OR md5='')"; return new MapperResult(sql, paramList); diff --git a/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/mapper/ConfigInfoTagMapper.java b/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/mapper/ConfigInfoTagMapper.java index 628170040d4..610f4100583 100644 --- a/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/mapper/ConfigInfoTagMapper.java +++ b/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/mapper/ConfigInfoTagMapper.java @@ -44,7 +44,6 @@ default MapperResult updateConfigInfo4TagCas(MapperContext context) { Object md5 = context.getUpdateParameter(FieldConstant.MD5); Object srcIp = context.getUpdateParameter(FieldConstant.SRC_IP); Object srcUser = context.getUpdateParameter(FieldConstant.SRC_USER); - Object gmtModified = context.getUpdateParameter(FieldConstant.GMT_MODIFIED); Object appName = context.getUpdateParameter(FieldConstant.APP_NAME); Object dataId = context.getWhereParameter(FieldConstant.DATA_ID); @@ -53,10 +52,10 @@ default MapperResult updateConfigInfo4TagCas(MapperContext context) { Object tagId = context.getWhereParameter(FieldConstant.TAG_ID); Object oldMd5 = context.getWhereParameter(FieldConstant.MD5); String sql = - "UPDATE config_info_tag SET content = ?, md5 = ?, src_ip = ?,src_user = ?,gmt_modified = ?,app_name = ? " + "UPDATE config_info_tag SET content = ?, md5 = ?, src_ip = ?,src_user = ?,gmt_modified = CURRENT_TIMESTAMP,app_name = ? " + "WHERE data_id = ? AND group_id = ? AND tenant_id = ? AND tag_id = ? AND (md5 = ? OR md5 IS NULL OR md5 = '')"; return new MapperResult(sql, - CollectionUtils.list(content, md5, srcIp, srcUser, gmtModified, appName, dataId, groupId, tenantId, + CollectionUtils.list(content, md5, srcIp, srcUser, appName, dataId, groupId, tenantId, tagId, oldMd5)); } diff --git a/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/derby/ConfigInfoBetaMapperByDerbyTest.java b/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/derby/ConfigInfoBetaMapperByDerbyTest.java index 2ed3be3c601..189c7d69174 100644 --- a/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/derby/ConfigInfoBetaMapperByDerbyTest.java +++ b/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/derby/ConfigInfoBetaMapperByDerbyTest.java @@ -72,7 +72,6 @@ public void testUpdateConfigInfo4BetaCas() { String newMD5 = "newMD5"; String srcIp = "1.1.1.1"; Object srcUser = "nacos"; - Object time = new Timestamp(System.currentTimeMillis()); Object appNameTmp = "newAppName"; Object desc = "description"; Object use = "use"; @@ -86,7 +85,6 @@ public void testUpdateConfigInfo4BetaCas() { context.putUpdateParameter(FieldConstant.BETA_IPS, betaIps); context.putUpdateParameter(FieldConstant.SRC_IP, srcIp); context.putUpdateParameter(FieldConstant.SRC_USER, srcUser); - context.putUpdateParameter(FieldConstant.GMT_MODIFIED, time); context.putUpdateParameter(FieldConstant.APP_NAME, appNameTmp); context.putUpdateParameter(FieldConstant.C_DESC, desc); context.putUpdateParameter(FieldConstant.C_USE, use); @@ -107,11 +105,10 @@ public void testUpdateConfigInfo4BetaCas() { String sql = mapperResult.getSql(); Assert.assertEquals(sql, "UPDATE config_info_beta SET content = ?,md5 = ?,beta_ips = ?,src_ip = ?,src_user = ?," - + "gmt_modified = ?,app_name = ? WHERE data_id = ? AND group_id = ? AND tenant_id = ? AND " + + "gmt_modified = CURRENT_TIMESTAMP,app_name = ? WHERE data_id = ? AND group_id = ? AND tenant_id = ? AND " + "(md5 = ? OR md5 is null OR md5 = '')"); Assert.assertArrayEquals(mapperResult.getParamList().toArray(), - new Object[] {newContent, newMD5, betaIps, srcIp, srcUser, time, appNameTmp, dataId, group, tenantId, - md5}); + new Object[]{newContent, newMD5, betaIps, srcIp, srcUser, appNameTmp, dataId, group, tenantId, md5}); } @Test diff --git a/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/derby/ConfigInfoMapperByDerbyTest.java b/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/derby/ConfigInfoMapperByDerbyTest.java index 29c382781f6..41b9485d718 100644 --- a/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/derby/ConfigInfoMapperByDerbyTest.java +++ b/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/derby/ConfigInfoMapperByDerbyTest.java @@ -328,7 +328,6 @@ public void testUpdateConfigInfoAtomicCas() { String newMD5 = "newMD5"; String srcIp = "1.1.1.1"; Object srcUser = "nacos"; - Object time = new Timestamp(System.currentTimeMillis()); Object appNameTmp = "newAppName"; Object desc = "description"; Object use = "use"; @@ -340,7 +339,6 @@ public void testUpdateConfigInfoAtomicCas() { context.putUpdateParameter(FieldConstant.MD5, newMD5); context.putUpdateParameter(FieldConstant.SRC_IP, srcIp); context.putUpdateParameter(FieldConstant.SRC_USER, srcUser); - context.putUpdateParameter(FieldConstant.GMT_MODIFIED, time); context.putUpdateParameter(FieldConstant.APP_NAME, appNameTmp); context.putUpdateParameter(FieldConstant.C_DESC, desc); context.putUpdateParameter(FieldConstant.C_USE, use); @@ -359,11 +357,11 @@ public void testUpdateConfigInfoAtomicCas() { MapperResult mapperResult = configInfoMapperByDerby.updateConfigInfoAtomicCas(context); Assert.assertEquals(mapperResult.getSql(), "UPDATE config_info SET " - + "content=?, md5 = ?, src_ip=?,src_user=?,gmt_modified=?, app_name=?,c_desc=?,c_use=?," + + "content=?, md5 = ?, src_ip=?,src_user=?,gmt_modified=CURRENT_TIMESTAMP, app_name=?,c_desc=?,c_use=?," + "effect=?,type=?,c_schema=?,encrypted_data_key=? " + "WHERE data_id=? AND group_id=? AND tenant_id=? AND (md5=? OR md5 IS NULL OR md5='')"); Assert.assertArrayEquals(mapperResult.getParamList().toArray(), - new Object[] {newContent, newMD5, srcIp, srcUser, time, appNameTmp, desc, use, effect, type, schema, + new Object[] {newContent, newMD5, srcIp, srcUser, appNameTmp, desc, use, effect, type, schema, encrypedDataKey, dataId, group, tenantId, md5}); } } diff --git a/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/derby/ConfigInfoTagMapperByDerbyTest.java b/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/derby/ConfigInfoTagMapperByDerbyTest.java index 0c552144a5a..21e227d76b9 100644 --- a/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/derby/ConfigInfoTagMapperByDerbyTest.java +++ b/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/derby/ConfigInfoTagMapperByDerbyTest.java @@ -73,7 +73,6 @@ public void testUpdateConfigInfo4TagCas() { String newMD5 = "newMD5"; String srcIp = "1.1.1.1"; Object srcUser = "nacos"; - Object time = new Timestamp(System.currentTimeMillis()); Object appNameTmp = "newAppName"; Object desc = "description"; Object use = "use"; @@ -85,7 +84,6 @@ public void testUpdateConfigInfo4TagCas() { context.putUpdateParameter(FieldConstant.MD5, newMD5); context.putUpdateParameter(FieldConstant.SRC_IP, srcIp); context.putUpdateParameter(FieldConstant.SRC_USER, srcUser); - context.putUpdateParameter(FieldConstant.GMT_MODIFIED, time); context.putUpdateParameter(FieldConstant.APP_NAME, appNameTmp); context.putUpdateParameter(FieldConstant.C_DESC, desc); context.putUpdateParameter(FieldConstant.C_USE, use); @@ -107,12 +105,11 @@ public void testUpdateConfigInfo4TagCas() { MapperResult mapperResult = configInfoTagMapperByDerby.updateConfigInfo4TagCas(context); Assert.assertEquals(mapperResult.getSql(), - "UPDATE config_info_tag SET content = ?, md5 = ?, src_ip = ?,src_user = ?,gmt_modified = ?," + "UPDATE config_info_tag SET content = ?, md5 = ?, src_ip = ?,src_user = ?,gmt_modified = CURRENT_TIMESTAMP," + "app_name = ? WHERE data_id = ? AND group_id = ? AND tenant_id = ? AND tag_id = ? AND " + "(md5 = ? OR md5 IS NULL OR md5 = '')"); Assert.assertArrayEquals(mapperResult.getParamList().toArray(), - new Object[] {newContent, newMD5, srcIp, srcUser, time, appNameTmp, dataId, group, tenantId, tagId, - md5}); + new Object[]{newContent, newMD5, srcIp, srcUser, appNameTmp, dataId, group, tenantId, tagId, md5}); } @Test diff --git a/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/mysql/ConfigInfoBetaMapperByMySqlTest.java b/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/mysql/ConfigInfoBetaMapperByMySqlTest.java index a06c21437c6..c92ba5f225f 100644 --- a/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/mysql/ConfigInfoBetaMapperByMySqlTest.java +++ b/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/mysql/ConfigInfoBetaMapperByMySqlTest.java @@ -72,7 +72,6 @@ public void testUpdateConfigInfo4BetaCas() { String newMD5 = "newMD5"; String srcIp = "1.1.1.1"; Object srcUser = "nacos"; - Object time = new Timestamp(System.currentTimeMillis()); Object appNameTmp = "newAppName"; Object desc = "description"; Object use = "use"; @@ -86,7 +85,6 @@ public void testUpdateConfigInfo4BetaCas() { context.putUpdateParameter(FieldConstant.BETA_IPS, betaIps); context.putUpdateParameter(FieldConstant.SRC_IP, srcIp); context.putUpdateParameter(FieldConstant.SRC_USER, srcUser); - context.putUpdateParameter(FieldConstant.GMT_MODIFIED, time); context.putUpdateParameter(FieldConstant.APP_NAME, appNameTmp); context.putUpdateParameter(FieldConstant.C_DESC, desc); context.putUpdateParameter(FieldConstant.C_USE, use); @@ -106,12 +104,11 @@ public void testUpdateConfigInfo4BetaCas() { MapperResult mapperResult = configInfoBetaMapperByMySql.updateConfigInfo4BetaCas(context); String sql = mapperResult.getSql(); - List paramList = mapperResult.getParamList(); Assert.assertEquals(sql, - "UPDATE config_info_beta SET content = ?,md5 = ?,beta_ips = ?,src_ip = ?,src_user = ?,gmt_modified = ?,app_name = ? " + "UPDATE config_info_beta SET content = ?,md5 = ?,beta_ips = ?,src_ip = ?,src_user = ?,gmt_modified = CURRENT_TIMESTAMP,app_name = ? " + "WHERE data_id = ? AND group_id = ? AND tenant_id = ? AND (md5 = ? OR md5 is null OR md5 = '')"); Assert.assertArrayEquals(mapperResult.getParamList().toArray(), - new Object[] {newContent, newMD5, betaIps, srcIp, srcUser, time, appNameTmp, dataId, group, tenantId, + new Object[]{newContent, newMD5, betaIps, srcIp, srcUser, appNameTmp, dataId, group, tenantId, md5}); } diff --git a/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/mysql/ConfigInfoTagMapperByMySqlTest.java b/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/mysql/ConfigInfoTagMapperByMySqlTest.java index 7632785b5d4..6f819ca34a3 100644 --- a/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/mysql/ConfigInfoTagMapperByMySqlTest.java +++ b/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/mysql/ConfigInfoTagMapperByMySqlTest.java @@ -73,7 +73,6 @@ public void testUpdateConfigInfo4TagCas() { String newMD5 = "newMD5"; String srcIp = "1.1.1.1"; Object srcUser = "nacos"; - Object time = new Timestamp(System.currentTimeMillis()); Object appNameTmp = "newAppName"; Object desc = "description"; Object use = "use"; @@ -85,7 +84,6 @@ public void testUpdateConfigInfo4TagCas() { context.putUpdateParameter(FieldConstant.MD5, newMD5); context.putUpdateParameter(FieldConstant.SRC_IP, srcIp); context.putUpdateParameter(FieldConstant.SRC_USER, srcUser); - context.putUpdateParameter(FieldConstant.GMT_MODIFIED, time); context.putUpdateParameter(FieldConstant.APP_NAME, appNameTmp); context.putUpdateParameter(FieldConstant.C_DESC, desc); context.putUpdateParameter(FieldConstant.C_USE, use); @@ -107,12 +105,11 @@ public void testUpdateConfigInfo4TagCas() { MapperResult mapperResult = configInfoTagMapperByMySql.updateConfigInfo4TagCas(context); Assert.assertEquals(mapperResult.getSql(), - "UPDATE config_info_tag SET content = ?, md5 = ?, src_ip = ?,src_user = ?,gmt_modified = ?," + "UPDATE config_info_tag SET content = ?, md5 = ?, src_ip = ?,src_user = ?,gmt_modified = CURRENT_TIMESTAMP," + "app_name = ? WHERE data_id = ? AND group_id = ? AND tenant_id = ? AND tag_id = ? AND " + "(md5 = ? OR md5 IS NULL OR md5 = '')"); Assert.assertArrayEquals(mapperResult.getParamList().toArray(), - new Object[] {newContent, newMD5, srcIp, srcUser, time, appNameTmp, dataId, group, tenantId, tagId, - md5}); + new Object[]{newContent, newMD5, srcIp, srcUser, appNameTmp, dataId, group, tenantId, tagId, md5}); } @Test