Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BIGTOP-4377: Add ut cases for command job classes in server module #184

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.bigtop.manager.dao.repository.ComponentDao;
import org.apache.bigtop.manager.server.command.job.AbstractJob;
import org.apache.bigtop.manager.server.command.job.JobContext;
import org.apache.bigtop.manager.server.command.stage.Stage;
import org.apache.bigtop.manager.server.holder.SpringContextHolder;

import java.util.ArrayList;
Expand Down Expand Up @@ -62,4 +63,9 @@ protected Map<String, List<String>> getComponentHostsMap() {

return componentHostsMap;
}

protected void setJobContextAndStagesForTest(JobContext jobContext, List<Stage> stages) {
this.jobContext = jobContext;
this.stages = stages;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.apache.bigtop.manager.dao.po.JobPO;
import org.apache.bigtop.manager.dao.po.StagePO;
import org.apache.bigtop.manager.dao.po.TaskPO;
import org.apache.bigtop.manager.server.command.job.AbstractJob;
import org.apache.bigtop.manager.server.command.job.JobContext;
import org.apache.bigtop.manager.server.command.stage.HostCheckStage;
import org.apache.bigtop.manager.server.command.stage.SetupJdkStage;
Expand All @@ -38,7 +37,7 @@

import java.util.List;

public class ClusterAddJob extends AbstractJob {
public class ClusterAddJob extends AbstractClusterJob {

private HostService hostService;

Expand Down Expand Up @@ -92,7 +91,7 @@ public String getName() {
return "Add cluster";
}

private void saveCluster() {
protected void saveCluster() {
CommandDTO commandDTO = jobContext.getCommandDTO();
ClusterDTO clusterDTO = ClusterConverter.INSTANCE.fromCommand2DTO(commandDTO.getClusterCommand());
clusterPO = clusterDao.findByName(clusterDTO.getName());
Expand All @@ -104,7 +103,7 @@ private void saveCluster() {
clusterDao.save(clusterPO);
}

private void saveHosts() {
protected void saveHosts() {
CommandDTO commandDTO = jobContext.getCommandDTO();
List<HostDTO> hostDTOList = commandDTO.getClusterCommand().getHosts();
for (HostDTO hostDTO : hostDTOList) {
Expand All @@ -113,7 +112,7 @@ private void saveHosts() {
}
}

private void linkJobToCluster() {
protected void linkJobToCluster() {
JobPO jobPO = getJobPO();
jobPO.setClusterId(clusterPO.getId());
jobDao.partialUpdateById(jobPO);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.bigtop.manager.dao.repository.ServiceDao;
import org.apache.bigtop.manager.server.command.job.AbstractJob;
import org.apache.bigtop.manager.server.command.job.JobContext;
import org.apache.bigtop.manager.server.command.stage.Stage;
import org.apache.bigtop.manager.server.holder.SpringContextHolder;

import java.util.HashMap;
Expand Down Expand Up @@ -64,4 +65,9 @@ protected Map<String, List<String>> getComponentHostsMap() {

return componentHostsMap;
}

protected void setJobContextAndStagesForTest(JobContext jobContext, List<Stage> stages) {
this.jobContext = jobContext;
this.stages = stages;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public String getName() {
return "Add components";
}

private void saveComponents(ComponentCommandDTO componentCommand) {
protected void saveComponents(ComponentCommandDTO componentCommand) {
Long clusterId = jobContext.getCommandDTO().getClusterId();
String componentName = componentCommand.getComponentName();
ServiceDTO serviceDTO = StackUtils.getServiceDTOByComponentName(componentName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.bigtop.manager.dao.repository.ComponentDao;
import org.apache.bigtop.manager.server.command.job.AbstractJob;
import org.apache.bigtop.manager.server.command.job.JobContext;
import org.apache.bigtop.manager.server.command.stage.Stage;
import org.apache.bigtop.manager.server.holder.SpringContextHolder;

import java.util.ArrayList;
Expand Down Expand Up @@ -71,4 +72,9 @@ private List<String> getHostnames() {
.flatMap(hostCommandDTO -> hostCommandDTO.getHostnames().stream())
.toList();
}

protected void setJobContextAndStagesForTest(JobContext jobContext, List<Stage> stages) {
this.jobContext = jobContext;
this.stages = stages;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public String getName() {
return "Add hosts";
}

private void saveHosts() {
protected void saveHosts() {
CommandDTO commandDTO = jobContext.getCommandDTO();
List<HostDTO> hostDTOList = HostConverter.INSTANCE.fromCommand2DTO(commandDTO.getHostCommands());
for (HostDTO hostDTO : hostDTOList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.bigtop.manager.dao.repository.ServiceDao;
import org.apache.bigtop.manager.server.command.job.AbstractJob;
import org.apache.bigtop.manager.server.command.job.JobContext;
import org.apache.bigtop.manager.server.command.stage.Stage;
import org.apache.bigtop.manager.server.holder.SpringContextHolder;
import org.apache.bigtop.manager.server.model.dto.command.ServiceCommandDTO;

Expand Down Expand Up @@ -84,4 +85,9 @@ private List<String> getServiceNames() {
.map(ServiceCommandDTO::getServiceName)
.toList();
}

protected void setJobContextAndStagesForTest(JobContext jobContext, List<Stage> stages) {
this.jobContext = jobContext;
this.stages = stages;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public String getName() {
return "Add services";
}

private void saveService(ServiceCommandDTO serviceCommand) {
protected void saveService(ServiceCommandDTO serviceCommand) {
CommandDTO commandDTO = jobContext.getCommandDTO();
Long clusterId = commandDTO.getClusterId();
String serviceName = serviceCommand.getServiceName();
Expand Down
Loading
Loading