From e5fb42cfa19e2094625203097f25eb35a450eacd Mon Sep 17 00:00:00 2001 From: tiny-x <185120555@qq.com> Date: Mon, 10 May 2021 11:03:51 +0800 Subject: [PATCH] fix: compatible with mysql 5.7+ Signed-off-by: tiny-x <185120555@qq.com> --- .../jackson/ArgumentsToMapDeserializer.java | 2 +- .../box/dao/mapper/ExperimentTaskMapper.java | 2 +- .../box/dao/repository/SceneRepository.java | 2 +- .../resources/generator/ClusterMapper.xml | 87 ------------------- .../main/resources/scene_param_component.json | 73 ++++++++++++++-- .../box/service/impl/DeviceServiceImpl.java | 2 +- 6 files changed, 68 insertions(+), 100 deletions(-) delete mode 100644 chaosblade-box-dao/src/main/resources/generator/ClusterMapper.xml diff --git a/chaosblade-box-common/src/main/java/com/alibaba/chaosblade/box/common/jackson/ArgumentsToMapDeserializer.java b/chaosblade-box-common/src/main/java/com/alibaba/chaosblade/box/common/jackson/ArgumentsToMapDeserializer.java index 5f2a06cb..4b3a30f9 100644 --- a/chaosblade-box-common/src/main/java/com/alibaba/chaosblade/box/common/jackson/ArgumentsToMapDeserializer.java +++ b/chaosblade-box-common/src/main/java/com/alibaba/chaosblade/box/common/jackson/ArgumentsToMapDeserializer.java @@ -44,7 +44,7 @@ public Map deserialize(JsonParser p, DeserializationContext ctxt if (jsonNode.get("value") != null && !jsonNode.get("value").isNull()) { String value = jsonNode.get("value").asText(); if (StrUtil.isBlank(value)) { - value = jsonNode.get("value").toString(); + value = jsonNode.get("value").toString().replace("\"",""); } if (StrUtil.isNotBlank(value)) { map.put(jsonNode.get("name").asText(), value); diff --git a/chaosblade-box-dao/src/main/java/com/alibaba/chaosblade/box/dao/mapper/ExperimentTaskMapper.java b/chaosblade-box-dao/src/main/java/com/alibaba/chaosblade/box/dao/mapper/ExperimentTaskMapper.java index 03fcd54d..46ec7e3e 100644 --- a/chaosblade-box-dao/src/main/java/com/alibaba/chaosblade/box/dao/mapper/ExperimentTaskMapper.java +++ b/chaosblade-box-dao/src/main/java/com/alibaba/chaosblade/box/dao/mapper/ExperimentTaskMapper.java @@ -33,7 +33,7 @@ public interface ExperimentTaskMapper extends BaseMapper { /** * */ - @Select("select count(*) as taskCount , date_format(gmt_start,'%Y-%m-%d') as `date` from t_chaos_experiment_task group by date(gmt_start)") + @Select("select count(*) as taskCount , max(date_format(gmt_start,'%Y-%m-%d')) as `date` from t_chaos_experiment_task group by date(gmt_start)") List> queryTaskStatistics(); } diff --git a/chaosblade-box-dao/src/main/java/com/alibaba/chaosblade/box/dao/repository/SceneRepository.java b/chaosblade-box-dao/src/main/java/com/alibaba/chaosblade/box/dao/repository/SceneRepository.java index e35224ef..066bdbe7 100644 --- a/chaosblade-box-dao/src/main/java/com/alibaba/chaosblade/box/dao/repository/SceneRepository.java +++ b/chaosblade-box-dao/src/main/java/com/alibaba/chaosblade/box/dao/repository/SceneRepository.java @@ -74,7 +74,7 @@ public Optional selectByCodeAndVersion(String code, String version) { public List selectByCode(String code) { QueryWrapper queryWrapper = QueryWrapperBuilder.build(); - queryWrapper.lambda().like(SceneDO::getSceneCode, code); + queryWrapper.lambda().likeRight(SceneDO::getSceneCode, code); return sceneMapper.selectList(queryWrapper); } diff --git a/chaosblade-box-dao/src/main/resources/generator/ClusterMapper.xml b/chaosblade-box-dao/src/main/resources/generator/ClusterMapper.xml deleted file mode 100644 index eda494d7..00000000 --- a/chaosblade-box-dao/src/main/resources/generator/ClusterMapper.xml +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - - - - - - id, gmt_create, gmt_modified, cluster_name, config - - - - delete from t_chaos_cluster - where id = #{id,jdbcType=BIGINT} - - - insert into t_chaos_cluster (gmt_create, gmt_modified, cluster_name, - config) - values (#{gmtCreate,jdbcType=TIMESTAMP}, #{gmtModified,jdbcType=TIMESTAMP}, #{clusterName,jdbcType=VARCHAR}, - #{config,jdbcType=VARCHAR}) - - - insert into t_chaos_cluster - - - gmt_create, - - - gmt_modified, - - - cluster_name, - - - config, - - - - - #{gmtCreate,jdbcType=TIMESTAMP}, - - - #{gmtModified,jdbcType=TIMESTAMP}, - - - #{clusterName,jdbcType=VARCHAR}, - - - #{config,jdbcType=VARCHAR}, - - - - - update t_chaos_cluster - - - gmt_create = #{gmtCreate,jdbcType=TIMESTAMP}, - - - gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}, - - - cluster_name = #{clusterName,jdbcType=VARCHAR}, - - - config = #{config,jdbcType=VARCHAR}, - - - where id = #{id,jdbcType=BIGINT} - - - update t_chaos_cluster - set gmt_create = #{gmtCreate,jdbcType=TIMESTAMP}, - gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}, - cluster_name = #{clusterName,jdbcType=VARCHAR}, - config = #{config,jdbcType=VARCHAR} - where id = #{id,jdbcType=BIGINT} - - diff --git a/chaosblade-box-scenario/chaosblade-box-scenario-api/src/main/resources/scene_param_component.json b/chaosblade-box-scenario/chaosblade-box-scenario-api/src/main/resources/scene_param_component.json index a99c9d6c..15306045 100644 --- a/chaosblade-box-scenario/chaosblade-box-scenario-api/src/main/resources/scene_param_component.json +++ b/chaosblade-box-scenario/chaosblade-box-scenario-api/src/main/resources/scene_param_component.json @@ -1,7 +1,68 @@ [ { - "sceneCode": "chaosblade.cpu.fullload", + "sceneCode": "chaosblade", "sceneParams": [ + { + "name": "debug", + "alias": "", + "description": "", + "component": { + "type": "radio", + "required": false, + "values": [ + { + "key": 0, + "label": "开启", + "value": "true" + }, + { + "key": 1, + "label": "关闭", + "value": "false" + } + ] + } + }, + { + "name": "timeout", + "alias": "", + "description": "", + "component": { + "type": "number", + "required": false, + "values": [] + } + }, + { + "name": "time", + "alias": "", + "description": "", + "component": { + "type": "number", + "required": false, + "values": [] + } + }, + { + "name": "effect-percent", + "alias": "", + "description": "", + "component": { + "type": "number", + "required": false, + "values": [] + } + }, + { + "name": "effect-count", + "alias": "", + "description": "", + "component": { + "type": "number", + "required": false, + "values": [] + } + }, { "name": "cpu-count", "alias": "", @@ -22,13 +83,7 @@ "maxValue": "100", "values": [] } - } - ] - }, - { - "sceneCode": "chaosblade.mem.load", - "sceneParams": [ - { + },{ "name": "reserve", "alias": "", "description": "", @@ -119,7 +174,7 @@ ] }, { - "sceneCode": "chaosblade.dubbo.delay", + "sceneCode": "chaosblade.dubbo", "sceneParams": [ { "name": "consumer", diff --git a/chaosblade-box-service/src/main/java/com/alibaba/chaosblade/box/service/impl/DeviceServiceImpl.java b/chaosblade-box-service/src/main/java/com/alibaba/chaosblade/box/service/impl/DeviceServiceImpl.java index e2fc9fc7..66898082 100644 --- a/chaosblade-box-service/src/main/java/com/alibaba/chaosblade/box/service/impl/DeviceServiceImpl.java +++ b/chaosblade-box-service/src/main/java/com/alibaba/chaosblade/box/service/impl/DeviceServiceImpl.java @@ -273,7 +273,7 @@ public KubernetesStatisticsResponse getKubernetesTotalStatistics() { .type(DeviceType.POD.getCode()) .build())) .namespaces(devicePodMapper.selectList(QueryWrapperBuilder.build() - .groupBy("namespace")).size()) + .groupBy("namespace").select("max(id)")).size()) .containers(devicePodRepository.selectList(DevicePodDO.builder().build()).stream().flatMap(devicePodDO -> Optional.ofNullable(devicePodDO.getContainers()).map( containers -> {