Skip to content

Commit

Permalink
Merge pull request #236 from intuit/zkofiro/datafile-compress-fix
Browse files Browse the repository at this point in the history
Added new routes for clients and fixed datafile compression issue
  • Loading branch information
Zakaria-Kofiro authored Apr 5, 2023
2 parents ea6683c + 5230cf7 commit 369701e
Show file tree
Hide file tree
Showing 22 changed files with 426 additions and 118 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
import com.intuit.tank.rest.mvc.rest.models.agent.TankHttpClientDefinitionContainer;
import com.intuit.tank.rest.mvc.rest.services.agent.AgentServiceV2;
import com.intuit.tank.vm.agent.messages.Headers;
import com.intuit.tank.vm.agent.messages.AgentTestStartData;
import com.intuit.tank.vm.agent.messages.AgentAvailability;
import com.intuit.tank.vm.agent.messages.AgentData;
import com.intuit.tank.vm.agent.messages.AgentTestStartData;

import org.springframework.core.io.InputStreamResource;
import org.springframework.http.HttpStatus;
Expand Down Expand Up @@ -80,10 +81,10 @@ public ResponseEntity<org.springframework.core.io.Resource> getSupportFiles() th
}

@RequestMapping(value = "/ready", method = RequestMethod.POST, consumes = { MediaType.APPLICATION_JSON_VALUE })
@Operation(description = "Registers an agent instance to a job and sets it's status to ready to start", summary = "Set an agent instance status to ready to start")
@Operation(description = "Registers an agent instance to a job and sets it's status to ready to start", summary = "Set an agent instance status to ready to start", hidden = true)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successfully set agent to ready"),
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
@ApiResponse(responseCode = "400", description = "Could not register agent due to bad request", content = @Content)
})
public ResponseEntity<AgentTestStartData> agentReady(
@RequestBody @Parameter(description = "agentData object that contains agent data settings", required = true) AgentData agentData) {
Expand All @@ -110,6 +111,18 @@ public ResponseEntity<TankHttpClientDefinitionContainer> getClients() {
return new ResponseEntity<>(agentService.getClients(), HttpStatus.OK);
}

@RequestMapping(value = "/availability", method = RequestMethod.POST, consumes = { MediaType.APPLICATION_JSON_VALUE })
@Operation(description = "Sets the availability status for a standalone agent", summary = "Set standalone agent availability", hidden = true)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successfully set agent availability"),
@ApiResponse(responseCode = "400", description = "Could not update agent availability due to bad request", content = @Content)
})
public ResponseEntity<Void> setStandaloneAgentAvailability(
@RequestBody @Parameter(description = "Agent availability request to update standalone agent availability", required = true) AgentAvailability availability) {
agentService.setStandaloneAgentAvailability(availability);
return ResponseEntity.ok().build();
}

// Instance status operations
@RequestMapping(value = "/instance/status/{instanceId}", method = RequestMethod.GET)
@Operation(description = "Returns the agent instance status", summary = "Get the agent instance status")
Expand All @@ -122,62 +135,62 @@ public ResponseEntity<CloudVmStatus> getInstanceStatus(@PathVariable @Parameter(
if (status != null) {
return new ResponseEntity<CloudVmStatus>(status, HttpStatus.OK);
}
return new ResponseEntity<CloudVmStatus>(status, HttpStatus.NOT_FOUND);
return ResponseEntity.notFound().build();
}

@RequestMapping(value = "/instance/status/{instanceId}", method = RequestMethod.PUT, consumes = { MediaType.APPLICATION_JSON_VALUE })
@Operation(description = "Sets the agent instance status via instanceID and CloudVMStatus payload", summary = "Set the agent instance status")
@Operation(description = "Sets the agent instance status via instanceID and CloudVMStatus payload", summary = "Set the agent instance status", hidden = true)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successfully set agent instance status"),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content)
@ApiResponse(responseCode = "400", description = "Could not update agent instance status due to bad request", content = @Content)
})
public ResponseEntity<Void> setInstanceStatus(@PathVariable @Parameter(description = "The instance ID associated with the instance", required = true) String instanceId,
@RequestBody @Parameter(description = "CloudVmStatus object that contains updated content", required = true) CloudVmStatus status) {
agentService.setInstanceStatus(instanceId, status);
return ResponseEntity.ok().build();
}

