-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor containerisation 1 (#952) * Introduce Services and Containers on BitriseDataModel * Validate containers * Test containerization config * Fix test names * Log output of failing docker test commands * Update docker tests * Refactor docker test bitrise.ymls * Fix docker-service-start-succeeds-after-retries test * Update models/models_methods.go Co-authored-by: Olivér Falvai <[email protected]> * Strip whitespace before validating container images * Update containerization validation error messages --------- Co-authored-by: Olivér Falvai <[email protected]> * rebase --------- Co-authored-by: Olivér Falvai <[email protected]>
- Loading branch information
Showing
15 changed files
with
989 additions
and
343 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,60 @@ | ||
format_version: 1.3.0 | ||
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git | ||
containers: | ||
invalid-port: | ||
image: frolvlad/alpine-bash:latest | ||
ports: | ||
- 22:22 | ||
valid-port: | ||
image: frolvlad/alpine-bash:latest | ||
ports: | ||
- 12341:12341 | ||
unhealthy-container: | ||
image: frolvlad/alpine-bash:latest | ||
options: --health-cmd "redis-cli ping" --health-interval 1s --health-timeout 3s --health-retries 2 | ||
invalid-option: | ||
image: frolvlad/alpine-bash:latest | ||
options: --invalid-option "fail now!" | ||
workflows: | ||
docker-create-fails-invalid-port: | ||
title: Expected to fail on docker create, invalid port provided | ||
container: | ||
image: frolvlad/alpine-bash:latest | ||
ports: | ||
- 22:22 | ||
steps: | ||
- script: | ||
title: Should not run due to prev error | ||
inputs: | ||
- content: exit 0 | ||
- with: | ||
container: invalid-port | ||
steps: | ||
- script: | ||
title: Should not run due to prev error | ||
inputs: | ||
- content: exit 0 | ||
docker-create-succeeds-valid-port: | ||
title: Expected to pass on docker create, valid port provided | ||
container: | ||
image: frolvlad/alpine-bash:latest | ||
ports: | ||
- 12341:12341 | ||
steps: | ||
- script: | ||
title: Should succeed | ||
inputs: | ||
- content: exit 0 | ||
- with: | ||
container: valid-port | ||
steps: | ||
- script: | ||
title: Should succeed | ||
inputs: | ||
- content: exit 0 | ||
docker-create-succeeds-with-false-unhealthy-container: | ||
title: Expected to log error on docker create | ||
description: Expected to log error on docker create, because healthchecks are wrong, however execution should continue | ||
container: | ||
image: frolvlad/alpine-bash:latest | ||
options: --health-cmd "redis-cli ping" --health-interval 1s --health-timeout 3s --health-retries 2 | ||
steps: | ||
- script: | ||
title: Should succceed | ||
inputs: | ||
- content: exit 0 | ||
- with: | ||
container: unhealthy-container | ||
steps: | ||
- script: | ||
title: Should succceed | ||
inputs: | ||
- content: exit 0 | ||
docker-create-fails-invalid-option: | ||
title: Expected to log error on docker create | ||
description: Expected to log error on docker create, because healthcheck are wrong, however execution should continue | ||
container: | ||
image: frolvlad/alpine-bash:latest | ||
options: --invalid-option "fail now!" | ||
steps: | ||
- script: | ||
title: Should fail | ||
inputs: | ||
- content: exit 0 | ||
- with: | ||
container: invalid-option | ||
steps: | ||
- script: | ||
title: Should fail | ||
inputs: | ||
- content: exit 0 |
108 changes: 108 additions & 0 deletions
108
_tests/integration/docker_multiple_containers_bitrise.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
format_version: 1.3.0 | ||
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git | ||
containers: | ||
step_execution_container: | ||
image: localhost:5001/healthy-image | ||
credentials: | ||
username: $DOCKER_USR_STEP_EXECUTION_CONTAINER | ||
password: $DOCKER_PW_STEP_EXECUTION_CONTAINER | ||
services: | ||
service_1_container: | ||
image: localhost:5002/healthy-image | ||
credentials: | ||
username: $DOCKER_USR_SERVICE_1_CONTAINER | ||
password: $DOCKER_PW_SERVICE_1_CONTAINER | ||
options: --health-cmd "stat /ready || exit 1" --health-interval 1s --health-timeout 3s --health-retries 3 | ||
service_2_container: | ||
image: localhost:5003/healthy-image | ||
credentials: | ||
username: $DOCKER_USR_SERVICE_2_CONTAINER | ||
password: $DOCKER_PW_SERVICE_2_CONTAINER | ||
options: --health-cmd "stat /ready || exit 1" --health-interval 1s --health-timeout 3s --health-retries 3 | ||
workflows: | ||
docker-login-multiple-containers: | ||
before_run: | ||
- _start_mock_registry_for_step_execution_container | ||
- _start_mock_registry_for_service_1_container | ||
- _start_mock_registry_for_service_2_container | ||
after_run: | ||
- _cleanup_mock_registry_for_step_execution_container | ||
- _cleanup_mock_registry_for_service_1_container | ||
- _cleanup_mock_registry_for_service_2_container | ||
title: Expected to pass docker login | ||
steps: | ||
- with: | ||
container: step_execution_container | ||
services: | ||
- service_1_container | ||
- service_2_container | ||
steps: | ||
- script: | ||
title: Should pass | ||
inputs: | ||
- content: exit 0 | ||
_start_mock_registry_for_step_execution_container: | ||
envs: | ||
- PORT: 5001 | ||
- USR: $DOCKER_USR_STEP_EXECUTION_CONTAINER | ||
- PASS: $DOCKER_PW_STEP_EXECUTION_CONTAINER | ||
after_run: | ||
- _start_mock_registry | ||
_start_mock_registry_for_service_1_container: | ||
envs: | ||
- PORT: 5002 | ||
- USR: $DOCKER_USR_SERVICE_1_CONTAINER | ||
- PASS: $DOCKER_PW_SERVICE_1_CONTAINER | ||
after_run: | ||
- _start_mock_registry | ||
_start_mock_registry_for_service_2_container: | ||
envs: | ||
- PORT: 5003 | ||
- USR: $DOCKER_USR_SERVICE_2_CONTAINER | ||
- PASS: $DOCKER_PW_SERVICE_2_CONTAINER | ||
after_run: | ||
- _start_mock_registry | ||
_start_mock_registry: | ||
steps: | ||
- script: | ||
title: setup mock registry for step execution container | ||
inputs: | ||
- content: |- | ||
mkdir auth_$PORT | ||
docker run --entrypoint htpasswd httpd:2 -Bbn $USR $PASS > auth_$PORT/htpasswd | ||
docker pull --platform linux/amd64 registry:latest | ||
docker run -d -p $PORT:5000 --restart always --name registry_$PORT \ | ||
-v "$(pwd)"/auth_$PORT:/auth_$PORT \ | ||
-e "REGISTRY_AUTH=htpasswd" \ | ||
-e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \ | ||
-e REGISTRY_AUTH_HTPASSWD_PATH=/auth_$PORT/htpasswd \ | ||
registry | ||
docker login localhost:$PORT -u $USR -p $PASS | ||
docker build -t healthy-image -f ${SRC_DIR_IN_GOPATH}/_tests/integration/docker_test.Dockerfile.healthy-container . | ||
docker tag healthy-image localhost:$PORT/healthy-image | ||
docker push localhost:$PORT/healthy-image | ||
docker logout localhost:$PORT | ||
_cleanup_mock_registry_for_step_execution_container: | ||
envs: | ||
- PORT: 5001 | ||
after_run: | ||
- _cleanup_mock_registry | ||
_cleanup_mock_registry_for_service_1_container: | ||
envs: | ||
- PORT: 5002 | ||
after_run: | ||
- _cleanup_mock_registry | ||
_cleanup_mock_registry_for_service_2_container: | ||
envs: | ||
- PORT: 5003 | ||
after_run: | ||
- _cleanup_mock_registry | ||
_cleanup_mock_registry: | ||
steps: | ||
- script: | ||
is_always_run: true | ||
title: cleanup mock registry | ||
inputs: | ||
- content: |- | ||
docker stop registry_$PORT | ||
docker rm registry_$PORT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
envs: | ||
- DOCKER_USR_STEP_EXECUTION_CONTAINER: test_usr_step_execution_container | ||
- DOCKER_PW_STEP_EXECUTION_CONTAINER: test_pwd_step_execution_container | ||
- DOCKER_USR_SERVICE_1_CONTAINER: test_usr_service_1_container | ||
- DOCKER_PW_SERVICE_1_CONTAINER: test_pwd_service_1_container | ||
- DOCKER_USR_SERVICE_2_CONTAINER: test_usr_service_2_container | ||
- DOCKER_PW_SERVICE_2_CONTAINER: test_pwd_service_2_container |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
FROM frolvlad/alpine-bash:latest | ||
CMD ["bash", "-c", "sleep 3; touch /ready; echo 'Im healthy now'; sleep infinity"] |
Oops, something went wrong.