Skip to content
Permalink
Browse files

Make Agent create the jobs folder rather than expecting it to exist

  • Loading branch information...
mprimi committed Oct 23, 2018
1 parent 237f3ee commit 5dc3d837063e7785597abaaa12c60c2237bbca51
@@ -187,14 +187,10 @@ private void createJobDirectory(
) throws SetUpJobException {
final File parentDir = jobDirectory.getParentFile();

if (!parentDir.exists() || !parentDir.isDirectory()) {
throw new SetUpJobException("Invalid destination for job directory: " + parentDir);
} else if (!parentDir.isAbsolute()) {
throw new SetUpJobException("Job directory parent path is not absolute: " + parentDir);
}

if (jobDirectory.exists()) {
throw new SetUpJobException("Job directory already exists: " + jobDirectory);
try {
Files.createDirectories(parentDir.toPath());
} catch (final IOException e) {
throw new SetUpJobException("Failed to create jobs directory", e);
}

try {
@@ -393,60 +393,6 @@ class SetUpJobActionSpec extends Specification {
e.getCause().getClass() == SetUpJobException
}

def "Non-existent job directory parent"() {
setup:

when:
action.executeStateAction(executionContext)

then:
2 * executionContext.getClaimedJobId() >> jobId
1 * heartbeatService.start(jobId)
1 * killService.start(jobId)
1 * executionContext.getCurrentJobStatus() >> jobStatus
1 * agentJobService.changeJobStatus(jobId, jobStatus, JobStatus.INIT, _ as String)
1 * executionContext.getJobSpecification() >> spec
1 * spec.getJobDirectoryLocation() >> new File(temporaryFolder.getRoot(), "nonexistent")
def e = thrown(RuntimeException)
e.getCause().getClass() == SetUpJobException
}

def "Invalid job directory parent"() {
setup:

when:
action.executeStateAction(executionContext)

then:
2 * executionContext.getClaimedJobId() >> jobId
1 * heartbeatService.start(jobId)
1 * killService.start(jobId)
1 * executionContext.getCurrentJobStatus() >> jobStatus
1 * agentJobService.changeJobStatus(jobId, jobStatus, JobStatus.INIT, _ as String)
1 * executionContext.getJobSpecification() >> spec
1 * spec.getJobDirectoryLocation() >> temporaryFolder.newFile()
def e = thrown(RuntimeException)
e.getCause().getClass() == SetUpJobException
}

def "Relative job directory parent"() {
setup:

when:
action.executeStateAction(executionContext)

then:
2 * executionContext.getClaimedJobId() >> jobId
1 * heartbeatService.start(jobId)
1 * killService.start(jobId)
1 * executionContext.getCurrentJobStatus() >> jobStatus
1 * agentJobService.changeJobStatus(jobId, jobStatus, JobStatus.INIT, _ as String)
1 * executionContext.getJobSpecification() >> spec
1 * spec.getJobDirectoryLocation() >> new File(".")
def e = thrown(RuntimeException)
e.getCause().getClass() == SetUpJobException
}

def "Existing job directory"() {
setup:
temporaryFolder.newFolder(jobId)

0 comments on commit 5dc3d83

Please sign in to comment.
You can’t perform that action at this time.