Skip to content
Open
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
38 changes: 26 additions & 12 deletions scripts/integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@ function usage() {
integration.sh --github-token <token> [OPTIONS]
Runs the integration tests.
OPTIONS
--help -h prints the command usage
--github-token <token> GitHub token to use when making API requests
--platform <cf|docker> Switchblade platform to execute the tests against
--help -h prints the command usage
--github-token <token> GitHub token to use when making API requests
--platform <cf|docker> Switchblade platform to execute the tests against
--keep-failed-containers Preserve failed test containers for debugging (default: false)
USAGE
}

function main() {
local src stack platform token cached parallel
local src stack platform token cached parallel keep_failed
src="$(find "${ROOTDIR}/src" -mindepth 1 -maxdepth 1 -type d )"
stack="${CF_STACK:-$(jq -r -S .stack "${ROOTDIR}/config.json")}"
platform="cf"
keep_failed="false"

while [[ "${#}" != 0 ]]; do
case "${1}" in
Expand All @@ -52,6 +54,11 @@ function main() {
shift 2
;;

--keep-failed-containers)
keep_failed="true"
shift 1
;;

--help|-h)
shift 1
usage
Expand Down Expand Up @@ -94,31 +101,37 @@ function main() {

echo "Running integration suite (cached: ${cached}, parallel: ${parallel})"

specs::run "${cached}" "${parallel}" "${stack}" "${platform}" "${token:-}"
specs::run "${cached}" "${parallel}" "${stack}" "${platform}" "${token:-}" "${keep_failed}"
done
}

function specs::run() {
local cached parallel stack platform token
local cached parallel stack platform token keep_failed
cached="${1}"
parallel="${2}"
stack="${3}"
platform="${4}"
token="${5}"
keep_failed="${6}"

local nodes cached_flag serial_flag platform_flag stack_flag token_flag
local nodes cached_flag serial_flag platform_flag stack_flag token_flag keep_failed_flag
cached_flag="--cached=${cached}"
serial_flag="--serial=true"
platform_flag="--platform=${platform}"
stack_flag="--stack=${stack}"
token_flag="--github-token=${token}"
keep_failed_flag=""
nodes=1

if [[ "${parallel}" == "true" ]]; then
nodes=3
serial_flag=""
fi

if [[ "${keep_failed}" == "true" ]]; then
keep_failed_flag="--keep-failed-containers"
fi

local buildpack_file
buildpack_file="$(buildpack::package "1.2.3" "${cached}" "${stack}")"

Expand All @@ -131,11 +144,12 @@ function specs::run() {
-mod vendor \
-v \
"${src}/integration" \
"${cached_flag}" \
"${platform_flag}" \
"${token_flag}" \
"${stack_flag}" \
"${serial_flag}"
${cached_flag} \
${platform_flag} \
${token_flag} \
${stack_flag} \
${serial_flag} \
${keep_failed_flag}
}

function buildpack::package() {
Expand Down
4 changes: 3 additions & 1 deletion src/ruby/integration/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ func testCache(platform switchblade.Platform, fixtures string) func(*testing.T,
})

it.After(func() {
Expect(platform.Delete.Execute(name)).To(Succeed())
if name != "" && (!settings.KeepFailedContainers || !t.Failed()) {
Expect(platform.Delete.Execute(name)).To(Succeed())
}
})

it("uses the cache for manifest dependencies when deployed twice", func() {
Expand Down
4 changes: 3 additions & 1 deletion src/ruby/integration/default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ func testDefault(platform switchblade.Platform, fixtures string) func(*testing.T
})

it.After(func() {
Expect(platform.Delete.Execute(name)).To(Succeed())
if name != "" && (!settings.KeepFailedContainers || !t.Failed()) {
Expect(platform.Delete.Execute(name)).To(Succeed())
}
})

context("when the ruby version is specified in the app", func() {
Expand Down
14 changes: 8 additions & 6 deletions src/ruby/integration/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,19 @@ var settings struct {
Path string
}

Cached bool
Serial bool
FixturesPath string
GitHubToken string
Platform string
Stack string
Cached bool
Serial bool
KeepFailedContainers bool
FixturesPath string
GitHubToken string
Platform string
Stack string
}

func init() {
flag.BoolVar(&settings.Cached, "cached", false, "run cached buildpack tests")
flag.BoolVar(&settings.Serial, "serial", false, "run serial buildpack tests")
flag.BoolVar(&settings.KeepFailedContainers, "keep-failed-containers", false, "preserve failed test containers for debugging")
flag.StringVar(&settings.Platform, "platform", "cf", `switchblade platform to test against ("cf" or "docker")`)
flag.StringVar(&settings.GitHubToken, "github-token", "", "use the token to make GitHub API requests")
flag.StringVar(&settings.Stack, "stack", "cflinuxfs4", "stack to use as default when pusing apps")
Expand Down
4 changes: 3 additions & 1 deletion src/ruby/integration/multibuildpack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ func testMultiBuildpack(platform switchblade.Platform, fixtures string) func(*te
})

it.After(func() {
Expect(platform.Delete.Execute(name)).To(Succeed())
if name != "" && (!settings.KeepFailedContainers || !t.Failed()) {
Expect(platform.Delete.Execute(name)).To(Succeed())
}
})

context("when ruby is a supply for the binary buildpack", func() {
Expand Down
4 changes: 3 additions & 1 deletion src/ruby/integration/offline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ func testOffline(platform switchblade.Platform, fixtures string) func(*testing.T
})

it.After(func() {
Expect(platform.Delete.Execute(name)).To(Succeed())
if name != "" && (!settings.KeepFailedContainers || !t.Failed()) {
Expect(platform.Delete.Execute(name)).To(Succeed())
}
})

it("runs a vendored cached app", func() {
Expand Down
4 changes: 3 additions & 1 deletion src/ruby/integration/override_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ func testOverride(platform switchblade.Platform, fixtures string) func(*testing.
})

it.After(func() {
Expect(platform.Delete.Execute(name)).To(Succeed())
if name != "" && (!settings.KeepFailedContainers || !t.Failed()) {
Expect(platform.Delete.Execute(name)).To(Succeed())
}
})

it("forces node from override buildpack", func() {
Expand Down
4 changes: 3 additions & 1 deletion src/ruby/integration/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ func testProxy(platform switchblade.Platform, fixtures, uri string) func(*testin
})

it.After(func() {
Expect(platform.Delete.Execute(name)).To(Succeed())
if name != "" && (!settings.KeepFailedContainers || !t.Failed()) {
Expect(platform.Delete.Execute(name)).To(Succeed())
}
})

it("builds an app with the proxy set", func() {
Expand Down
Loading