Skip to content

Commit

Permalink
Fix testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
lukfor committed Nov 12, 2023
1 parent 6c7fed0 commit b269c9b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
13 changes: 10 additions & 3 deletions src/test/java/cloudgene/mapred/jobs/WorkflowEngineTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.List;
import java.util.Map;

import cloudgene.mapred.jobs.workspace.IWorkspace;
import org.junit.jupiter.api.Test;

import cloudgene.mapred.TestApplication;
Expand Down Expand Up @@ -470,10 +471,10 @@ public void testWriteTextToStdOutStep() throws Exception {

assertEquals(AbstractJob.STATE_SUCCESS, job.getState());

String stdout = FileUtil.path(application.getSettings().getLocalWorkspace(), job.getId(), "std.out");
String stdout = FileUtil.path(application.getSettings().getLocalWorkspace(), job.getId(), "logs", "std.out");
String contentStdOut = FileUtil.readFileAsString(stdout);

String log = FileUtil.path(application.getSettings().getLocalWorkspace(), job.getId(), "job.txt");
String log = FileUtil.path(application.getSettings().getLocalWorkspace(), job.getId(), "logs", "job.txt");
String contentlog = FileUtil.readFileAsString(log);

assertTrue(contentStdOut.contains("taks write to system out"));
Expand Down Expand Up @@ -670,10 +671,16 @@ public CloudgeneJob createJobFromWdl(WdlApp app, Map<String, String> inputs, Use
String localWorkspace = FileUtil.path(settings.getLocalWorkspace(), id);
FileUtil.createDirectory(localWorkspace);


// setup workspace
IWorkspace workspace = workspaceFactory.getDefault();
workspace.setJob(id);
workspace.setup();

CloudgeneJob job = new CloudgeneJob(user, id, app, inputs);
job.setId(id);
job.setName(id);
job.setWorkspace(workspaceFactory.getDefault());
job.setWorkspace(workspace);
job.setLocalWorkspace(localWorkspace);
job.setSettings(settings);
job.setApplication(app.getName() + " " + app.getVersion());
Expand Down
12 changes: 9 additions & 3 deletions src/test/java/cloudgene/mapred/steps/TestCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.List;
import java.util.Map;

import cloudgene.mapred.jobs.workspace.IWorkspace;
import org.junit.jupiter.api.Test;

import cloudgene.mapred.TestApplication;
Expand Down Expand Up @@ -57,13 +58,13 @@ public void testValidCommand() throws Exception {
assertEquals(messages.get(0).getType(), WorkflowContext.OK);
assertTrue(messages.get(0).getMessage().contains("Execution successful."));

String stdout = FileUtil.path(application.getSettings().getLocalWorkspace(), job.getId(), "std.out");
String stdout = FileUtil.path(application.getSettings().getLocalWorkspace(), job.getId(), "logs", "std.out");
String contentStdOut = FileUtil.readFileAsString(stdout);

// simple ls result check
assertTrue(contentStdOut.contains("invalid-command.yaml"));

String jobLog = FileUtil.path(application.getSettings().getLocalWorkspace(), job.getId(), "job.txt");
String jobLog = FileUtil.path(application.getSettings().getLocalWorkspace(), job.getId(), "logs", "job.txt");
String contentjobLog = FileUtil.readFileAsString(jobLog);

// simple check if exit code = 0
Expand Down Expand Up @@ -139,9 +140,14 @@ public CloudgeneJob createJobFromWdl(WdlApp app, Map<String, String> inputs) thr
String localWorkspace = FileUtil.path(settings.getLocalWorkspace(), id);
FileUtil.createDirectory(localWorkspace);

// setup workspace
IWorkspace workspace = workspaceFactory.getDefault();
workspace.setJob(id);
workspace.setup();

CloudgeneJob job = new CloudgeneJob(user, id, app, inputs);
job.setId(id);
job.setWorkspace(workspaceFactory.getDefault());
job.setWorkspace(workspace);
job.setName(id);
job.setLocalWorkspace(localWorkspace);
job.setSettings(settings);
Expand Down

0 comments on commit b269c9b

Please sign in to comment.