You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2023/01/18 05:51:35 UTC

[skywalking-python] branch master updated: Use slim in plugin tests (#268)

This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking-python.git


The following commit(s) were added to refs/heads/master by this push:
     new 748d451  Use slim in plugin tests (#268)
748d451 is described below

commit 748d4516a6a56517936e56dbc56dffa0c0984fd3
Author: Superskyyy <Su...@outlook.com>
AuthorDate: Wed Jan 18 00:51:29 2023 -0500

    Use slim in plugin tests (#268)
---
 .github/workflows/CI.yaml                           | 4 ++--
 CHANGELOG.md                                        | 1 +
 Makefile                                            | 2 +-
 docs/en/setup/Plugins.md                            | 2 +-
 skywalking/plugins/sw_mysqlclient.py                | 2 +-
 tests/plugin/Dockerfile.plugin                      | 9 ++++-----
 tests/plugin/conftest.py                            | 7 ++++++-
 tests/plugin/data/sw_mysqlclient/docker-compose.yml | 3 ++-
 8 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml
index 54bb50e..9b4e32e 100644
--- a/.github/workflows/CI.yaml
+++ b/.github/workflows/CI.yaml
@@ -127,7 +127,7 @@ jobs:
     runs-on: ubuntu-latest
     strategy:
       matrix: # may support pypy in the future
-        python-version: [ "3.7", "3.8", "3.9", "3.10" ]
+        python-version: [ "3.7-slim", "3.8-slim", "3.9-slim", "3.10-slim" ]
       fail-fast: false
     env:
       BASE_PYTHON_IMAGE: ${{ matrix.python-version }}
@@ -172,7 +172,7 @@ jobs:
       - name: Pull SkyWalking Python agent base image
         uses: actions/download-artifact@v3
         with:
-          name: docker-images-skywalking-python-plugin-${{ matrix.python-version }}
+          name: docker-images-skywalking-python-plugin-${{ matrix.python-version }}-slim
           path: docker-images
       - name: Load docker images
         run: find docker-images -name "*.tar" -exec docker load -i {} \;
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2050d5a..6643360 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -40,6 +40,7 @@
   - Sync OAP, SWCTL versions in E2E and fix test cases (#249)
   - Overhaul development flow with Poetry (#249)
   - Fix grpcio-tools generated message type (#253)
+  - Switch plugin tests to use slim Python images (#268)
 
 ### 0.8.0
 - Feature:
diff --git a/Makefile b/Makefile
index e6f0f78..0a3ca2e 100644
--- a/Makefile
+++ b/Makefile
@@ -94,7 +94,7 @@ license: clean
 .PHONY: test
 test: env
 	sudo apt-get -y install jq
-	docker build --build-arg BASE_PYTHON_IMAGE=3.7 -t apache/skywalking-python-agent:latest-plugin --no-cache . -f tests/plugin/Dockerfile.plugin
+	docker build --build-arg BASE_PYTHON_IMAGE=3.7-slim -t apache/skywalking-python-agent:latest-plugin --no-cache . -f tests/plugin/Dockerfile.plugin
 	poetry run pytest -v $(bash tests/gather_test_paths.sh)
 
 .PHONY: package
diff --git a/docs/en/setup/Plugins.md b/docs/en/setup/Plugins.md
index 99826fa..420f314 100644
--- a/docs/en/setup/Plugins.md
+++ b/docs/en/setup/Plugins.md
@@ -30,7 +30,7 @@ Library | Python Version - Lib Version | Plugin Name
 | [http_server](https://docs.python.org/3/library/http.server.html) | Python >=3.7 - ['*'];  | `sw_http_server` |
 | [werkzeug](https://werkzeug.palletsprojects.com/) | Python >=3.7 - ['1.0.1', '2.0'];  | `sw_http_server` |
 | [kafka-python](https://kafka-python.readthedocs.io) | Python >=3.7 - ['2.0'];  | `sw_kafka` |
-| [mysqlclient](https://mysqlclient.readthedocs.io/) | Python >=3.7 - ['2.1.0'];  | `sw_mysqlclient` |
+| [mysqlclient](https://mysqlclient.readthedocs.io/) | Python >=3.7 - ['2.1.*'];  | `sw_mysqlclient` |
 | [psycopg[binary]](https://www.psycopg.org/) | Python >=3.7 - ['3.0'];  | `sw_psycopg` |
 | [psycopg2-binary](https://www.psycopg.org/) | Python >=3.10 - NOT SUPPORTED YET; Python >=3.7 - ['2.9'];  | `sw_psycopg2` |
 | [pymongo](https://pymongo.readthedocs.io) | Python >=3.7 - ['3.11.*'];  | `sw_pymongo` |
diff --git a/skywalking/plugins/sw_mysqlclient.py b/skywalking/plugins/sw_mysqlclient.py
index bbd5774..9650b0d 100644
--- a/skywalking/plugins/sw_mysqlclient.py
+++ b/skywalking/plugins/sw_mysqlclient.py
@@ -22,7 +22,7 @@ from skywalking.trace.tags import TagDbType, TagDbInstance, TagDbStatement, TagD
 link_vector = ['https://mysqlclient.readthedocs.io/']
 support_matrix = {
     'mysqlclient': {
-        '>=3.7': ['2.1.0']
+        '>=3.7': ['2.1.*']
     }
 }
 note = """"""
diff --git a/tests/plugin/Dockerfile.plugin b/tests/plugin/Dockerfile.plugin
index 61a0640..5e30a8c 100644
--- a/tests/plugin/Dockerfile.plugin
+++ b/tests/plugin/Dockerfile.plugin
@@ -17,11 +17,10 @@ ARG BASE_PYTHON_IMAGE
 
 FROM python:${BASE_PYTHON_IMAGE}
 
-ARG ROOT=.
-
 WORKDIR /agent
 
-ADD $ROOT /agent
-
-RUN cd /agent && make install
+COPY . /agent
 
+RUN apt-get update \
+    && apt-get install -y --no-install-recommends build-essential procps \
+    && cd /agent && make install \
diff --git a/tests/plugin/conftest.py b/tests/plugin/conftest.py
index 5a3bb18..6f6ee52 100644
--- a/tests/plugin/conftest.py
+++ b/tests/plugin/conftest.py
@@ -62,12 +62,17 @@ def docker_compose(request: FixtureRequest, prepare: Callable, version: str) ->
                 exception_delay += 10
                 exception = e
                 stdout, stderr = compose.get_logs()
+        else:  # when exception isn't in prepare,  e.g. system-level/pip error/healthcheck stuck
+            exception = 'Exception is in container startup, please pay attention to log and ' \
+                        'ensure system/python package installation or healthcheck utility is working'
+            stdout, stderr = compose.get_logs()
+
 
         if exception:
             print(f'STDOUT:\n{stdout.decode("utf-8")}')
             print('==================================')
             print(f'STDERR:\n{stderr.decode("utf-8")}')
 
-            raise Exception(f"""Wait time exceeded {exception_delay} secs. Exception {exception}""")
+            raise Exception(f"""Wait time exceeded {exception_delay} secs. {exception}""")
 
         yield compose
diff --git a/tests/plugin/data/sw_mysqlclient/docker-compose.yml b/tests/plugin/data/sw_mysqlclient/docker-compose.yml
index 311ec43..9f37163 100644
--- a/tests/plugin/data/sw_mysqlclient/docker-compose.yml
+++ b/tests/plugin/data/sw_mysqlclient/docker-compose.yml
@@ -48,7 +48,8 @@ services:
       - 9091:9091
     volumes:
       - .:/app
-    command: ['bash', '-c', 'pip install flask && pip install -r /app/requirements.txt && sw-python run python3 /app/services/provider.py']
+    # required external dependency for mysql-client
+    command: ['bash', '-c', 'apt-get install -y python3-dev default-libmysqlclient-dev && pip install flask && pip install -r /app/requirements.txt && sw-python run python3 /app/services/provider.py']
     depends_on:
       collector:
         condition: service_healthy