Skip to content

Commit

Permalink
Explicity flushing and closing the writer before executing the run.sh…
Browse files Browse the repository at this point in the history
… script.
  • Loading branch information
amitsharmaak committed Mar 14, 2016
1 parent 4862401 commit 2ecca53
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ public void executeTask(
log.info("Executing Job Kickoff Task in the workflow.");
super.executeTask(context);

// At this point all contents are written to the run script and we call an explicit flush and close to write
// the contents to the file before we execute it.
try {
writer.flush();
writer.close();
} catch (IOException e) {
throw new GenieServerException("Failed to execute job with exception." + e);
}

final String runScript = this.jobWorkingDirectory
+ JobConstants.FILE_PATH_DELIMITER
+ JobConstants.GENIE_JOB_LAUNCHER_SCRIPT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@
import com.netflix.genie.core.jpa.repositories.JpaJobRepository;
import com.netflix.genie.core.jpa.repositories.JpaJobRequestRepository;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.SystemUtils;
import org.hamcrest.Matchers;
import org.junit.After;
import org.junit.Assert;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -366,6 +368,7 @@ public void cleanup() {
*/
@Test
public void testSubmitJobMethod() throws Exception {
Assume.assumeTrue(SystemUtils.IS_OS_UNIX);
final String commandArgs = "-c 'echo hello world'";

final List<ClusterCriteria> clusterCriteriaList = new ArrayList<>();
Expand Down Expand Up @@ -502,6 +505,7 @@ public void testSubmitJobMethod() throws Exception {
*/
@Test
public void testSubmitJobMethodAlreadyExists() throws Exception {
Assume.assumeTrue(SystemUtils.IS_OS_UNIX);
final String commandArgs = "-c 'echo hello world'";

final List<ClusterCriteria> clusterCriteriaList = new ArrayList<>();
Expand Down Expand Up @@ -579,6 +583,7 @@ public void testSubmitJobMethodAlreadyExists() throws Exception {
*/
@Test
public void testSubmitJobMethodMissingCluster() throws Exception {
Assume.assumeTrue(SystemUtils.IS_OS_UNIX);
final String commandArgs = "-c 'echo hello world'";

final List<ClusterCriteria> clusterCriteriaList = new ArrayList<>();
Expand Down Expand Up @@ -621,6 +626,7 @@ public void testSubmitJobMethodMissingCluster() throws Exception {
*/
@Test
public void testSubmitJobMethodMissingCommand() throws Exception {
Assume.assumeTrue(SystemUtils.IS_OS_UNIX);
final String commandArgs = "-c 'echo hello world'";

final List<ClusterCriteria> clusterCriteriaList = new ArrayList<>();
Expand Down Expand Up @@ -662,6 +668,7 @@ public void testSubmitJobMethodMissingCommand() throws Exception {
*/
// @Test
// public void testSubmitJobMethodKill() throws Exception {
// Assume.assumeTrue(SystemUtils.IS_OS_UNIX);
// final String commandArgs = "-c 'ls foo'";
//
// final List<ClusterCriteria> clusterCriteriaList = new ArrayList<>();
Expand Down Expand Up @@ -724,6 +731,7 @@ public void testSubmitJobMethodMissingCommand() throws Exception {
*/
@Test
public void testSubmitJobMethodFailure() throws Exception {
Assume.assumeTrue(SystemUtils.IS_OS_UNIX);
final String commandArgs = "-c 'exit 1'";

final List<ClusterCriteria> clusterCriteriaList = new ArrayList<>();
Expand Down

0 comments on commit 2ecca53

Please sign in to comment.