From 26a21566bfbc13f03e08ab3b2c96958dc3c62dfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=AE=B6=E5=90=8D?= <13774486042@163.com> Date: Wed, 10 Aug 2022 15:04:56 +0800 Subject: [PATCH] [python] Add local dev mod runing python integate tests (#11362) --- .../pydolphinscheduler/DEVELOP.md | 14 +++++++++- .../tests/integration/conftest.py | 27 +++++++++++-------- .../pydolphinscheduler/tox.ini | 9 ++++++- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/dolphinscheduler-python/pydolphinscheduler/DEVELOP.md b/dolphinscheduler-python/pydolphinscheduler/DEVELOP.md index d09363ae65..c893418487 100644 --- a/dolphinscheduler-python/pydolphinscheduler/DEVELOP.md +++ b/dolphinscheduler-python/pydolphinscheduler/DEVELOP.md @@ -188,11 +188,14 @@ It would not only run unit test but also show each file coverage which cover rat line show you total coverage of you code. If your CI failed with coverage you could go and find some reason by this command output. -#### Integrate Test +### Integrate Test Integrate Test can not run when you execute command `tox -e local-ci` because it needs external environment including [Docker](https://docs.docker.com/get-docker/) and specific image build by [maven](https://maven.apache.org/install.html). Here we would show you the step to run integrate test in directory `dolphinscheduler-python/pydolphinscheduler/tests/integration`. +There are two ways to run integrate tests. + +#### Method 1: Launch Docker Container Locally ```shell # Go to project root directory and build Docker image @@ -210,6 +213,15 @@ cd ../../ tox -e integrate-test ``` +#### Method 2: Start Standalone Server in IntelliJ IDEA + +```shell +# Start the standalone server in IDEA + +# Go to pydolphinscheduler root directory and run integrate tests +tox -e local-integrate-test +``` + ## Add LICENSE When New Dependencies Adding When you add a new package in pydolphinscheduler, you should also add the package's LICENSE to directory diff --git a/dolphinscheduler-python/pydolphinscheduler/tests/integration/conftest.py b/dolphinscheduler-python/pydolphinscheduler/tests/integration/conftest.py index a9cd352710..236956b6e3 100644 --- a/dolphinscheduler-python/pydolphinscheduler/tests/integration/conftest.py +++ b/dolphinscheduler-python/pydolphinscheduler/tests/integration/conftest.py @@ -17,6 +17,8 @@ """py.test conftest.py file for package integration test.""" +import os + import pytest from tests.testing.docker_wrapper import DockerWrapper @@ -33,14 +35,17 @@ def docker_setup_teardown(): For more information about conftest.py see: https://docs.pytest.org/en/latest/example/simple.html#package-directory-level-fixtures-setups """ - docker_wrapper = DockerWrapper( - image="apache/dolphinscheduler-standalone-server:ci", - container_name="ci-dolphinscheduler-standalone-server", - ) - ports = {"25333/tcp": 25333} - container = docker_wrapper.run_until_log( - log="Started StandaloneServer in", tty=True, ports=ports - ) - assert container is not None - yield - docker_wrapper.remove_container() + if os.environ.get("skip_launch_docker") == "true": + yield True + else: + docker_wrapper = DockerWrapper( + image="apache/dolphinscheduler-standalone-server:ci", + container_name="ci-dolphinscheduler-standalone-server", + ) + ports = {"25333/tcp": 25333} + container = docker_wrapper.run_until_log( + log="Started StandaloneServer in", tty=True, ports=ports + ) + assert container is not None + yield + docker_wrapper.remove_container() diff --git a/dolphinscheduler-python/pydolphinscheduler/tox.ini b/dolphinscheduler-python/pydolphinscheduler/tox.ini index 8e9280f057..4e21bcb513 100644 --- a/dolphinscheduler-python/pydolphinscheduler/tox.ini +++ b/dolphinscheduler-python/pydolphinscheduler/tox.ini @@ -16,7 +16,7 @@ # under the License. [tox] -envlist = local-ci, auto-lint, lint, doc-build-test, code-test, integrate-test, py{36,37,38,39} +envlist = local-ci, auto-lint, lint, doc-build-test, code-test, integrate-test, local-integrate-test, py{36,37,38,39} [testenv] whitelist_externals = make @@ -53,6 +53,13 @@ extras = test commands = python -m pytest tests/integration/ +[testenv:local-integrate-test] +extras = test +setenv = + skip_launch_docker = true +commands = + {[testenv:integrate-test]commands} + [testenv:local-ci] extras = dev commands =