Skip to content

Commit

Permalink
plan/example-rust: fix the test with new sdk and optimize build (#1327)
Browse files Browse the repository at this point in the history
* plan/example-rust: speed up build using docker layers

* plan/example-rust: make sure the test ends on success

* plans/example-rust: using latest version

* plans/example-rust: move empty file in Dockerfile

* ci: split tests

* ci: make tests easier to run on dev machines

* ci: add run for examples

* ci: clean and simplify tests

* plan/example-rust: tweak the test to make it pass

* plan/example-rust: skip log parsing in CI test

* ci: compute absolute directory

* ci: preload docker images in examples
  • Loading branch information
laurentsenta committed Jun 14, 2022
1 parent 8f16642 commit 5368947
Show file tree
Hide file tree
Showing 24 changed files with 1,166 additions and 362 deletions.
51 changes: 49 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,19 @@ workflows:
- lint:
requires:
- prepare-tidy
- build-test-linux:
- build-test-linux-test-go:
requires:
- prepare-tidy
- build-test-linux-k8s:
requires:
- prepare-tidy
- build-test-linux-docker:
requires:
- prepare-tidy
- build-test-linux-local:
requires:
- prepare-tidy
- build-test-linux-examples:
requires:
- prepare-tidy
- build-macos:
Expand Down Expand Up @@ -115,7 +127,7 @@ jobs:
name: "make lint"
command: make lint

build-test-linux:
build-test-linux-test-go:
executor: linux
steps:
- setup-install-bins
Expand All @@ -127,19 +139,54 @@ jobs:
command: |
cd $HOME/project
make test-go
build-test-linux-k8s:
executor: linux
steps:
- setup-install-bins
- run:
name: "build testground"
command: make install
- run:
name: "create kind cluster"
command: make kind-cluster
- run:
name: "run cluster:k8s integration tests"
command: make test-integ-cluster-k8s

build-test-linux-docker:
executor: linux
steps:
- setup-install-bins
- run:
name: "build testground"
command: make install
- run:
name: "run local:docker integration tests"
command: make test-integ-local-docker

build-test-linux-local:
executor: linux
steps:
- setup-install-bins
- run:
name: "build testground"
command: make install
- run:
name: "run local:exec integration tests"
command: make test-integ-local-exec

build-test-linux-examples:
executor: linux
steps:
- setup-install-bins
- run:
name: "build testground"
command: make install
- run:
name: "run examples integration tests"
command: make test-integ-examples

build-macos:
macos:
xcode: 13.2.0
Expand Down
17 changes: 11 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,16 @@ test-go:
testground plan import --from ./plans/example
$(call eachmod,go test -p 1 -v $(GOTFLAGS) ./...)

test-integration: test-integ-cluster-k8s test-integ-local-docker test-integ-local-exec
test-integration: test-integ-cluster-k8s test-integ-local-exec test-integ-local-docker test-integ-examples

# Note that in these tests, we override the SYNC_SERVICE env var,
# so that testground connects to the instance exposed with `make kind-cluster`
test-integ-cluster-k8s:
./integration_tests/01_k8s_kind_placebo_ok.sh
./integration_tests/02_k8s_kind_placebo_stall.sh
SYNC_SERVICE_HOST=localhost ./integration_tests/01_k8s_kind_placebo_ok.sh
SYNC_SERVICE_HOST=localhost ./integration_tests/02_k8s_kind_placebo_stall.sh

test-integ-local-exec:
./integration_tests/03_exec_go_placebo_ok.sh

test-integ-local-docker:
./integration_tests/04_docker_placebo_ok.sh
Expand All @@ -60,12 +65,12 @@ test-integ-local-docker:
./integration_tests/09_docker_splitbrain_accept.sh
./integration_tests/10_docker_splitbrain_reject.sh
./integration_tests/11_docker_splitbrain_drop.sh
./integration_tests/12_docker_example-js_pingpong.sh
./integration_tests/13_docker_builder_configuration.sh
./integration_tests/13_02_docker_builder_configuration.sh

test-integ-local-exec:
./integration_tests/03_exec_go_placebo_ok.sh
test-integ-examples:
./integration_tests/example_01_rust.sh
./integration_tests/example_02_js_pingpong.sh

kind-cluster:
kind create cluster --wait 90s
Expand Down
4 changes: 2 additions & 2 deletions env-kind.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ ulimits = [
]

[daemon]
listen = ":8080"
listen = ":8040"

[daemon.scheduler]
task_timeout_min = 5
task_repo_type = "disk"

[client]
endpoint = "http://localhost:8080"
endpoint = "http://localhost:8040"
user = "myname"
39 changes: 22 additions & 17 deletions integration_tests/01_k8s_kind_placebo_ok.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#!/bin/bash

export SYNC_SERVICE_HOST=localhost
my_dir="$(dirname "$0")"
my_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$my_dir/header.sh"

testground plan import --from plans/placebo
testground build single --builder docker:go --plan placebo --wait | tee build.out
testground plan import --from ./plans --name testground

pushd $TEMPDIR

testground build single \
--plan testground/placebo \
--builder docker:go \
--wait | tee build.out
export ARTIFACT=$(awk -F\" '/generated build artifact/ {print $8}' build.out)
docker tag $ARTIFACT testplan:placebo

Expand All @@ -14,19 +18,20 @@ docker tag $ARTIFACT testplan:placebo
# The plan is renamed as `testplan:placebo` because kind will check DockerHub if the tag is `latest`.
kind load docker-image testplan:placebo

pushd $TEMPDIR
testground healthcheck --runner local:docker --fix
testground run single --runner cluster:k8s --builder docker:go --use-build testplan:placebo --instances 1 --plan placebo --testcase ok --collect --wait | tee run.out
RUNID=$(awk '/finished run with ID/ { print $9 }' run.out)
echo "checking run $RUNID"
file $RUNID.tgz
LENGTH=${#RUNID}
test $LENGTH -eq 20
tar -xzvvf $RUNID.tgz
SIZEOUT=$(cat ./"$RUNID"/single/0/run.out | wc -c)
echo "run.out is $SIZEOUT bytes."
SIZEERR=$(cat ./"$RUNID"/single/0/run.err | wc -c)
test $SIZEOUT -gt 0 && test $SIZEERR -eq 0

testground run single \
--plan=testground/placebo \
--testcase=ok \
--builder=docker:go \
--use-build=testplan:placebo \
--runner=cluster:k8s \
--instances=1 \
--collect \
--wait | tee run.out

assert_run_output_is_correct run.out

popd

echo "terminating remaining containers"
Expand Down
28 changes: 22 additions & 6 deletions integration_tests/02_k8s_kind_placebo_stall.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#!/bin/bash

export SYNC_SERVICE_HOST=localhost
my_dir="$(dirname "$0")"
my_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$my_dir/header.sh"

testground plan import --from plans/placebo
testground build single --builder docker:go --plan placebo --wait | tee build.out
testground plan import --from ./plans --name testground

pushd $TEMPDIR

testground build single \
--plan testground/placebo \
--builder docker:go \
--wait | tee build.out
export ARTIFACT=$(awk -F\" '/generated build artifact/ {print $8}' build.out)
docker tag $ARTIFACT testplan:placebo

Expand All @@ -15,13 +19,25 @@ docker tag $ARTIFACT testplan:placebo
kind load docker-image testplan:placebo

testground healthcheck --runner local:docker --fix
testground run single --runner cluster:k8s --builder docker:go --use-build testplan:placebo --instances 2 --plan placebo --testcase stall --wait &

testground run single \
--plan=testground/placebo \
--testcase=stall \
--builder=docker:go \
--use-build=testplan:placebo \
--runner=cluster:k8s \
--instances=2 \
--collect \
--wait&

sleep 20
BEFORE=$(kubectl get pods | grep placebo | grep Running | wc -l)
testground terminate --runner=cluster:k8s
sleep 10
AFTER=$(kubectl get pods | grep placebo | grep Running | wc -l)
test $BEFORE -gt $AFTER

popd

echo "terminating remaining containers"
testground terminate --builder docker:go
31 changes: 16 additions & 15 deletions integration_tests/03_exec_go_placebo_ok.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
#!/bin/bash

my_dir="$(dirname "$0")"
my_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$my_dir/header.sh"

testground plan import --from ./plans --name testground

pushd $TEMPDIR
testground plan import --from plans/placebo
testground run single --runner local:exec --builder exec:go --instances 2 --plan placebo --testcase ok --collect --wait | tee run.out
RUNID=$(awk '/finished run with ID/ { print $9 }' run.out)
echo "checking run $RUNID"
file $RUNID.tgz
LENGTH=${#RUNID}
test $LENGTH -eq 20
tar -xzvvf $RUNID.tgz
SIZEOUT=$(cat ./"$RUNID"/single/0/run.out | wc -c)
echo "run.out is $SIZEOUT bytes."
SIZEERR=$(cat ./"$RUNID"/single/0/run.err | wc -c)
test $SIZEOUT -gt 0 && test $SIZEERR -eq 0

testground run single \
--plan=testground/placebo \
--testcase=ok \
--builder=exec:go \
--runner=local:exec \
--instances=2 \
--collect \
--wait | tee run.out

assert_run_output_is_correct run.out

popd

echo "terminating remaining containers"
testground terminate --runner local:exec
testground terminate --runner local:exec
38 changes: 22 additions & 16 deletions integration_tests/04_docker_placebo_ok.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
#!/bin/bash

my_dir="$(dirname "$0")"
my_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$my_dir/header.sh"

testground plan import --from plans/placebo
testground build single --builder docker:go --plan placebo --wait | tee build.out
testground plan import --from ./plans --name testground

pushd $TEMPDIR

testground build single \
--plan testground/placebo \
--builder docker:go \
--wait | tee build.out
export ARTIFACT=$(awk -F\" '/generated build artifact/ {print $8}' build.out)
docker tag $ARTIFACT testplan:placebo

pushd $TEMPDIR
testground healthcheck --runner local:docker --fix
testground run single --runner local:docker --builder docker:go --use-build testplan:placebo --instances 1 --plan placebo --testcase ok --collect --wait | tee run.out
RUNID=$(awk '/finished run with ID/ { print $9 }' run.out)
echo "checking run $RUNID"
file $RUNID.tgz
LENGTH=${#RUNID}
test $LENGTH -eq 20
tar -xzvvf $RUNID.tgz
SIZEOUT=$(cat ./"$RUNID"/single/0/run.out | wc -c)
echo "run.out is $SIZEOUT bytes."
SIZEERR=$(cat ./"$RUNID"/single/0/run.err | wc -c)
test $SIZEOUT -gt 0 && test $SIZEERR -eq 0

testground run single \
--plan=testground/placebo \
--testcase=ok \
--builder=docker:go \
--use-build=testplan:placebo \
--runner=local:docker \
--instances=1 \
--collect \
--wait | tee run.out

assert_run_output_is_correct run.out

popd

echo "terminating remaining containers"
Expand Down
27 changes: 22 additions & 5 deletions integration_tests/05_docker_placebo_stall.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,39 @@
#!/bin/bash

my_dir="$(dirname "$0")"
my_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$my_dir/header.sh"

testground plan import --from plans/placebo
testground build single --builder docker:go --plan placebo --wait | tee build.out
testground plan import --from ./plans --name testground

pushd $TEMPDIR

testground build single \
--plan testground/placebo \
--builder docker:go \
--wait | tee build.out
export ARTIFACT=$(awk -F\" '/generated build artifact/ {print $8}' build.out)
docker tag $ARTIFACT testplan:placebo

testground healthcheck --runner local:docker --fix
testground run single --runner local:docker --builder docker:go --use-build testplan:placebo --instances 2 --plan placebo --testcase stall --wait &

testground run single \
--plan=testground/placebo \
--testcase=stall \
--builder=docker:go \
--use-build=testplan:placebo \
--runner=local:docker \
--instances=2 \
--collect \
--wait&

sleep 20
BEFORE=$(docker ps | grep placebo | wc -l)
testground terminate --runner=local:docker
sleep 10
AFTER=$(docker ps | grep placebo | wc -l)
test $BEFORE -gt $AFTER

popd

echo "terminating remaining containers"
testground terminate --runner local:docker
testground terminate --builder docker:go

0 comments on commit 5368947

Please sign in to comment.