@RequestMapping(value = "/instance/stop/{instanceId}", method = RequestMethod.GET)
@RequestMapping(value = "/instance/stop/{instanceId}", method = RequestMethod.GET, produces = { MediaType.TEXT_PLAIN_VALUE } )
@Operation(description = "Stops specific agent instance by instance ID", summary = "Stop an agent instance")
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Successfully stopped agent instance"),
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
@ApiResponse(responseCode = "200", description = "Successfully stopped agent instance"),
@ApiResponse(responseCode = "400", description = "Could not update agent instance status due to invalid instanceId", content = @Content)
})
public ResponseEntity<Void> stopInstance(@PathVariable @Parameter(description = "The instance ID associated with the instance", required = true) String instanceId) {
agentService.stopInstance(instanceId);
return ResponseEntity.noContent().build();
public ResponseEntity<String> stopInstance(@PathVariable @Parameter(description = "The instance ID associated with the instance", required = true) String instanceId) {
String status = agentService.stopInstance(instanceId);
return new ResponseEntity<>(status, HttpStatus.OK);
}

@RequestMapping(value = "/instance/pause/{instanceId}", method = RequestMethod.GET)
@RequestMapping(value = "/instance/pause/{instanceId}", method = RequestMethod.GET, produces = { MediaType.TEXT_PLAIN_VALUE } )
@Operation(description = "Pauses a specific running agent instance by instance ID", summary = "Pause a running agent instance")
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Successfully paused agent instance"),
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
@ApiResponse(responseCode = "200", description = "Successfully paused agent instance"),
@ApiResponse(responseCode = "400", description = "Could not update agent instance status due to invalid instanceId", content = @Content)
})
public ResponseEntity<Void> pauseInstance(@PathVariable @Parameter(description = "The instance ID associated with the instance", required = true) String instanceId) {
agentService.pauseInstance(instanceId);
return ResponseEntity.noContent().build();
public ResponseEntity<String> pauseInstance(@PathVariable @Parameter(description = "The instance ID associated with the instance", required = true) String instanceId) {
String status = agentService.pauseInstance(instanceId);
return new ResponseEntity<>(status, HttpStatus.OK);
}

@RequestMapping(value = "/instance/resume/{instanceId}", method = RequestMethod.GET)
@RequestMapping(value = "/instance/resume/{instanceId}", method = RequestMethod.GET, produces = { MediaType.TEXT_PLAIN_VALUE } )
@Operation(description = "Resumes a specific paused agent instance by instance ID", summary = "Resume a paused agent instance")
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Successfully resumed agent instance"),
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
@ApiResponse(responseCode = "200", description = "Successfully resumed agent instance"),
@ApiResponse(responseCode = "400", description = "Could not update agent instance status due to invalid instanceId", content = @Content)
})
public ResponseEntity<Void> resumeInstance(@PathVariable @Parameter(description = "The instance ID associated with the instance", required = true) String instanceId) {
agentService.resumeInstance(instanceId);
return ResponseEntity.noContent().build();
public ResponseEntity<String> resumeInstance(@PathVariable @Parameter(description = "The instance ID associated with the instance", required = true) String instanceId) {
String status = agentService.resumeInstance(instanceId);
return new ResponseEntity<>(status, HttpStatus.OK);
}

@RequestMapping(value = "/instance/kill/{instanceId}", method = RequestMethod.GET)
@RequestMapping(value = "/instance/kill/{instanceId}", method = RequestMethod.GET, produces = { MediaType.TEXT_PLAIN_VALUE } )
@Operation(description = "Terminates a specific agent instance by instance ID", summary = "Terminate an agent instance")
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Successfully terminated agent instance"),
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
@ApiResponse(responseCode = "200", description = "Successfully terminated agent instance"),
@ApiResponse(responseCode = "400", description = "Could not update agent instance status due to invalid instanceId", content = @Content)
})
public ResponseEntity<Void> killInstance(@PathVariable @Parameter(description = "The instance ID associated with the instance", required = true) String instanceId) {
agentService.killInstance(instanceId);
return ResponseEntity.noContent().build();
public ResponseEntity<String> killInstance(@PathVariable @Parameter(description = "The instance ID associated with the instance", required = true) String instanceId) {
String status = agentService.killInstance(instanceId);
return new ResponseEntity<>(status, HttpStatus.OK);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ public ResponseEntity<DataFileDescriptorContainer> getDatafiles() {
return new ResponseEntity<>(dataFileService.getDatafiles(), HttpStatus.OK);
}

@RequestMapping(value = "/names", method = RequestMethod.GET)
@Operation(description = "Returns all datafile names with corresponding datafile IDs", summary = "Get all datafile names with datafile IDs")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successfully found all datafile names with IDs", content = @Content),
@ApiResponse(responseCode = "404", description = "All datafile names with IDs could not be found", content = @Content)
})
public ResponseEntity<Map<Integer, String>> getAllDatafileNames() {
return new ResponseEntity<>(dataFileService.getAllDatafileNames(), HttpStatus.OK);
}

