This is an automated email from the ASF dual-hosted git repository. kezhenxu94 pushed a commit to branch test/polish in repository https://gitbox.apache.org/repos/asf/skywalking-python.git
commit 52bd1ab7b87a6e856b4694f445952b2327f220ec Author: kezhenxu94 <[email protected]> AuthorDate: Wed Jul 1 00:12:39 2020 +0800 Polish the test framework for simplicity of local test - Extract as many commonly-used codes as possible - Rename the test class to a more general one as contributors tend to copy-paste w/o modifying the class name --- .../docker-compose.base.yml} | 38 ++---------------- tests/plugin/sw_http/docker-compose.yml | 45 ++++++---------------- tests/plugin/sw_http/services/consumer.py | 1 - tests/plugin/sw_http/services/provider.py | 1 - tests/plugin/sw_http/test_http.py | 2 +- tests/plugin/sw_http_wsgi/docker-compose.yml | 45 ++++++---------------- tests/plugin/sw_http_wsgi/services/consumer.py | 1 - tests/plugin/sw_http_wsgi/services/provider.py | 1 - tests/plugin/sw_http_wsgi/test_http_wsgi.py | 2 +- tests/plugin/sw_requests/docker-compose.yml | 45 ++++++---------------- tests/plugin/sw_requests/services/consumer.py | 1 - tests/plugin/sw_requests/services/provider.py | 1 - tests/plugin/sw_requests/test_request.py | 2 +- 13 files changed, 40 insertions(+), 145 deletions(-) diff --git a/tests/plugin/sw_http/docker-compose.yml b/tests/plugin/docker/docker-compose.base.yml similarity index 60% copy from tests/plugin/sw_http/docker-compose.yml copy to tests/plugin/docker/docker-compose.base.yml index 3f0d305..bb18365 100644 --- a/tests/plugin/sw_http/docker-compose.yml +++ b/tests/plugin/docker/docker-compose.base.yml @@ -20,7 +20,7 @@ version: '2.1' services: collector: build: - context: ../docker + context: . dockerfile: Dockerfile.tool ports: - 19876:19876 @@ -33,46 +33,16 @@ services: timeout: 60s retries: 120 - provider: + agent: build: context: ../../../ dockerfile: tests/plugin/docker/Dockerfile.agent - networks: - - beyond - ports: - - 9091:9091 - volumes: - - ./services/provider.py:/app/provider.py environment: SW_AGENT_COLLECTOR_BACKEND_SERVICES: collector:19876 - command: ['python3', '/app/provider.py'] - depends_on: - collector: - condition: service_healthy - healthcheck: - test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/9091"] - interval: 5s - timeout: 60s - retries: 120 - - consumer: - build: - context: ../../../ - dockerfile: tests/plugin/docker/Dockerfile.agent + SW_AGENT_LOGGING_LEVEL: DEBUG networks: - beyond - ports: - - 9090:9090 - volumes: - - ./services/consumer.py:/app/consumer.py - environment: - SW_AGENT_COLLECTOR_BACKEND_SERVICES: collector:19876 - command: ['python3', '/app/consumer.py'] - depends_on: - collector: - condition: service_healthy - provider: - condition: service_healthy + command: ['python3', '/entrypoint.py'] networks: beyond: diff --git a/tests/plugin/sw_http/docker-compose.yml b/tests/plugin/sw_http/docker-compose.yml index 3f0d305..019cfd7 100644 --- a/tests/plugin/sw_http/docker-compose.yml +++ b/tests/plugin/sw_http/docker-compose.yml @@ -19,33 +19,18 @@ version: '2.1' services: collector: - build: - context: ../docker - dockerfile: Dockerfile.tool - ports: - - 19876:19876 - - 12800:12800 - networks: - - beyond - healthcheck: - test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/12800"] - interval: 5s - timeout: 60s - retries: 120 + extends: + service: collector + file: ../docker/docker-compose.base.yml provider: - build: - context: ../../../ - dockerfile: tests/plugin/docker/Dockerfile.agent - networks: - - beyond + extends: + service: agent + file: ../docker/docker-compose.base.yml ports: - 9091:9091 volumes: - - ./services/provider.py:/app/provider.py - environment: - SW_AGENT_COLLECTOR_BACKEND_SERVICES: collector:19876 - command: ['python3', '/app/provider.py'] + - ./services/provider.py:/entrypoint.py depends_on: collector: condition: service_healthy @@ -56,23 +41,15 @@ services: retries: 120 consumer: - build: - context: ../../../ - dockerfile: tests/plugin/docker/Dockerfile.agent - networks: - - beyond + extends: + service: agent + file: ../docker/docker-compose.base.yml ports: - 9090:9090 volumes: - - ./services/consumer.py:/app/consumer.py - environment: - SW_AGENT_COLLECTOR_BACKEND_SERVICES: collector:19876 - command: ['python3', '/app/consumer.py'] + - ./services/consumer.py:/entrypoint.py depends_on: collector: condition: service_healthy provider: condition: service_healthy - -networks: - beyond: diff --git a/tests/plugin/sw_http/services/consumer.py b/tests/plugin/sw_http/services/consumer.py index 43f60bd..e0d59bf 100644 --- a/tests/plugin/sw_http/services/consumer.py +++ b/tests/plugin/sw_http/services/consumer.py @@ -21,7 +21,6 @@ from skywalking import agent, config if __name__ == '__main__': config.service_name = 'consumer' - config.logging_level = 'DEBUG' agent.start() import socketserver diff --git a/tests/plugin/sw_http/services/provider.py b/tests/plugin/sw_http/services/provider.py index 7af884a..3cdd5f2 100644 --- a/tests/plugin/sw_http/services/provider.py +++ b/tests/plugin/sw_http/services/provider.py @@ -21,7 +21,6 @@ from skywalking import agent, config if __name__ == '__main__': config.service_name = 'provider' - config.logging_level = 'DEBUG' agent.start() import socketserver diff --git a/tests/plugin/sw_http/test_http.py b/tests/plugin/sw_http/test_http.py index eacaa98..856db04 100644 --- a/tests/plugin/sw_http/test_http.py +++ b/tests/plugin/sw_http/test_http.py @@ -26,7 +26,7 @@ from testcontainers.compose import DockerCompose from tests.plugin import BasePluginTest -class TestRequestPlugin(BasePluginTest): +class TestPlugin(BasePluginTest): @classmethod def setUpClass(cls): cls.compose = DockerCompose(filepath=dirname(abspath(__file__))) diff --git a/tests/plugin/sw_http_wsgi/docker-compose.yml b/tests/plugin/sw_http_wsgi/docker-compose.yml index 3f0d305..019cfd7 100644 --- a/tests/plugin/sw_http_wsgi/docker-compose.yml +++ b/tests/plugin/sw_http_wsgi/docker-compose.yml @@ -19,33 +19,18 @@ version: '2.1' services: collector: - build: - context: ../docker - dockerfile: Dockerfile.tool - ports: - - 19876:19876 - - 12800:12800 - networks: - - beyond - healthcheck: - test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/12800"] - interval: 5s - timeout: 60s - retries: 120 + extends: + service: collector + file: ../docker/docker-compose.base.yml provider: - build: - context: ../../../ - dockerfile: tests/plugin/docker/Dockerfile.agent - networks: - - beyond + extends: + service: agent + file: ../docker/docker-compose.base.yml ports: - 9091:9091 volumes: - - ./services/provider.py:/app/provider.py - environment: - SW_AGENT_COLLECTOR_BACKEND_SERVICES: collector:19876 - command: ['python3', '/app/provider.py'] + - ./services/provider.py:/entrypoint.py depends_on: collector: condition: service_healthy @@ -56,23 +41,15 @@ services: retries: 120 consumer: - build: - context: ../../../ - dockerfile: tests/plugin/docker/Dockerfile.agent - networks: - - beyond + extends: + service: agent + file: ../docker/docker-compose.base.yml ports: - 9090:9090 volumes: - - ./services/consumer.py:/app/consumer.py - environment: - SW_AGENT_COLLECTOR_BACKEND_SERVICES: collector:19876 - command: ['python3', '/app/consumer.py'] + - ./services/consumer.py:/entrypoint.py depends_on: collector: condition: service_healthy provider: condition: service_healthy - -networks: - beyond: diff --git a/tests/plugin/sw_http_wsgi/services/consumer.py b/tests/plugin/sw_http_wsgi/services/consumer.py index 43f60bd..e0d59bf 100644 --- a/tests/plugin/sw_http_wsgi/services/consumer.py +++ b/tests/plugin/sw_http_wsgi/services/consumer.py @@ -21,7 +21,6 @@ from skywalking import agent, config if __name__ == '__main__': config.service_name = 'consumer' - config.logging_level = 'DEBUG' agent.start() import socketserver diff --git a/tests/plugin/sw_http_wsgi/services/provider.py b/tests/plugin/sw_http_wsgi/services/provider.py index a8c4b84..93433c2 100644 --- a/tests/plugin/sw_http_wsgi/services/provider.py +++ b/tests/plugin/sw_http_wsgi/services/provider.py @@ -21,7 +21,6 @@ from skywalking import agent, config if __name__ == '__main__': config.service_name = 'provider' - config.logging_level = 'DEBUG' agent.start() from werkzeug import Request, Response diff --git a/tests/plugin/sw_http_wsgi/test_http_wsgi.py b/tests/plugin/sw_http_wsgi/test_http_wsgi.py index eacaa98..856db04 100644 --- a/tests/plugin/sw_http_wsgi/test_http_wsgi.py +++ b/tests/plugin/sw_http_wsgi/test_http_wsgi.py @@ -26,7 +26,7 @@ from testcontainers.compose import DockerCompose from tests.plugin import BasePluginTest -class TestRequestPlugin(BasePluginTest): +class TestPlugin(BasePluginTest): @classmethod def setUpClass(cls): cls.compose = DockerCompose(filepath=dirname(abspath(__file__))) diff --git a/tests/plugin/sw_requests/docker-compose.yml b/tests/plugin/sw_requests/docker-compose.yml index 3f0d305..019cfd7 100644 --- a/tests/plugin/sw_requests/docker-compose.yml +++ b/tests/plugin/sw_requests/docker-compose.yml @@ -19,33 +19,18 @@ version: '2.1' services: collector: - build: - context: ../docker - dockerfile: Dockerfile.tool - ports: - - 19876:19876 - - 12800:12800 - networks: - - beyond - healthcheck: - test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/12800"] - interval: 5s - timeout: 60s - retries: 120 + extends: + service: collector + file: ../docker/docker-compose.base.yml provider: - build: - context: ../../../ - dockerfile: tests/plugin/docker/Dockerfile.agent - networks: - - beyond + extends: + service: agent + file: ../docker/docker-compose.base.yml ports: - 9091:9091 volumes: - - ./services/provider.py:/app/provider.py - environment: - SW_AGENT_COLLECTOR_BACKEND_SERVICES: collector:19876 - command: ['python3', '/app/provider.py'] + - ./services/provider.py:/entrypoint.py depends_on: collector: condition: service_healthy @@ -56,23 +41,15 @@ services: retries: 120 consumer: - build: - context: ../../../ - dockerfile: tests/plugin/docker/Dockerfile.agent - networks: - - beyond + extends: + service: agent + file: ../docker/docker-compose.base.yml ports: - 9090:9090 volumes: - - ./services/consumer.py:/app/consumer.py - environment: - SW_AGENT_COLLECTOR_BACKEND_SERVICES: collector:19876 - command: ['python3', '/app/consumer.py'] + - ./services/consumer.py:/entrypoint.py depends_on: collector: condition: service_healthy provider: condition: service_healthy - -networks: - beyond: diff --git a/tests/plugin/sw_requests/services/consumer.py b/tests/plugin/sw_requests/services/consumer.py index 4328fc1..6681ac9 100644 --- a/tests/plugin/sw_requests/services/consumer.py +++ b/tests/plugin/sw_requests/services/consumer.py @@ -21,7 +21,6 @@ from skywalking import agent, config if __name__ == '__main__': config.service_name = 'consumer' - config.logging_level = 'DEBUG' agent.start() import socketserver diff --git a/tests/plugin/sw_requests/services/provider.py b/tests/plugin/sw_requests/services/provider.py index 7af884a..3cdd5f2 100644 --- a/tests/plugin/sw_requests/services/provider.py +++ b/tests/plugin/sw_requests/services/provider.py @@ -21,7 +21,6 @@ from skywalking import agent, config if __name__ == '__main__': config.service_name = 'provider' - config.logging_level = 'DEBUG' agent.start() import socketserver diff --git a/tests/plugin/sw_requests/test_request.py b/tests/plugin/sw_requests/test_request.py index eacaa98..856db04 100644 --- a/tests/plugin/sw_requests/test_request.py +++ b/tests/plugin/sw_requests/test_request.py @@ -26,7 +26,7 @@ from testcontainers.compose import DockerCompose from tests.plugin import BasePluginTest -class TestRequestPlugin(BasePluginTest): +class TestPlugin(BasePluginTest): @classmethod def setUpClass(cls): cls.compose = DockerCompose(filepath=dirname(abspath(__file__)))
