Skip to content

Commit

Permalink
feature: update frontend to 0.4.1
Browse files Browse the repository at this point in the history
Signed-off-by: tiny-x <185120555@qq.com>
  • Loading branch information
tiny-x committed May 10, 2021
1 parent e5fb42c commit 3a5f574
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.alibaba.chaosblade.box.service.collect;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.EnumUtil;
Expand Down Expand Up @@ -310,25 +311,29 @@ public void afterPropertiesSet() {
if (strategy.value() == collectorType) {
if (value instanceof NodeCollector) {
nodeCollector = (NodeCollector) value;
if (enableCollect) {
nodeCollect(nodeCollector, Query.builder().build());
}
}
if (value instanceof PodCollector) {
podCollector = (PodCollector) value;
if (enableCollect) {
podCollect(podCollector, Query.builder().build());
}
}
if (value instanceof ContainerCollector) {
containerCollector = (ContainerCollector) value;
if (enableCollect) {
containerCollect(containerCollector, Query.builder().build());
}
}
}
}

// todo
if (enableCollect) {
ClusterDO clusterDO;
List<ClusterDO> aDefault = clusterRepository.selectList(ClusterDO.builder().clusterName("default").build());
if (CollUtil.isEmpty(aDefault)) {
clusterDO = ClusterDO.builder().clusterName("default").build();
clusterRepository.insert(clusterDO);
} else {
clusterDO = aDefault.get(0);
}
collect(Query.builder().clusterId(clusterDO.getId()).build());
}

ScheduledExecutorService scheduledExecutorService = new ScheduledThreadPoolExecutor(1);

