Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

🐛 : docker runner doesn't work anymore #194

Merged
merged 3 commits into from
Dec 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

<properties>
<java.version>11</java.version>
<jersey.version>2.27</jersey.version>
<junit-jupiter.version>5.5.2</junit-jupiter.version>
<kotlin.version>1.3.61</kotlin.version>
<testcontainers.version>1.12.4</testcontainers.version>
Expand Down Expand Up @@ -147,7 +148,7 @@
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>2.29.1</version>
<version>${jersey.version}</version>
</dependency>

<dependency>
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/io/codeka/gaia/runner/DockerRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ int runContainerForJob(JobWorkflow jobWorkflow, String script) {
return Math.toIntExact(containerExit.statusCode());
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
LOG.error("Interrupted Exception", e);
return 99;
} catch (DockerException | IOException | StackRunnerException e) {
LOG.error("Exception when running job", e);
return 99;
}
}
Expand Down
43 changes: 43 additions & 0 deletions src/test/java/io/codeka/gaia/runner/DockerRunnerIT.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package io.codeka.gaia.runner

import io.codeka.gaia.runner.config.DockerConfig
import io.codeka.gaia.settings.bo.Settings
import io.codeka.gaia.stacks.bo.Job
import io.codeka.gaia.stacks.workflow.JobWorkflow
import org.junit.Assert
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.TestPropertySource

@SpringBootTest(classes = [DockerRunner::class, DockerConfig::class, Settings::class, HttpHijackWorkaround::class])
@EnableConfigurationProperties
@TestPropertySource(properties = ["gaia.dockerDaemonUrl=unix:///var/run/docker.sock"])
class DockerRunnerIT {

@Autowired
private lateinit var dockerRunner: DockerRunner

@Test
fun `runContainerForJob() should work with a simple script`() {
val script = "echo 'Hello World'"

val job = Job()
job.cliVersion = "0.12.18"
val jobWorkflow = JobWorkflow(job)

Assert.assertEquals(0, dockerRunner.runContainerForJob(jobWorkflow, script).toLong())
}

@Test
fun `runContainerForJob() should return the script exit code`() {
val script = "exit 5"

val job = Job()
job.cliVersion = "0.12.18"
val jobWorkflow = JobWorkflow(job)

Assert.assertEquals(5, dockerRunner.runContainerForJob(jobWorkflow, script).toLong())
}
}