Skip to content
This repository has been archived by the owner on Oct 22, 2023. It is now read-only.

Commit

Permalink
Add test case for dependency that takes a long time to become healthy.
Browse files Browse the repository at this point in the history
This currently fails on Linux due to
square/okhttp#4233.
  • Loading branch information
charleskorn committed Sep 23, 2018
1 parent 990acce commit 70cb24a
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
Copyright 2017-2018 Charles Korn.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package batect.journeytests

import batect.journeytests.testutils.ApplicationRunner
import batect.journeytests.testutils.itCleansUpAllContainersItCreates
import batect.journeytests.testutils.itCleansUpAllNetworksItCreates
import com.natpryce.hamkrest.assertion.assertThat
import com.natpryce.hamkrest.containsSubstring
import com.natpryce.hamkrest.equalTo
import org.jetbrains.spek.api.Spek
import org.jetbrains.spek.api.dsl.given
import org.jetbrains.spek.api.dsl.it
import org.jetbrains.spek.api.dsl.on

object TaskWithSlowHealthyDependencyJourneyTest : Spek({
given("a task with a healthy dependency that takes a long time to become healthy") {
val runner = ApplicationRunner("task-with-slow-healthy-dependency")

on("running that task") {
val result = runner.runApplication(listOf("the-task"))

it("displays the output from that task") {
assertThat(result.output, containsSubstring("Started!"))
}

it("returns the exit code from that task") {
assertThat(result.exitCode, equalTo(0))
}

itCleansUpAllContainersItCreates(result)
itCleansUpAllNetworksItCreates(result)
}
}
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
project_name: task-with-slow-healthy-dependency-test

containers:
build-env:
image: alpine:3.7

dependency:
build_directory: dependency


tasks:
the-task:
run:
container: build-env
command: "sh -c 'echo Started!'"
dependencies:
- dependency
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM alpine:3.7

COPY health-check.sh /tools/

HEALTHCHECK --interval=2s --timeout=15s --retries=1 CMD /tools/health-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env sh

set -e

sleep 11
exit 0

0 comments on commit 70cb24a

Please sign in to comment.