Browse Source

[python] Add local dev mod runing python integate tests (#11362)

陈家名 2 years ago
parent
commit
26a21566bf

+ 13 - 1
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

+ 16 - 11
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()

+ 8 - 1
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 =