@RequestMapping(value = "/{datafileId}", method = RequestMethod.GET)
@Operation(description = "Returns a specific datafile description by datafile ID", summary = "Get a specific datafile description")
@ApiResponses(value = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,11 @@ public ResponseEntity<JobContainer> getJobsByProject(@PathVariable @Parameter(de

@RequestMapping(method = RequestMethod.POST, consumes = { MediaType.APPLICATION_JSON_VALUE })
@Operation(description = "Given a job request payload, creates a new job under an existing project and returns new jobId and created status in response \n\n" +
"Note: Make sure projectId matches an existing project to successfully add job to project's job queue" +
"Note: Make sure projectId matches an existing project to successfully create the job for that project \n\n" +
"Parameters: \n\n" +
" - jobInstanceName is accepted as a string \n\n" +
" - jobInstanceName and projectName are accepted as strings (both optional) \n\n" +
" - jobInstanceName overrides projectName for naming jobs \n\n" +
" - passing only projectName creates jobs named: '{projectName}_{total_users}\\_users\\_{timestamp}' \n\n" +
" - rampTime and simulationTime are accepted as time strings i.e 60s, 12m, 24h \n\n" +
" - stopBehavior is matched against accepted values ( END_OF_STEP, END_OF_SCRIPT, END_OF_SCRIPT_GROUP, END_OF_TEST ) \n\n" +
" - vmInstance matches against AWS EC2 Instance Types i.e c5.large, c5.xlarge, etc \n\n"+
Expand All @@ -91,7 +93,7 @@ public ResponseEntity<JobContainer> getJobsByProject(@PathVariable @Parameter(de
" - jobRegions.users are accepted as integer strings i.e \"100\", \"4000\" \n\n", summary = "Create a new job")
@ApiResponses(value = {
@ApiResponse(responseCode = "201", description = "Successfully created job", content = @Content),
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
@ApiResponse(responseCode = "400", description = "Could not create job due to bad request", content = @Content)
})
public ResponseEntity<Map<String, String>> createJob(
@RequestBody @Parameter(description = "request", required = true) CreateJobRequest request) {
Expand Down Expand Up @@ -146,58 +148,58 @@ public ResponseEntity<CloudVmStatusContainer> getJobVMStatuses(@PathVariable @Pa

// Job Status Setters

@RequestMapping(value = "/start/{jobId}", method = RequestMethod.GET)
@RequestMapping(value = "/start/{jobId}", method = RequestMethod.GET, produces = { MediaType.TEXT_PLAIN_VALUE } )
@Operation(description = "Starts a specific job by job id", summary = "Start a specific job")
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Successfully started job"),
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
@ApiResponse(responseCode = "200", description = "Successfully started job"),
@ApiResponse(responseCode = "400", description = "Could not update job status due to invalid jobId", content = @Content)
})
public ResponseEntity<Void> startJob(@PathVariable @Parameter(description = "The job ID associated with the job", required = true) Integer jobId) {
jobService.startJob(jobId);
return ResponseEntity.noContent().build();
public ResponseEntity<String> startJob(@PathVariable @Parameter(description = "The job ID associated with the job", required = true) Integer jobId) {
String status = jobService.startJob(jobId);
return new ResponseEntity<>(status, HttpStatus.OK);
}

@RequestMapping(value = "/stop/{jobId}", method = RequestMethod.GET)
@RequestMapping(value = "/stop/{jobId}", method = RequestMethod.GET, produces = { MediaType.TEXT_PLAIN_VALUE } )
@Operation(description = "Stops a specific job by job id", summary = "Stop a specific job")
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Successfully stopped job"),
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
@ApiResponse(responseCode = "200", description = "Successfully stopped job"),
@ApiResponse(responseCode = "400", description = "Could not update job status due to invalid jobId", content = @Content)
})
public ResponseEntity<Void> stopJob(@PathVariable @Parameter(description = "The job ID associated with the job", required = true) Integer jobId) {
jobService.stopJob(jobId);
return ResponseEntity.noContent().build();
public ResponseEntity<String> stopJob(@PathVariable @Parameter(description = "The job ID associated with the job", required = true) Integer jobId) {
String status = jobService.stopJob(jobId);
return new ResponseEntity<>(status, HttpStatus.OK);
}

@RequestMapping(value = "/pause/{jobId}", method = RequestMethod.GET)
@RequestMapping(value = "/pause/{jobId}", method = RequestMethod.GET, produces = { MediaType.TEXT_PLAIN_VALUE } )
@Operation(description = "Pauses a specific job by job id", summary = "Pause a job")
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Successfully paused job"),
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
@ApiResponse(responseCode = "200", description = "Successfully paused job"),
@ApiResponse(responseCode = "400", description = "Could not update job status due to invalid jobId", content = @Content)
})
public ResponseEntity<Void> pauseJob(@PathVariable @Parameter(description = "The job ID associated with the job", required = true) Integer jobId) {
jobService.pauseJob(jobId);
return ResponseEntity.noContent().build();
public ResponseEntity<String> pauseJob(@PathVariable @Parameter(description = "The job ID associated with the job", required = true) Integer jobId) {
String status = jobService.pauseJob(jobId);
return new ResponseEntity<>(status, HttpStatus.OK);
}

@RequestMapping(value = "/resume/{jobId}", method = RequestMethod.GET)
@RequestMapping(value = "/resume/{jobId}", method = RequestMethod.GET, produces = { MediaType.TEXT_PLAIN_VALUE } )
@Operation(description = "Resumes a specific job by job id", summary = "Resume a paused job")
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Successfully resumed job"),
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
@ApiResponse(responseCode = "200", description = "Successfully resumed job"),
@ApiResponse(responseCode = "400", description = "Could not update job status due to invalid jobId", content = @Content)
})
public ResponseEntity<Void> resumeJob(@PathVariable @Parameter(description = "The job ID associated with the job", required = true) Integer jobId) {
jobService.resumeJob(jobId);
return ResponseEntity.noContent().build();
public ResponseEntity<String> resumeJob(@PathVariable @Parameter(description = "The job ID associated with the job", required = true) Integer jobId) {
String status = jobService.resumeJob(jobId);
return new ResponseEntity<>(status, HttpStatus.OK);
}

@RequestMapping(value = "/kill/{jobId}", method = RequestMethod.GET)
@RequestMapping(value = "/kill/{jobId}", method = RequestMethod.GET, produces = { MediaType.TEXT_PLAIN_VALUE } )
@Operation(description = "Terminates a specific job by job id", summary = "Terminate a specific job")
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Successfully terminated job"),
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
@ApiResponse(responseCode = "200", description = "Successfully terminated job"),
@ApiResponse(responseCode = "400", description = "Could not update job status due to invalid jobId", content = @Content)
})
public ResponseEntity<Void> killJob(@PathVariable @Parameter(description = "The job ID associated with the job", required = true) Integer jobId) {
jobService.killJob(jobId);
return ResponseEntity.noContent().build();
public ResponseEntity<String> killJob(@PathVariable @Parameter(description = "The job ID associated with the job", required = true) Integer jobId) {
String status = jobService.killJob(jobId);
return new ResponseEntity<>(status, HttpStatus.OK);
}
}
Loading

0 comments on commit 369701e

Please sign in to comment.