Skip to content
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
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: '2'
services:
tests:
image: buildkite/plugin-tester:v4.0.0
image: buildkite/plugin-tester:v4.1.0
volumes:
- ".:/plugin"
2 changes: 1 addition & 1 deletion tests/build.bats
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bats

load '/usr/local/lib/bats/load.bash'
load "${BATS_PLUGIN_PATH}/load.bash"
load '../lib/shared'

# export DOCKER_COMPOSE_STUB_DEBUG=/dev/stdout
Expand Down
4 changes: 2 additions & 2 deletions tests/cleanup.bats
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bats

load '/usr/local/lib/bats/load.bash'
load "${BATS_PLUGIN_PATH}/load.bash"
load '../lib/shared'
load '../lib/run'

Expand All @@ -21,7 +21,7 @@ load '../lib/run'
"-f docker-compose.yml -p buildkite1111 rm --force -v : echo removing stopped containers" \
"-f docker-compose.yml -p buildkite1111 down --remove-orphans --volumes : echo removing everything"

run $PWD/hooks/pre-exit
run "$PWD"/hooks/pre-exit

assert_success
assert_output --partial "Cleaning up after docker-compose"
Expand Down
14 changes: 6 additions & 8 deletions tests/docker-compose-cleanup.bats
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
#!/usr/bin/env bats

load '/usr/local/lib/bats/load.bash'
load "${BATS_PLUGIN_PATH}/load.bash"
load '../lib/shared'
load '../lib/run'