scheduledExecutorService.scheduleAtFixedRate(() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ private List<DeviceMeta> getDeviceMetas(CreateExperimentRequest createExperiment
}
).collect(Collectors.toList());
if (original.equals(ChaosTools.CHAOS_BLADE.getName())) {
createExperimentRequest.getParameters().put("names", nodes.stream().map(DeviceMeta::getNodeName).collect(Collectors.joining()));
createExperimentRequest.getParameters().put("names", nodes.stream().map(DeviceMeta::getNodeName).collect(Collectors.joining(",")));
} else if (original.equals(ChaosTools.LITMUS_CHAOS.getName())) {
createExperimentRequest.getParameters().put("TARGET_NODES", nodes.stream().map(DeviceMeta::getNodeName).collect(Collectors.joining()));
createExperimentRequest.getParameters().put("TARGET_NODES", nodes.stream().map(DeviceMeta::getNodeName).collect(Collectors.joining(",")));
}
return nodes;
case POD:
Expand Down Expand Up @@ -205,15 +205,15 @@ private List<DeviceMeta> getDeviceMetas(CreateExperimentRequest createExperiment
}
).collect(Collectors.toList());
if (original.equals(ChaosTools.CHAOS_BLADE.getName())) {
createExperimentRequest.getParameters().put("names", list.stream().map(DeviceMeta::getPodName).distinct().collect(Collectors.joining()));
String containerNames = list.stream().map(DeviceMeta::getContainerName).distinct().collect(Collectors.joining());
if (StrUtil.isNotBlank(containerNames)) {
createExperimentRequest.getParameters().put("names", list.stream().map(DeviceMeta::getPodName).distinct().collect(Collectors.joining(",")));
String containerNames = list.stream().map(DeviceMeta::getContainerName).distinct().collect(Collectors.joining(","));
if (StrUtil.isNotBlank(containerNames) && !"null".equals(containerNames)) {
createExperimentRequest.getParameters().put("container-names", containerNames);
}
} else if (original.equals(ChaosTools.LITMUS_CHAOS.getName())) {
createExperimentRequest.getParameters().put("TARGET_PODS", list.stream().map(DeviceMeta::getPodName).distinct().collect(Collectors.joining()));
String containerNames = list.stream().map(DeviceMeta::getContainerName).distinct().collect(Collectors.joining());
if (StrUtil.isNotBlank(containerNames)) {
createExperimentRequest.getParameters().put("TARGET_PODS", list.stream().map(DeviceMeta::getPodName).distinct().collect(Collectors.joining(",")));
String containerNames = list.stream().map(DeviceMeta::getContainerName).distinct().collect(Collectors.joining(","));
if (StrUtil.isNotBlank(containerNames) && !"null".equals(containerNames)) {
createExperimentRequest.getParameters().put("TARGET_CONTAINER", containerNames);
}
}
Expand Down
4 changes: 2 additions & 2 deletions chaosblade-box-web/src/main/resources/web/build/umi.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion chaosblade-box-web/src/main/resources/web/build/umi.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.alibaba.chaosblade.box.web.controller;

import com.alibaba.chaosblade.box.scenario.api.init.SceneParamComponentLoader;
import com.alibaba.chaosblade.box.service.ClusterService;
import com.alibaba.chaosblade.box.service.K8SToolsService;
import com.alibaba.chaosblade.box.web.ChaosbladeBoxApplication;
Expand Down Expand Up @@ -62,6 +63,9 @@ public class AgentReportControllerTest {
@MockBean
private MetricCateGoryLoader metricCateGoryLoader;

@MockBean
private SceneParamComponentLoader sceneParamComponentLoader;

@MockBean
private ClusterService clusterService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.alibaba.chaosblade.box.web.controller;

import com.alibaba.chaosblade.box.scenario.api.init.SceneParamComponentLoader;
import com.alibaba.chaosblade.box.service.ClusterService;
import com.alibaba.chaosblade.box.service.K8SToolsService;
import com.alibaba.chaosblade.box.web.ChaosbladeBoxApplication;
Expand Down Expand Up @@ -64,6 +65,9 @@ public class ExperimentControllerTest {
@MockBean
private MetricCateGoryLoader metricCateGoryLoader;

@MockBean
private SceneParamComponentLoader sceneParamComponentLoader;

@MockBean
private ClusterService clusterService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.alibaba.chaosblade.box.web.controller;

import com.alibaba.chaosblade.box.scenario.api.init.SceneParamComponentLoader;
import com.alibaba.chaosblade.box.service.ClusterService;
import com.alibaba.chaosblade.box.service.K8SToolsService;
import com.alibaba.chaosblade.box.web.ChaosbladeBoxApplication;
Expand Down Expand Up @@ -67,6 +68,9 @@ public class ExperimentTaskControllerTest {
@MockBean
private MetricCateGoryLoader metricCateGoryLoader;

@MockBean
private SceneParamComponentLoader sceneParamComponentLoader;

@MockBean
private ClusterService clusterService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.alibaba.chaosblade.box.web.controller;

import cn.hutool.core.collection.CollUtil;
import com.alibaba.chaosblade.box.scenario.api.init.SceneParamComponentLoader;
import com.alibaba.chaosblade.box.service.ClusterService;
import com.alibaba.chaosblade.box.service.K8SToolsService;
import com.alibaba.chaosblade.box.service.model.device.*;
Expand Down Expand Up @@ -72,6 +73,9 @@ public class MachineControllerTest {
@MockBean
private MetricCateGoryLoader metricCateGoryLoader;

@MockBean
private SceneParamComponentLoader sceneParamComponentLoader;

@MockBean
private ClusterService clusterService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.alibaba.chaosblade.box.web.controller;

import com.alibaba.chaosblade.box.scenario.api.init.SceneParamComponentLoader;
import com.alibaba.chaosblade.box.service.ClusterService;
import com.alibaba.chaosblade.box.service.K8SToolsService;
import com.alibaba.chaosblade.box.web.ChaosbladeBoxApplication;
Expand Down Expand Up @@ -65,6 +66,9 @@ public class MainControllerTest {
@MockBean
private SceneCategoryLoader sceneCategoryLoader;

@MockBean
private SceneParamComponentLoader sceneParamComponentLoader;

@MockBean
private MetricCateGoryLoader metricCateGoryLoader;

Expand Down

0 comments on commit 3a5f574

Please sign in to comment.