aboutsummaryrefslogtreecommitdiffstats
path: root/library/recipes/docker_compose/test
diff options
context:
space:
mode:
authorvitalyisaev <vitalyisaev@ydb.tech>2023-11-30 13:26:22 +0300
committervitalyisaev <vitalyisaev@ydb.tech>2023-11-30 15:44:45 +0300
commit0a98fece5a9b54f16afeb3a94b3eb3105e9c3962 (patch)
tree291d72dbd7e9865399f668c84d11ed86fb190bbf /library/recipes/docker_compose/test
parentcb2c8d75065e5b3c47094067cb4aa407d4813298 (diff)
downloadydb-0a98fece5a9b54f16afeb3a94b3eb3105e9c3962.tar.gz
YQ Connector:Use docker-compose in integrational tests
Diffstat (limited to 'library/recipes/docker_compose/test')
-rw-r--r--library/recipes/docker_compose/test/acceptance/data/invalid_test_container_name/Dockerfile2
-rw-r--r--library/recipes/docker_compose/test/acceptance/data/invalid_test_container_name/docker-compose.yml8
-rw-r--r--library/recipes/docker_compose/test/acceptance/data/invalid_test_container_name/test.py5
-rw-r--r--library/recipes/docker_compose/test/acceptance/data/invalid_test_container_name/ya.make24
-rw-r--r--library/recipes/docker_compose/test/acceptance/data/test_container_with_existing_command/Dockerfile2
-rw-r--r--library/recipes/docker_compose/test/acceptance/data/test_container_with_existing_command/docker-compose.yml9
-rw-r--r--library/recipes/docker_compose/test/acceptance/data/test_container_with_existing_command/test.py5
-rw-r--r--library/recipes/docker_compose/test/acceptance/data/test_container_with_existing_command/ya.make24
-rw-r--r--library/recipes/docker_compose/test/acceptance/data/test_container_with_existing_user/Dockerfile2
-rw-r--r--library/recipes/docker_compose/test/acceptance/data/test_container_with_existing_user/docker-compose.yml8
-rw-r--r--library/recipes/docker_compose/test/acceptance/data/test_container_with_existing_user/test.py5
-rw-r--r--library/recipes/docker_compose/test/acceptance/data/test_container_with_existing_user/ya.make24
-rw-r--r--library/recipes/docker_compose/test/acceptance/data/test_recipe_container_exit_0/docker-compose.yml6
-rw-r--r--library/recipes/docker_compose/test/acceptance/data/test_recipe_container_exit_0/srv1/Dockerfile4
-rw-r--r--library/recipes/docker_compose/test/acceptance/data/test_recipe_container_exit_0/srv1/app.py2
-rw-r--r--library/recipes/docker_compose/test/acceptance/data/test_recipe_container_exit_0/srv2/Dockerfile4
-rw-r--r--library/recipes/docker_compose/test/acceptance/data/test_recipe_container_exit_0/srv2/app.py6
-rw-r--r--library/recipes/docker_compose/test/acceptance/data/test_recipe_container_exit_0/test.py2
-rw-r--r--library/recipes/docker_compose/test/acceptance/data/test_recipe_container_exit_0/ya.make21
-rw-r--r--library/recipes/docker_compose/test/acceptance/data/test_recipe_container_fail/docker-compose.yml6
-rw-r--r--library/recipes/docker_compose/test/acceptance/data/test_recipe_container_fail/srv1/Dockerfile4
-rw-r--r--library/recipes/docker_compose/test/acceptance/data/test_recipe_container_fail/srv1/app.py5
-rw-r--r--library/recipes/docker_compose/test/acceptance/data/test_recipe_container_fail/srv2/Dockerfile4
-rw-r--r--library/recipes/docker_compose/test/acceptance/data/test_recipe_container_fail/srv2/app.py6
-rw-r--r--library/recipes/docker_compose/test/acceptance/data/test_recipe_container_fail/test.py2
-rw-r--r--library/recipes/docker_compose/test/acceptance/data/test_recipe_container_fail/ya.make21
-rw-r--r--library/recipes/docker_compose/test/acceptance/test_docker_compose.py92
-rw-r--r--library/recipes/docker_compose/test/acceptance/ya.make40
-rw-r--r--library/recipes/docker_compose/test/ut/context.yml9
-rw-r--r--library/recipes/docker_compose/test/ut/data/dir1/file3.txt0
-rw-r--r--library/recipes/docker_compose/test/ut/data/dir2/file4.txt0
-rw-r--r--library/recipes/docker_compose/test/ut/data/file1.txt0
-rw-r--r--library/recipes/docker_compose/test/ut/data/file2.txt0
-rw-r--r--library/recipes/docker_compose/test/ut/init_dir/init.txt1
-rw-r--r--library/recipes/docker_compose/test/ut/test_docker_context.py31
-rw-r--r--library/recipes/docker_compose/test/ut/ya.make16
-rw-r--r--library/recipes/docker_compose/test/ya.make4
37 files changed, 404 insertions, 0 deletions
diff --git a/library/recipes/docker_compose/test/acceptance/data/invalid_test_container_name/Dockerfile b/library/recipes/docker_compose/test/acceptance/data/invalid_test_container_name/Dockerfile
new file mode 100644
index 0000000000..be2ca6ee27
--- /dev/null
+++ b/library/recipes/docker_compose/test/acceptance/data/invalid_test_container_name/Dockerfile
@@ -0,0 +1,2 @@
+FROM ubuntu:xenial
+ADD . /code
diff --git a/library/recipes/docker_compose/test/acceptance/data/invalid_test_container_name/docker-compose.yml b/library/recipes/docker_compose/test/acceptance/data/invalid_test_container_name/docker-compose.yml
new file mode 100644
index 0000000000..5eef027d27
--- /dev/null
+++ b/library/recipes/docker_compose/test/acceptance/data/invalid_test_container_name/docker-compose.yml
@@ -0,0 +1,8 @@
+version: '3.4'
+services:
+ test:
+ user: $CURRENT_UID
+ build:
+ context: .
+ redis:
+ image: "redis:alpine@sha256:66ccc75f079ab9059c900e9545bbd271bff78a66f94b45827e6901f57fb973f1"
diff --git a/library/recipes/docker_compose/test/acceptance/data/invalid_test_container_name/test.py b/library/recipes/docker_compose/test/acceptance/data/invalid_test_container_name/test.py
new file mode 100644
index 0000000000..980943f48a
--- /dev/null
+++ b/library/recipes/docker_compose/test/acceptance/data/invalid_test_container_name/test.py
@@ -0,0 +1,5 @@
+import os
+
+
+def test_compose_works():
+ assert os.path.exists("/code")
diff --git a/library/recipes/docker_compose/test/acceptance/data/invalid_test_container_name/ya.make b/library/recipes/docker_compose/test/acceptance/data/invalid_test_container_name/ya.make
new file mode 100644
index 0000000000..4e623da45d
--- /dev/null
+++ b/library/recipes/docker_compose/test/acceptance/data/invalid_test_container_name/ya.make
@@ -0,0 +1,24 @@
+PY3TEST()
+
+OWNER(g:yatool)
+
+TEST_SRCS(
+ test.py
+)
+
+# To use docker-compose.yml from another directory, set DOCKER_COMPOSE_FILE variable with Arcadia relative path to the file
+# and do not forget to add the directory to the DATA macro, e.g.:
+# SET(DOCKER_COMPOSE_FILE library/recipes/docker_compose/test/docker-compose-1.yml)
+# DATA(arcadia/library/recipes/docker_compose/test)
+
+SET(DOCKER_TEST_HOST not_existing_container_name)
+
+INCLUDE(${ARCADIA_ROOT}/library/recipes/docker_compose/recipe.inc)
+
+TAG(
+ ya:external
+ ya:force_sandbox
+ ya:dirty
+)
+
+END()
diff --git a/library/recipes/docker_compose/test/acceptance/data/test_container_with_existing_command/Dockerfile b/library/recipes/docker_compose/test/acceptance/data/test_container_with_existing_command/Dockerfile
new file mode 100644
index 0000000000..be2ca6ee27
--- /dev/null
+++ b/library/recipes/docker_compose/test/acceptance/data/test_container_with_existing_command/Dockerfile
@@ -0,0 +1,2 @@
+FROM ubuntu:xenial
+ADD . /code
diff --git a/library/recipes/docker_compose/test/acceptance/data/test_container_with_existing_command/docker-compose.yml b/library/recipes/docker_compose/test/acceptance/data/test_container_with_existing_command/docker-compose.yml
new file mode 100644
index 0000000000..39a25fc869
--- /dev/null
+++ b/library/recipes/docker_compose/test/acceptance/data/test_container_with_existing_command/docker-compose.yml
@@ -0,0 +1,9 @@
+version: '3.4'
+services:
+ test:
+ user: $CURRENT_UID
+ build:
+ context: .
+ command: 'echo "say hello"'
+ redis:
+ image: "redis:alpine@sha256:66ccc75f079ab9059c900e9545bbd271bff78a66f94b45827e6901f57fb973f1"
diff --git a/library/recipes/docker_compose/test/acceptance/data/test_container_with_existing_command/test.py b/library/recipes/docker_compose/test/acceptance/data/test_container_with_existing_command/test.py
new file mode 100644
index 0000000000..980943f48a
--- /dev/null
+++ b/library/recipes/docker_compose/test/acceptance/data/test_container_with_existing_command/test.py
@@ -0,0 +1,5 @@
+import os
+
+
+def test_compose_works():
+ assert os.path.exists("/code")
diff --git a/library/recipes/docker_compose/test/acceptance/data/test_container_with_existing_command/ya.make b/library/recipes/docker_compose/test/acceptance/data/test_container_with_existing_command/ya.make
new file mode 100644
index 0000000000..6ea9fdfc8a
--- /dev/null
+++ b/library/recipes/docker_compose/test/acceptance/data/test_container_with_existing_command/ya.make
@@ -0,0 +1,24 @@
+PY3TEST()
+
+OWNER(g:yatool)
+
+TEST_SRCS(
+ test.py
+)
+
+# To use docker-compose.yml from another directory, set DOCKER_COMPOSE_FILE variable with Arcadia relative path to the file
+# and do not forget to add the directory to the DATA macro, e.g.:
+# SET(DOCKER_COMPOSE_FILE library/recipes/docker_compose/test/docker-compose-1.yml)
+# DATA(arcadia/library/recipes/docker_compose/test)
+
+SET(DOCKER_TEST_HOST test)
+
+INCLUDE(${ARCADIA_ROOT}/library/recipes/docker_compose/recipe.inc)
+
+TAG(
+ ya:external
+ ya:force_sandbox
+ ya:dirty
+)
+
+END()
diff --git a/library/recipes/docker_compose/test/acceptance/data/test_container_with_existing_user/Dockerfile b/library/recipes/docker_compose/test/acceptance/data/test_container_with_existing_user/Dockerfile
new file mode 100644
index 0000000000..be2ca6ee27
--- /dev/null
+++ b/library/recipes/docker_compose/test/acceptance/data/test_container_with_existing_user/Dockerfile
@@ -0,0 +1,2 @@
+FROM ubuntu:xenial
+ADD . /code
diff --git a/library/recipes/docker_compose/test/acceptance/data/test_container_with_existing_user/docker-compose.yml b/library/recipes/docker_compose/test/acceptance/data/test_container_with_existing_user/docker-compose.yml
new file mode 100644
index 0000000000..798539866c
--- /dev/null
+++ b/library/recipes/docker_compose/test/acceptance/data/test_container_with_existing_user/docker-compose.yml
@@ -0,0 +1,8 @@
+version: '3.4'
+services:
+ test:
+ build:
+ context: .
+ user: 'root:root'
+ redis:
+ image: "redis:alpine@sha256:66ccc75f079ab9059c900e9545bbd271bff78a66f94b45827e6901f57fb973f1"
diff --git a/library/recipes/docker_compose/test/acceptance/data/test_container_with_existing_user/test.py b/library/recipes/docker_compose/test/acceptance/data/test_container_with_existing_user/test.py
new file mode 100644
index 0000000000..980943f48a
--- /dev/null
+++ b/library/recipes/docker_compose/test/acceptance/data/test_container_with_existing_user/test.py
@@ -0,0 +1,5 @@
+import os
+
+
+def test_compose_works():
+ assert os.path.exists("/code")
diff --git a/library/recipes/docker_compose/test/acceptance/data/test_container_with_existing_user/ya.make b/library/recipes/docker_compose/test/acceptance/data/test_container_with_existing_user/ya.make
new file mode 100644
index 0000000000..6ea9fdfc8a
--- /dev/null
+++ b/library/recipes/docker_compose/test/acceptance/data/test_container_with_existing_user/ya.make
@@ -0,0 +1,24 @@
+PY3TEST()
+
+OWNER(g:yatool)
+
+TEST_SRCS(
+ test.py
+)
+
+# To use docker-compose.yml from another directory, set DOCKER_COMPOSE_FILE variable with Arcadia relative path to the file
+# and do not forget to add the directory to the DATA macro, e.g.:
+# SET(DOCKER_COMPOSE_FILE library/recipes/docker_compose/test/docker-compose-1.yml)
+# DATA(arcadia/library/recipes/docker_compose/test)
+
+SET(DOCKER_TEST_HOST test)
+
+INCLUDE(${ARCADIA_ROOT}/library/recipes/docker_compose/recipe.inc)
+
+TAG(
+ ya:external
+ ya:force_sandbox
+ ya:dirty
+)
+
+END()
diff --git a/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_exit_0/docker-compose.yml b/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_exit_0/docker-compose.yml
new file mode 100644
index 0000000000..73f93866e9
--- /dev/null
+++ b/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_exit_0/docker-compose.yml
@@ -0,0 +1,6 @@
+version: '3.4'
+services:
+ srv1:
+ build: srv1
+ srv2:
+ build: srv2
diff --git a/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_exit_0/srv1/Dockerfile b/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_exit_0/srv1/Dockerfile
new file mode 100644
index 0000000000..3b871be284
--- /dev/null
+++ b/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_exit_0/srv1/Dockerfile
@@ -0,0 +1,4 @@
+FROM python:3.4-alpine
+ADD . /code
+WORKDIR /code
+CMD ["python", "app.py"]
diff --git a/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_exit_0/srv1/app.py b/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_exit_0/srv1/app.py
new file mode 100644
index 0000000000..244a421fe3
--- /dev/null
+++ b/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_exit_0/srv1/app.py
@@ -0,0 +1,2 @@
+if __name__ == "__main__":
+ pass
diff --git a/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_exit_0/srv2/Dockerfile b/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_exit_0/srv2/Dockerfile
new file mode 100644
index 0000000000..3b871be284
--- /dev/null
+++ b/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_exit_0/srv2/Dockerfile
@@ -0,0 +1,4 @@
+FROM python:3.4-alpine
+ADD . /code
+WORKDIR /code
+CMD ["python", "app.py"]
diff --git a/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_exit_0/srv2/app.py b/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_exit_0/srv2/app.py
new file mode 100644
index 0000000000..cfff70f109
--- /dev/null
+++ b/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_exit_0/srv2/app.py
@@ -0,0 +1,6 @@
+import time
+
+
+if __name__ == "__main__":
+ while True:
+ time.sleep(1)
diff --git a/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_exit_0/test.py b/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_exit_0/test.py
new file mode 100644
index 0000000000..fe819e6c1a
--- /dev/null
+++ b/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_exit_0/test.py
@@ -0,0 +1,2 @@
+def test_simple():
+ return
diff --git a/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_exit_0/ya.make b/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_exit_0/ya.make
new file mode 100644
index 0000000000..01260fb7e5
--- /dev/null
+++ b/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_exit_0/ya.make
@@ -0,0 +1,21 @@
+PY3TEST()
+
+OWNER(g:yatool)
+
+TEST_SRCS(
+ test.py
+)
+
+# To use docker-compose.yml from another directory, set DOCKER_COMPOSE_FILE variable with Arcadia relative path to the file
+# and do not forget to add the directory to the DATA macro, e.g.:
+# SET(DOCKER_COMPOSE_FILE library/recipes/docker_compose/test/docker-compose-1.yml)
+# DATA(arcadia/library/recipes/docker_compose/test)
+
+INCLUDE(${ARCADIA_ROOT}/library/recipes/docker_compose/recipe.inc)
+
+TAG(
+ ya:external
+ ya:force_sandbox
+)
+
+END()
diff --git a/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_fail/docker-compose.yml b/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_fail/docker-compose.yml
new file mode 100644
index 0000000000..73f93866e9
--- /dev/null
+++ b/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_fail/docker-compose.yml
@@ -0,0 +1,6 @@
+version: '3.4'
+services:
+ srv1:
+ build: srv1
+ srv2:
+ build: srv2
diff --git a/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_fail/srv1/Dockerfile b/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_fail/srv1/Dockerfile
new file mode 100644
index 0000000000..3b871be284
--- /dev/null
+++ b/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_fail/srv1/Dockerfile
@@ -0,0 +1,4 @@
+FROM python:3.4-alpine
+ADD . /code
+WORKDIR /code
+CMD ["python", "app.py"]
diff --git a/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_fail/srv1/app.py b/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_fail/srv1/app.py
new file mode 100644
index 0000000000..55b1ce720e
--- /dev/null
+++ b/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_fail/srv1/app.py
@@ -0,0 +1,5 @@
+import sys
+
+
+if __name__ == "__main__":
+ sys.exit(5)
diff --git a/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_fail/srv2/Dockerfile b/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_fail/srv2/Dockerfile
new file mode 100644
index 0000000000..3b871be284
--- /dev/null
+++ b/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_fail/srv2/Dockerfile
@@ -0,0 +1,4 @@
+FROM python:3.4-alpine
+ADD . /code
+WORKDIR /code
+CMD ["python", "app.py"]
diff --git a/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_fail/srv2/app.py b/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_fail/srv2/app.py
new file mode 100644
index 0000000000..cfff70f109
--- /dev/null
+++ b/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_fail/srv2/app.py
@@ -0,0 +1,6 @@
+import time
+
+
+if __name__ == "__main__":
+ while True:
+ time.sleep(1)
diff --git a/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_fail/test.py b/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_fail/test.py
new file mode 100644
index 0000000000..fe819e6c1a
--- /dev/null
+++ b/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_fail/test.py
@@ -0,0 +1,2 @@
+def test_simple():
+ return
diff --git a/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_fail/ya.make b/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_fail/ya.make
new file mode 100644
index 0000000000..01260fb7e5
--- /dev/null
+++ b/library/recipes/docker_compose/test/acceptance/data/test_recipe_container_fail/ya.make
@@ -0,0 +1,21 @@
+PY3TEST()
+
+OWNER(g:yatool)
+
+TEST_SRCS(
+ test.py
+)
+
+# To use docker-compose.yml from another directory, set DOCKER_COMPOSE_FILE variable with Arcadia relative path to the file
+# and do not forget to add the directory to the DATA macro, e.g.:
+# SET(DOCKER_COMPOSE_FILE library/recipes/docker_compose/test/docker-compose-1.yml)
+# DATA(arcadia/library/recipes/docker_compose/test)
+
+INCLUDE(${ARCADIA_ROOT}/library/recipes/docker_compose/recipe.inc)
+
+TAG(
+ ya:external
+ ya:force_sandbox
+)
+
+END()
diff --git a/library/recipes/docker_compose/test/acceptance/test_docker_compose.py b/library/recipes/docker_compose/test/acceptance/test_docker_compose.py
new file mode 100644
index 0000000000..8253f63392
--- /dev/null
+++ b/library/recipes/docker_compose/test/acceptance/test_docker_compose.py
@@ -0,0 +1,92 @@
+# coding: utf-8
+
+import os
+
+import test.tests.common as tests_common
+import yatest.common
+
+
+class TestDockerCompose(tests_common.YaTest):
+
+ def test_run(self):
+ res = self.run_ya_make_test(cwd=yatest.common.source_path("library/recipes/docker_compose/example"), args=["-A", "--test-type", "py3test"])
+ assert res.get_tests_count() == 1
+ assert res.get_suites_count() == 1
+
+ res.verify_test("test.py", "test_compose_works", "OK")
+ for output_type in ['std_out', 'std_err']:
+ assert os.path.exists(os.path.join(
+ res.output_root, "library/recipes/docker_compose/example",
+ "test-results", "py3test", "testing_out_stuff", "containers", "example_redis_1", "container_{}.log".format(output_type)
+ ))
+ assert os.path.exists(os.path.join(
+ res.output_root, "library/recipes/docker_compose/example",
+ "test-results", "py3test", "testing_out_stuff", "containers", "example_web_1", "container_{}.log".format(output_type)
+ ))
+
+ def test_run_with_context(self):
+ res = self.run_ya_make_test(cwd=yatest.common.source_path("library/recipes/docker_compose/example_with_context"), args=["-A", "--test-type", "py3test"])
+ assert res.get_tests_count() == 1
+ assert res.get_suites_count() == 1
+
+ res.verify_test("test.py", "test_compose_works", "OK")
+
+ def test_run_test_in_container(self):
+ with open("stdin", "wb") as stdin:
+ # need to pass stdin as docker-compose exec needs it (it runs `docker exec --interactive`)
+ res = self.run_ya_make_test(
+ cwd=yatest.common.source_path("library/recipes/docker_compose/example_test_container"), args=["-A", "--test-type", "py3test"], stdin=stdin)
+ assert res.get_tests_count() == 1
+ assert res.get_suites_count() == 1
+
+ res.verify_test("test.py", "test_compose_works", "OK")
+
+ def test_invalid_test_container_name(self):
+ res = self.run_ya_make_test(cwd=yatest.common.test_source_path("data/invalid_test_container_name"), args=["-A", "--test-type", "py3test"])
+ assert res.get_tests_count() == 0
+ assert res.get_suites_count() == 1
+ assert "Service with name 'not_existing_container_name' was not found to be setup as a host for running test" in res.err
+
+ def test_container_with_existing_command(self):
+ res = self.run_ya_make_test(cwd=yatest.common.test_source_path("data/test_container_with_existing_command"), args=["-A", "--test-type", "py3test"])
+ assert res.get_tests_count() == 0
+ assert res.get_suites_count() == 1
+ assert "Test hosting service 'test' has `command` section which is not supported by testing framework" in res.err
+
+ def test_container_with_existing_user(self):
+ res = self.run_ya_make_test(cwd=yatest.common.test_source_path("data/test_container_with_existing_user"), args=["-A", "--test-type", "py3test"])
+ assert res.get_tests_count() == 0
+ assert res.get_suites_count() == 1
+ assert "Test hosting service 'test' has `user` section which is not supported by testing framework" in res.err
+
+ def test_run_with_recipe_config(self):
+ with open("stdin", "wb") as stdin:
+ # need to pass stdin as docker-compose exec needs it (it runs `docker exec --interactive`
+ res = self.run_ya_make_test(
+ cwd=yatest.common.source_path("library/recipes/docker_compose/example_with_recipe_config"),
+ args=["-A", "--test-type", "py3test"],
+ stdin=stdin
+ )
+
+ assert res.get_tests_count() == 1
+ assert res.get_suites_count() == 1
+
+ res.verify_test("test.py", "test", "OK")
+
+ assert os.path.exists(os.path.join(
+ res.output_root,
+ "library/recipes/docker_compose/example_with_recipe_config/test-results/py3test/testing_out_stuff/containers/py3test_test_1/output/",
+ "out.txt",
+ ))
+
+ def test_recipe_container_exit_0(self):
+ res = self.run_ya_make_test(cwd=yatest.common.test_source_path("data/test_recipe_container_exit_0"),
+ args=["-A", "--test-type", "py3test"])
+ res.verify_test("test.py", "test_simple", "OK")
+
+ def test_recipe_container_fail(self):
+ res = self.run_ya_make_test(cwd=yatest.common.test_source_path("data/test_recipe_container_fail"),
+ args=["-A", "--test-type", "py3test"])
+ assert "DockerComposeRecipeException" in res.err
+ assert "Has failed containers" in res.err
+ assert "srv1" in res.err
diff --git a/library/recipes/docker_compose/test/acceptance/ya.make b/library/recipes/docker_compose/test/acceptance/ya.make
new file mode 100644
index 0000000000..069ac4257c
--- /dev/null
+++ b/library/recipes/docker_compose/test/acceptance/ya.make
@@ -0,0 +1,40 @@
+
+PY3TEST()
+
+TEST_SRCS(
+ test_docker_compose.py
+)
+
+INCLUDE(${ARCADIA_ROOT}/library/recipes/docker_compose/large.inc)
+INCLUDE(${ARCADIA_ROOT}/devtools/ya/chameleon_bin/recipe.inc)
+
+TAG(
+ ya:external
+ ya:force_sandbox
+ ya:dirty
+)
+
+REQUIREMENTS(
+ container:4467981730 # bionic with fuse allowed
+ cpu:all
+ dns:dns64
+)
+
+DATA(
+ arcadia/library/recipes/docker_compose/example
+ arcadia/library/recipes/docker_compose/example_with_context
+ arcadia/library/recipes/docker_compose/example_test_container
+ arcadia/library/recipes/docker_compose/example_with_recipe_config
+)
+
+PEERDIR(
+ devtools/ya/test/tests/lib/common
+)
+
+DEPENDS(
+ devtools/ya/test/programs/test_tool/bin
+ devtools/ya/test/programs/test_tool/bin3
+ devtools/ymake/bin
+)
+
+END()
diff --git a/library/recipes/docker_compose/test/ut/context.yml b/library/recipes/docker_compose/test/ut/context.yml
new file mode 100644
index 0000000000..655bd657aa
--- /dev/null
+++ b/library/recipes/docker_compose/test/ut/context.yml
@@ -0,0 +1,9 @@
+context1:
+ - arcadia://library/recipes/docker_compose/test/ut/data/dir1: dir1
+ - arcadia://library/recipes/docker_compose/test/ut/data/dir2: dir1/dir2
+ - arcadia://library/recipes/docker_compose/test/ut/data/file1.txt: file1.txt
+ - arcadia://library/recipes/docker_compose/test/ut/data/file2.txt: dir1/file2.txt
+ - build://devtools/dummy_arcadia/hello_world/hello_world: dir1/hello
+
+context2:
+ - arcadia://library/recipes/docker_compose/test/ut/data/file1.txt: file1.txt \ No newline at end of file
diff --git a/library/recipes/docker_compose/test/ut/data/dir1/file3.txt b/library/recipes/docker_compose/test/ut/data/dir1/file3.txt
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/library/recipes/docker_compose/test/ut/data/dir1/file3.txt
diff --git a/library/recipes/docker_compose/test/ut/data/dir2/file4.txt b/library/recipes/docker_compose/test/ut/data/dir2/file4.txt
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/library/recipes/docker_compose/test/ut/data/dir2/file4.txt
diff --git a/library/recipes/docker_compose/test/ut/data/file1.txt b/library/recipes/docker_compose/test/ut/data/file1.txt
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/library/recipes/docker_compose/test/ut/data/file1.txt
diff --git a/library/recipes/docker_compose/test/ut/data/file2.txt b/library/recipes/docker_compose/test/ut/data/file2.txt
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/library/recipes/docker_compose/test/ut/data/file2.txt
diff --git a/library/recipes/docker_compose/test/ut/init_dir/init.txt b/library/recipes/docker_compose/test/ut/init_dir/init.txt
new file mode 100644
index 0000000000..a0a41ab1c0
--- /dev/null
+++ b/library/recipes/docker_compose/test/ut/init_dir/init.txt
@@ -0,0 +1 @@
+init.txt \ No newline at end of file
diff --git a/library/recipes/docker_compose/test/ut/test_docker_context.py b/library/recipes/docker_compose/test/ut/test_docker_context.py
new file mode 100644
index 0000000000..2e8008afb6
--- /dev/null
+++ b/library/recipes/docker_compose/test/ut/test_docker_context.py
@@ -0,0 +1,31 @@
+import os
+import yaml
+import yatest.common
+
+import library.recipes.docker_compose.lib as lib
+
+
+def test_create_context():
+ root = yatest.common.work_path("context_root")
+ with open(yatest.common.test_source_path("context.yml")) as f:
+ ctx = yaml.safe_load(f)
+ context = lib._create_context(ctx, yatest.common.test_source_path("init_dir"), root)
+ assert "context1" in context
+ expected_context_paths = {
+ "context1": [
+ "init.txt",
+ "dir1/file3.txt",
+ "dir1/dir2/file4.txt",
+ "file1.txt",
+ "dir1/file2.txt",
+ "dir1/hello",
+ ],
+ "context2": [
+ "init.txt",
+ "file1.txt",
+ ]
+ }
+ for c, expected_paths in expected_context_paths.iteritems():
+ assert c in context
+ for p in expected_paths:
+ assert os.path.exists(os.path.join(root, c, p))
diff --git a/library/recipes/docker_compose/test/ut/ya.make b/library/recipes/docker_compose/test/ut/ya.make
new file mode 100644
index 0000000000..008bf2beed
--- /dev/null
+++ b/library/recipes/docker_compose/test/ut/ya.make
@@ -0,0 +1,16 @@
+PY2TEST()
+
+TEST_SRCS(
+ test_docker_context.py
+)
+
+PEERDIR(
+ contrib/python/PyYAML
+ library/recipes/docker_compose/lib
+)
+
+DEPENDS(
+ devtools/dummy_arcadia/hello_world
+)
+
+END()
diff --git a/library/recipes/docker_compose/test/ya.make b/library/recipes/docker_compose/test/ya.make
new file mode 100644
index 0000000000..1dd36ee3f6
--- /dev/null
+++ b/library/recipes/docker_compose/test/ya.make
@@ -0,0 +1,4 @@
+RECURSE(
+ acceptance
+ ut
+)