@test "Default cleanup of docker-compose" {
setup () {
run_docker_compose() {
# shellcheck disable=2317 # funtion used by loaded scripts
echo "$@"
}
}

@test "Default cleanup of docker-compose" {
run compose_cleanup

assert_success
Expand All @@ -18,9 +22,6 @@ load '../lib/run'

@test "Possible to gracefully shutdown containers in docker-compose cleanup" {
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_GRACEFUL_SHUTDOWN=1
run_docker_compose() {
echo "$@"
}
run compose_cleanup

assert_success
Expand All @@ -31,9 +32,6 @@ load '../lib/run'

@test "Possible to skip volume destruction in docker-compose cleanup" {
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_LEAVE_VOLUMES=1
run_docker_compose() {
echo "$@"
}
run compose_cleanup

assert_success
Expand Down
2 changes: 1 addition & 1 deletion tests/docker-compose-config.bats
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bats

load '/usr/local/lib/bats/load.bash'
load "${BATS_PLUGIN_PATH}/load.bash"
load '../lib/shared'

@test "Read docker-compose config when none exists" {
Expand Down
2 changes: 1 addition & 1 deletion tests/docker-compose-images.bats
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# export DOCKER_COMPOSE_STUB_DEBUG=/dev/tty

load '/usr/local/lib/bats/load.bash'
load "${BATS_PLUGIN_PATH}/load.bash"
load '../lib/shared'
load '../lib/push'

Expand Down
2 changes: 1 addition & 1 deletion tests/docker-compose-verbosity.bats
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bats

load '/usr/local/lib/bats/load.bash'
load "${BATS_PLUGIN_PATH}/load.bash"
load '../lib/shared'
load '../lib/run'

Expand Down
2 changes: 1 addition & 1 deletion tests/image-override-file.bats
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bats

load '/usr/local/lib/bats/load.bash'
load "${BATS_PLUGIN_PATH}/load.bash"
load '../lib/shared'

myservice_override_file1=$(cat <<-EOF
Expand Down
28 changes: 8 additions & 20 deletions tests/logs.bats
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
#!/usr/bin/env bats

load '/usr/local/lib/bats/load.bash'
load "${BATS_PLUGIN_PATH}/load.bash"
load '../lib/run'
load '../lib/shared'

# export DOCKER_PS_BY_PROJECT_STUB_DEBUG=/dev/tty
# export CHECK_LINKED_CONTAINERS_AND_SAVE_LOGS_STUB_DEBUG=/dev/tty
# export DOCKER_STUB_DEBUG=/dev/tty

@test "Upload log settings: on-error" {
export LOG_DIR="docker-compose-logs"

setup () {
function docker_ps_by_project() {
# shellcheck disable=2317 # funtion used by loaded scripts
cat tests/fixtures/id-service-multiple-services.txt
}

function plugin_prompt_and_run() {
# shellcheck disable=2317 # funtion used by loaded scripts
echo "ran plugin_prompt_and_run"
}
}

@test "Upload log settings: on-error" {
export LOG_DIR="docker-compose-logs"

stub docker \
"inspect --format={{.State.ExitCode}} 456456 : echo 1" \
Expand All @@ -36,14 +40,6 @@ load '../lib/shared'
@test "Upload log settings: always" {
export LOG_DIR="docker-compose-logs"

function docker_ps_by_project() {
cat tests/fixtures/id-service-multiple-services.txt
}

function plugin_prompt_and_run() {
echo "ran plugin_prompt_and_run"
}

stub docker \
"inspect --format={{.State.ExitCode}} 456456 : echo 1" \
"logs -t 456456 : echo got logs for failed" \
Expand All @@ -62,14 +58,6 @@ load '../lib/shared'
@test "Upload log settings: never" {
export LOG_DIR="docker-compose-logs"

function docker_ps_by_project() {
cat tests/fixtures/id-service-multiple-services.txt
}

function plugin_prompt_and_run() {
echo "ran plugin_prompt_and_run"
}

run check_linked_containers_and_save_logs \
"main" "/tmp/docker-compose-logs" "never"

Expand Down
2 changes: 1 addition & 1 deletion tests/metadata.bats
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# export BUILDKITE_AGENT_STUB_DEBUG=/dev/tty

load '/usr/local/lib/bats/load.bash'
load "${BATS_PLUGIN_PATH}/load.bash"
load '../lib/shared'
load '../lib/metadata'

Expand Down
10 changes: 5 additions & 5 deletions tests/multiple-commands.bats
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bats

load '/usr/local/lib/bats/load.bash'
load "${BATS_PLUGIN_PATH}/load.bash"
load '../lib/shared'
load '../lib/metadata'

Expand Down Expand Up @@ -37,7 +37,7 @@ setup_file() {
"meta-data exists docker-compose-plugin-built-image-tag-myservice : test -f /tmp/build-run-metadata" \
"meta-data get docker-compose-plugin-built-image-tag-myservice : cat /tmp/build-run-metadata"

run $PWD/hooks/command
run "$PWD"/hooks/command

assert_success
assert_output --partial "Building services myservice"
Expand Down Expand Up @@ -73,7 +73,7 @@ setup_file() {
"pull my.repository/llamas:test-myservice-build-1 : echo pulled pre-built image" \
"tag my.repository/llamas:test-myservice-build-1 buildkite12_myservice : echo re-tagged pre-built image"

run $PWD/hooks/command
run "$PWD"/hooks/command

assert_success

Expand Down Expand Up @@ -104,7 +104,7 @@ setup_file() {
"meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 1" \
"meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 1"

run $PWD/hooks/command
run "$PWD"/hooks/command

assert_success

Expand Down Expand Up @@ -142,7 +142,7 @@ setup_file() {
"pull myservice-tag : echo pulled pre-built image" \
"tag myservice-tag buildkite12_myservice : echo re-tagged pre-built image"

run $PWD/hooks/command
run "$PWD"/hooks/command

assert_success

Expand Down
10 changes: 5 additions & 5 deletions tests/output.bats
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bats

load '/usr/local/lib/bats/load.bash'
load "${BATS_PLUGIN_PATH}/load.bash"
load '../lib/shared'
load '../lib/run'

Expand Down Expand Up @@ -45,7 +45,7 @@ setup_file() {
"logs -t 456456 : exit 0" \
"inspect --format={{.State.ExitCode}} 789789 : echo 0"

run $PWD/hooks/command
run "$PWD"/hooks/command

assert_success
assert_output --partial "built myservice"
Expand Down Expand Up @@ -89,7 +89,7 @@ setup_file() {
"logs -t 456456 : exit 0" \
"inspect --format={{.State.ExitCode}} 789789 : echo 0"

run $PWD/hooks/command
run "$PWD"/hooks/command

assert_failure
assert_output --partial "built myservice"
Expand Down Expand Up @@ -128,7 +128,7 @@ setup_file() {
"inspect --format={{.State.ExitCode}} 456456 : echo 0" \
"inspect --format={{.State.ExitCode}} 789789 : echo 0"

run $PWD/hooks/command
run "$PWD"/hooks/command

assert_success
assert_output --partial "built myservice"
Expand Down Expand Up @@ -168,7 +168,7 @@ setup_file() {
"ps -a --filter label=com.docker.compose.project=buildkite1111 -q : echo" \
"ps -a --filter label=com.docker.compose.project=buildkite1111 --format '{{.ID}}\\t{{.Label \"com.docker.compose.service\"}}' : cat tests/fixtures/id-service-no-services.txt"

run $PWD/hooks/command
run "$PWD"/hooks/command

assert_success
assert_output --partial "built myservice"
Expand Down
2 changes: 1 addition & 1 deletion tests/plugin-config.bats
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bats

load '/usr/local/lib/bats/load.bash'
load "${BATS_PLUGIN_PATH}/load.bash"
load '../lib/shared'

@test "Read existing config without default" {
Expand Down
2 changes: 1 addition & 1 deletion tests/project-name.bats
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bats

load '/usr/local/lib/bats/load.bash'
load "${BATS_PLUGIN_PATH}/load.bash"
load '../lib/shared'

@test "Project name comes from BUILDKITE_JOB_ID" {
Expand Down
14 changes: 7 additions & 7 deletions tests/push.bats
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bats

load '/usr/local/lib/bats/load.bash'
load "${BATS_PLUGIN_PATH}/load.bash"
load '../lib/shared'

# export DOCKER_COMPOSE_STUB_DEBUG=/dev/tty
Expand All @@ -24,7 +24,7 @@ load '../lib/shared'
stub docker \
"image inspect somewhere.dkr.ecr.some-region.amazonaws.com/blah : exit 0"

run $PWD/hooks/command
run "$PWD"/hooks/command

assert_success
assert_output --partial ":warning: Skipping build"
Expand Down Expand Up @@ -59,7 +59,7 @@ load '../lib/shared'
"meta-data exists docker-compose-plugin-built-image-tag-myservice1 : exit 1" \
"meta-data exists docker-compose-plugin-built-image-tag-myservice2 : exit 1"

run $PWD/hooks/command
run "$PWD"/hooks/command

assert_success
assert_output --partial "tagging image1"
Expand Down Expand Up @@ -90,7 +90,7 @@ load '../lib/shared'
"meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 0" \
"meta-data get docker-compose-plugin-built-image-tag-myservice : echo myimage"

run $PWD/hooks/command
run "$PWD"/hooks/command

assert_success
assert_output --partial "pulled prebuilt image"
Expand All @@ -110,7 +110,7 @@ load '../lib/shared'
stub docker-compose \
"-f docker-compose.yml -p buildkite1111 config : echo blah"

run $PWD/hooks/command
run "$PWD"/hooks/command

assert_success
refute_output --partial "pulled prebuilt image"
Expand Down Expand Up @@ -152,7 +152,7 @@ load '../lib/shared'
"meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 0" \
"meta-data get docker-compose-plugin-built-image-tag-myservice : echo prebuilt"

run $PWD/hooks/command
run "$PWD"/hooks/command

assert_success
assert_output --partial "pulled prebuilt image"
Expand Down Expand Up @@ -185,7 +185,7 @@ load '../lib/shared'
"tag buildkite1111_helper my.repository/helper:llamas : echo tagged helper" \
"push my.repository/helper:llamas : echo pushed helper"

run $PWD/hooks/command
run "$PWD"/hooks/command

assert_success
assert_output --partial "built helper"
Expand Down
2 changes: 1 addition & 1 deletion tests/run.bats
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bats

load '/usr/local/lib/bats/load.bash'
load "${BATS_PLUGIN_PATH}/load.bash"
load '../lib/shared'
load '../lib/run'

Expand Down
2 changes: 1 addition & 1 deletion tests/v2/build.bats
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bats

load '/usr/local/lib/bats/load.bash'
load "${BATS_PLUGIN_PATH}/load.bash"
load '../../lib/shared'

# export DOCKER_COMPOSE_STUB_DEBUG=/dev/stdout
Expand Down
Loading