add test for hijacked one-off build
#138350035]
@@ -46,7 +46,7 @@ var _ = Describe("[#129726125] Hijacked containers", func() {
return
}
- It("does not delete hijacked containers from the database, and sets a 5 minute TTL on the container in garden", func() {
+ It("does not delete hijacked build containers from the database, and sets a 5 minute TTL on the container in garden", func() {
By("setting the pipeline that has a build")
fly("set-pipeline", "-n", "-c", "pipelines/task-waiting.yml", "-p", "hijacked-containers-test")
@@ -63,6 +63,7 @@ var _ = Describe("[#129726125] Hijacked containers", func() {
"-b", "1",
"-s", "simple-task",
"touch", "/tmp/stop-waiting",
+ "and", "sleep", "3600",
)
By("triggering a new build")
@@ -87,6 +88,33 @@ var _ = Describe("[#129726125] Hijacked containers", func() {
Eventually(getContainer, 10*time.Minute, 30*time.Second).Should(Equal(hijackedContainerResult{false, false}))
})
+
+ It("does not delete hijacked one-off build containers from the database, and sets a 5 minute TTL on the container in garden", func() {
+ By("triggering a one-off build")
+ buildSession := spawnFly("execute", "-c", "tasks/wait.yml")
+ Eventually(buildSession).Should(gbytes.Say("waiting for /tmp/stop-waiting"))
+
+ By("hijacking into the build container")
+ hijackSession := spawnFlyInteractive(
+ bytes.NewBufferString("3\n"),
+ "hijack",
+ "-b", "1",
+ "touch", "/tmp/stop-waiting",
+ "and", "sleep", "3600",
+ )
+
+ By("waiting for build to finish")
+ <-buildSession.Exited
+
+ By("verifying the hijacked container exists via fly and Garden")
+ Consistently(getContainer, 2*time.Minute, 30*time.Second).Should(Equal(hijackedContainerResult{true, true}))
+
+ By("unhijacking and seeing the container removed via fly/Garden after 5 minutes")
+ hijackSession.Terminate()
+ <-hijackSession.Exited
+
+ Eventually(getContainer, 10*time.Minute, 30*time.Second).Should(Equal(hijackedContainerResult{false, false}))
+ })
})
type hijackedContainerResult struct {
