Skip to content

Commit e0eb0de

Browse files
committed
Update computation service tests
1 parent 8e8fb68 commit e0eb0de

File tree

2 files changed

+255
-193
lines changed

2 files changed

+255
-193
lines changed

src/main/java/com/iexec/worker/docker/ComputationService.java

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -207,43 +207,23 @@ public void runComputation(ComputeMeta computeMeta, TaskDescription taskDescript
207207
public void runPostCompute(ComputeMeta computeMeta, TaskDescription taskDescription) {
208208
String chainTaskId = taskDescription.getChainTaskId();
209209
log.info("Running post-compute [chainTaskId:{}, isTee:{}]", chainTaskId, taskDescription.isTeeTask());
210-
boolean isSuccessfulPostCompute;
210+
boolean isSuccess;
211211
String postComputeStdout = "";
212212
if (taskDescription.isTeeTask()) {
213213
DockerExecutionResult dockerExecutionResult = runTeePostCompute(computeMeta.getSecureSessionId(), taskDescription);
214-
isSuccessfulPostCompute = dockerExecutionResult.isSuccess();
214+
isSuccess = dockerExecutionResult.isSuccess();
215215
postComputeStdout = dockerExecutionResult.getStdout();
216216
} else {
217-
isSuccessfulPostCompute = runNonTeePostCompute(taskDescription);
217+
isSuccess = runNonTeePostCompute(taskDescription);
218218
}
219-
computeMeta.setPostComputed(isSuccessfulPostCompute);
219+
computeMeta.setPostComputed(isSuccess);
220220
computeMeta.setStdout(computeMeta.getStdout() + "\n" + postComputeStdout);
221221
// save /output/stdout.txt file
222222
String stdoutFilePath = workerConfigService.getTaskOutputDir(chainTaskId) + File.separator + STDOUT_FILENAME;
223223
File stdoutFile = FileHelper.createFileWithContent(stdoutFilePath, computeMeta.getStdout());
224224
log.info("Saved stdout file [path:{}]", stdoutFile.getAbsolutePath());
225225
}
226226

227-
228-
public ComputedFile getComputedFile(String chainTaskId) {
229-
ComputedFile computedFile = IexecFileHelper.readComputedFile(chainTaskId,
230-
workerConfigService.getTaskOutputDir(chainTaskId));
231-
if (computedFile == null) {
232-
log.error("Failed to getComputedFile (computed.json missing)[chainTaskId:{}]", chainTaskId);
233-
return null;
234-
}
235-
if (computedFile.getResultDigest() == null || computedFile.getResultDigest().isEmpty()){
236-
String resultDigest = computeResultDigest(computedFile);
237-
if (resultDigest.isEmpty()){
238-
log.error("Failed to getComputedFile (resultDigest is empty but cant compute it)" +
239-
"[chainTaskId:{}, computedFile:{}]", chainTaskId, computedFile);
240-
return null;
241-
}
242-
computedFile.setResultDigest(resultDigest);
243-
}
244-
return computedFile;
245-
}
246-
247227
private DockerExecutionResult runTeePostCompute(String secureSessionId, TaskDescription taskDescription) {
248228
String chainTaskId = taskDescription.getChainTaskId();
249229
List<String> sconeUploaderEnv = sconeTeeService.buildSconeDockerEnv(secureSessionId + "/post-compute",
@@ -290,6 +270,25 @@ private boolean runNonTeePostCompute(TaskDescription taskDescription) {
290270
return true;
291271
}
292272

273+
public ComputedFile getComputedFile(String chainTaskId) {
274+
ComputedFile computedFile = IexecFileHelper.readComputedFile(chainTaskId,
275+
workerConfigService.getTaskOutputDir(chainTaskId));
276+
if (computedFile == null) {
277+
log.error("Failed to getComputedFile (computed.json missing)[chainTaskId:{}]", chainTaskId);
278+
return null;
279+
}
280+
if (computedFile.getResultDigest() == null || computedFile.getResultDigest().isEmpty()){
281+
String resultDigest = computeResultDigest(computedFile);
282+
if (resultDigest.isEmpty()){
283+
log.error("Failed to getComputedFile (resultDigest is empty but cant compute it)" +
284+
"[chainTaskId:{}, computedFile:{}]", chainTaskId, computedFile);
285+
return null;
286+
}
287+
computedFile.setResultDigest(resultDigest);
288+
}
289+
return computedFile;
290+
}
291+
293292
private String computeResultDigest(ComputedFile computedFile) {
294293
String chainTaskId = computedFile.getTaskId() ;
295294
String resultDigest;

0 commit comments

Comments
 (0)