From b8b2eda6951e8701ed9b9d2369136297c9a09868 Mon Sep 17 00:00:00 2001 From: Zakaria Kofiro <31355049+Zakaria-Kofiro@users.noreply.github.com> Date: Tue, 6 Feb 2024 10:40:56 -0800 Subject: [PATCH] update to two step instead of gate rush (#296) Co-authored-by: zkofiro --- .../intuit/tank/vm/vmManager/JobRequest.java | 6 ++++ .../tank/vm/vmManager/JobRequestImpl.java | 15 +++++++++ .../vm/vmManager/JobRequestImplCpTest.java | 1 + .../java/com/intuit/tank/project/BaseJob.java | 19 ++++++++++++ .../mvc/rest/util/JobDetailFormatter.java | 1 + .../perfManager/workLoads/JobManager.java | 31 ++++++++++--------- .../workLoads/WorkLoadFactory.java | 1 + .../com/intuit/tank/job/ActJobNodeBean.java | 1 + .../java/com/intuit/tank/job/JobNodeBean.java | 16 ++++++++++ .../com/intuit/tank/job/JobQueueAction.java | 4 ++- .../tank/project/JobDetailFormatter.java | 1 + .../com/intuit/tank/project/JobMaker.java | 17 ++++++++++ web/web_ui/src/main/webapp/agents/index.xhtml | 7 +++-- .../projects/addWorkloadToJobQueue.xhtml | 19 ++++++++++++ .../webapp/projects/projectjobqueue.xhtml | 7 +++-- 15 files changed, 125 insertions(+), 21 deletions(-) diff --git a/api/src/main/java/com/intuit/tank/vm/vmManager/JobRequest.java b/api/src/main/java/com/intuit/tank/vm/vmManager/JobRequest.java index 2b58fa5ed..3bb941166 100644 --- a/api/src/main/java/com/intuit/tank/vm/vmManager/JobRequest.java +++ b/api/src/main/java/com/intuit/tank/vm/vmManager/JobRequest.java @@ -93,6 +93,12 @@ public interface JobRequest extends Serializable { */ public abstract boolean isUseEips(); + /** + * + * @return + */ + public abstract boolean isUseTwoStep(); + /** * @return the userIntervalIncrement */ diff --git a/api/src/main/java/com/intuit/tank/vm/vmManager/JobRequestImpl.java b/api/src/main/java/com/intuit/tank/vm/vmManager/JobRequestImpl.java index 9f99982ba..0430c7091 100644 --- a/api/src/main/java/com/intuit/tank/vm/vmManager/JobRequestImpl.java +++ b/api/src/main/java/com/intuit/tank/vm/vmManager/JobRequestImpl.java @@ -50,6 +50,7 @@ public final class JobRequestImpl implements Serializable, JobRequest { private int baselineVirtualUsers; private long simulationTime; private boolean useEips; + private boolean useTwoStep; private int userIntervalIncrement; private String reportingMode = TankConstants.RESULTS_NONE; private String loggingProfile = LoggingProfile.STANDARD.name(); @@ -87,6 +88,13 @@ public boolean isUseEips() { return useEips; } + /** + * @return the useTwoStep + */ + public boolean isUseTwoStep() { + return useTwoStep; + } + /** * @return the stopBehavior */ @@ -310,6 +318,7 @@ public String toString() { .append("stopBehavior", StopBehavior.fromString(stopBehavior).getDisplay()) .append("simulationTime", simulationTime) .append("useEips", useEips) + .append("useTwoStep", useTwoStep) .append("baselineVirtualUsers", baselineVirtualUsers) .append("userIntervalIncrement", userIntervalIncrement) .append("endRate", endRate) @@ -422,6 +431,12 @@ public GeneratorT withUseEips(boolean aValue) { return (GeneratorT) this; } + @SuppressWarnings("unchecked") + public GeneratorT withUseTwoStep(boolean aValue) { + instance.useTwoStep = aValue; + return (GeneratorT) this; + } + @SuppressWarnings("unchecked") public GeneratorT withLoggingProfile(String aValue) { instance.loggingProfile = aValue; diff --git a/api/src/test/java/com/intuit/tank/vm/vmManager/JobRequestImplCpTest.java b/api/src/test/java/com/intuit/tank/vm/vmManager/JobRequestImplCpTest.java index 2273d04d9..b24733144 100644 --- a/api/src/test/java/com/intuit/tank/vm/vmManager/JobRequestImplCpTest.java +++ b/api/src/test/java/com/intuit/tank/vm/vmManager/JobRequestImplCpTest.java @@ -171,6 +171,7 @@ public void testToString() { .append("stopBehavior", StopBehavior.fromString(request.getStopBehavior()).getDisplay()) .append("simulationTime", request.getSimulationTime()) .append("useEips", request.isUseEips()) + .append("useTwoStep", request.isUseTwoStep()) .append("baselineVirtualUsers", request.getBaselineVirtualUsers()) .append("userIntervalIncrement", "0") .append("endRate", "0.0") diff --git a/data_model/src/main/java/com/intuit/tank/project/BaseJob.java b/data_model/src/main/java/com/intuit/tank/project/BaseJob.java index 43196ee28..0c4bc9327 100644 --- a/data_model/src/main/java/com/intuit/tank/project/BaseJob.java +++ b/data_model/src/main/java/com/intuit/tank/project/BaseJob.java @@ -107,6 +107,9 @@ public abstract class BaseJob extends BaseEntity { @Column(name = "use_eips") private Boolean useEips; + @Column(name = "use_two_step") + private Boolean useTwoStep; + /** * */ @@ -137,6 +140,7 @@ public BaseJob(BaseJob copy) { this.numAgents = copy.numAgents; this.vmInstanceType = copy.vmInstanceType; this.useEips = copy.useEips; + this.useTwoStep = copy.useTwoStep; this.tankClientClass = copy.getTankClientClass(); } @@ -189,6 +193,21 @@ public void setUseEips(boolean useEips) { this.useEips = useEips; } + /** + * @return two-step job start setting + */ + public boolean isUseTwoStep() { + return useTwoStep != null ? useTwoStep : false; + } + + /** + * @param useTwoStep + * enable/disable two-step job starts + */ + public void setUseTwoStep(boolean useTwoStep) { + this.useTwoStep = useTwoStep; + } + /** * * @return diff --git a/rest-mvc/src/main/java/com/intuit/tank/rest/mvc/rest/util/JobDetailFormatter.java b/rest-mvc/src/main/java/com/intuit/tank/rest/mvc/rest/util/JobDetailFormatter.java index 3ed29f5e9..4bf540acc 100644 --- a/rest-mvc/src/main/java/com/intuit/tank/rest/mvc/rest/util/JobDetailFormatter.java +++ b/rest-mvc/src/main/java/com/intuit/tank/rest/mvc/rest/util/JobDetailFormatter.java @@ -80,6 +80,7 @@ protected static String buildDetails(JobValidator validator, Workload workload, addProperty(sb, "Tank Http Client", config.getAgentConfig().getTankClientName(proposedJobInstance.getTankClientClass())); addProperty(sb, "Agent VM Type", getVmDetails(config, proposedJobInstance.getVmInstanceType())); addProperty(sb, "Assign Elastic Ips", Boolean.toString(proposedJobInstance.isUseEips())); + addProperty(sb, "Enable Two-Step Job Start", Boolean.toString(proposedJobInstance.isUseTwoStep())); if(proposedJobInstance.getIncrementStrategy().equals(IncrementStrategy.standard)) { addProperty(sb, "Number of Agents", Integer.toString(proposedJobInstance.getNumAgents())); } else { diff --git a/tank_vmManager/src/main/java/com/intuit/tank/perfManager/workLoads/JobManager.java b/tank_vmManager/src/main/java/com/intuit/tank/perfManager/workLoads/JobManager.java index b170b8a72..c5df421ef 100644 --- a/tank_vmManager/src/main/java/com/intuit/tank/perfManager/workLoads/JobManager.java +++ b/tank_vmManager/src/main/java/com/intuit/tank/perfManager/workLoads/JobManager.java @@ -193,20 +193,23 @@ private void startTest(final JobInfo info) { try { Thread.sleep(RETRY_SLEEP);// 30 seconds } catch (InterruptedException ignored) { } - info.agentData // set agent status from pending to ready to run - .forEach(agentData -> { - CloudVmStatus status = vmTracker.getStatus(agentData.getInstanceId()); - if (status != null) { - status.setVmStatus(VMStatus.ready); - vmTracker.setStatus(status); - } - }); - LOG.info(new ObjectMessage(ImmutableMap.of("Message","Waiting for start agents command to start test for job " + jobId))); - try { - jobInfoMapLocalCache.get(jobId).latch.await(); - } catch (InterruptedException ignored) {} - LOG.info(new ObjectMessage(ImmutableMap.of("Message","Start agents command received - Sending start commands for job " + jobId + " asynchronously to following agents: " + - info.agentData.stream().collect(Collectors.toMap(AgentData::getInstanceId, AgentData::getInstanceUrl))))); + if(info.jobRequest.isUseTwoStep()) { // two-step job start - set agent status to ready and wait for command to start load + info.agentData // set agent status from pending to ready to run + .forEach(agentData -> { + CloudVmStatus status = vmTracker.getStatus(agentData.getInstanceId()); + if (status != null) { + status.setVmStatus(VMStatus.ready); + vmTracker.setStatus(status); + } + }); + LOG.info(new ObjectMessage(ImmutableMap.of("Message", "Waiting for start agents command to start test for job " + jobId))); + try { + jobInfoMapLocalCache.get(jobId).latch.await(); + } catch (InterruptedException ignored) { + } + LOG.info(new ObjectMessage(ImmutableMap.of("Message", "Start agents command received - Sending start commands for job " + jobId + " asynchronously to following agents: " + + info.agentData.stream().collect(Collectors.toMap(AgentData::getInstanceId, AgentData::getInstanceUrl))))); + } info.agentData.parallelStream() .map(agentData -> agentData.getInstanceUrl() + AgentCommand.start.getPath()) .map(URI::create) diff --git a/tank_vmManager/src/main/java/com/intuit/tank/perfManager/workLoads/WorkLoadFactory.java b/tank_vmManager/src/main/java/com/intuit/tank/perfManager/workLoads/WorkLoadFactory.java index 445a6b605..5c440e56e 100644 --- a/tank_vmManager/src/main/java/com/intuit/tank/perfManager/workLoads/WorkLoadFactory.java +++ b/tank_vmManager/src/main/java/com/intuit/tank/perfManager/workLoads/WorkLoadFactory.java @@ -136,6 +136,7 @@ private JobRequest jobToJobRequest(JobInstance job) { .withStopBehavior(job.getStopBehavior()) .withReportingMode(job.getReportingMode()) .withUseEips(job.isUseEips()) + .withUseTwoStep(job.isUseTwoStep()) .withVmInstanceType(job.getVmInstanceType()) .withnumUsersPerAgent(job.getNumUsersPerAgent()) .withNumAgents(job.getNumAgents()) diff --git a/web/web_support/src/main/java/com/intuit/tank/job/ActJobNodeBean.java b/web/web_support/src/main/java/com/intuit/tank/job/ActJobNodeBean.java index 645f023d9..99947207d 100644 --- a/web/web_support/src/main/java/com/intuit/tank/job/ActJobNodeBean.java +++ b/web/web_support/src/main/java/com/intuit/tank/job/ActJobNodeBean.java @@ -42,6 +42,7 @@ public ActJobNodeBean(JobInstance job, boolean hasRights, FastDateFormat fmt) { this.setActiveUsers(String.valueOf(job.getBaselineVirtualUsers())); this.setTotalUsers(String.valueOf(job.getTotalVirtualUsers())); this.setTargetRampRate(String.valueOf(job.getTargetRampRate() * job.getNumAgents())); + this.setUseTwoStep(job.isUseTwoStep()); this.jobDetails = job.getJobDetails(); this.estimatedNonlinearSteadyStateUsers = estimateNonlinearSteadyStateUsers(job.getTargetRampRate(), job.getRampTime(), job.getNumAgents()); this.setStartTime(job.getStartTime()); diff --git a/web/web_support/src/main/java/com/intuit/tank/job/JobNodeBean.java b/web/web_support/src/main/java/com/intuit/tank/job/JobNodeBean.java index 9333b7bf4..fe60734ac 100644 --- a/web/web_support/src/main/java/com/intuit/tank/job/JobNodeBean.java +++ b/web/web_support/src/main/java/com/intuit/tank/job/JobNodeBean.java @@ -50,6 +50,7 @@ public abstract class JobNodeBean implements Serializable { private Date startTime; private Date endTime; private boolean hasRights = false; + private Boolean useTwoStep = false; private Map> statusDetailMap; // private Map> tpsInfoMap; private int tps; @@ -229,6 +230,21 @@ public void setTargetRampRate(String targetRampRate) { this.targetRampRate = targetRampRate; } + /** + * @return two-step job start setting + */ + public boolean isUseTwoStep() { + return useTwoStep != null ? useTwoStep : false; + } + + /** + * @param useTwoStep + * two-step job start setting + */ + public void setUseTwoStep(boolean useTwoStep) { + this.useTwoStep = useTwoStep; + } + /** * @return the validation errors */ diff --git a/web/web_support/src/main/java/com/intuit/tank/job/JobQueueAction.java b/web/web_support/src/main/java/com/intuit/tank/job/JobQueueAction.java index a62bbc9a0..9ac6979c5 100644 --- a/web/web_support/src/main/java/com/intuit/tank/job/JobQueueAction.java +++ b/web/web_support/src/main/java/com/intuit/tank/job/JobQueueAction.java @@ -63,7 +63,9 @@ public void startAgents(JobNodeBean node) { AWSXRay.getCurrentSegment().putAnnotation("job.action", "startAgents"); AWSXRay.getCurrentSegment().putAnnotation("jobId", node.getJobId()); if (node instanceof ActJobNodeBean) { - controller.startAgents(node.getId()); + if(node.isUseTwoStep()) { + controller.startAgents(node.getId()); + } } } diff --git a/web/web_support/src/main/java/com/intuit/tank/project/JobDetailFormatter.java b/web/web_support/src/main/java/com/intuit/tank/project/JobDetailFormatter.java index 0b133cdee..30a1cca1f 100644 --- a/web/web_support/src/main/java/com/intuit/tank/project/JobDetailFormatter.java +++ b/web/web_support/src/main/java/com/intuit/tank/project/JobDetailFormatter.java @@ -86,6 +86,7 @@ protected static String buildDetails(JobValidator validator, Workload workload, addProperty(sb, "Tank Http Client", config.getAgentConfig().getTankClientName(proposedJobInstance.getTankClientClass())); addProperty(sb, "Agent VM Type", getVmDetails(config, proposedJobInstance.getVmInstanceType())); addProperty(sb, "Assign Elastic Ips", Boolean.toString(proposedJobInstance.isUseEips())); + addProperty(sb, "Enable Two-Step Job Start", Boolean.toString(proposedJobInstance.isUseTwoStep())); if(proposedJobInstance.getIncrementStrategy().equals(IncrementStrategy.standard)) { addProperty(sb, "Number of Agents", Integer.toString(proposedJobInstance.getNumAgents())); } else { diff --git a/web/web_support/src/main/java/com/intuit/tank/project/JobMaker.java b/web/web_support/src/main/java/com/intuit/tank/project/JobMaker.java index a912569c9..26adbff2e 100644 --- a/web/web_support/src/main/java/com/intuit/tank/project/JobMaker.java +++ b/web/web_support/src/main/java/com/intuit/tank/project/JobMaker.java @@ -264,6 +264,22 @@ public void setUseEips(boolean b) { projectBean.getJobConfiguration().setUseEips(b); } + /** + * + * @return + */ + public boolean isUseTwoStep() { + return projectBean.getJobConfiguration().isUseTwoStep(); + } + + /** + * + * @return + */ + public void setUseTwoStep(boolean b) { + projectBean.getJobConfiguration().setUseTwoStep(b); + } + /** * * @param location @@ -311,6 +327,7 @@ public void createJobInstance() { proposedJobInstance.setCreator(securityContext.getCallerPrincipal().getName()); proposedJobInstance.setScheduledTime(new Date()); proposedJobInstance.setUseEips(isUseEips()); + proposedJobInstance.setUseTwoStep((isUseTwoStep())); proposedJobInstance.setTankClientClass(getTankClientClass()); proposedJobInstance.setLocation(getLocation()); proposedJobInstance.setVmInstanceType(getVmInstanceType()); diff --git a/web/web_ui/src/main/webapp/agents/index.xhtml b/web/web_ui/src/main/webapp/agents/index.xhtml index 805d14e57..78623dc12 100644 --- a/web/web_ui/src/main/webapp/agents/index.xhtml +++ b/web/web_ui/src/main/webapp/agents/index.xhtml @@ -108,8 +108,9 @@ - - + + + @@ -189,7 +190,7 @@ disabled="#{!node.isRunnable() or !jobQueueManager.canControlJob(node)}" ajax="true" update=":mainForm:jobTableId" />
@@ -117,6 +118,24 @@ value="#{jobMaker.useEips}" />
+ +
+
+ + +
+
+ + +
+
diff --git a/web/web_ui/src/main/webapp/projects/projectjobqueue.xhtml b/web/web_ui/src/main/webapp/projects/projectjobqueue.xhtml index 715cb16af..a4ee1bbf9 100644 --- a/web/web_ui/src/main/webapp/projects/projectjobqueue.xhtml +++ b/web/web_ui/src/main/webapp/projects/projectjobqueue.xhtml @@ -113,8 +113,9 @@ style="width:#{projectJobQueueManager.tablePrefs.getSize('statusColumn')}px;" rendered="#{projectJobQueueManager.tablePrefs.isVisible('statusColumn')}"> - - + + +