Skip to content

Commit 369701e

Browse files
Merge pull request #236 from intuit/zkofiro/datafile-compress-fix
Added new routes for clients and fixed datafile compression issue
2 parents ea6683c + 5230cf7 commit 369701e

22 files changed

+426
-118
lines changed

rest-mvc/src/main/java/com/intuit/tank/rest/mvc/rest/controllers/AgentController.java

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
import com.intuit.tank.rest.mvc.rest.models.agent.TankHttpClientDefinitionContainer;
1212
import com.intuit.tank.rest.mvc.rest.services.agent.AgentServiceV2;
1313
import com.intuit.tank.vm.agent.messages.Headers;
14-
import com.intuit.tank.vm.agent.messages.AgentTestStartData;
14+
import com.intuit.tank.vm.agent.messages.AgentAvailability;
1515
import com.intuit.tank.vm.agent.messages.AgentData;
16+
import com.intuit.tank.vm.agent.messages.AgentTestStartData;
1617

1718
import org.springframework.core.io.InputStreamResource;
1819
import org.springframework.http.HttpStatus;
@@ -80,10 +81,10 @@ public ResponseEntity<org.springframework.core.io.Resource> getSupportFiles() th
8081
}
8182

8283
@RequestMapping(value = "/ready", method = RequestMethod.POST, consumes = { MediaType.APPLICATION_JSON_VALUE })
83-
@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")
84+
@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)
8485
@ApiResponses(value = {
8586
@ApiResponse(responseCode = "200", description = "Successfully set agent to ready"),
86-
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
87+
@ApiResponse(responseCode = "400", description = "Could not register agent due to bad request", content = @Content)
8788
})
8889
public ResponseEntity<AgentTestStartData> agentReady(
8990
@RequestBody @Parameter(description = "agentData object that contains agent data settings", required = true) AgentData agentData) {
@@ -110,6 +111,18 @@ public ResponseEntity<TankHttpClientDefinitionContainer> getClients() {
110111
return new ResponseEntity<>(agentService.getClients(), HttpStatus.OK);
111112
}
112113

114+
@RequestMapping(value = "/availability", method = RequestMethod.POST, consumes = { MediaType.APPLICATION_JSON_VALUE })
115+
@Operation(description = "Sets the availability status for a standalone agent", summary = "Set standalone agent availability", hidden = true)
116+
@ApiResponses(value = {
117+
@ApiResponse(responseCode = "200", description = "Successfully set agent availability"),
118+
@ApiResponse(responseCode = "400", description = "Could not update agent availability due to bad request", content = @Content)
119+
})
120+
public ResponseEntity<Void> setStandaloneAgentAvailability(
121+
@RequestBody @Parameter(description = "Agent availability request to update standalone agent availability", required = true) AgentAvailability availability) {
122+
agentService.setStandaloneAgentAvailability(availability);
123+
return ResponseEntity.ok().build();
124+
}
125+
113126
// Instance status operations
114127
@RequestMapping(value = "/instance/status/{instanceId}", method = RequestMethod.GET)
115128
@Operation(description = "Returns the agent instance status", summary = "Get the agent instance status")
@@ -122,62 +135,62 @@ public ResponseEntity<CloudVmStatus> getInstanceStatus(@PathVariable @Parameter(
122135
if (status != null) {
123136
return new ResponseEntity<CloudVmStatus>(status, HttpStatus.OK);
124137
}
125-
return new ResponseEntity<CloudVmStatus>(status, HttpStatus.NOT_FOUND);
138+
return ResponseEntity.notFound().build();
126139
}
127140

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

140-
@RequestMapping(value = "/instance/stop/{instanceId}", method = RequestMethod.GET)
153+
@RequestMapping(value = "/instance/stop/{instanceId}", method = RequestMethod.GET, produces = { MediaType.TEXT_PLAIN_VALUE } )
141154
@Operation(description = "Stops specific agent instance by instance ID", summary = "Stop an agent instance")
142155
@ApiResponses(value = {
143-
@ApiResponse(responseCode = "204", description = "Successfully stopped agent instance"),
144-
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
156+
@ApiResponse(responseCode = "200", description = "Successfully stopped agent instance"),
157+
@ApiResponse(responseCode = "400", description = "Could not update agent instance status due to invalid instanceId", content = @Content)
145158
})
146-
public ResponseEntity<Void> stopInstance(@PathVariable @Parameter(description = "The instance ID associated with the instance", required = true) String instanceId) {
147-
agentService.stopInstance(instanceId);
148-
return ResponseEntity.noContent().build();
159+
public ResponseEntity<String> stopInstance(@PathVariable @Parameter(description = "The instance ID associated with the instance", required = true) String instanceId) {
160+
String status = agentService.stopInstance(instanceId);
161+
return new ResponseEntity<>(status, HttpStatus.OK);
149162
}
150163

151-
@RequestMapping(value = "/instance/pause/{instanceId}", method = RequestMethod.GET)
164+
@RequestMapping(value = "/instance/pause/{instanceId}", method = RequestMethod.GET, produces = { MediaType.TEXT_PLAIN_VALUE } )
152165
@Operation(description = "Pauses a specific running agent instance by instance ID", summary = "Pause a running agent instance")
153166
@ApiResponses(value = {
154-
@ApiResponse(responseCode = "204", description = "Successfully paused agent instance"),
155-
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
167+
@ApiResponse(responseCode = "200", description = "Successfully paused agent instance"),
168+
@ApiResponse(responseCode = "400", description = "Could not update agent instance status due to invalid instanceId", content = @Content)
156169
})
157-
public ResponseEntity<Void> pauseInstance(@PathVariable @Parameter(description = "The instance ID associated with the instance", required = true) String instanceId) {
158-
agentService.pauseInstance(instanceId);
159-
return ResponseEntity.noContent().build();
170+
public ResponseEntity<String> pauseInstance(@PathVariable @Parameter(description = "The instance ID associated with the instance", required = true) String instanceId) {
171+
String status = agentService.pauseInstance(instanceId);
172+
return new ResponseEntity<>(status, HttpStatus.OK);
160173
}
161174

162-
@RequestMapping(value = "/instance/resume/{instanceId}", method = RequestMethod.GET)
175+
@RequestMapping(value = "/instance/resume/{instanceId}", method = RequestMethod.GET, produces = { MediaType.TEXT_PLAIN_VALUE } )
163176
@Operation(description = "Resumes a specific paused agent instance by instance ID", summary = "Resume a paused agent instance")
164177
@ApiResponses(value = {
165-
@ApiResponse(responseCode = "204", description = "Successfully resumed agent instance"),
166-
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
178+
@ApiResponse(responseCode = "200", description = "Successfully resumed agent instance"),
179+
@ApiResponse(responseCode = "400", description = "Could not update agent instance status due to invalid instanceId", content = @Content)
167180
})
168-
public ResponseEntity<Void> resumeInstance(@PathVariable @Parameter(description = "The instance ID associated with the instance", required = true) String instanceId) {
169-
agentService.resumeInstance(instanceId);
170-
return ResponseEntity.noContent().build();
181+
public ResponseEntity<String> resumeInstance(@PathVariable @Parameter(description = "The instance ID associated with the instance", required = true) String instanceId) {
182+
String status = agentService.resumeInstance(instanceId);
183+
return new ResponseEntity<>(status, HttpStatus.OK);
171184
}
172185

173-
@RequestMapping(value = "/instance/kill/{instanceId}", method = RequestMethod.GET)
186+
@RequestMapping(value = "/instance/kill/{instanceId}", method = RequestMethod.GET, produces = { MediaType.TEXT_PLAIN_VALUE } )
174187
@Operation(description = "Terminates a specific agent instance by instance ID", summary = "Terminate an agent instance")
175188
@ApiResponses(value = {
176-
@ApiResponse(responseCode = "204", description = "Successfully terminated agent instance"),
177-
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
189+
@ApiResponse(responseCode = "200", description = "Successfully terminated agent instance"),
190+
@ApiResponse(responseCode = "400", description = "Could not update agent instance status due to invalid instanceId", content = @Content)
178191
})
179-
public ResponseEntity<Void> killInstance(@PathVariable @Parameter(description = "The instance ID associated with the instance", required = true) String instanceId) {
180-
agentService.killInstance(instanceId);
181-
return ResponseEntity.noContent().build();
192+
public ResponseEntity<String> killInstance(@PathVariable @Parameter(description = "The instance ID associated with the instance", required = true) String instanceId) {
193+
String status = agentService.killInstance(instanceId);
194+
return new ResponseEntity<>(status, HttpStatus.OK);
182195
}
183196
}

rest-mvc/src/main/java/com/intuit/tank/rest/mvc/rest/controllers/DataFileController.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ public ResponseEntity<DataFileDescriptorContainer> getDatafiles() {
5959
return new ResponseEntity<>(dataFileService.getDatafiles(), HttpStatus.OK);
6060
}
6161

62+
@RequestMapping(value = "/names", method = RequestMethod.GET)
63+
@Operation(description = "Returns all datafile names with corresponding datafile IDs", summary = "Get all datafile names with datafile IDs")
64+
@ApiResponses(value = {
65+
@ApiResponse(responseCode = "200", description = "Successfully found all datafile names with IDs", content = @Content),
66+
@ApiResponse(responseCode = "404", description = "All datafile names with IDs could not be found", content = @Content)
67+
})
68+
public ResponseEntity<Map<Integer, String>> getAllDatafileNames() {
69+
return new ResponseEntity<>(dataFileService.getAllDatafileNames(), HttpStatus.OK);
70+
}
71+
6272
@RequestMapping(value = "/{datafileId}", method = RequestMethod.GET)
6373
@Operation(description = "Returns a specific datafile description by datafile ID", summary = "Get a specific datafile description")
6474
@ApiResponses(value = {

rest-mvc/src/main/java/com/intuit/tank/rest/mvc/rest/controllers/JobController.java

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,11 @@ public ResponseEntity<JobContainer> getJobsByProject(@PathVariable @Parameter(de
8080

8181
@RequestMapping(method = RequestMethod.POST, consumes = { MediaType.APPLICATION_JSON_VALUE })
8282
@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" +
83-
"Note: Make sure projectId matches an existing project to successfully add job to project's job queue" +
83+
"Note: Make sure projectId matches an existing project to successfully create the job for that project \n\n" +
8484
"Parameters: \n\n" +
85-
" - jobInstanceName is accepted as a string \n\n" +
85+
" - jobInstanceName and projectName are accepted as strings (both optional) \n\n" +
86+
" - jobInstanceName overrides projectName for naming jobs \n\n" +
87+
" - passing only projectName creates jobs named: '{projectName}_{total_users}\\_users\\_{timestamp}' \n\n" +
8688
" - rampTime and simulationTime are accepted as time strings i.e 60s, 12m, 24h \n\n" +
8789
" - stopBehavior is matched against accepted values ( END_OF_STEP, END_OF_SCRIPT, END_OF_SCRIPT_GROUP, END_OF_TEST ) \n\n" +
8890
" - vmInstance matches against AWS EC2 Instance Types i.e c5.large, c5.xlarge, etc \n\n"+
@@ -91,7 +93,7 @@ public ResponseEntity<JobContainer> getJobsByProject(@PathVariable @Parameter(de
9193
" - jobRegions.users are accepted as integer strings i.e \"100\", \"4000\" \n\n", summary = "Create a new job")
9294
@ApiResponses(value = {
9395
@ApiResponse(responseCode = "201", description = "Successfully created job", content = @Content),
94-
@ApiResponse(responseCode = "400", description = "Bad request", content = @Content)
96+
@ApiResponse(responseCode = "400", description = "Could not create job due to bad request", content = @Content)
9597
})
9698
public ResponseEntity<Map<String, String>> createJob(
9799
@RequestBody @Parameter(description = "request", required = true) CreateJobRequest request) {
@@ -146,58 +148,58 @@ public ResponseEntity<CloudVmStatusContainer> getJobVMStatuses(@PathVariable @Pa
146148

147149
// Job Status Setters
148150

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

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

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

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

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

0 commit comments

Comments
 (0)