From 2ceab90a6e2420aa3619e5cd8743d9c5fd9acc90 Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Wed, 16 Feb 2022 23:53:43 -0500 Subject: [PATCH 01/35] test error intentional Signed-off-by: Superskyyy --- tests/plugin/conftest.py | 45 ++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/tests/plugin/conftest.py b/tests/plugin/conftest.py index 4a43e25f..771be0d1 100644 --- a/tests/plugin/conftest.py +++ b/tests/plugin/conftest.py @@ -50,25 +50,30 @@ def docker_compose(request, prepare, version): with open(os.path.join(cwd, 'requirements.txt'), mode='w') as req: req.write(version) - compose = DockerCompose(filepath=cwd) - - compose.start() - - exception = None - exception_delay = 100 - for _ in range(0, 10): - try: - prepare() - exception = None - break - except Exception as e: - time.sleep(10) - exception = e - if exception: - time.sleep(exception_delay) - compose.stop() - raise Exception(f"""Wait time exceeded {exception_delay} secs. Exception {exception}""") - - yield compose + with DockerCompose(filepath=cwd) as compose: + exception = None + exception_delay = 0 + # stdout_dignose, stderr_dignose = None + for _ in range(1): + try: + prepare() + exception = None + break + except Exception as e: + time.sleep(10) + exception_delay += 10 + exception = e + stdout, stderr = compose.get_logs() + + if exception: + compose.stop() + print(f'STDOUT:\\n{stdout}') + print('====================================') + print(f'STDERR:\\n{stderr}') + + raise Exception(f"""Wait time exceeded {exception_delay} secs. Exception {exception}""") + + yield compose + compose.stop() From c11f82bbdf6689500716086ad37c6ecd92c5fee0 Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Thu, 17 Feb 2022 00:06:08 -0500 Subject: [PATCH 02/35] test error intentional Signed-off-by: Superskyyy --- tests/plugin/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/plugin/conftest.py b/tests/plugin/conftest.py index 771be0d1..2b448438 100644 --- a/tests/plugin/conftest.py +++ b/tests/plugin/conftest.py @@ -54,7 +54,7 @@ def docker_compose(request, prepare, version): exception = None exception_delay = 0 # stdout_dignose, stderr_dignose = None - for _ in range(1): + for _ in range(10): try: prepare() exception = None From 2e6e4fdfba76abec818b597dfb558199d513f1dc Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Thu, 17 Feb 2022 00:21:36 -0500 Subject: [PATCH 03/35] test error intentional Signed-off-by: Superskyyy --- tests/plugin/web/sw_fastapi/services/consumer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/plugin/web/sw_fastapi/services/consumer.py b/tests/plugin/web/sw_fastapi/services/consumer.py index d4dfd93f..35f52ff9 100644 --- a/tests/plugin/web/sw_fastapi/services/consumer.py +++ b/tests/plugin/web/sw_fastapi/services/consumer.py @@ -25,7 +25,7 @@ @app.get('/users') async def application(): - res = requests.get('http://provider:9091/users') + res = requests.get('http://provider:9092/users') return res.json() uvicorn.run(app, host='0.0.0.0', port=9090) From 8b82be061be4b1820680f8aa70d588eba2f729ee Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Thu, 17 Feb 2022 00:38:10 -0500 Subject: [PATCH 04/35] test error intentional Signed-off-by: Superskyyy --- tests/plugin/web/sw_fastapi/services/consumer.py | 2 +- tests/plugin/web/sw_fastapi/test_fastapi.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/plugin/web/sw_fastapi/services/consumer.py b/tests/plugin/web/sw_fastapi/services/consumer.py index 35f52ff9..d4dfd93f 100644 --- a/tests/plugin/web/sw_fastapi/services/consumer.py +++ b/tests/plugin/web/sw_fastapi/services/consumer.py @@ -25,7 +25,7 @@ @app.get('/users') async def application(): - res = requests.get('http://provider:9092/users') + res = requests.get('http://provider:9091/users') return res.json() uvicorn.run(app, host='0.0.0.0', port=9090) diff --git a/tests/plugin/web/sw_fastapi/test_fastapi.py b/tests/plugin/web/sw_fastapi/test_fastapi.py index 1f4e3d41..d19e1152 100644 --- a/tests/plugin/web/sw_fastapi/test_fastapi.py +++ b/tests/plugin/web/sw_fastapi/test_fastapi.py @@ -27,7 +27,7 @@ @pytest.fixture def prepare(): # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/users?test=test1&test=test2&test2=test2') + return lambda *_: requests.get('http://0.0.11.0:9090/users?test=test1&test=test2&test2=test2') class TestPlugin(TestPluginBase): From fea6ca6082aaf93f12141caa45facb9717017134 Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Thu, 17 Feb 2022 01:41:18 -0500 Subject: [PATCH 05/35] test error intentional Signed-off-by: Superskyyy --- tests/plugin/conftest.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/plugin/conftest.py b/tests/plugin/conftest.py index 2b448438..eaaf4abd 100644 --- a/tests/plugin/conftest.py +++ b/tests/plugin/conftest.py @@ -54,22 +54,22 @@ def docker_compose(request, prepare, version): exception = None exception_delay = 0 # stdout_dignose, stderr_dignose = None - for _ in range(10): + for _ in range(1): try: prepare() exception = None break except Exception as e: - time.sleep(10) + time.sleep(20) exception_delay += 10 exception = e stdout, stderr = compose.get_logs() if exception: compose.stop() - print(f'STDOUT:\\n{stdout}') + print(f'STDOUT:\n{stdout.decode("utf-8")}') print('====================================') - print(f'STDERR:\\n{stderr}') + print(f'STDERR:\n{stderr.decode("utf-8")}') raise Exception(f"""Wait time exceeded {exception_delay} secs. Exception {exception}""") From bc4a883d2a914dfbb29f4a25a6050efbe2de6d3e Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Thu, 17 Feb 2022 01:52:44 -0500 Subject: [PATCH 06/35] test error intentional Signed-off-by: Superskyyy --- .github/workflows/CI.yaml | 2 +- tests/plugin/conftest.py | 2 +- tests/plugin/data/__init__.py | 16 -- .../plugin/data/sw_elasticsearch/__init__.py | 16 -- .../data/sw_elasticsearch/docker-compose.yml | 64 ----- .../data/sw_elasticsearch/expected.data.yml | 88 ------- .../sw_elasticsearch/services/__init__.py | 16 -- .../sw_elasticsearch/services/consumer.py | 46 ---- .../sw_elasticsearch/test_elasticsearch.py | 36 --- tests/plugin/data/sw_kafka/__init__.py | 16 -- tests/plugin/data/sw_kafka/docker-compose.yml | 109 -------- tests/plugin/data/sw_kafka/expected.data.yml | 86 ------- .../plugin/data/sw_kafka/services/__init__.py | 16 -- .../plugin/data/sw_kafka/services/consumer.py | 32 --- .../plugin/data/sw_kafka/services/producer.py | 33 --- tests/plugin/data/sw_kafka/test_kafka.py | 36 --- tests/plugin/data/sw_mysqlclient/__init__.py | 16 -- .../data/sw_mysqlclient/docker-compose.yml | 86 ------- .../data/sw_mysqlclient/expected.data.yml | 109 -------- .../data/sw_mysqlclient/services/__init__.py | 16 -- .../data/sw_mysqlclient/services/consumer.py | 32 --- .../data/sw_mysqlclient/services/provider.py | 39 --- .../data/sw_mysqlclient/test_mysqlclient.py | 36 --- tests/plugin/data/sw_psycopg/__init__.py | 16 -- .../plugin/data/sw_psycopg/docker-compose.yml | 87 ------- .../plugin/data/sw_psycopg/expected.data.yml | 110 --------- .../data/sw_psycopg/services/__init__.py | 16 -- .../data/sw_psycopg/services/consumer.py | 32 --- .../data/sw_psycopg/services/provider.py | 40 --- tests/plugin/data/sw_psycopg/test_psycopg.py | 36 --- tests/plugin/data/sw_psycopg2/__init__.py | 16 -- .../data/sw_psycopg2/docker-compose.yml | 86 ------- .../plugin/data/sw_psycopg2/expected.data.yml | 112 --------- .../data/sw_psycopg2/services/__init__.py | 16 -- .../data/sw_psycopg2/services/consumer.py | 32 --- .../data/sw_psycopg2/services/provider.py | 40 --- .../plugin/data/sw_psycopg2/test_psycopg2.py | 36 --- tests/plugin/data/sw_pymongo/__init__.py | 16 -- .../plugin/data/sw_pymongo/docker-compose.yml | 82 ------ .../plugin/data/sw_pymongo/expected.data.yml | 233 ------------------ .../data/sw_pymongo/services/__init__.py | 16 -- .../data/sw_pymongo/services/consumer.py | 34 --- .../data/sw_pymongo/services/provider.py | 58 ----- tests/plugin/data/sw_pymongo/test_pymongo.py | 36 --- tests/plugin/data/sw_pymysql/__init__.py | 16 -- .../plugin/data/sw_pymysql/docker-compose.yml | 86 ------- .../plugin/data/sw_pymysql/expected.data.yml | 109 -------- .../data/sw_pymysql/services/__init__.py | 16 -- .../data/sw_pymysql/services/consumer.py | 32 --- .../data/sw_pymysql/services/provider.py | 39 --- tests/plugin/data/sw_pymysql/test_pymysql.py | 36 --- tests/plugin/data/sw_rabbitmq/__init__.py | 16 -- .../data/sw_rabbitmq/docker-compose.yml | 93 ------- .../plugin/data/sw_rabbitmq/expected.data.yml | 90 ------- .../data/sw_rabbitmq/services/__init__.py | 16 -- .../data/sw_rabbitmq/services/consumer.py | 45 ---- .../data/sw_rabbitmq/services/producer.py | 41 --- .../plugin/data/sw_rabbitmq/test_rabbitmq.py | 36 --- tests/plugin/data/sw_redis/__init__.py | 16 -- tests/plugin/data/sw_redis/docker-compose.yml | 79 ------ tests/plugin/data/sw_redis/expected.data.yml | 124 ---------- .../plugin/data/sw_redis/services/__init__.py | 16 -- .../plugin/data/sw_redis/services/consumer.py | 32 --- .../plugin/data/sw_redis/services/provider.py | 39 --- tests/plugin/data/sw_redis/test_redis.py | 36 --- tests/plugin/http/__init__.py | 16 -- tests/plugin/http/sw_aiohttp/__init__.py | 16 -- .../plugin/http/sw_aiohttp/docker-compose.yml | 66 ----- .../plugin/http/sw_aiohttp/expected.data.yml | 89 ------- .../http/sw_aiohttp/services/__init__.py | 16 -- .../http/sw_aiohttp/services/consumer.py | 37 --- .../http/sw_aiohttp/services/provider.py | 32 --- tests/plugin/http/sw_aiohttp/test_aiohttp.py | 36 --- tests/plugin/http/sw_http/__init__.py | 16 -- tests/plugin/http/sw_http/docker-compose.yml | 66 ----- tests/plugin/http/sw_http/expected.data.yml | 90 ------- .../plugin/http/sw_http/services/__init__.py | 16 -- .../plugin/http/sw_http/services/consumer.py | 44 ---- .../plugin/http/sw_http/services/provider.py | 38 --- tests/plugin/http/sw_http/test_http.py | 33 --- tests/plugin/http/sw_http_wsgi/__init__.py | 16 -- .../http/sw_http_wsgi/docker-compose.yml | 66 ----- .../http/sw_http_wsgi/expected.data.yml | 91 ------- .../http/sw_http_wsgi/services/__init__.py | 16 -- .../http/sw_http_wsgi/services/consumer.py | 43 ---- .../http/sw_http_wsgi/services/provider.py | 32 --- .../http/sw_http_wsgi/test_http_wsgi.py | 36 --- tests/plugin/http/sw_requests/__init__.py | 16 -- .../http/sw_requests/docker-compose.yml | 66 ----- .../plugin/http/sw_requests/expected.data.yml | 90 ------- .../http/sw_requests/services/__init__.py | 16 -- .../http/sw_requests/services/consumer.py | 39 --- .../http/sw_requests/services/provider.py | 38 --- tests/plugin/http/sw_requests/test_request.py | 36 --- tests/plugin/http/sw_urllib3/__init__.py | 16 -- .../plugin/http/sw_urllib3/docker-compose.yml | 66 ----- .../plugin/http/sw_urllib3/expected.data.yml | 93 ------- .../http/sw_urllib3/services/__init__.py | 16 -- .../http/sw_urllib3/services/consumer.py | 34 --- .../http/sw_urllib3/services/provider.py | 32 --- tests/plugin/http/sw_urllib3/test_urllib3.py | 36 --- tests/plugin/web/sw_django/__init__.py | 16 -- tests/plugin/web/sw_django/docker-compose.yml | 67 ----- tests/plugin/web/sw_django/expected.data.yml | 90 ------- .../plugin/web/sw_django/services/__init__.py | 16 -- .../plugin/web/sw_django/services/consumer.py | 45 ---- .../plugin/web/sw_django/services/provider.py | 45 ---- tests/plugin/web/sw_django/test_django.py | 36 --- tests/plugin/web/sw_falcon/__init__.py | 16 -- tests/plugin/web/sw_falcon/docker-compose.yml | 66 ----- tests/plugin/web/sw_falcon/expected.data.yml | 85 ------- .../plugin/web/sw_falcon/services/__init__.py | 16 -- .../plugin/web/sw_falcon/services/consumer.py | 27 -- .../plugin/web/sw_falcon/services/provider.py | 30 --- tests/plugin/web/sw_falcon/test_falcon.py | 37 --- tests/plugin/web/sw_flask/__init__.py | 16 -- tests/plugin/web/sw_flask/docker-compose.yml | 66 ----- tests/plugin/web/sw_flask/expected.data.yml | 160 ------------ .../plugin/web/sw_flask/services/__init__.py | 16 -- .../plugin/web/sw_flask/services/consumer.py | 47 ---- .../plugin/web/sw_flask/services/provider.py | 33 --- tests/plugin/web/sw_flask/test_flask.py | 40 --- tests/plugin/web/sw_pyramid/__init__.py | 16 -- .../plugin/web/sw_pyramid/docker-compose.yml | 66 ----- tests/plugin/web/sw_pyramid/expected.data.yml | 91 ------- .../web/sw_pyramid/services/__init__.py | 16 -- .../web/sw_pyramid/services/consumer.py | 42 ---- .../web/sw_pyramid/services/provider.py | 43 ---- tests/plugin/web/sw_pyramid/test_pyramid.py | 36 --- tests/plugin/web/sw_sanic/__init__.py | 16 -- tests/plugin/web/sw_sanic/docker-compose.yml | 65 ----- tests/plugin/web/sw_sanic/expected.data.yml | 92 ------- .../plugin/web/sw_sanic/services/__init__.py | 16 -- .../plugin/web/sw_sanic/services/consumer.py | 31 --- .../plugin/web/sw_sanic/services/provider.py | 33 --- tests/plugin/web/sw_sanic/test_sanic.py | 36 --- tests/plugin/web/sw_tornado/__init__.py | 16 -- .../plugin/web/sw_tornado/docker-compose.yml | 66 ----- tests/plugin/web/sw_tornado/expected.data.yml | 90 ------- .../web/sw_tornado/services/__init__.py | 16 -- .../web/sw_tornado/services/consumer.py | 35 --- .../web/sw_tornado/services/provider.py | 37 --- tests/plugin/web/sw_tornado/test_tornado.py | 36 --- 143 files changed, 2 insertions(+), 6479 deletions(-) delete mode 100644 tests/plugin/data/__init__.py delete mode 100644 tests/plugin/data/sw_elasticsearch/__init__.py delete mode 100644 tests/plugin/data/sw_elasticsearch/docker-compose.yml delete mode 100644 tests/plugin/data/sw_elasticsearch/expected.data.yml delete mode 100644 tests/plugin/data/sw_elasticsearch/services/__init__.py delete mode 100644 tests/plugin/data/sw_elasticsearch/services/consumer.py delete mode 100644 tests/plugin/data/sw_elasticsearch/test_elasticsearch.py delete mode 100644 tests/plugin/data/sw_kafka/__init__.py delete mode 100644 tests/plugin/data/sw_kafka/docker-compose.yml delete mode 100644 tests/plugin/data/sw_kafka/expected.data.yml delete mode 100644 tests/plugin/data/sw_kafka/services/__init__.py delete mode 100644 tests/plugin/data/sw_kafka/services/consumer.py delete mode 100644 tests/plugin/data/sw_kafka/services/producer.py delete mode 100644 tests/plugin/data/sw_kafka/test_kafka.py delete mode 100644 tests/plugin/data/sw_mysqlclient/__init__.py delete mode 100644 tests/plugin/data/sw_mysqlclient/docker-compose.yml delete mode 100644 tests/plugin/data/sw_mysqlclient/expected.data.yml delete mode 100644 tests/plugin/data/sw_mysqlclient/services/__init__.py delete mode 100644 tests/plugin/data/sw_mysqlclient/services/consumer.py delete mode 100644 tests/plugin/data/sw_mysqlclient/services/provider.py delete mode 100644 tests/plugin/data/sw_mysqlclient/test_mysqlclient.py delete mode 100644 tests/plugin/data/sw_psycopg/__init__.py delete mode 100644 tests/plugin/data/sw_psycopg/docker-compose.yml delete mode 100644 tests/plugin/data/sw_psycopg/expected.data.yml delete mode 100644 tests/plugin/data/sw_psycopg/services/__init__.py delete mode 100644 tests/plugin/data/sw_psycopg/services/consumer.py delete mode 100644 tests/plugin/data/sw_psycopg/services/provider.py delete mode 100644 tests/plugin/data/sw_psycopg/test_psycopg.py delete mode 100644 tests/plugin/data/sw_psycopg2/__init__.py delete mode 100644 tests/plugin/data/sw_psycopg2/docker-compose.yml delete mode 100644 tests/plugin/data/sw_psycopg2/expected.data.yml delete mode 100644 tests/plugin/data/sw_psycopg2/services/__init__.py delete mode 100644 tests/plugin/data/sw_psycopg2/services/consumer.py delete mode 100644 tests/plugin/data/sw_psycopg2/services/provider.py delete mode 100644 tests/plugin/data/sw_psycopg2/test_psycopg2.py delete mode 100644 tests/plugin/data/sw_pymongo/__init__.py delete mode 100644 tests/plugin/data/sw_pymongo/docker-compose.yml delete mode 100644 tests/plugin/data/sw_pymongo/expected.data.yml delete mode 100644 tests/plugin/data/sw_pymongo/services/__init__.py delete mode 100644 tests/plugin/data/sw_pymongo/services/consumer.py delete mode 100644 tests/plugin/data/sw_pymongo/services/provider.py delete mode 100644 tests/plugin/data/sw_pymongo/test_pymongo.py delete mode 100644 tests/plugin/data/sw_pymysql/__init__.py delete mode 100644 tests/plugin/data/sw_pymysql/docker-compose.yml delete mode 100644 tests/plugin/data/sw_pymysql/expected.data.yml delete mode 100644 tests/plugin/data/sw_pymysql/services/__init__.py delete mode 100644 tests/plugin/data/sw_pymysql/services/consumer.py delete mode 100644 tests/plugin/data/sw_pymysql/services/provider.py delete mode 100644 tests/plugin/data/sw_pymysql/test_pymysql.py delete mode 100644 tests/plugin/data/sw_rabbitmq/__init__.py delete mode 100644 tests/plugin/data/sw_rabbitmq/docker-compose.yml delete mode 100644 tests/plugin/data/sw_rabbitmq/expected.data.yml delete mode 100644 tests/plugin/data/sw_rabbitmq/services/__init__.py delete mode 100644 tests/plugin/data/sw_rabbitmq/services/consumer.py delete mode 100644 tests/plugin/data/sw_rabbitmq/services/producer.py delete mode 100644 tests/plugin/data/sw_rabbitmq/test_rabbitmq.py delete mode 100644 tests/plugin/data/sw_redis/__init__.py delete mode 100644 tests/plugin/data/sw_redis/docker-compose.yml delete mode 100644 tests/plugin/data/sw_redis/expected.data.yml delete mode 100644 tests/plugin/data/sw_redis/services/__init__.py delete mode 100644 tests/plugin/data/sw_redis/services/consumer.py delete mode 100644 tests/plugin/data/sw_redis/services/provider.py delete mode 100644 tests/plugin/data/sw_redis/test_redis.py delete mode 100644 tests/plugin/http/__init__.py delete mode 100644 tests/plugin/http/sw_aiohttp/__init__.py delete mode 100644 tests/plugin/http/sw_aiohttp/docker-compose.yml delete mode 100644 tests/plugin/http/sw_aiohttp/expected.data.yml delete mode 100644 tests/plugin/http/sw_aiohttp/services/__init__.py delete mode 100644 tests/plugin/http/sw_aiohttp/services/consumer.py delete mode 100644 tests/plugin/http/sw_aiohttp/services/provider.py delete mode 100644 tests/plugin/http/sw_aiohttp/test_aiohttp.py delete mode 100644 tests/plugin/http/sw_http/__init__.py delete mode 100644 tests/plugin/http/sw_http/docker-compose.yml delete mode 100644 tests/plugin/http/sw_http/expected.data.yml delete mode 100644 tests/plugin/http/sw_http/services/__init__.py delete mode 100644 tests/plugin/http/sw_http/services/consumer.py delete mode 100644 tests/plugin/http/sw_http/services/provider.py delete mode 100644 tests/plugin/http/sw_http/test_http.py delete mode 100644 tests/plugin/http/sw_http_wsgi/__init__.py delete mode 100644 tests/plugin/http/sw_http_wsgi/docker-compose.yml delete mode 100644 tests/plugin/http/sw_http_wsgi/expected.data.yml delete mode 100644 tests/plugin/http/sw_http_wsgi/services/__init__.py delete mode 100644 tests/plugin/http/sw_http_wsgi/services/consumer.py delete mode 100644 tests/plugin/http/sw_http_wsgi/services/provider.py delete mode 100644 tests/plugin/http/sw_http_wsgi/test_http_wsgi.py delete mode 100644 tests/plugin/http/sw_requests/__init__.py delete mode 100644 tests/plugin/http/sw_requests/docker-compose.yml delete mode 100644 tests/plugin/http/sw_requests/expected.data.yml delete mode 100644 tests/plugin/http/sw_requests/services/__init__.py delete mode 100644 tests/plugin/http/sw_requests/services/consumer.py delete mode 100644 tests/plugin/http/sw_requests/services/provider.py delete mode 100644 tests/plugin/http/sw_requests/test_request.py delete mode 100644 tests/plugin/http/sw_urllib3/__init__.py delete mode 100644 tests/plugin/http/sw_urllib3/docker-compose.yml delete mode 100644 tests/plugin/http/sw_urllib3/expected.data.yml delete mode 100644 tests/plugin/http/sw_urllib3/services/__init__.py delete mode 100644 tests/plugin/http/sw_urllib3/services/consumer.py delete mode 100644 tests/plugin/http/sw_urllib3/services/provider.py delete mode 100644 tests/plugin/http/sw_urllib3/test_urllib3.py delete mode 100644 tests/plugin/web/sw_django/__init__.py delete mode 100644 tests/plugin/web/sw_django/docker-compose.yml delete mode 100644 tests/plugin/web/sw_django/expected.data.yml delete mode 100644 tests/plugin/web/sw_django/services/__init__.py delete mode 100644 tests/plugin/web/sw_django/services/consumer.py delete mode 100644 tests/plugin/web/sw_django/services/provider.py delete mode 100644 tests/plugin/web/sw_django/test_django.py delete mode 100644 tests/plugin/web/sw_falcon/__init__.py delete mode 100644 tests/plugin/web/sw_falcon/docker-compose.yml delete mode 100644 tests/plugin/web/sw_falcon/expected.data.yml delete mode 100644 tests/plugin/web/sw_falcon/services/__init__.py delete mode 100644 tests/plugin/web/sw_falcon/services/consumer.py delete mode 100644 tests/plugin/web/sw_falcon/services/provider.py delete mode 100644 tests/plugin/web/sw_falcon/test_falcon.py delete mode 100644 tests/plugin/web/sw_flask/__init__.py delete mode 100644 tests/plugin/web/sw_flask/docker-compose.yml delete mode 100644 tests/plugin/web/sw_flask/expected.data.yml delete mode 100644 tests/plugin/web/sw_flask/services/__init__.py delete mode 100644 tests/plugin/web/sw_flask/services/consumer.py delete mode 100644 tests/plugin/web/sw_flask/services/provider.py delete mode 100644 tests/plugin/web/sw_flask/test_flask.py delete mode 100644 tests/plugin/web/sw_pyramid/__init__.py delete mode 100644 tests/plugin/web/sw_pyramid/docker-compose.yml delete mode 100644 tests/plugin/web/sw_pyramid/expected.data.yml delete mode 100644 tests/plugin/web/sw_pyramid/services/__init__.py delete mode 100644 tests/plugin/web/sw_pyramid/services/consumer.py delete mode 100644 tests/plugin/web/sw_pyramid/services/provider.py delete mode 100644 tests/plugin/web/sw_pyramid/test_pyramid.py delete mode 100644 tests/plugin/web/sw_sanic/__init__.py delete mode 100644 tests/plugin/web/sw_sanic/docker-compose.yml delete mode 100644 tests/plugin/web/sw_sanic/expected.data.yml delete mode 100644 tests/plugin/web/sw_sanic/services/__init__.py delete mode 100644 tests/plugin/web/sw_sanic/services/consumer.py delete mode 100644 tests/plugin/web/sw_sanic/services/provider.py delete mode 100644 tests/plugin/web/sw_sanic/test_sanic.py delete mode 100644 tests/plugin/web/sw_tornado/__init__.py delete mode 100644 tests/plugin/web/sw_tornado/docker-compose.yml delete mode 100644 tests/plugin/web/sw_tornado/expected.data.yml delete mode 100644 tests/plugin/web/sw_tornado/services/__init__.py delete mode 100644 tests/plugin/web/sw_tornado/services/consumer.py delete mode 100644 tests/plugin/web/sw_tornado/services/provider.py delete mode 100644 tests/plugin/web/sw_tornado/test_tornado.py diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index 31d3937d..9539b8fd 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -62,7 +62,7 @@ jobs: timeout-minutes: 60 strategy: matrix: - python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"] + python-version: ["3.10"] test-path: ${{fromJson(needs.prep-plugin-and-unit-tests.outputs.matrix)}} fail-fast: false env: diff --git a/tests/plugin/conftest.py b/tests/plugin/conftest.py index eaaf4abd..96a9dc3d 100644 --- a/tests/plugin/conftest.py +++ b/tests/plugin/conftest.py @@ -54,7 +54,7 @@ def docker_compose(request, prepare, version): exception = None exception_delay = 0 # stdout_dignose, stderr_dignose = None - for _ in range(1): + for _ in range(5): try: prepare() exception = None diff --git a/tests/plugin/data/__init__.py b/tests/plugin/data/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/data/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/data/sw_elasticsearch/__init__.py b/tests/plugin/data/sw_elasticsearch/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/data/sw_elasticsearch/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/data/sw_elasticsearch/docker-compose.yml b/tests/plugin/data/sw_elasticsearch/docker-compose.yml deleted file mode 100644 index feb48072..00000000 --- a/tests/plugin/data/sw_elasticsearch/docker-compose.yml +++ /dev/null @@ -1,64 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -version: '2.1' - -services: - collector: - extends: - service: collector - file: ../../docker-compose.base.yml - - elasticsearch: - image: elasticsearch:6.8.11 - hostname: elasticsearch - expose: - - 9200 - environment: - - cluster.name=docker-node - - xpack.security.enabled=false - - bootstrap.memory_lock=true - - "ES_JAVA_OPTS=-Xms256m -Xmx256m" - - discovery.type=single-node - healthcheck: - test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/9200"] - interval: 5s - timeout: 60s - retries: 120 - networks: - - beyond - - consumer: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9090:9090 - volumes: - - .:/app - command: ['bash', '-c', 'pip install flask && pip install -r /app/requirements.txt && sw-python run python3 /app/services/consumer.py'] - depends_on: - collector: - condition: service_healthy - elasticsearch: - condition: service_healthy - environment: - SW_AGENT_NAME: consumer - SW_AGENT_LOGGING_LEVEL: DEBUG - SW_ELASTICSEARCH_TRACE_DSL: 'True' -networks: - beyond: diff --git a/tests/plugin/data/sw_elasticsearch/expected.data.yml b/tests/plugin/data/sw_elasticsearch/expected.data.yml deleted file mode 100644 index 0e1bfd87..00000000 --- a/tests/plugin/data/sw_elasticsearch/expected.data.yml +++ /dev/null @@ -1,88 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -segmentItems: - - serviceName: consumer - segmentSize: 1 - segments: - - segmentId: not null - spans: - - operationName: Elasticsearch/PUT/test - parentSpanId: 0 - spanId: 1 - spanLayer: Database - startTime: gt 0 - endTime: gt 0 - componentId: 47 - isError: false - spanType: Exit - peer: elasticsearch:9200 - skipAnalysis: false - tags: - - key: db.type - value: Elasticsearch - - key: db.statement - value: '' - - operationName: Elasticsearch/PUT/test/test/1 - parentSpanId: 0 - spanId: 2 - spanLayer: Database - startTime: gt 0 - endTime: gt 0 - componentId: 47 - isError: false - spanType: Exit - peer: elasticsearch:9200 - skipAnalysis: false - tags: - - key: db.type - value: Elasticsearch - - key: db.statement - value: '{''song'': ''Despacito'', ''artist'': ''Luis Fonsi''}' - - operationName: Elasticsearch/GET/test/_doc/1 - parentSpanId: 0 - spanId: 3 - spanLayer: Database - startTime: gt 0 - endTime: gt 0 - componentId: 47 - isError: false - spanType: Exit - peer: elasticsearch:9200 - skipAnalysis: false - tags: - - key: db.type - value: Elasticsearch - - key: db.statement - value: '' - - operationName: /users - parentSpanId: -1 - spanId: 0 - spanLayer: Http - tags: - - key: http.method - value: GET - - key: http.url - value: http://0.0.0.0:9090/users - - key: http.status.code - value: '200' - startTime: gt 0 - endTime: gt 0 - componentId: 7001 - spanType: Entry - peer: not null - skipAnalysis: false diff --git a/tests/plugin/data/sw_elasticsearch/services/__init__.py b/tests/plugin/data/sw_elasticsearch/services/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/data/sw_elasticsearch/services/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/data/sw_elasticsearch/services/consumer.py b/tests/plugin/data/sw_elasticsearch/services/consumer.py deleted file mode 100644 index 087d9361..00000000 --- a/tests/plugin/data/sw_elasticsearch/services/consumer.py +++ /dev/null @@ -1,46 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -from elasticsearch import Elasticsearch - - -if __name__ == '__main__': - from flask import Flask, jsonify - - app = Flask(__name__) - client = Elasticsearch('http://elasticsearch:9200/') - index_name = 'test' - - def create_index(): - client.indices.create(index=index_name, ignore=400) - - def save_index(): - data = {'song': 'Despacito', 'artist': 'Luis Fonsi'} - client.index(index=index_name, doc_type='test', id=1, body=data) - - def search(): - client.get(index=index_name, id=1) - - @app.route('/users', methods=['POST', 'GET']) - def application(): - create_index() - save_index() - search() - return jsonify({'song': 'Despacito', 'artist': 'Luis Fonsi'}) - - PORT = 9090 - app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/data/sw_elasticsearch/test_elasticsearch.py b/tests/plugin/data/sw_elasticsearch/test_elasticsearch.py deleted file mode 100644 index 738f626a..00000000 --- a/tests/plugin/data/sw_elasticsearch/test_elasticsearch.py +++ /dev/null @@ -1,36 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from typing import Callable - -import pytest -import requests - -from skywalking.plugins.sw_elasticsearch import support_matrix -from tests.orchestrator import get_test_vector -from tests.plugin.base import TestPluginBase - - -@pytest.fixture -def prepare(): - # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/users') - - -class TestPlugin(TestPluginBase): - @pytest.mark.parametrize('version', get_test_vector(lib_name='elasticsearch', support_matrix=support_matrix)) - def test_plugin(self, docker_compose, version): - self.validate() diff --git a/tests/plugin/data/sw_kafka/__init__.py b/tests/plugin/data/sw_kafka/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/data/sw_kafka/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/data/sw_kafka/docker-compose.yml b/tests/plugin/data/sw_kafka/docker-compose.yml deleted file mode 100644 index 618aeb52..00000000 --- a/tests/plugin/data/sw_kafka/docker-compose.yml +++ /dev/null @@ -1,109 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -version: '2.1' - -services: - collector: - extends: - service: collector - file: ../../docker-compose.base.yml - - zookeeper-server: - image: zookeeper:3.4 - hostname: zookeeper-server - ports: - - 2181:2181 - networks: - - beyond - healthcheck: - test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/2181"] - interval: 5s - timeout: 60s - retries: 120 - - kafka-server: - image: bitnami/kafka:2.1.1 - hostname: kafka-server - ports: - - 9092:9092 - environment: - - KAFKA_ZOOKEEPER_CONNECT=zookeeper-server:2181 - - KAFKA_BROKER_ID=1 - - ALLOW_PLAINTEXT_LISTENER=yes - - KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 - networks: - - beyond - healthcheck: - test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/9092"] - interval: 5s - timeout: 60s - retries: 120 - depends_on: - zookeeper-server: - condition: service_healthy - - producer: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9090:9090 - volumes: - - .:/app - command: ['bash', '-c', 'pip install flask && pip install -r /app/requirements.txt && sw-python run python3 /app/services/producer.py'] - healthcheck: - test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/9090"] - interval: 5s - timeout: 60s - retries: 120 - depends_on: - collector: - condition: service_healthy - kafka-server: - condition: service_healthy - consumer: - condition: service_healthy - environment: - SW_AGENT_NAME: producer - SW_AGENT_LOGGING_LEVEL: INFO - - consumer: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9091:9091 - volumes: - - .:/app - command: ['bash', '-c', 'pip install flask && pip install -r /app/requirements.txt && sw-python run python3 /app/services/consumer.py'] - healthcheck: - test: ["CMD", "bash", "-c", "ps -ef | grep /app/services/consumer | grep -v grep"] - interval: 5s - timeout: 60s - retries: 120 - depends_on: - collector: - condition: service_healthy - kafka-server: - condition: service_healthy - environment: - SW_AGENT_NAME: consumer - SW_AGENT_LOGGING_LEVEL: INFO - -networks: - beyond: diff --git a/tests/plugin/data/sw_kafka/expected.data.yml b/tests/plugin/data/sw_kafka/expected.data.yml deleted file mode 100644 index 837c390b..00000000 --- a/tests/plugin/data/sw_kafka/expected.data.yml +++ /dev/null @@ -1,86 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -segmentItems: - - serviceName: producer - segmentSize: 1 - segments: - - segmentId: not null - spans: - - operationName: Kafka/skywalking/Producer - parentSpanId: 0 - spanId: 1 - spanLayer: MQ - tags: - - key: mq.broker - value: 'kafka-server:9092' - - key: mq.topic - value: skywalking - startTime: gt 0 - endTime: gt 0 - componentId: 40 - spanType: Exit - peer: kafka-server:9092 - skipAnalysis: false - - operationName: /users - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - tags: - - key: http.method - value: GET - - key: http.url - value: http://0.0.0.0:9090/users - - key: http.status.code - value: '200' - startTime: gt 0 - endTime: gt 0 - componentId: 7001 - spanType: Entry - peer: not null - skipAnalysis: false - - serviceName: consumer - segmentSize: 1 - segments: - - segmentId: not null - spans: - - operationName: Kafka/skywalking/Consumer/skywalking - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: MQ - tags: - - key: mq.broker - value: 'kafka-server:9092' - - key: mq.topic - value: skywalking - refs: - - parentEndpoint: Kafka/skywalking/Producer - networkAddress: 'kafka-server:9092' - refType: CrossProcess - parentSpanId: 1 - parentTraceSegmentId: not null - parentServiceInstance: not null - parentService: producer - traceId: not null - startTime: gt 0 - endTime: gt 0 - componentId: 41 - spanType: Entry - peer: '' - skipAnalysis: false diff --git a/tests/plugin/data/sw_kafka/services/__init__.py b/tests/plugin/data/sw_kafka/services/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/data/sw_kafka/services/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/data/sw_kafka/services/consumer.py b/tests/plugin/data/sw_kafka/services/consumer.py deleted file mode 100644 index 71bf36b0..00000000 --- a/tests/plugin/data/sw_kafka/services/consumer.py +++ /dev/null @@ -1,32 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -if __name__ == '__main__': - topic = 'skywalking' - server_list = ['kafka-server:9092'] - group_id = 'skywalking' - client_id = '0' - - from kafka import KafkaConsumer - from kafka import TopicPartition - consumer = KafkaConsumer(group_id=group_id, - client_id=client_id, - bootstrap_servers=server_list) - partition = TopicPartition(topic, int(client_id)) - consumer.assign([partition]) - for msg in consumer: - print(msg) diff --git a/tests/plugin/data/sw_kafka/services/producer.py b/tests/plugin/data/sw_kafka/services/producer.py deleted file mode 100644 index c5cd8db6..00000000 --- a/tests/plugin/data/sw_kafka/services/producer.py +++ /dev/null @@ -1,33 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - - -if __name__ == '__main__': - from flask import Flask, jsonify - from kafka import KafkaProducer - - app = Flask(__name__) - producer = KafkaProducer(bootstrap_servers=['kafka-server:9092'], api_version=(1, 0, 1)) - - @app.route('/users', methods=['POST', 'GET']) - def application(): - producer.send('skywalking', b'some_message_bytes') - - return jsonify({'song': 'Despacito', 'artist': 'Luis Fonsi'}) - - PORT = 9090 - app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/data/sw_kafka/test_kafka.py b/tests/plugin/data/sw_kafka/test_kafka.py deleted file mode 100644 index a383c5a6..00000000 --- a/tests/plugin/data/sw_kafka/test_kafka.py +++ /dev/null @@ -1,36 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from typing import Callable - -import pytest -import requests - -from skywalking.plugins.sw_kafka import support_matrix -from tests.orchestrator import get_test_vector -from tests.plugin.base import TestPluginBase - - -@pytest.fixture -def prepare(): - # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/users') - - -class TestPlugin(TestPluginBase): - @pytest.mark.parametrize('version', get_test_vector(lib_name='kafka-python', support_matrix=support_matrix)) - def test_plugin(self, docker_compose, version): - self.validate() diff --git a/tests/plugin/data/sw_mysqlclient/__init__.py b/tests/plugin/data/sw_mysqlclient/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/data/sw_mysqlclient/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/data/sw_mysqlclient/docker-compose.yml b/tests/plugin/data/sw_mysqlclient/docker-compose.yml deleted file mode 100644 index 311ec430..00000000 --- a/tests/plugin/data/sw_mysqlclient/docker-compose.yml +++ /dev/null @@ -1,86 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -version: '2.1' - -services: - collector: - extends: - service: collector - file: ../../docker-compose.base.yml - - mysql: - image: mysql:5.7 - hostname: mysql - ports: - - 3306:3306 - - 33060:33060 - environment: - - MYSQL_ROOT_PASSWORD=root - - MYSQL_DATABASE=test - healthcheck: - test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/3306"] - interval: 5s - timeout: 60s - retries: 120 - networks: - - beyond - - provider: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9091:9091 - volumes: - - .:/app - command: ['bash', '-c', 'pip install flask && pip install -r /app/requirements.txt && sw-python run python3 /app/services/provider.py'] - depends_on: - collector: - condition: service_healthy - mysql: - condition: service_healthy - healthcheck: - test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/9091"] - interval: 5s - timeout: 60s - retries: 120 - environment: - SW_AGENT_NAME: provider - SW_AGENT_LOGGING_LEVEL: DEBUG - SW_SQL_PARAMETERS_LENGTH: 512 - - consumer: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9090:9090 - volumes: - - .:/app - command: ['bash', '-c', 'pip install flask && sw-python run python3 /app/services/consumer.py'] - depends_on: - collector: - condition: service_healthy - provider: - condition: service_healthy - environment: - SW_AGENT_NAME: consumer - SW_AGENT_LOGGING_LEVEL: DEBUG - -networks: - beyond: diff --git a/tests/plugin/data/sw_mysqlclient/expected.data.yml b/tests/plugin/data/sw_mysqlclient/expected.data.yml deleted file mode 100644 index cae7ce25..00000000 --- a/tests/plugin/data/sw_mysqlclient/expected.data.yml +++ /dev/null @@ -1,109 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -segmentItems: - - serviceName: provider - segmentSize: 1 - segments: - - segmentId: not null - spans: - - operationName: Mysql/MysqlClient/execute - parentSpanId: 0 - spanId: 1 - spanLayer: Database - tags: - - key: db.type - value: mysql - - key: db.instance - value: mysql - - key: db.statement - value: 'select * from user where user = %s' - - key: db.sql.parameters - value: '[root]' - startTime: gt 0 - endTime: gt 0 - componentId: 7013 - spanType: Exit - peer: mysql:3306 - skipAnalysis: false - - operationName: /users - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - tags: - - key: http.method - value: POST - - key: http.url - value: http://provider:9091/users - - key: http.status.code - value: '200' - refs: - - parentEndpoint: /users - networkAddress: provider:9091 - refType: CrossProcess - parentSpanId: 1 - parentTraceSegmentId: not null - parentServiceInstance: not null - parentService: consumer - traceId: not null - startTime: gt 0 - endTime: gt 0 - componentId: 7001 - spanType: Entry - peer: not null - skipAnalysis: false - - serviceName: consumer - segmentSize: 1 - segments: - - segmentId: not null - spans: - - operationName: /users - parentSpanId: 0 - spanId: 1 - spanLayer: Http - tags: - - key: http.method - value: POST - - key: http.url - value: http://provider:9091/users - - key: http.status.code - value: '200' - startTime: gt 0 - endTime: gt 0 - componentId: 7002 - spanType: Exit - peer: provider:9091 - skipAnalysis: false - - operationName: /users - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - tags: - - key: http.method - value: GET - - key: http.url - value: http://0.0.0.0:9090/users - - key: http.status.code - value: '200' - startTime: gt 0 - endTime: gt 0 - componentId: 7001 - spanType: Entry - peer: not null - skipAnalysis: false \ No newline at end of file diff --git a/tests/plugin/data/sw_mysqlclient/services/__init__.py b/tests/plugin/data/sw_mysqlclient/services/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/data/sw_mysqlclient/services/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/data/sw_mysqlclient/services/consumer.py b/tests/plugin/data/sw_mysqlclient/services/consumer.py deleted file mode 100644 index 3085092a..00000000 --- a/tests/plugin/data/sw_mysqlclient/services/consumer.py +++ /dev/null @@ -1,32 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import requests - - -if __name__ == '__main__': - from flask import Flask, jsonify - - app = Flask(__name__) - - @app.route('/users', methods=['POST', 'GET']) - def application(): - res = requests.post('http://provider:9091/users') - return jsonify(res.json()) - - PORT = 9090 - app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/data/sw_mysqlclient/services/provider.py b/tests/plugin/data/sw_mysqlclient/services/provider.py deleted file mode 100644 index 8e24f6e0..00000000 --- a/tests/plugin/data/sw_mysqlclient/services/provider.py +++ /dev/null @@ -1,39 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import time - -if __name__ == '__main__': - from flask import Flask, jsonify - import MySQLdb - - app = Flask(__name__) - - @app.route('/users', methods=['POST', 'GET']) - def application(): - time.sleep(0.5) - connection = MySQLdb.connect(host='mysql', user='root', passwd='root', db='mysql', charset='utf8mb4') - with connection.cursor() as cursor: - sql = 'select * from user where user = %s' - cursor.execute(sql, ('root',)) - - connection.close() - - return jsonify({'song': 'Despacito', 'artist': 'Luis Fonsi'}) - - PORT = 9091 - app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/data/sw_mysqlclient/test_mysqlclient.py b/tests/plugin/data/sw_mysqlclient/test_mysqlclient.py deleted file mode 100644 index f306fb29..00000000 --- a/tests/plugin/data/sw_mysqlclient/test_mysqlclient.py +++ /dev/null @@ -1,36 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from typing import Callable - -import pytest -import requests - -from skywalking.plugins.sw_mysqlclient import support_matrix -from tests.orchestrator import get_test_vector -from tests.plugin.base import TestPluginBase - - -@pytest.fixture -def prepare(): - # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/users') - - -class TestPlugin(TestPluginBase): - @pytest.mark.parametrize('version', get_test_vector(lib_name='mysqlclient', support_matrix=support_matrix)) - def test_plugin(self, docker_compose, version): - self.validate() diff --git a/tests/plugin/data/sw_psycopg/__init__.py b/tests/plugin/data/sw_psycopg/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/data/sw_psycopg/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/data/sw_psycopg/docker-compose.yml b/tests/plugin/data/sw_psycopg/docker-compose.yml deleted file mode 100644 index bc88f5e8..00000000 --- a/tests/plugin/data/sw_psycopg/docker-compose.yml +++ /dev/null @@ -1,87 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -version: '2.1' - -services: - collector: - extends: - service: collector - file: ../../docker-compose.base.yml - - postgres: - image: postgres:11 - hostname: postgres - ports: - - "5432:5444" - environment: - - POSTGRES_USER=root - - POSTGRES_PASSWORD=root - - POSTGRES_DB=admin - - POSTGRES_PORT=5444 - healthcheck: - test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/5432"] - interval: 5s - timeout: 60s - retries: 120 - networks: - - beyond - - provider: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9091:9091 - volumes: - - .:/app - command: ['bash', '-c', 'pip install flask && pip install -r /app/requirements.txt && sw-python run python3 /app/services/provider.py'] - depends_on: - collector: - condition: service_healthy - postgres: - condition: service_healthy - healthcheck: - test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/9091"] - interval: 5s - timeout: 60s - retries: 120 - environment: - SW_AGENT_NAME: provider - SW_AGENT_LOGGING_LEVEL: DEBUG - SW_SQL_PARAMETERS_LENGTH: 512 - - consumer: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9090:9090 - volumes: - - .:/app - command: ['bash', '-c', 'pip install flask && sw-python run python3 /app/services/consumer.py'] - depends_on: - collector: - condition: service_healthy - provider: - condition: service_healthy - environment: - SW_AGENT_NAME: consumer - SW_AGENT_LOGGING_LEVEL: DEBUG - -networks: - beyond: diff --git a/tests/plugin/data/sw_psycopg/expected.data.yml b/tests/plugin/data/sw_psycopg/expected.data.yml deleted file mode 100644 index 2544a3be..00000000 --- a/tests/plugin/data/sw_psycopg/expected.data.yml +++ /dev/null @@ -1,110 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -segmentItems: - - serviceName: provider - segmentSize: 1 - segments: - - segmentId: not null - spans: - - operationName: PostgreSLQ/Psycopg/execute - parentSpanId: 0 - spanId: 1 - spanLayer: Database - tags: - - key: db.type - value: PostgreSQL - - key: db.instance - value: admin - - key: db.statement - value: 'select * from user where user = %s' - - key: db.sql.parameters - value: '[root]' - startTime: gt 0 - endTime: gt 0 - isError: false - componentId: 7010 - spanType: Exit - peer: postgres:5432 - skipAnalysis: false - - operationName: /users - parentSpanId: -1 - spanId: 0 - spanLayer: Http - tags: - - key: http.method - value: POST - - key: http.url - value: http://provider:9091/users - - key: http.status.code - value: '200' - refs: - - parentEndpoint: /users - networkAddress: provider:9091 - refType: CrossProcess - parentSpanId: 1 - parentTraceSegmentId: not null - parentServiceInstance: not null - parentService: consumer - traceId: not null - startTime: gt 0 - endTime: gt 0 - componentId: 7001 - spanType: Entry - peer: not null - skipAnalysis: false - - serviceName: consumer - segmentSize: 1 - segments: - - segmentId: not null - spans: - - operationName: /users - parentSpanId: 0 - spanId: 1 - spanLayer: Http - tags: - - key: http.method - value: POST - - key: http.url - value: http://provider:9091/users - - key: http.status.code - value: '200' - startTime: gt 0 - endTime: gt 0 - componentId: 7002 - isError: false - spanType: Exit - peer: provider:9091 - skipAnalysis: false - - operationName: /users - parentSpanId: -1 - spanId: 0 - spanLayer: Http - tags: - - key: http.method - value: GET - - key: http.url - value: http://0.0.0.0:9090/users - - key: http.status.code - value: '200' - startTime: gt 0 - endTime: gt 0 - componentId: 7001 - isError: false - spanType: Entry - peer: not null - skipAnalysis: false \ No newline at end of file diff --git a/tests/plugin/data/sw_psycopg/services/__init__.py b/tests/plugin/data/sw_psycopg/services/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/data/sw_psycopg/services/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/data/sw_psycopg/services/consumer.py b/tests/plugin/data/sw_psycopg/services/consumer.py deleted file mode 100644 index 3085092a..00000000 --- a/tests/plugin/data/sw_psycopg/services/consumer.py +++ /dev/null @@ -1,32 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import requests - - -if __name__ == '__main__': - from flask import Flask, jsonify - - app = Flask(__name__) - - @app.route('/users', methods=['POST', 'GET']) - def application(): - res = requests.post('http://provider:9091/users') - return jsonify(res.json()) - - PORT = 9090 - app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/data/sw_psycopg/services/provider.py b/tests/plugin/data/sw_psycopg/services/provider.py deleted file mode 100644 index 29e0325d..00000000 --- a/tests/plugin/data/sw_psycopg/services/provider.py +++ /dev/null @@ -1,40 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import time - - -if __name__ == '__main__': - from flask import Flask, jsonify - import psycopg - - app = Flask(__name__) - - @app.route('/users', methods=['POST', 'GET']) - def application(): - time.sleep(0.5) - connection = psycopg.connect(host='postgres', user='root', password='root', dbname='admin', port=5432) - with connection.cursor() as cursor: - sql = 'select * from user where user = %s' - cursor.execute(sql, ('root',)) - - connection.close() - - return jsonify({'song': 'Despacito', 'artist': 'Luis Fonsi'}) - - PORT = 9091 - app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/data/sw_psycopg/test_psycopg.py b/tests/plugin/data/sw_psycopg/test_psycopg.py deleted file mode 100644 index a8f284dd..00000000 --- a/tests/plugin/data/sw_psycopg/test_psycopg.py +++ /dev/null @@ -1,36 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from typing import Callable - -import pytest -import requests - -from skywalking.plugins.sw_psycopg import support_matrix -from tests.orchestrator import get_test_vector -from tests.plugin.base import TestPluginBase - - -@pytest.fixture -def prepare(): - # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/users') - - -class TestPlugin(TestPluginBase): - @pytest.mark.parametrize('version', get_test_vector(lib_name='psycopg[binary]', support_matrix=support_matrix)) - def test_plugin(self, docker_compose, version): - self.validate() diff --git a/tests/plugin/data/sw_psycopg2/__init__.py b/tests/plugin/data/sw_psycopg2/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/data/sw_psycopg2/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/data/sw_psycopg2/docker-compose.yml b/tests/plugin/data/sw_psycopg2/docker-compose.yml deleted file mode 100644 index a564216e..00000000 --- a/tests/plugin/data/sw_psycopg2/docker-compose.yml +++ /dev/null @@ -1,86 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -version: '2.1' - -services: - collector: - extends: - service: collector - file: ../../docker-compose.base.yml - - postgres: - image: postgres:11 - hostname: postgres - ports: - - 5432:5432 - environment: - - POSTGRES_USER=root - - POSTGRES_PASSWORD=root - - POSTGRES_DB=admin - healthcheck: - test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/5432"] - interval: 5s - timeout: 60s - retries: 120 - networks: - - beyond - - provider: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9091:9091 - volumes: - - .:/app - command: ['bash', '-c', 'pip install flask && pip install -r /app/requirements.txt && sw-python run python3 /app/services/provider.py'] - depends_on: - collector: - condition: service_healthy - postgres: - condition: service_healthy - healthcheck: - test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/9091"] - interval: 5s - timeout: 60s - retries: 120 - environment: - SW_AGENT_NAME: provider - SW_AGENT_LOGGING_LEVEL: DEBUG - SW_SQL_PARAMETERS_LENGTH: 512 - - consumer: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9090:9090 - volumes: - - .:/app - command: ['bash', '-c', 'pip install flask && sw-python run python3 /app/services/consumer.py'] - depends_on: - collector: - condition: service_healthy - provider: - condition: service_healthy - environment: - SW_AGENT_NAME: consumer - SW_AGENT_LOGGING_LEVEL: DEBUG - -networks: - beyond: diff --git a/tests/plugin/data/sw_psycopg2/expected.data.yml b/tests/plugin/data/sw_psycopg2/expected.data.yml deleted file mode 100644 index c5a91a11..00000000 --- a/tests/plugin/data/sw_psycopg2/expected.data.yml +++ /dev/null @@ -1,112 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -segmentItems: - - serviceName: provider - segmentSize: 1 - segments: - - segmentId: not null - spans: - - operationName: PostgreSLQ/Psycopg/execute - parentSpanId: 0 - spanId: 1 - spanLayer: Database - tags: - - key: db.type - value: PostgreSQL - - key: db.instance - value: admin - - key: db.statement - value: 'select * from user where user = %s' - - key: db.sql.parameters - value: '[root]' - startTime: gt 0 - endTime: gt 0 - isError: false - componentId: 7010 - spanType: Exit - peer: postgres:5432 - skipAnalysis: false - - operationName: /users - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - tags: - - key: http.method - value: POST - - key: http.url - value: http://provider:9091/users - - key: http.status.code - value: '200' - refs: - - parentEndpoint: /users - networkAddress: provider:9091 - refType: CrossProcess - parentSpanId: 1 - parentTraceSegmentId: not null - parentServiceInstance: not null - parentService: consumer - traceId: not null - startTime: gt 0 - endTime: gt 0 - componentId: 7001 - spanType: Entry - peer: not null - skipAnalysis: false - - serviceName: consumer - segmentSize: 1 - segments: - - segmentId: not null - spans: - - operationName: /users - parentSpanId: 0 - spanId: 1 - spanLayer: Http - tags: - - key: http.method - value: POST - - key: http.url - value: http://provider:9091/users - - key: http.status.code - value: '200' - startTime: gt 0 - endTime: gt 0 - componentId: 7002 - isError: false - spanType: Exit - peer: provider:9091 - skipAnalysis: false - - operationName: /users - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - tags: - - key: http.method - value: GET - - key: http.url - value: http://0.0.0.0:9090/users - - key: http.status.code - value: '200' - startTime: gt 0 - endTime: gt 0 - componentId: 7001 - isError: false - spanType: Entry - peer: not null - skipAnalysis: false \ No newline at end of file diff --git a/tests/plugin/data/sw_psycopg2/services/__init__.py b/tests/plugin/data/sw_psycopg2/services/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/data/sw_psycopg2/services/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/data/sw_psycopg2/services/consumer.py b/tests/plugin/data/sw_psycopg2/services/consumer.py deleted file mode 100644 index 3085092a..00000000 --- a/tests/plugin/data/sw_psycopg2/services/consumer.py +++ /dev/null @@ -1,32 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import requests - - -if __name__ == '__main__': - from flask import Flask, jsonify - - app = Flask(__name__) - - @app.route('/users', methods=['POST', 'GET']) - def application(): - res = requests.post('http://provider:9091/users') - return jsonify(res.json()) - - PORT = 9090 - app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/data/sw_psycopg2/services/provider.py b/tests/plugin/data/sw_psycopg2/services/provider.py deleted file mode 100644 index 8a5bed75..00000000 --- a/tests/plugin/data/sw_psycopg2/services/provider.py +++ /dev/null @@ -1,40 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import time - - -if __name__ == '__main__': - from flask import Flask, jsonify - import psycopg2 - - app = Flask(__name__) - - @app.route('/users', methods=['POST', 'GET']) - def application(): - time.sleep(0.5) - connection = psycopg2.connect(host='postgres', user='root', password='root', dbname='admin') - with connection.cursor() as cursor: - sql = 'select * from user where user = %s' - cursor.execute(sql, ('root',)) - - connection.close() - - return jsonify({'song': 'Despacito', 'artist': 'Luis Fonsi'}) - - PORT = 9091 - app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/data/sw_psycopg2/test_psycopg2.py b/tests/plugin/data/sw_psycopg2/test_psycopg2.py deleted file mode 100644 index d6f954d4..00000000 --- a/tests/plugin/data/sw_psycopg2/test_psycopg2.py +++ /dev/null @@ -1,36 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from typing import Callable - -import pytest -import requests - -from skywalking.plugins.sw_psycopg2 import support_matrix -from tests.orchestrator import get_test_vector -from tests.plugin.base import TestPluginBase - - -@pytest.fixture -def prepare(): - # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/users') - - -class TestPlugin(TestPluginBase): - @pytest.mark.parametrize('version', get_test_vector(lib_name='psycopg2-binary', support_matrix=support_matrix)) - def test_plugin(self, docker_compose, version): - self.validate() diff --git a/tests/plugin/data/sw_pymongo/__init__.py b/tests/plugin/data/sw_pymongo/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/data/sw_pymongo/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/data/sw_pymongo/docker-compose.yml b/tests/plugin/data/sw_pymongo/docker-compose.yml deleted file mode 100644 index 588db5b9..00000000 --- a/tests/plugin/data/sw_pymongo/docker-compose.yml +++ /dev/null @@ -1,82 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -version: '2.1' - -services: - collector: - extends: - service: collector - file: ../../docker-compose.base.yml - - mongo: - image: mongo:4.2 - hostname: mongo - ports: - - 27017:27017 - healthcheck: - test: echo 'db.runCommand("ping").ok' | mongo mongo:27017/test --quiet - interval: 5s - timeout: 60s - retries: 120 - networks: - - beyond - - provider: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9091:9091 - volumes: - - .:/app - command: ['bash', '-c', 'pip install flask && pip install -r /app/requirements.txt && sw-python run python3 /app/services/provider.py'] - depends_on: - collector: - condition: service_healthy - mongo: - condition: service_healthy - healthcheck: - test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/9091"] - interval: 5s - timeout: 60s - retries: 120 - environment: - SW_AGENT_NAME: provider - SW_AGENT_LOGGING_LEVEL: DEBUG - SW_PYMONGO_TRACE_PARAMETERS: 'True' - - consumer: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9090:9090 - volumes: - - .:/app - command: ['bash', '-c', 'pip install flask && sw-python run python3 /app/services/consumer.py'] - depends_on: - collector: - condition: service_healthy - provider: - condition: service_healthy - environment: - SW_AGENT_NAME: consumer - SW_AGENT_LOGGING_LEVEL: DEBUG - -networks: - beyond: diff --git a/tests/plugin/data/sw_pymongo/expected.data.yml b/tests/plugin/data/sw_pymongo/expected.data.yml deleted file mode 100644 index 6afd5487..00000000 --- a/tests/plugin/data/sw_pymongo/expected.data.yml +++ /dev/null @@ -1,233 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -segmentItems: - - serviceName: provider - segmentSize: 3 - segments: - - segmentId: not null - spans: - - operationName: MongoDB/MixedBulkWriteOperation - parentSpanId: 0 - spanId: 1 - spanLayer: Database - startTime: gt 0 - endTime: gt 0 - componentId: 9 - spanType: Exit - peer: not null - skipAnalysis: false - tags: - - key: db.type - value: MongoDB - - key: db.instance - value: test-database - - key: db.statement - value: not null - - operationName: /insert_many - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - startTime: gt 0 - endTime: gt 0 - componentId: 7001 - spanType: Entry - peer: not null - skipAnalysis: false - tags: - - key: http.method - value: GET - - key: http.url - value: http://provider:9091/insert_many - - key: http.status.code - value: '200' - refs: - - parentEndpoint: /insert_many - networkAddress: provider:9091 - refType: CrossProcess - parentSpanId: 1 - parentTraceSegmentId: not null - parentServiceInstance: not null - parentService: consumer - traceId: not null - - segmentId: not null - spans: - - operationName: MongoDB/FindOperation - parentSpanId: 0 - spanId: 1 - spanLayer: Database - startTime: gt 0 - endTime: gt 0 - componentId: 9 - spanType: Exit - peer: not null - skipAnalysis: false - tags: - - key: db.type - value: MongoDB - - key: db.instance - value: test-database - - key: db.statement - value: not null - - operationName: /find_one - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - startTime: gt 0 - endTime: gt 0 - componentId: 7001 - spanType: Entry - peer: not null - skipAnalysis: false - tags: - - key: http.method - value: GET - - key: http.url - value: http://provider:9091/find_one - - key: http.status.code - value: '200' - refs: - - parentEndpoint: /find_one - networkAddress: provider:9091 - refType: CrossProcess - parentSpanId: 2 - parentTraceSegmentId: not null - parentServiceInstance: not null - parentService: consumer - traceId: not null - - segmentId: not null - spans: - - operationName: MongoDB/DeleteOperation - parentSpanId: 0 - spanId: 1 - spanLayer: Database - startTime: gt 0 - endTime: gt 0 - componentId: 9 - spanType: Exit - peer: not null - skipAnalysis: false - tags: - - key: db.type - value: MongoDB - - key: db.instance - value: test-database - - key: db.statement - value: not null - - operationName: /delete_one - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - startTime: gt 0 - endTime: gt 0 - componentId: 7001 - spanType: Entry - peer: not null - skipAnalysis: false - tags: - - key: http.method - value: GET - - key: http.url - value: http://provider:9091/delete_one - - key: http.status.code - value: '200' - refs: - - parentEndpoint: /delete_one - networkAddress: provider:9091 - refType: CrossProcess - parentSpanId: 3 - parentTraceSegmentId: not null - parentServiceInstance: not null - parentService: consumer - traceId: not null - - serviceName: consumer - segmentSize: 1 - segments: - - segmentId: not null - spans: - - operationName: /insert_many - parentSpanId: 0 - spanId: 1 - spanLayer: Http - startTime: gt 0 - endTime: gt 0 - componentId: 7002 - spanType: Exit - peer: provider:9091 - skipAnalysis: false - tags: - - key: http.method - value: GET - - key: http.url - value: http://provider:9091/insert_many - - key: http.status.code - value: '200' - - operationName: /find_one - parentSpanId: 0 - spanId: 2 - spanLayer: Http - startTime: gt 0 - endTime: gt 0 - componentId: 7002 - spanType: Exit - peer: provider:9091 - skipAnalysis: false - tags: - - key: http.method - value: GET - - key: http.url - value: http://provider:9091/find_one - - key: http.status.code - value: '200' - - operationName: /delete_one - parentSpanId: 0 - spanId: 3 - spanLayer: Http - startTime: gt 0 - endTime: gt 0 - componentId: 7002 - spanType: Exit - peer: provider:9091 - skipAnalysis: false - tags: - - key: http.method - value: GET - - key: http.url - value: http://provider:9091/delete_one - - key: http.status.code - value: '200' - - operationName: /users - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - startTime: gt 0 - endTime: gt 0 - componentId: 7001 - spanType: Entry - peer: not null - skipAnalysis: false - tags: - - key: http.method - value: GET - - key: http.url - value: http://0.0.0.0:9090/users - - key: http.status.code - value: '200' diff --git a/tests/plugin/data/sw_pymongo/services/__init__.py b/tests/plugin/data/sw_pymongo/services/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/data/sw_pymongo/services/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/data/sw_pymongo/services/consumer.py b/tests/plugin/data/sw_pymongo/services/consumer.py deleted file mode 100644 index 610494e5..00000000 --- a/tests/plugin/data/sw_pymongo/services/consumer.py +++ /dev/null @@ -1,34 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import requests - - -if __name__ == '__main__': - from flask import Flask, jsonify - - app = Flask(__name__) - - @app.route('/users', methods=['POST', 'GET']) - def application(): - requests.get('http://provider:9091/insert_many') - requests.get('http://provider:9091/find_one') - res = requests.get('http://provider:9091/delete_one') - return jsonify(res.json()) - - PORT = 9090 - app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/data/sw_pymongo/services/provider.py b/tests/plugin/data/sw_pymongo/services/provider.py deleted file mode 100644 index 67ba9b0f..00000000 --- a/tests/plugin/data/sw_pymongo/services/provider.py +++ /dev/null @@ -1,58 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import time - -from flask import Flask, jsonify -from pymongo import MongoClient - -client = MongoClient('mongodb://mongo:27017/') -db = client['test-database'] -collection = db['test-collection'] - - -app = Flask(__name__) - - -@app.route('/insert_many', methods=['GET']) -def test_insert_many(): - time.sleep(0.5) - new_posts = [{'song': 'Despacito'}, - {'artist': 'Luis Fonsi'}] - result = collection.insert_many(new_posts) - return jsonify({'ok': result.acknowledged}) - - -@app.route('/find_one', methods=['GET']) -def test_find_one(): - time.sleep(0.5) - result = collection.find_one({'song': 'Despacito'}) - # have to get the result and use it. if not lint will report error - print(result) - return jsonify({'song': 'Despacito'}) - - -@app.route('/delete_one', methods=['GET']) -def test_delete_one(): - time.sleep(0.5) - result = collection.delete_one({'song': 'Despacito'}) - return jsonify({'ok': result.acknowledged}) - - -if __name__ == '__main__': - PORT = 9091 - app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/data/sw_pymongo/test_pymongo.py b/tests/plugin/data/sw_pymongo/test_pymongo.py deleted file mode 100644 index 3b2b81af..00000000 --- a/tests/plugin/data/sw_pymongo/test_pymongo.py +++ /dev/null @@ -1,36 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from typing import Callable - -import pytest -import requests - -from skywalking.plugins.sw_pymongo import support_matrix -from tests.orchestrator import get_test_vector -from tests.plugin.base import TestPluginBase - - -@pytest.fixture -def prepare(): - # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/users') - - -class TestPlugin(TestPluginBase): - @pytest.mark.parametrize('version', get_test_vector(lib_name='pymongo', support_matrix=support_matrix)) - def test_plugin(self, docker_compose, version): - self.validate() diff --git a/tests/plugin/data/sw_pymysql/__init__.py b/tests/plugin/data/sw_pymysql/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/data/sw_pymysql/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/data/sw_pymysql/docker-compose.yml b/tests/plugin/data/sw_pymysql/docker-compose.yml deleted file mode 100644 index 311ec430..00000000 --- a/tests/plugin/data/sw_pymysql/docker-compose.yml +++ /dev/null @@ -1,86 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -version: '2.1' - -services: - collector: - extends: - service: collector - file: ../../docker-compose.base.yml - - mysql: - image: mysql:5.7 - hostname: mysql - ports: - - 3306:3306 - - 33060:33060 - environment: - - MYSQL_ROOT_PASSWORD=root - - MYSQL_DATABASE=test - healthcheck: - test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/3306"] - interval: 5s - timeout: 60s - retries: 120 - networks: - - beyond - - provider: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9091:9091 - volumes: - - .:/app - command: ['bash', '-c', 'pip install flask && pip install -r /app/requirements.txt && sw-python run python3 /app/services/provider.py'] - depends_on: - collector: - condition: service_healthy - mysql: - condition: service_healthy - healthcheck: - test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/9091"] - interval: 5s - timeout: 60s - retries: 120 - environment: - SW_AGENT_NAME: provider - SW_AGENT_LOGGING_LEVEL: DEBUG - SW_SQL_PARAMETERS_LENGTH: 512 - - consumer: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9090:9090 - volumes: - - .:/app - command: ['bash', '-c', 'pip install flask && sw-python run python3 /app/services/consumer.py'] - depends_on: - collector: - condition: service_healthy - provider: - condition: service_healthy - environment: - SW_AGENT_NAME: consumer - SW_AGENT_LOGGING_LEVEL: DEBUG - -networks: - beyond: diff --git a/tests/plugin/data/sw_pymysql/expected.data.yml b/tests/plugin/data/sw_pymysql/expected.data.yml deleted file mode 100644 index 901f8eb2..00000000 --- a/tests/plugin/data/sw_pymysql/expected.data.yml +++ /dev/null @@ -1,109 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -segmentItems: - - serviceName: provider - segmentSize: 1 - segments: - - segmentId: not null - spans: - - operationName: Mysql/PyMsql/execute - parentSpanId: 0 - spanId: 1 - spanLayer: Database - tags: - - key: db.type - value: mysql - - key: db.instance - value: mysql - - key: db.statement - value: 'select * from user where user = %s' - - key: db.sql.parameters - value: '[root]' - startTime: gt 0 - endTime: gt 0 - componentId: 7003 - spanType: Exit - peer: mysql:3306 - skipAnalysis: false - - operationName: /users - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - tags: - - key: http.method - value: POST - - key: http.url - value: http://provider:9091/users - - key: http.status.code - value: '200' - refs: - - parentEndpoint: /users - networkAddress: provider:9091 - refType: CrossProcess - parentSpanId: 1 - parentTraceSegmentId: not null - parentServiceInstance: not null - parentService: consumer - traceId: not null - startTime: gt 0 - endTime: gt 0 - componentId: 7001 - spanType: Entry - peer: not null - skipAnalysis: false - - serviceName: consumer - segmentSize: 1 - segments: - - segmentId: not null - spans: - - operationName: /users - parentSpanId: 0 - spanId: 1 - spanLayer: Http - tags: - - key: http.method - value: POST - - key: http.url - value: http://provider:9091/users - - key: http.status.code - value: '200' - startTime: gt 0 - endTime: gt 0 - componentId: 7002 - spanType: Exit - peer: provider:9091 - skipAnalysis: false - - operationName: /users - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - tags: - - key: http.method - value: GET - - key: http.url - value: http://0.0.0.0:9090/users - - key: http.status.code - value: '200' - startTime: gt 0 - endTime: gt 0 - componentId: 7001 - spanType: Entry - peer: not null - skipAnalysis: false \ No newline at end of file diff --git a/tests/plugin/data/sw_pymysql/services/__init__.py b/tests/plugin/data/sw_pymysql/services/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/data/sw_pymysql/services/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/data/sw_pymysql/services/consumer.py b/tests/plugin/data/sw_pymysql/services/consumer.py deleted file mode 100644 index 3085092a..00000000 --- a/tests/plugin/data/sw_pymysql/services/consumer.py +++ /dev/null @@ -1,32 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import requests - - -if __name__ == '__main__': - from flask import Flask, jsonify - - app = Flask(__name__) - - @app.route('/users', methods=['POST', 'GET']) - def application(): - res = requests.post('http://provider:9091/users') - return jsonify(res.json()) - - PORT = 9090 - app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/data/sw_pymysql/services/provider.py b/tests/plugin/data/sw_pymysql/services/provider.py deleted file mode 100644 index 3486016d..00000000 --- a/tests/plugin/data/sw_pymysql/services/provider.py +++ /dev/null @@ -1,39 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import time - -if __name__ == '__main__': - from flask import Flask, jsonify - import pymysql.cursors - - app = Flask(__name__) - - @app.route('/users', methods=['POST', 'GET']) - def application(): - time.sleep(0.5) - connection = pymysql.connect(host='mysql', user='root', password='root', db='mysql', charset='utf8mb4') - with connection.cursor() as cursor: - sql = 'select * from user where user = %s' - cursor.execute(sql, ('root',)) - - connection.close() - - return jsonify({'song': 'Despacito', 'artist': 'Luis Fonsi'}) - - PORT = 9091 - app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/data/sw_pymysql/test_pymysql.py b/tests/plugin/data/sw_pymysql/test_pymysql.py deleted file mode 100644 index 12ca1660..00000000 --- a/tests/plugin/data/sw_pymysql/test_pymysql.py +++ /dev/null @@ -1,36 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from typing import Callable - -import pytest -import requests - -from skywalking.plugins.sw_pymysql import support_matrix -from tests.orchestrator import get_test_vector -from tests.plugin.base import TestPluginBase - - -@pytest.fixture -def prepare(): - # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/users') - - -class TestPlugin(TestPluginBase): - @pytest.mark.parametrize('version', get_test_vector(lib_name='pymysql', support_matrix=support_matrix)) - def test_plugin(self, docker_compose, version): - self.validate() diff --git a/tests/plugin/data/sw_rabbitmq/__init__.py b/tests/plugin/data/sw_rabbitmq/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/data/sw_rabbitmq/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/data/sw_rabbitmq/docker-compose.yml b/tests/plugin/data/sw_rabbitmq/docker-compose.yml deleted file mode 100644 index 66d49ddd..00000000 --- a/tests/plugin/data/sw_rabbitmq/docker-compose.yml +++ /dev/null @@ -1,93 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -version: '2.1' - -services: - collector: - extends: - service: collector - file: ../../docker-compose.base.yml - - rabbitmq-server: - image: rabbitmq:3.8.18 - hostname: rabbitmq-server - ports: - - 5672:5672 - - 15672:15672 - environment: - - RABBITMQ_DEFAULT_PASS=admin - - RABBITMQ_DEFAULT_USER=admin - - RABBITMQ_DEFAULT_VHOST=/ - networks: - - beyond - healthcheck: - test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/5672"] - interval: 5s - timeout: 60s - retries: 120 - - producer: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9090:9090 - volumes: - - .:/app - command: ['bash', '-c', 'pip install flask && pip install -r /app/requirements.txt && sw-python run python3 /app/services/producer.py'] - healthcheck: - test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/9090"] - interval: 5s - timeout: 60s - retries: 120 - depends_on: - collector: - condition: service_healthy - rabbitmq-server: - condition: service_healthy - consumer: - condition: service_healthy - environment: - SW_AGENT_NAME: producer - SW_AGENT_LOGGING_LEVEL: INFO - - consumer: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9091:9091 - volumes: - - .:/app - command: ['bash', '-c', 'pip install flask && pip install -r /app/requirements.txt && sw-python run python3 /app/services/consumer.py'] - healthcheck: - test: ["CMD", "bash", "-c", "ps -ef | grep /app/services/consumer | grep -v grep"] - interval: 5s - timeout: 60s - retries: 120 - depends_on: - collector: - condition: service_healthy - rabbitmq-server: - condition: service_healthy - environment: - SW_AGENT_NAME: consumer - SW_AGENT_LOGGING_LEVEL: INFO - -networks: - beyond: diff --git a/tests/plugin/data/sw_rabbitmq/expected.data.yml b/tests/plugin/data/sw_rabbitmq/expected.data.yml deleted file mode 100644 index e5e9a79b..00000000 --- a/tests/plugin/data/sw_rabbitmq/expected.data.yml +++ /dev/null @@ -1,90 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -segmentItems: - - serviceName: producer - segmentSize: 1 - segments: - - segmentId: not null - spans: - - operationName: RabbitMQ/Topic/test/Queue/test/Producer - parentSpanId: 0 - spanId: 1 - spanLayer: MQ - tags: - - key: mq.broker - value: 'rabbitmq-server:5672' - - key: mq.topic - value: test - - key: mq.queue - value: test - startTime: gt 0 - endTime: gt 0 - componentId: 52 - spanType: Exit - peer: rabbitmq-server:5672 - skipAnalysis: false - - operationName: /users - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - tags: - - key: http.method - value: GET - - key: http.url - value: http://0.0.0.0:9090/users - - key: http.status.code - value: '200' - startTime: gt 0 - endTime: gt 0 - componentId: 7001 - spanType: Entry - peer: not null - skipAnalysis: false - - serviceName: consumer - segmentSize: 1 - segments: - - segmentId: not null - spans: - - operationName: RabbitMQ/Topic/test/Queue/test/Consumer - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: MQ - tags: - - key: mq.broker - value: 'rabbitmq-server:5672' - - key: mq.topic - value: test - - key: mq.queue - value: test - refs: - - parentEndpoint: RabbitMQ/Topic/test/Queue/test/Producer - networkAddress: 'rabbitmq-server:5672' - refType: CrossProcess - parentSpanId: 1 - parentTraceSegmentId: not null - parentServiceInstance: not null - parentService: producer - traceId: not null - startTime: gt 0 - endTime: gt 0 - componentId: 53 - spanType: Entry - peer: '' - skipAnalysis: false diff --git a/tests/plugin/data/sw_rabbitmq/services/__init__.py b/tests/plugin/data/sw_rabbitmq/services/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/data/sw_rabbitmq/services/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/data/sw_rabbitmq/services/consumer.py b/tests/plugin/data/sw_rabbitmq/services/consumer.py deleted file mode 100644 index d6e0dea3..00000000 --- a/tests/plugin/data/sw_rabbitmq/services/consumer.py +++ /dev/null @@ -1,45 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -if __name__ == '__main__': - import pika - - parameters = (pika.URLParameters('amqp://admin:admin@rabbitmq-server:5672/%2F')) - - connection = pika.BlockingConnection(parameters) - - channel = connection.channel() - channel.queue_declare('test') - channel.exchange_declare('test') - channel.queue_bind(exchange='test', queue='test', routing_key='test') - for method_frame, properties, body in channel.consume('test'): - # Display the message parts and acknowledge the message - print(method_frame, properties, body) - channel.basic_ack(method_frame.delivery_tag) - - # Escape out of the loop after 10 messages - if method_frame.delivery_tag == 10: - break - - try: - # Loop so we can communicate with RabbitMQ - connection.ioloop.start() - except KeyboardInterrupt: - # Gracefully close the connection - connection.close() - # Loop until we're fully closed, will stop on its own - connection.ioloop.start() diff --git a/tests/plugin/data/sw_rabbitmq/services/producer.py b/tests/plugin/data/sw_rabbitmq/services/producer.py deleted file mode 100644 index 66a7dc09..00000000 --- a/tests/plugin/data/sw_rabbitmq/services/producer.py +++ /dev/null @@ -1,41 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - - -if __name__ == '__main__': - from flask import Flask, jsonify - app = Flask(__name__) - import pika - parameters = (pika.URLParameters('amqp://admin:admin@rabbitmq-server:5672/%2F')) - - @app.route('/users', methods=['POST', 'GET']) - def application(): - connection = pika.BlockingConnection(parameters) - channel = connection.channel() - channel.queue_declare('test') - channel.exchange_declare('test') - channel.queue_bind(exchange='test', queue='test', routing_key='test') - channel.basic_publish( - exchange='test', routing_key='test', - properties=pika.BasicProperties(headers={'key': 'value'}), - body=b'Test message.') - connection.close() - - return jsonify({'song': 'Despacito', 'artist': 'Luis Fonsi'}) - - PORT = 9090 - app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/data/sw_rabbitmq/test_rabbitmq.py b/tests/plugin/data/sw_rabbitmq/test_rabbitmq.py deleted file mode 100644 index e9ab3812..00000000 --- a/tests/plugin/data/sw_rabbitmq/test_rabbitmq.py +++ /dev/null @@ -1,36 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from typing import Callable - -import pytest -import requests - -from skywalking.plugins.sw_rabbitmq import support_matrix -from tests.orchestrator import get_test_vector -from tests.plugin.base import TestPluginBase - - -@pytest.fixture -def prepare(): - # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/users') - - -class TestPlugin(TestPluginBase): - @pytest.mark.parametrize('version', get_test_vector(lib_name='pika', support_matrix=support_matrix)) - def test_plugin(self, docker_compose, version): - self.validate() diff --git a/tests/plugin/data/sw_redis/__init__.py b/tests/plugin/data/sw_redis/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/data/sw_redis/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/data/sw_redis/docker-compose.yml b/tests/plugin/data/sw_redis/docker-compose.yml deleted file mode 100644 index 468cf64e..00000000 --- a/tests/plugin/data/sw_redis/docker-compose.yml +++ /dev/null @@ -1,79 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -version: '2.1' - -services: - collector: - extends: - service: collector - file: ../../docker-compose.base.yml - - redis: - image: redis:3.2.9-alpine - hostname: redis - ports: - - 6379:6379 - healthcheck: - test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/6379"] - interval: 5s - timeout: 60s - retries: 120 - networks: - - beyond - - provider: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9091:9091 - volumes: - - .:/app - command: ['bash', '-c', 'pip install flask && pip install -r /app/requirements.txt && sw-python run python3 /app/services/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 - environment: - SW_AGENT_NAME: provider - SW_AGENT_LOGGING_LEVEL: DEBUG - - consumer: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9090:9090 - volumes: - - .:/app - command: ['bash', '-c', 'pip install flask && sw-python run python3 /app/services/consumer.py'] - depends_on: - collector: - condition: service_healthy - provider: - condition: service_healthy - environment: - SW_AGENT_NAME: consumer - SW_AGENT_LOGGING_LEVEL: DEBUG - -networks: - beyond: diff --git a/tests/plugin/data/sw_redis/expected.data.yml b/tests/plugin/data/sw_redis/expected.data.yml deleted file mode 100644 index cbf57ada..00000000 --- a/tests/plugin/data/sw_redis/expected.data.yml +++ /dev/null @@ -1,124 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -segmentItems: - - serviceName: provider - segmentSize: 1 - segments: - - segmentId: not null - spans: - - operationName: Redis/SET - parentSpanId: 0 - spanId: 1 - spanLayer: Cache - tags: - - key: db.type - value: Redis - - key: db.instance - value: '0' - - key: db.statement - value: 'SET' - startTime: gt 0 - endTime: gt 0 - componentId: 7 - spanType: Exit - peer: redis:6379 - skipAnalysis: false - - operationName: Redis/GET - parentSpanId: 0 - spanId: 2 - spanLayer: Cache - tags: - - key: db.type - value: Redis - - key: db.instance - value: '0' - - key: db.statement - value: 'GET' - startTime: gt 0 - endTime: gt 0 - componentId: 7 - spanType: Exit - peer: redis:6379 - skipAnalysis: false - - operationName: /users - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - tags: - - key: http.method - value: POST - - key: http.url - value: http://provider:9091/users - - key: http.status.code - value: '200' - refs: - - parentEndpoint: /users - networkAddress: provider:9091 - refType: CrossProcess - parentSpanId: 1 - parentTraceSegmentId: not null - parentServiceInstance: not null - parentService: consumer - traceId: not null - startTime: gt 0 - endTime: gt 0 - componentId: 7001 - spanType: Entry - peer: not null - skipAnalysis: false - - serviceName: consumer - segmentSize: 1 - segments: - - segmentId: not null - spans: - - operationName: /users - parentSpanId: 0 - spanId: 1 - spanLayer: Http - tags: - - key: http.method - value: POST - - key: http.url - value: http://provider:9091/users - - key: http.status.code - value: '200' - startTime: gt 0 - endTime: gt 0 - componentId: 7002 - spanType: Exit - peer: provider:9091 - skipAnalysis: false - - operationName: /users - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - tags: - - key: http.method - value: GET - - key: http.url - value: http://0.0.0.0:9090/users - - key: http.status.code - value: '200' - startTime: gt 0 - endTime: gt 0 - componentId: 7001 - spanType: Entry - peer: not null - skipAnalysis: false \ No newline at end of file diff --git a/tests/plugin/data/sw_redis/services/__init__.py b/tests/plugin/data/sw_redis/services/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/data/sw_redis/services/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/data/sw_redis/services/consumer.py b/tests/plugin/data/sw_redis/services/consumer.py deleted file mode 100644 index 3085092a..00000000 --- a/tests/plugin/data/sw_redis/services/consumer.py +++ /dev/null @@ -1,32 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import requests - - -if __name__ == '__main__': - from flask import Flask, jsonify - - app = Flask(__name__) - - @app.route('/users', methods=['POST', 'GET']) - def application(): - res = requests.post('http://provider:9091/users') - return jsonify(res.json()) - - PORT = 9090 - app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/data/sw_redis/services/provider.py b/tests/plugin/data/sw_redis/services/provider.py deleted file mode 100644 index 2e02461e..00000000 --- a/tests/plugin/data/sw_redis/services/provider.py +++ /dev/null @@ -1,39 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import time - - -if __name__ == '__main__': - from flask import Flask, jsonify - import redis - - app = Flask(__name__) - - @app.route('/users', methods=['POST', 'GET']) - def application(): - time.sleep(0.5) - - r = redis.StrictRedis(host='redis', port=6379, db=0) - - r.set('foo', 'bar') - r.get('foo') - - return jsonify({'song': 'Despacito', 'artist': 'Luis Fonsi'}) - - PORT = 9091 - app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/data/sw_redis/test_redis.py b/tests/plugin/data/sw_redis/test_redis.py deleted file mode 100644 index a3ca1b98..00000000 --- a/tests/plugin/data/sw_redis/test_redis.py +++ /dev/null @@ -1,36 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from typing import Callable - -import pytest -import requests - -from skywalking.plugins.sw_redis import support_matrix -from tests.orchestrator import get_test_vector -from tests.plugin.base import TestPluginBase - - -@pytest.fixture -def prepare(): - # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/users') - - -class TestPlugin(TestPluginBase): - @pytest.mark.parametrize('version', get_test_vector(lib_name='redis', support_matrix=support_matrix)) - def test_plugin(self, docker_compose, version): - self.validate() diff --git a/tests/plugin/http/__init__.py b/tests/plugin/http/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/http/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/http/sw_aiohttp/__init__.py b/tests/plugin/http/sw_aiohttp/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/http/sw_aiohttp/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/http/sw_aiohttp/docker-compose.yml b/tests/plugin/http/sw_aiohttp/docker-compose.yml deleted file mode 100644 index ad9f832f..00000000 --- a/tests/plugin/http/sw_aiohttp/docker-compose.yml +++ /dev/null @@ -1,66 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -version: '2.1' - -services: - collector: - extends: - service: collector - file: ../../docker-compose.base.yml - - provider: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9091:9091 - volumes: - - .:/app - command: ['bash', '-c', 'pip install -r /app/requirements.txt && sw-python run sw-python run python3 /app/services/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 - environment: - SW_AGENT_NAME: provider - SW_AGENT_LOGGING_LEVEL: DEBUG - - consumer: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9090:9090 - volumes: - - .:/app - command: ['bash', '-c', 'pip install -r /app/requirements.txt && sw-python run sw-python run python3 /app/services/consumer.py'] - depends_on: - collector: - condition: service_healthy - provider: - condition: service_healthy - environment: - SW_AGENT_NAME: consumer - SW_AGENT_LOGGING_LEVEL: DEBUG - -networks: - beyond: diff --git a/tests/plugin/http/sw_aiohttp/expected.data.yml b/tests/plugin/http/sw_aiohttp/expected.data.yml deleted file mode 100644 index 60e2e760..00000000 --- a/tests/plugin/http/sw_aiohttp/expected.data.yml +++ /dev/null @@ -1,89 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -segmentItems: - - serviceName: provider - segmentSize: 1 - segments: - - segmentId: not null - spans: - - operationName: /skywalking - parentSpanId: -1 - spanId: 0 - spanLayer: Http - tags: - - key: http.method - value: GET - - key: http.url - value: http://provider:9091/skywalking - - key: http.status.code - value: '200' - refs: - - parentEndpoint: /skywalking - networkAddress: provider:9091 - refType: CrossProcess - parentSpanId: 1 - parentTraceSegmentId: not null - parentServiceInstance: not null - parentService: consumer - traceId: not null - startTime: gt 0 - endTime: gt 0 - componentId: 7008 - spanType: Entry - peer: not null - skipAnalysis: false - - serviceName: consumer - segmentSize: 1 - segments: - - segmentId: not null - spans: - - operationName: /skywalking - parentSpanId: 0 - spanId: 1 - spanLayer: Http - tags: - - key: http.method - value: GET - - key: http.url - value: http://provider:9091/skywalking - - key: http.status.code - value: '200' - startTime: gt 0 - endTime: gt 0 - componentId: 7008 - spanType: Exit - peer: provider:9091 - skipAnalysis: false - - operationName: /skywalking - parentSpanId: -1 - spanId: 0 - spanLayer: Http - tags: - - key: http.method - value: GET - - key: http.url - value: http://0.0.0.0:9090/skywalking - - key: http.status.code - value: '200' - startTime: gt 0 - endTime: gt 0 - componentId: 7008 - spanType: Entry - peer: not null - skipAnalysis: false - diff --git a/tests/plugin/http/sw_aiohttp/services/__init__.py b/tests/plugin/http/sw_aiohttp/services/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/http/sw_aiohttp/services/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/http/sw_aiohttp/services/consumer.py b/tests/plugin/http/sw_aiohttp/services/consumer.py deleted file mode 100644 index 8869b864..00000000 --- a/tests/plugin/http/sw_aiohttp/services/consumer.py +++ /dev/null @@ -1,37 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import time - -import aiohttp -from aiohttp import web - - -async def handle(request): - name = request.match_info.get('name', 'Anonymous') - - async with aiohttp.ClientSession() as session: - async with session.get(f'http://user:pass@provider:9091/{name}') as response: - time.sleep(.5) - json = await response.json() - return web.Response(text=str(json)) - - -app = web.Application() -app.add_routes([web.get('/', handle), web.get('/{name}', handle)]) - -if __name__ == '__main__': - web.run_app(app, port=9090) diff --git a/tests/plugin/http/sw_aiohttp/services/provider.py b/tests/plugin/http/sw_aiohttp/services/provider.py deleted file mode 100644 index 165d551e..00000000 --- a/tests/plugin/http/sw_aiohttp/services/provider.py +++ /dev/null @@ -1,32 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -from aiohttp import web - - -async def handle(request): - name = request.match_info.get('name', 'Anonymous') - return web.json_response({ - name: name, - }) - - -app = web.Application() -app.add_routes([web.get('/', handle), web.get('/{name}', handle)]) - -if __name__ == '__main__': - web.run_app(app, port=9091) diff --git a/tests/plugin/http/sw_aiohttp/test_aiohttp.py b/tests/plugin/http/sw_aiohttp/test_aiohttp.py deleted file mode 100644 index 1e72a89f..00000000 --- a/tests/plugin/http/sw_aiohttp/test_aiohttp.py +++ /dev/null @@ -1,36 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from typing import Callable - -import pytest -import requests - -from skywalking.plugins.sw_aiohttp import support_matrix -from tests.orchestrator import get_test_vector -from tests.plugin.base import TestPluginBase - - -@pytest.fixture # pyre-ignore -def prepare(): - # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/skywalking') - - -class TestPlugin(TestPluginBase): - @pytest.mark.parametrize('version', get_test_vector(lib_name='aiohttp', support_matrix=support_matrix)) - def test_plugin(self, docker_compose, version): - self.validate() diff --git a/tests/plugin/http/sw_http/__init__.py b/tests/plugin/http/sw_http/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/http/sw_http/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/http/sw_http/docker-compose.yml b/tests/plugin/http/sw_http/docker-compose.yml deleted file mode 100644 index f5c5fb3d..00000000 --- a/tests/plugin/http/sw_http/docker-compose.yml +++ /dev/null @@ -1,66 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -version: '2.1' - -services: - collector: - extends: - service: collector - file: ../../docker-compose.base.yml - - provider: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9091:9091 - volumes: - - .:/app - command: [ 'bash', '-c', 'sw-python run python3 /app/services/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 - environment: - SW_AGENT_NAME: provider - SW_AGENT_LOGGING_LEVEL: DEBUG - - consumer: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9090:9090 - volumes: - - .:/app - command: [ 'bash', '-c', 'sw-python run python3 /app/services/consumer.py' ] - depends_on: - collector: - condition: service_healthy - provider: - condition: service_healthy - environment: - SW_AGENT_NAME: consumer - SW_AGENT_LOGGING_LEVEL: DEBUG - -networks: - beyond: diff --git a/tests/plugin/http/sw_http/expected.data.yml b/tests/plugin/http/sw_http/expected.data.yml deleted file mode 100644 index 16adce86..00000000 --- a/tests/plugin/http/sw_http/expected.data.yml +++ /dev/null @@ -1,90 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -segmentItems: - - serviceName: provider - segmentSize: 1 - segments: - - segmentId: not null - spans: - - operationName: /users - parentSpanId: -1 - spanId: 0 - spanLayer: Http - tags: - - key: http.method - value: POST - - key: http.url - value: http://provider:9091/users - - key: http.status.code - value: '200' - refs: - - parentEndpoint: /users - networkAddress: provider:9091 - refType: CrossProcess - parentSpanId: 1 - parentTraceSegmentId: not null - parentServiceInstance: not null - parentService: consumer - traceId: not null - startTime: gt 0 - endTime: gt 0 - componentId: 7000 - spanType: Entry - peer: not null - skipAnalysis: false - - serviceName: consumer - segmentSize: 1 - segments: - - segmentId: not null - spans: - - operationName: /users - parentSpanId: 0 - spanId: 1 - spanLayer: Http - tags: - - key: http.method - value: POST - - key: http.url - value: http://provider:9091/users - - key: http.status.code - value: '200' - startTime: gt 0 - endTime: gt 0 - componentId: 7000 - spanType: Exit - peer: provider:9091 - skipAnalysis: false - - operationName: / - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - tags: - - key: http.method - value: POST - - key: http.url - value: http://0.0.0.0:9090/ - - key: http.status.code - value: '200' - startTime: gt 0 - endTime: gt 0 - componentId: 7000 - spanType: Entry - peer: not null - skipAnalysis: false - diff --git a/tests/plugin/http/sw_http/services/__init__.py b/tests/plugin/http/sw_http/services/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/http/sw_http/services/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/http/sw_http/services/consumer.py b/tests/plugin/http/sw_http/services/consumer.py deleted file mode 100644 index bd9e769e..00000000 --- a/tests/plugin/http/sw_http/services/consumer.py +++ /dev/null @@ -1,44 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -from urllib import request - - -if __name__ == '__main__': - - import socketserver - from http.server import BaseHTTPRequestHandler - - class SimpleHTTPRequestHandler(BaseHTTPRequestHandler): - def do_POST(self): # noqa - self.send_response(200) - self.send_header('Content-Type', 'application/json; charset=utf-8') - self.end_headers() - - data = '{"name": "whatever"}'.encode('utf8') - req = request.Request('http://provider:9091/users') - req.add_header('Content-Type', 'application/json; charset=utf-8') - req.add_header('Content-Length', str(len(data))) - with request.urlopen(req, data): - self.wfile.write(data) - - PORT = 9090 - Handler = SimpleHTTPRequestHandler - - with socketserver.TCPServer(('', PORT), Handler) as httpd: - print('serving at port', PORT) - httpd.serve_forever() diff --git a/tests/plugin/http/sw_http/services/provider.py b/tests/plugin/http/sw_http/services/provider.py deleted file mode 100644 index d57d7e0d..00000000 --- a/tests/plugin/http/sw_http/services/provider.py +++ /dev/null @@ -1,38 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import time - - -if __name__ == '__main__': - import socketserver - from http.server import BaseHTTPRequestHandler - - class SimpleHTTPRequestHandler(BaseHTTPRequestHandler): - - def do_POST(self): # noqa - time.sleep(0.5) - self.send_response(200) - self.send_header('Content-Type', 'application/json') - self.end_headers() - self.wfile.write('{"song": "Despacito", "artist": "Luis Fonsi"}'.encode('ascii')) - - PORT = 9091 - Handler = SimpleHTTPRequestHandler - - with socketserver.TCPServer(('', PORT), Handler) as httpd: - httpd.serve_forever() diff --git a/tests/plugin/http/sw_http/test_http.py b/tests/plugin/http/sw_http/test_http.py deleted file mode 100644 index d9317baa..00000000 --- a/tests/plugin/http/sw_http/test_http.py +++ /dev/null @@ -1,33 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from typing import Callable - -import pytest -import requests - -from tests.plugin.base import TestPluginBase - - -@pytest.fixture -def prepare(): - # type: () -> Callable - return lambda *_: requests.post('http://0.0.0.0:9090') - - -class TestPlugin(TestPluginBase): - def test_plugin(self, docker_compose, version): - self.validate() diff --git a/tests/plugin/http/sw_http_wsgi/__init__.py b/tests/plugin/http/sw_http_wsgi/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/http/sw_http_wsgi/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/http/sw_http_wsgi/docker-compose.yml b/tests/plugin/http/sw_http_wsgi/docker-compose.yml deleted file mode 100644 index 99f19505..00000000 --- a/tests/plugin/http/sw_http_wsgi/docker-compose.yml +++ /dev/null @@ -1,66 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -version: '2.1' - -services: - collector: - extends: - service: collector - file: ../../docker-compose.base.yml - - provider: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9091:9091 - volumes: - - .:/app - command: ['bash', '-c', 'pip install -r /app/requirements.txt && sw-python run python3 /app/services/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 - environment: - SW_AGENT_NAME: provider - SW_AGENT_LOGGING_LEVEL: DEBUG - - consumer: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9090:9090 - volumes: - - .:/app - command: ['bash', '-c', 'pip install -r /app/requirements.txt && sw-python run python3 /app/services/consumer.py'] - depends_on: - collector: - condition: service_healthy - provider: - condition: service_healthy - environment: - SW_AGENT_NAME: consumer - SW_AGENT_LOGGING_LEVEL: DEBUG - -networks: - beyond: diff --git a/tests/plugin/http/sw_http_wsgi/expected.data.yml b/tests/plugin/http/sw_http_wsgi/expected.data.yml deleted file mode 100644 index 9ccfec5f..00000000 --- a/tests/plugin/http/sw_http_wsgi/expected.data.yml +++ /dev/null @@ -1,91 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -segmentItems: - - serviceName: provider - segmentSize: 1 - segments: - - segmentId: not null - spans: - - operationName: /users - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - tags: - - key: http.method - value: POST - - key: http.url - value: http://provider:9091/users - - key: http.status.code - value: '200' - refs: - - parentEndpoint: /users - networkAddress: provider:9091 - refType: CrossProcess - parentSpanId: 1 - parentTraceSegmentId: not null - parentServiceInstance: not null - parentService: consumer - traceId: not null - startTime: gt 0 - endTime: gt 0 - componentId: 7000 - spanType: Entry - peer: not null - skipAnalysis: false - - serviceName: consumer - segmentSize: 1 - segments: - - segmentId: not null - spans: - - operationName: /users - parentSpanId: 0 - spanId: 1 - spanLayer: Http - tags: - - key: http.method - value: POST - - key: http.url - value: http://provider:9091/users - - key: http.status.code - value: '200' - startTime: gt 0 - endTime: gt 0 - componentId: 7000 - spanType: Exit - peer: provider:9091 - skipAnalysis: false - - operationName: / - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - tags: - - key: http.method - value: POST - - key: http.url - value: http://0.0.0.0:9090/ - - key: http.status.code - value: '200' - startTime: gt 0 - endTime: gt 0 - componentId: 7000 - spanType: Entry - peer: not null - skipAnalysis: false - diff --git a/tests/plugin/http/sw_http_wsgi/services/__init__.py b/tests/plugin/http/sw_http_wsgi/services/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/http/sw_http_wsgi/services/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/http/sw_http_wsgi/services/consumer.py b/tests/plugin/http/sw_http_wsgi/services/consumer.py deleted file mode 100644 index 41e5e4f0..00000000 --- a/tests/plugin/http/sw_http_wsgi/services/consumer.py +++ /dev/null @@ -1,43 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -from urllib import request - - -if __name__ == '__main__': - import socketserver - from http.server import BaseHTTPRequestHandler - - class SimpleHTTPRequestHandler(BaseHTTPRequestHandler): - def do_POST(self): # noqa - self.send_response(200) - self.send_header('Content-Type', 'application/json; charset=utf-8') - self.end_headers() - - data = '{"name": "whatever"}'.encode('utf8') - req = request.Request('http://provider:9091/users') - req.add_header('Content-Type', 'application/json; charset=utf-8') - req.add_header('Content-Length', str(len(data))) - with request.urlopen(req, data): - self.wfile.write(data) - - PORT = 9090 - Handler = SimpleHTTPRequestHandler - - with socketserver.TCPServer(('', PORT), Handler) as httpd: - print('serving at port', PORT) - httpd.serve_forever() diff --git a/tests/plugin/http/sw_http_wsgi/services/provider.py b/tests/plugin/http/sw_http_wsgi/services/provider.py deleted file mode 100644 index b28377dc..00000000 --- a/tests/plugin/http/sw_http_wsgi/services/provider.py +++ /dev/null @@ -1,32 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import time - - -if __name__ == '__main__': - from werkzeug import Request, Response - - @Request.application - def application(request): - time.sleep(0.5) - return Response('{"song": "Despacito", "artist": "Luis Fonsi"}') - - from werkzeug.serving import run_simple - - PORT = 9091 - run_simple('', PORT, application) diff --git a/tests/plugin/http/sw_http_wsgi/test_http_wsgi.py b/tests/plugin/http/sw_http_wsgi/test_http_wsgi.py deleted file mode 100644 index 4a2a1f13..00000000 --- a/tests/plugin/http/sw_http_wsgi/test_http_wsgi.py +++ /dev/null @@ -1,36 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from typing import Callable - -import pytest -import requests - -from skywalking.plugins.sw_http_server import support_matrix -from tests.orchestrator import get_test_vector -from tests.plugin.base import TestPluginBase - - -@pytest.fixture -def prepare(): - # type: () -> Callable - return lambda *_: requests.post('http://0.0.0.0:9090') - - -class TestPlugin(TestPluginBase): - @pytest.mark.parametrize('version', get_test_vector(lib_name='werkzeug', support_matrix=support_matrix)) - def test_plugin(self, docker_compose, version): - self.validate() diff --git a/tests/plugin/http/sw_requests/__init__.py b/tests/plugin/http/sw_requests/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/http/sw_requests/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/http/sw_requests/docker-compose.yml b/tests/plugin/http/sw_requests/docker-compose.yml deleted file mode 100644 index 0b66033f..00000000 --- a/tests/plugin/http/sw_requests/docker-compose.yml +++ /dev/null @@ -1,66 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -version: '2.1' - -services: - collector: - extends: - service: collector - file: ../../docker-compose.base.yml - - provider: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9091:9091 - volumes: - - .:/app - depends_on: - collector: - condition: service_healthy - command: ['bash', '-c', 'pip install -r /app/requirements.txt && sw-python run python3 /app/services/provider.py'] - healthcheck: - test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/9091"] - interval: 5s - timeout: 60s - retries: 120 - environment: - SW_AGENT_NAME: provider - SW_AGENT_LOGGING_LEVEL: DEBUG - - consumer: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9090:9090 - volumes: - - .:/app - command: ['bash', '-c', 'pip install -r /app/requirements.txt && sw-python run python3 /app/services/consumer.py'] - depends_on: - collector: - condition: service_healthy - provider: - condition: service_healthy - environment: - SW_AGENT_NAME: consumer - SW_AGENT_LOGGING_LEVEL: DEBUG - -networks: - beyond: diff --git a/tests/plugin/http/sw_requests/expected.data.yml b/tests/plugin/http/sw_requests/expected.data.yml deleted file mode 100644 index 5cee8ed6..00000000 --- a/tests/plugin/http/sw_requests/expected.data.yml +++ /dev/null @@ -1,90 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -segmentItems: - - serviceName: provider - segmentSize: 1 - segments: - - segmentId: not null - spans: - - operationName: /users - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - tags: - - key: http.method - value: POST - - key: http.url - value: http://provider:9091/users - - key: http.status.code - value: '200' - refs: - - parentEndpoint: /users - networkAddress: provider:9091 - refType: CrossProcess - parentSpanId: 1 - parentTraceSegmentId: not null - parentServiceInstance: not null - parentService: consumer - traceId: not null - startTime: gt 0 - endTime: gt 0 - componentId: 7000 - spanType: Entry - peer: not null - skipAnalysis: false - - serviceName: consumer - segmentSize: 1 - segments: - - segmentId: not null - spans: - - operationName: /users - parentSpanId: 0 - spanId: 1 - spanLayer: Http - tags: - - key: http.method - value: POST - - key: http.url - value: http://provider:9091/users - - key: http.status.code - value: '200' - startTime: gt 0 - endTime: gt 0 - componentId: 7002 - spanType: Exit - peer: provider:9091 - skipAnalysis: false - - operationName: / - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - tags: - - key: http.method - value: POST - - key: http.url - value: http://0.0.0.0:9090/ - - key: http.status.code - value: '200' - startTime: gt 0 - endTime: gt 0 - componentId: 7000 - spanType: Entry - peer: not null - skipAnalysis: false \ No newline at end of file diff --git a/tests/plugin/http/sw_requests/services/__init__.py b/tests/plugin/http/sw_requests/services/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/http/sw_requests/services/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/http/sw_requests/services/consumer.py b/tests/plugin/http/sw_requests/services/consumer.py deleted file mode 100644 index db0d10e9..00000000 --- a/tests/plugin/http/sw_requests/services/consumer.py +++ /dev/null @@ -1,39 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import requests - - -if __name__ == '__main__': - import socketserver - from http.server import BaseHTTPRequestHandler - - class SimpleHTTPRequestHandler(BaseHTTPRequestHandler): - def do_POST(self): # noqa - self.send_response(200) - self.send_header('Content-Type', 'application/json; charset=utf-8') - self.end_headers() - - res = requests.post('http://provider:9091/users') - self.wfile.write(str(res.json()).encode('utf8')) - - PORT = 9090 - Handler = SimpleHTTPRequestHandler - - with socketserver.TCPServer(('', PORT), Handler) as httpd: - print('serving at port', PORT) - httpd.serve_forever() diff --git a/tests/plugin/http/sw_requests/services/provider.py b/tests/plugin/http/sw_requests/services/provider.py deleted file mode 100644 index d57d7e0d..00000000 --- a/tests/plugin/http/sw_requests/services/provider.py +++ /dev/null @@ -1,38 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import time - - -if __name__ == '__main__': - import socketserver - from http.server import BaseHTTPRequestHandler - - class SimpleHTTPRequestHandler(BaseHTTPRequestHandler): - - def do_POST(self): # noqa - time.sleep(0.5) - self.send_response(200) - self.send_header('Content-Type', 'application/json') - self.end_headers() - self.wfile.write('{"song": "Despacito", "artist": "Luis Fonsi"}'.encode('ascii')) - - PORT = 9091 - Handler = SimpleHTTPRequestHandler - - with socketserver.TCPServer(('', PORT), Handler) as httpd: - httpd.serve_forever() diff --git a/tests/plugin/http/sw_requests/test_request.py b/tests/plugin/http/sw_requests/test_request.py deleted file mode 100644 index 81083269..00000000 --- a/tests/plugin/http/sw_requests/test_request.py +++ /dev/null @@ -1,36 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from typing import Callable - -import pytest -import requests - -from skywalking.plugins.sw_requests import support_matrix -from tests.orchestrator import get_test_vector -from tests.plugin.base import TestPluginBase - - -@pytest.fixture -def prepare(): - # type: () -> Callable - return lambda *_: requests.post('http://0.0.0.0:9090') - - -class TestPlugin(TestPluginBase): - @pytest.mark.parametrize('version', get_test_vector(lib_name='requests', support_matrix=support_matrix)) - def test_plugin(self, docker_compose, version): - self.validate() diff --git a/tests/plugin/http/sw_urllib3/__init__.py b/tests/plugin/http/sw_urllib3/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/http/sw_urllib3/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/http/sw_urllib3/docker-compose.yml b/tests/plugin/http/sw_urllib3/docker-compose.yml deleted file mode 100644 index e3dac0a2..00000000 --- a/tests/plugin/http/sw_urllib3/docker-compose.yml +++ /dev/null @@ -1,66 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -version: '2.1' - -services: - collector: - extends: - service: collector - file: ../../docker-compose.base.yml - - provider: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9091:9091 - volumes: - - .:/app - command: ['bash', '-c', 'pip install flask && sw-python run python3 /app/services/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 - environment: - SW_AGENT_NAME: provider - SW_AGENT_LOGGING_LEVEL: DEBUG - - consumer: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9090:9090 - volumes: - - .:/app - command: ['bash', '-c', 'pip install flask && pip install -r /app/requirements.txt && sw-python run python3 /app/services/consumer.py'] - depends_on: - collector: - condition: service_healthy - provider: - condition: service_healthy - environment: - SW_AGENT_NAME: consumer - SW_AGENT_LOGGING_LEVEL: DEBUG - -networks: - beyond: diff --git a/tests/plugin/http/sw_urllib3/expected.data.yml b/tests/plugin/http/sw_urllib3/expected.data.yml deleted file mode 100644 index d67762ec..00000000 --- a/tests/plugin/http/sw_urllib3/expected.data.yml +++ /dev/null @@ -1,93 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - - -segmentItems: - - serviceName: provider - segmentSize: 1 - segments: - - segmentId: not null - spans: - - operationName: /users - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - tags: - - key: http.method - value: POST - - key: http.url - value: http://provider:9091/users - - key: http.status.code - value: '200' - refs: - - parentEndpoint: /users - networkAddress: 'provider:9091' - refType: CrossProcess - parentSpanId: 1 - parentTraceSegmentId: not null - parentServiceInstance: not null - parentService: consumer - traceId: not null - startTime: gt 0 - endTime: gt 0 - componentId: 7001 - spanType: Entry - peer: not null - skipAnalysis: false - - serviceName: consumer - segmentSize: 1 - segments: - - segmentId: not null - spans: - - operationName: /users - parentSpanId: 0 - spanId: 1 - spanLayer: Http - startTime: gt 0 - endTime: gt 0 - componentId: 7006 - isError: false - spanType: Exit - peer: not null - skipAnalysis: false - tags: - - key: http.method - value: POST - - key: http.url - value: 'http://provider:9091/users' - - key: http.status.code - value: '200' - - operationName: /users - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - startTime: gt 0 - endTime: gt 0 - componentId: 7001 - isError: false - spanType: Entry - peer: not null - skipAnalysis: false - tags: - - key: http.method - value: GET - - key: http.url - value: 'http://0.0.0.0:9090/users' - - key: http.status.code - value: '200' \ No newline at end of file diff --git a/tests/plugin/http/sw_urllib3/services/__init__.py b/tests/plugin/http/sw_urllib3/services/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/http/sw_urllib3/services/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/http/sw_urllib3/services/consumer.py b/tests/plugin/http/sw_urllib3/services/consumer.py deleted file mode 100644 index c2522004..00000000 --- a/tests/plugin/http/sw_urllib3/services/consumer.py +++ /dev/null @@ -1,34 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import json - - -if __name__ == '__main__': - from flask import Flask, jsonify - - app = Flask(__name__) - import urllib3 - - @app.route('/users', methods=['POST', 'GET']) - def application(): - http = urllib3.PoolManager() - res = http.request('POST', 'http://provider:9091/users') - - return jsonify(json.loads(res.data.decode('utf-8'))) - - PORT = 9090 - app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/http/sw_urllib3/services/provider.py b/tests/plugin/http/sw_urllib3/services/provider.py deleted file mode 100644 index dba7163d..00000000 --- a/tests/plugin/http/sw_urllib3/services/provider.py +++ /dev/null @@ -1,32 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import time - - -if __name__ == '__main__': - from flask import Flask, jsonify - - app = Flask(__name__) - - @app.route('/users', methods=['POST', 'GET']) - def application(): - time.sleep(0.5) - return jsonify({'song': 'Despacito', 'artist': 'Luis Fonsi'}) - - PORT = 9091 - app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/http/sw_urllib3/test_urllib3.py b/tests/plugin/http/sw_urllib3/test_urllib3.py deleted file mode 100644 index 9316d1ed..00000000 --- a/tests/plugin/http/sw_urllib3/test_urllib3.py +++ /dev/null @@ -1,36 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from typing import Callable - -import pytest -import requests - -from skywalking.plugins.sw_urllib3 import support_matrix -from tests.orchestrator import get_test_vector -from tests.plugin.base import TestPluginBase - - -@pytest.fixture -def prepare(): - # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/users') - - -class TestPlugin(TestPluginBase): - @pytest.mark.parametrize('version', get_test_vector(lib_name='urllib3', support_matrix=support_matrix)) - def test_plugin(self, docker_compose, version): - self.validate() diff --git a/tests/plugin/web/sw_django/__init__.py b/tests/plugin/web/sw_django/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/web/sw_django/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/web/sw_django/docker-compose.yml b/tests/plugin/web/sw_django/docker-compose.yml deleted file mode 100644 index 242d2342..00000000 --- a/tests/plugin/web/sw_django/docker-compose.yml +++ /dev/null @@ -1,67 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -version: '2.1' - -services: - collector: - extends: - service: collector - file: ../../docker-compose.base.yml - - provider: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9091:9091 - volumes: - - .:/app - command: ['bash', '-c', 'pip install -r /app/requirements.txt && sw-python run python3 /app/services/provider.py runserver 0.0.0.0:9091'] - 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 - environment: - SW_AGENT_NAME: provider - SW_AGENT_LOGGING_LEVEL: DEBUG - - consumer: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9090:9090 - volumes: - - .:/app - command: ['bash', '-c', 'pip install -r /app/requirements.txt && sw-python run python3 /app/services/consumer.py runserver 0.0.0.0:9090'] - depends_on: - collector: - condition: service_healthy - provider: - condition: service_healthy - environment: - SW_AGENT_NAME: consumer - SW_AGENT_LOGGING_LEVEL: DEBUG - SW_DJANGO_COLLECT_HTTP_PARAMS: 'True' - -networks: - beyond: diff --git a/tests/plugin/web/sw_django/expected.data.yml b/tests/plugin/web/sw_django/expected.data.yml deleted file mode 100644 index 9222ce0f..00000000 --- a/tests/plugin/web/sw_django/expected.data.yml +++ /dev/null @@ -1,90 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -segmentItems: - - serviceName: provider - segmentSize: 1 - segments: - - segmentId: not null - spans: - - operationName: /users - parentSpanId: -1 - spanId: 0 - spanLayer: Http - startTime: gt 0 - endTime: gt 0 - componentId: 7004 - spanType: Entry - peer: not null - skipAnalysis: false - tags: - - key: http.method - value: POST - - key: http.url - value: http://provider:9091/users - - key: http.status.code - value: '200' - refs: - - parentEndpoint: /users - networkAddress: provider:9091 - refType: CrossProcess - parentSpanId: 1 - parentTraceSegmentId: not null - parentServiceInstance: not null - parentService: consumer - traceId: not null - - serviceName: consumer - segmentSize: 1 - segments: - - segmentId: not null - spans: - - operationName: /users - parentSpanId: 0 - spanId: 1 - spanLayer: Http - startTime: gt 0 - endTime: gt 0 - componentId: 7002 - spanType: Exit - peer: provider:9091 - skipAnalysis: false - tags: - - key: http.method - value: POST - - key: http.url - value: http://provider:9091/users - - key: http.status.code - value: '200' - - operationName: /users - parentSpanId: -1 - spanId: 0 - spanLayer: Http - startTime: gt 0 - endTime: gt 0 - componentId: 7004 - spanType: Entry - peer: not null - skipAnalysis: false - tags: - - key: http.method - value: GET - - key: http.url - value: http://0.0.0.0:9090/users - - key: http.params - value: "test=[test1,test2]\ntest2=[test2]" - - key: http.status.code - value: '200' diff --git a/tests/plugin/web/sw_django/services/__init__.py b/tests/plugin/web/sw_django/services/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/web/sw_django/services/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/web/sw_django/services/consumer.py b/tests/plugin/web/sw_django/services/consumer.py deleted file mode 100644 index 43ef0de7..00000000 --- a/tests/plugin/web/sw_django/services/consumer.py +++ /dev/null @@ -1,45 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import sys - -import requests -from django.conf import settings -from django.conf.urls import url -from django.http import JsonResponse - -settings.configure( - DEBUG=True, - ROOT_URLCONF=__name__, - ALLOWED_HOSTS=['*'], -) - - -def index(request): - res = requests.post('http://provider:9091/users') - return JsonResponse(res.json()) - - -urlpatterns = ( - url('users', index), -) - - -if __name__ == '__main__': - from django.core.management import execute_from_command_line - - execute_from_command_line(sys.argv) diff --git a/tests/plugin/web/sw_django/services/provider.py b/tests/plugin/web/sw_django/services/provider.py deleted file mode 100644 index 5ae277d9..00000000 --- a/tests/plugin/web/sw_django/services/provider.py +++ /dev/null @@ -1,45 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import sys -import time - -from django.conf import settings -from django.conf.urls import url -from django.http import JsonResponse - -settings.configure( - DEBUG=True, - ROOT_URLCONF=__name__, - ALLOWED_HOSTS=['*'], -) - - -def index(request): - time.sleep(0.5) - return JsonResponse({'song': 'Despacito', 'artist': 'Luis Fonsi'}) - - -urlpatterns = ( - url('users', index), -) - - -if __name__ == '__main__': - from django.core.management import execute_from_command_line - - execute_from_command_line(sys.argv) diff --git a/tests/plugin/web/sw_django/test_django.py b/tests/plugin/web/sw_django/test_django.py deleted file mode 100644 index 0ef92a60..00000000 --- a/tests/plugin/web/sw_django/test_django.py +++ /dev/null @@ -1,36 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from typing import Callable - -import pytest -import requests - -from skywalking.plugins.sw_django import support_matrix -from tests.orchestrator import get_test_vector -from tests.plugin.base import TestPluginBase - - -@pytest.fixture -def prepare(): - # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/users?test=test1&test=test2&test2=test2') - - -class TestPlugin(TestPluginBase): - @pytest.mark.parametrize('version', get_test_vector(lib_name='django', support_matrix=support_matrix)) - def test_plugin(self, docker_compose, version): - self.validate() diff --git a/tests/plugin/web/sw_falcon/__init__.py b/tests/plugin/web/sw_falcon/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/web/sw_falcon/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/web/sw_falcon/docker-compose.yml b/tests/plugin/web/sw_falcon/docker-compose.yml deleted file mode 100644 index 6cdba022..00000000 --- a/tests/plugin/web/sw_falcon/docker-compose.yml +++ /dev/null @@ -1,66 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -version: '2.1' - -services: - collector: - extends: - service: collector - file: ../../docker-compose.base.yml - - provider: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9091:9091 - volumes: - - .:/app - command: [ 'bash', '-c', 'pip install hug && pip install -r /app/requirements.txt && sw-python run hug -f /app/services/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 - environment: - SW_AGENT_NAME: provider - SW_AGENT_LOGGING_LEVEL: DEBUG - - consumer: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9090:9090 - volumes: - - .:/app - command: [ 'bash', '-c', 'pip install hug && pip install -r /app/requirements.txt && sw-python run hug -f /app/services/consumer.py' ] - depends_on: - collector: - condition: service_healthy - provider: - condition: service_healthy - environment: - SW_AGENT_NAME: consumer - SW_AGENT_LOGGING_LEVEL: DEBUG - -networks: - beyond: diff --git a/tests/plugin/web/sw_falcon/expected.data.yml b/tests/plugin/web/sw_falcon/expected.data.yml deleted file mode 100644 index 23f74400..00000000 --- a/tests/plugin/web/sw_falcon/expected.data.yml +++ /dev/null @@ -1,85 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -segmentItems: -- segmentSize: 1 - segments: - - segmentId: not null - spans: - - componentId: 7012 - endTime: gt 0 - isError: false - operationName: /users - parentSpanId: -1 - peer: not null - skipAnalysis: false - spanId: 0 - spanLayer: Http - spanType: Entry - startTime: gt 0 - tags: - - key: http.method - value: GET - - key: http.url - value: http://provider:9091/users - - key: http.status.code - value: '200' - - key: http.status.msg - value: OK - serviceName: provider -- segmentSize: 1 - segments: - - segmentId: not null - spans: - - componentId: 7002 - endTime: gt 0 - isError: false - operationName: /users - parentSpanId: 0 - peer: provider:9091 - skipAnalysis: false - spanId: 1 - spanLayer: Http - spanType: Exit - startTime: gt 0 - tags: - - key: http.method - value: GET - - key: http.url - value: http://provider:9091/users - - key: http.status.code - value: '200' - - componentId: 7012 - endTime: gt 0 - isError: false - operationName: /users - parentSpanId: -1 - peer: not null - skipAnalysis: false - spanId: 0 - spanLayer: Http - spanType: Entry - startTime: gt 0 - tags: - - key: http.method - value: GET - - key: http.url - value: http://0.0.0.0:9090/users - - key: http.status.code - value: '200' - - key: http.status.msg - value: OK - serviceName: consumer \ No newline at end of file diff --git a/tests/plugin/web/sw_falcon/services/__init__.py b/tests/plugin/web/sw_falcon/services/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/web/sw_falcon/services/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/web/sw_falcon/services/consumer.py b/tests/plugin/web/sw_falcon/services/consumer.py deleted file mode 100644 index 49cbf7d9..00000000 --- a/tests/plugin/web/sw_falcon/services/consumer.py +++ /dev/null @@ -1,27 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import hug -import requests - - -@hug.get('/users') -def get(): - res = requests.get('http://provider:9091/users') - return res.json() - - -hug.API(__name__).http.serve(port=9090) diff --git a/tests/plugin/web/sw_falcon/services/provider.py b/tests/plugin/web/sw_falcon/services/provider.py deleted file mode 100644 index c87f187b..00000000 --- a/tests/plugin/web/sw_falcon/services/provider.py +++ /dev/null @@ -1,30 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import json -import time - -import hug - - -@hug.get('/users') -def get(): - time.sleep(0.5) - return json.dumps({'song': 'Despacito', 'artist': 'Luis Fonsi'}) - - -hug.API(__name__).http.serve(port=9091) diff --git a/tests/plugin/web/sw_falcon/test_falcon.py b/tests/plugin/web/sw_falcon/test_falcon.py deleted file mode 100644 index 17aa61fc..00000000 --- a/tests/plugin/web/sw_falcon/test_falcon.py +++ /dev/null @@ -1,37 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -from typing import Callable - -import pytest -import requests - -from skywalking.plugins.sw_falcon import support_matrix -from tests.orchestrator import get_test_vector -from tests.plugin.base import TestPluginBase - - -@pytest.fixture -def prepare(): - # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/users') - - -class TestPlugin(TestPluginBase): - @pytest.mark.parametrize('version', get_test_vector(lib_name='hug', support_matrix=support_matrix)) - def test_plugin(self, docker_compose, version): - self.validate() diff --git a/tests/plugin/web/sw_flask/__init__.py b/tests/plugin/web/sw_flask/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/web/sw_flask/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/web/sw_flask/docker-compose.yml b/tests/plugin/web/sw_flask/docker-compose.yml deleted file mode 100644 index bb6961fd..00000000 --- a/tests/plugin/web/sw_flask/docker-compose.yml +++ /dev/null @@ -1,66 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -version: '2.1' - -services: - collector: - extends: - service: collector - file: ../../docker-compose.base.yml - - provider: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9091:9091 - volumes: - - .:/app - command: ['bash', '-c', 'pip install flask && pip install -r /app/requirements.txt && sw-python run python3 /app/services/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 - environment: - SW_AGENT_NAME: provider - SW_AGENT_LOGGING_LEVEL: DEBUG - - consumer: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9090:9090 - volumes: - - .:/app - command: ['bash', '-c', 'pip install flask && pip install -r /app/requirements.txt && sw-python run python3 /app/services/consumer.py'] - depends_on: - collector: - condition: service_healthy - provider: - condition: service_healthy - environment: - SW_AGENT_NAME: consumer - SW_AGENT_LOGGING_LEVEL: DEBUG - SW_FLASK_COLLECT_HTTP_PARAMS: 'True' -networks: - beyond: diff --git a/tests/plugin/web/sw_flask/expected.data.yml b/tests/plugin/web/sw_flask/expected.data.yml deleted file mode 100644 index 6d4dcf94..00000000 --- a/tests/plugin/web/sw_flask/expected.data.yml +++ /dev/null @@ -1,160 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -segmentItems: - - serviceName: provider - segmentSize: 2 - segments: - - segmentId: not null - spans: - - operationName: /users - parentSpanId: -1 - spanId: 0 - spanLayer: Http - tags: - - key: http.method - value: POST - - key: http.url - value: http://provider:9091/users - - key: http.status.code - value: '200' - refs: - - parentEndpoint: /users - networkAddress: 'provider:9091' - refType: CrossProcess - parentSpanId: 1 - parentTraceSegmentId: not null - parentServiceInstance: not null - parentService: consumer - traceId: not null - startTime: gt 0 - endTime: gt 0 - componentId: 7001 - spanType: Entry - peer: not null - skipAnalysis: false - - segmentId: not null - spans: - - operationName: /users - parentSpanId: -1 - spanId: 0 - spanLayer: Http - tags: - - key: http.method - value: POST - - key: http.url - value: http://provider:9091/users - - key: http.status.code - value: '200' - refs: - - parentEndpoint: /users - networkAddress: 'provider:9091' - refType: CrossProcess - parentSpanId: 1 - parentTraceSegmentId: not null - parentServiceInstance: not null - parentService: consumer - traceId: not null - startTime: gt 0 - endTime: gt 0 - componentId: 7001 - spanType: Entry - peer: not null - skipAnalysis: false - - serviceName: consumer - segmentSize: 2 - segments: - - segmentId: not null - spans: - - operationName: /users - parentSpanId: 0 - spanId: 1 - spanLayer: Http - startTime: gt 0 - endTime: gt 0 - componentId: 7002 - isError: false - spanType: Exit - peer: provider:9091 - skipAnalysis: false - tags: - - key: http.method - value: POST - - key: http.url - value: 'http://provider:9091/users' - - key: http.status.code - value: '200' - - operationName: /test - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Unknown - startTime: gt 0 - endTime: gt 0 - componentId: 0 - isError: false - spanType: Local - peer: '' - skipAnalysis: false - refs: - - parentEndpoint: /users - networkAddress: '' - refType: CrossThread - parentSpanId: 0 - parentTraceSegmentId: not null - parentServiceInstance: not null - parentService: consumer - traceId: not null - - segmentId: not null - spans: - - operationName: /users - parentSpanId: 0 - spanId: 1 - spanLayer: Http - tags: - - key: http.method - value: POST - - key: http.url - value: http://provider:9091/users - - key: http.status.code - value: '200' - startTime: gt 0 - endTime: gt 0 - componentId: 7002 - spanType: Exit - peer: provider:9091 - skipAnalysis: false - - operationName: /users - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - tags: - - key: http.method - value: GET - - key: http.url - value: http://0.0.0.0:9090/users - - key: http.params - value: "test=[test1,test2]\ntest2=[test2]" - - key: http.status.code - value: '200' - startTime: gt 0 - endTime: gt 0 - componentId: 7001 - spanType: Entry - peer: not null - skipAnalysis: false diff --git a/tests/plugin/web/sw_flask/services/__init__.py b/tests/plugin/web/sw_flask/services/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/web/sw_flask/services/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/web/sw_flask/services/consumer.py b/tests/plugin/web/sw_flask/services/consumer.py deleted file mode 100644 index 7e0a4f03..00000000 --- a/tests/plugin/web/sw_flask/services/consumer.py +++ /dev/null @@ -1,47 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import requests - -from skywalking.decorators import runnable - -if __name__ == '__main__': - from flask import Flask, jsonify - - app = Flask(__name__) - - @app.route('/users', methods=['POST', 'GET']) - def application(): - from skywalking.trace.context import get_context - get_context().put_correlation('correlation', 'correlation') - - @runnable(op='/test') - def post(): - requests.post('http://provider:9091/users') - - from threading import Thread - t = Thread(target=post) - t.start() - - res = requests.post('http://provider:9091/users') - - t.join() - - return jsonify(res.json()) - - PORT = 9090 - app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/web/sw_flask/services/provider.py b/tests/plugin/web/sw_flask/services/provider.py deleted file mode 100644 index 43f6d49f..00000000 --- a/tests/plugin/web/sw_flask/services/provider.py +++ /dev/null @@ -1,33 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import time - - -if __name__ == '__main__': - from flask import Flask, jsonify - - app = Flask(__name__) - - @app.route('/users', methods=['POST', 'GET']) - def application(): - from skywalking.trace.context import get_context - time.sleep(0.5) - return jsonify({'correlation': get_context().get_correlation('correlation')}) - - PORT = 9091 - app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/web/sw_flask/test_flask.py b/tests/plugin/web/sw_flask/test_flask.py deleted file mode 100644 index f2524382..00000000 --- a/tests/plugin/web/sw_flask/test_flask.py +++ /dev/null @@ -1,40 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from typing import Callable - -import pytest -import requests - -from skywalking.plugins.sw_flask import support_matrix -from tests.orchestrator import get_test_vector -from tests.plugin.base import TestPluginBase - - -@pytest.fixture -def prepare(): - # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/users?test=test1&test=test2&test2=test2') - - -class TestPlugin(TestPluginBase): - @pytest.mark.parametrize('version', get_test_vector(lib_name='flask', support_matrix=support_matrix)) - def test_plugin(self, docker_compose, version): - self.validate() - - response = requests.get('http://0.0.0.0:9090/users') - assert response.status_code == 200 - assert response.json()['correlation'] == 'correlation' diff --git a/tests/plugin/web/sw_pyramid/__init__.py b/tests/plugin/web/sw_pyramid/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/web/sw_pyramid/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/web/sw_pyramid/docker-compose.yml b/tests/plugin/web/sw_pyramid/docker-compose.yml deleted file mode 100644 index 99f19505..00000000 --- a/tests/plugin/web/sw_pyramid/docker-compose.yml +++ /dev/null @@ -1,66 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -version: '2.1' - -services: - collector: - extends: - service: collector - file: ../../docker-compose.base.yml - - provider: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9091:9091 - volumes: - - .:/app - command: ['bash', '-c', 'pip install -r /app/requirements.txt && sw-python run python3 /app/services/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 - environment: - SW_AGENT_NAME: provider - SW_AGENT_LOGGING_LEVEL: DEBUG - - consumer: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9090:9090 - volumes: - - .:/app - command: ['bash', '-c', 'pip install -r /app/requirements.txt && sw-python run python3 /app/services/consumer.py'] - depends_on: - collector: - condition: service_healthy - provider: - condition: service_healthy - environment: - SW_AGENT_NAME: consumer - SW_AGENT_LOGGING_LEVEL: DEBUG - -networks: - beyond: diff --git a/tests/plugin/web/sw_pyramid/expected.data.yml b/tests/plugin/web/sw_pyramid/expected.data.yml deleted file mode 100644 index b68b0ed2..00000000 --- a/tests/plugin/web/sw_pyramid/expected.data.yml +++ /dev/null @@ -1,91 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -segmentItems: - - serviceName: provider - segmentSize: 1 - segments: - - segmentId: not null - spans: - - operationName: /pyramid - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - tags: - - key: http.method - value: POST - - key: http.url - value: http://provider:9091/pyramid - - key: http.status.code - value: '200' - refs: - - parentEndpoint: /pyramid - networkAddress: provider:9091 - refType: CrossProcess - parentSpanId: 1 - parentTraceSegmentId: not null - parentServiceInstance: not null - parentService: consumer - traceId: not null - startTime: gt 0 - endTime: gt 0 - componentId: 7009 - spanType: Entry - peer: not null - skipAnalysis: false - - serviceName: consumer - segmentSize: 1 - segments: - - segmentId: not null - spans: - - operationName: /pyramid - parentSpanId: 0 - spanId: 1 - spanLayer: Http - tags: - - key: http.method - value: POST - - key: http.url - value: http://provider:9091/pyramid - - key: http.status.code - value: '200' - startTime: gt 0 - endTime: gt 0 - componentId: 7000 - spanType: Exit - peer: provider:9091 - skipAnalysis: false - - operationName: /pyramid - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - tags: - - key: http.method - value: GET - - key: http.url - value: http://0.0.0.0:9090/pyramid - - key: http.status.code - value: '200' - startTime: gt 0 - endTime: gt 0 - componentId: 7009 - spanType: Entry - peer: not null - skipAnalysis: false - diff --git a/tests/plugin/web/sw_pyramid/services/__init__.py b/tests/plugin/web/sw_pyramid/services/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/web/sw_pyramid/services/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/web/sw_pyramid/services/consumer.py b/tests/plugin/web/sw_pyramid/services/consumer.py deleted file mode 100644 index 64c63786..00000000 --- a/tests/plugin/web/sw_pyramid/services/consumer.py +++ /dev/null @@ -1,42 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from urllib import request -from wsgiref.simple_server import make_server - -from pyramid.config import Configurator -from pyramid.response import Response - - -def index(req): - data = '{"name": "whatever"}'.encode('utf8') - req = request.Request(f'http://provider:9091/{req.path.lstrip("/")}') - req.add_header('Content-Type', 'application/json; charset=utf-8') - req.add_header('Content-Length', str(len(data))) - with request.urlopen(req, data): - return Response(data) - - -if __name__ == '__main__': - with Configurator() as config: - config.add_route('pyramid', '/pyramid') - config.add_view(index, route_name='pyramid') - - app = config.make_wsgi_app() - - server = make_server('0.0.0.0', 9090, app) - - server.serve_forever() diff --git a/tests/plugin/web/sw_pyramid/services/provider.py b/tests/plugin/web/sw_pyramid/services/provider.py deleted file mode 100644 index cef6af2d..00000000 --- a/tests/plugin/web/sw_pyramid/services/provider.py +++ /dev/null @@ -1,43 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -from wsgiref.simple_server import make_server - -from pyramid.config import Configurator -from pyramid.response import Response - - -def index(request): - return Response('Hello World!') - - -def error(request): - raise Exception('Error!') - - -if __name__ == '__main__': - with Configurator() as config: - config.add_route('pyramid', '/pyramid') - config.add_route('error', '/error') - config.add_view(index, route_name='pyramid') - config.add_view(error, route_name='error') - - app = config.make_wsgi_app() - - server = make_server('0.0.0.0', 9091, app) - - server.serve_forever() diff --git a/tests/plugin/web/sw_pyramid/test_pyramid.py b/tests/plugin/web/sw_pyramid/test_pyramid.py deleted file mode 100644 index 95b1d9f1..00000000 --- a/tests/plugin/web/sw_pyramid/test_pyramid.py +++ /dev/null @@ -1,36 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from typing import Callable - -import pytest -import requests - -from skywalking.plugins.sw_pyramid import support_matrix -from tests.orchestrator import get_test_vector -from tests.plugin.base import TestPluginBase - - -@pytest.fixture -def prepare(): - # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/pyramid') - - -class TestPlugin(TestPluginBase): - @pytest.mark.parametrize('version', get_test_vector(lib_name='pyramid', support_matrix=support_matrix)) - def test_plugin(self, docker_compose, version): - self.validate() diff --git a/tests/plugin/web/sw_sanic/__init__.py b/tests/plugin/web/sw_sanic/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/web/sw_sanic/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/web/sw_sanic/docker-compose.yml b/tests/plugin/web/sw_sanic/docker-compose.yml deleted file mode 100644 index 0d311bc1..00000000 --- a/tests/plugin/web/sw_sanic/docker-compose.yml +++ /dev/null @@ -1,65 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -version: '2.1' - -services: - collector: - extends: - service: collector - file: ../../docker-compose.base.yml - - provider: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9091:9091 - volumes: - - .:/app - command: ['bash', '-c', 'pip install sanic && pip install -r /app/requirements.txt && sw-python run python3 /app/services/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 - environment: - SW_AGENT_NAME: provider - SW_AGENT_LOGGING_LEVEL: DEBUG - consumer: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9090:9090 - volumes: - - .:/app - command: ['bash', '-c', 'pip install sanic && pip install -r /app/requirements.txt && sw-python run python3 /app/services/consumer.py'] - depends_on: - collector: - condition: service_healthy - provider: - condition: service_healthy - environment: - SW_AGENT_NAME: consumer - SW_AGENT_LOGGING_LEVEL: DEBUG - SW_SANIC_COLLECT_HTTP_PARAMS: 'True' -networks: - beyond: diff --git a/tests/plugin/web/sw_sanic/expected.data.yml b/tests/plugin/web/sw_sanic/expected.data.yml deleted file mode 100644 index 3c4ca4c1..00000000 --- a/tests/plugin/web/sw_sanic/expected.data.yml +++ /dev/null @@ -1,92 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -segmentItems: - - serviceName: provider - segmentSize: 1 - segments: - - segmentId: not null - spans: - - operationName: /users - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - tags: - - key: http.method - value: GET - - key: http.url - value: http://provider:9091/users - - key: http.status.code - value: '200' - refs: - - parentEndpoint: /users - networkAddress: provider:9091 - refType: CrossProcess - parentSpanId: 1 - parentTraceSegmentId: not null - parentServiceInstance: not null - parentService: consumer - traceId: not null - startTime: gt 0 - endTime: gt 0 - componentId: 7007 - spanType: Entry - peer: not null - skipAnalysis: false - - serviceName: consumer - segmentSize: 1 - segments: - - segmentId: not null - spans: - - operationName: /users - parentSpanId: 0 - spanId: 1 - spanLayer: Http - tags: - - key: http.method - value: GET - - key: http.url - value: http://provider:9091/users - - key: http.status.code - value: '200' - startTime: gt 0 - endTime: gt 0 - componentId: 7002 - spanType: Exit - peer: provider:9091 - skipAnalysis: false - - operationName: /users - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - tags: - - key: http.method - value: GET - - key: http.url - value: http://0.0.0.0:9090/users - - key: http.params - value: "test=[test1,test2]\ntest2=[test2]" - - key: http.status.code - value: '200' - startTime: gt 0 - endTime: gt 0 - componentId: 7007 - spanType: Entry - peer: not null - skipAnalysis: false \ No newline at end of file diff --git a/tests/plugin/web/sw_sanic/services/__init__.py b/tests/plugin/web/sw_sanic/services/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/web/sw_sanic/services/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/web/sw_sanic/services/consumer.py b/tests/plugin/web/sw_sanic/services/consumer.py deleted file mode 100644 index a2ae35bb..00000000 --- a/tests/plugin/web/sw_sanic/services/consumer.py +++ /dev/null @@ -1,31 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import requests - -if __name__ == '__main__': - from sanic import Sanic, response - - app = Sanic(__name__) - - @app.route('/users', methods=['GET']) - async def application(req): - res = requests.get('http://provider:9091/users') - return response.json(res.json()) - - PORT = 9090 - app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/web/sw_sanic/services/provider.py b/tests/plugin/web/sw_sanic/services/provider.py deleted file mode 100644 index 2cc7ba92..00000000 --- a/tests/plugin/web/sw_sanic/services/provider.py +++ /dev/null @@ -1,33 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import time - -if __name__ == '__main__': - from sanic import Sanic, response - - app = Sanic(__name__) - - @app.route('/users', methods=['GET']) - async def application(req): - time.sleep(0.5) - return response.json( - {'song': 'Despacito', 'artist': 'Luis Fonsi'} - ) - - PORT = 9091 - app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/web/sw_sanic/test_sanic.py b/tests/plugin/web/sw_sanic/test_sanic.py deleted file mode 100644 index 3413f4a9..00000000 --- a/tests/plugin/web/sw_sanic/test_sanic.py +++ /dev/null @@ -1,36 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from typing import Callable - -import pytest -import requests - -from skywalking.plugins.sw_sanic import support_matrix -from tests.orchestrator import get_test_vector -from tests.plugin.base import TestPluginBase - - -@pytest.fixture -def prepare(): - # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/users?test=test1&test=test2&test2=test2') - - -class TestPlugin(TestPluginBase): - @pytest.mark.parametrize('version', get_test_vector(lib_name='sanic', support_matrix=support_matrix)) - def test_plugin(self, docker_compose, version): - self.validate() diff --git a/tests/plugin/web/sw_tornado/__init__.py b/tests/plugin/web/sw_tornado/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/web/sw_tornado/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/web/sw_tornado/docker-compose.yml b/tests/plugin/web/sw_tornado/docker-compose.yml deleted file mode 100644 index 424c7c6a..00000000 --- a/tests/plugin/web/sw_tornado/docker-compose.yml +++ /dev/null @@ -1,66 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -version: '2.1' - -services: - collector: - extends: - service: collector - file: ../../docker-compose.base.yml - - provider: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9091:9091 - volumes: - - .:/app - command: ['bash', '-c', 'pip3 install -r /app/requirements.txt && sw-python run python3 /app/services/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 - environment: - SW_AGENT_NAME: provider - SW_AGENT_LOGGING_LEVEL: DEBUG - - consumer: - extends: - service: agent - file: ../../docker-compose.base.yml - ports: - - 9090:9090 - volumes: - - .:/app - command: ['bash', '-c', 'pip3 install -r /app/requirements.txt && sw-python run python3 /app/services/consumer.py'] - depends_on: - collector: - condition: service_healthy - provider: - condition: service_healthy - environment: - SW_AGENT_NAME: consumer - SW_AGENT_LOGGING_LEVEL: DEBUG - -networks: - beyond: diff --git a/tests/plugin/web/sw_tornado/expected.data.yml b/tests/plugin/web/sw_tornado/expected.data.yml deleted file mode 100644 index c2bb860d..00000000 --- a/tests/plugin/web/sw_tornado/expected.data.yml +++ /dev/null @@ -1,90 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -segmentItems: - - serviceName: provider - segmentSize: 1 - segments: - - segmentId: not null - spans: - - operationName: /users - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - tags: - - key: http.method - value: GET - - key: http.url - value: http://provider:9091/users - - key: http.status.code - value: '200' - refs: - - parentEndpoint: /users - networkAddress: provider:9091 - refType: CrossProcess - parentSpanId: 1 - parentTraceSegmentId: not null - parentServiceInstance: not null - parentService: consumer - traceId: not null - startTime: gt 0 - endTime: gt 0 - componentId: 7005 - spanType: Entry - peer: not null - skipAnalysis: false - - serviceName: consumer - segmentSize: 1 - segments: - - segmentId: not null - spans: - - operationName: /users - parentSpanId: 0 - spanId: 1 - spanLayer: Http - tags: - - key: http.method - value: GET - - key: http.url - value: http://provider:9091/users - - key: http.status.code - value: '200' - startTime: gt 0 - endTime: gt 0 - componentId: 7002 - spanType: Exit - peer: provider:9091 - skipAnalysis: false - - operationName: /users - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - tags: - - key: http.method - value: GET - - key: http.url - value: http://0.0.0.0:9090/users - - key: http.status.code - value: '200' - startTime: gt 0 - endTime: gt 0 - componentId: 7005 - spanType: Entry - peer: not null - skipAnalysis: false \ No newline at end of file diff --git a/tests/plugin/web/sw_tornado/services/__init__.py b/tests/plugin/web/sw_tornado/services/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/web/sw_tornado/services/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/web/sw_tornado/services/consumer.py b/tests/plugin/web/sw_tornado/services/consumer.py deleted file mode 100644 index bc2c2e32..00000000 --- a/tests/plugin/web/sw_tornado/services/consumer.py +++ /dev/null @@ -1,35 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -if __name__ == '__main__': - import requests - import tornado.ioloop - import tornado.web - - class MainHandler(tornado.web.RequestHandler): - def get(self): - res = requests.get('http://provider:9091/users') - self.write(res.text) - - def make_app(): - return tornado.web.Application([ - (r'/users', MainHandler), - ]) - - app = make_app() - app.listen(9090, '0.0.0.0') - tornado.ioloop.IOLoop.current().start() diff --git a/tests/plugin/web/sw_tornado/services/provider.py b/tests/plugin/web/sw_tornado/services/provider.py deleted file mode 100644 index c36beb54..00000000 --- a/tests/plugin/web/sw_tornado/services/provider.py +++ /dev/null @@ -1,37 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -if __name__ == '__main__': - import json - import time - - import tornado.ioloop - import tornado.web - - class MainHandler(tornado.web.RequestHandler): - def get(self): - time.sleep(0.5) - self.write(json.dumps({'song': 'Despacito', 'artist': 'Luis Fonsi'})) - - def make_app(): - return tornado.web.Application([ - (r'/users', MainHandler), - ]) - - app = make_app() - app.listen(9091, '0.0.0.0') - tornado.ioloop.IOLoop.current().start() diff --git a/tests/plugin/web/sw_tornado/test_tornado.py b/tests/plugin/web/sw_tornado/test_tornado.py deleted file mode 100644 index 15693af8..00000000 --- a/tests/plugin/web/sw_tornado/test_tornado.py +++ /dev/null @@ -1,36 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from typing import Callable - -import pytest -import requests - -from skywalking.plugins.sw_tornado import support_matrix -from tests.orchestrator import get_test_vector -from tests.plugin.base import TestPluginBase - - -@pytest.fixture -def prepare(): - # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/users') - - -class TestPlugin(TestPluginBase): - @pytest.mark.parametrize('version', get_test_vector(lib_name='tornado', support_matrix=support_matrix)) - def test_plugin(self, docker_compose, version): - self.validate() From 93916ca4deb4a7ba2be381ea9059698b66cddfa3 Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Thu, 17 Feb 2022 01:59:08 -0500 Subject: [PATCH 07/35] test error intentional Signed-off-by: Superskyyy --- tests/plugin/data/__init__.py | 16 ++++++++++++++++ tests/plugin/http/__init__.py | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 tests/plugin/data/__init__.py create mode 100644 tests/plugin/http/__init__.py diff --git a/tests/plugin/data/__init__.py b/tests/plugin/data/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/data/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/http/__init__.py b/tests/plugin/http/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/http/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# From 5f7aaef0912cf126681b5b772730d82485dece46 Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Thu, 17 Feb 2022 02:07:37 -0500 Subject: [PATCH 08/35] test error intentional Signed-off-by: Superskyyy --- tests/plugin/conftest.py | 4 ++-- tests/plugin/data/__init__.py | 16 ---------------- tests/plugin/http/__init__.py | 16 ---------------- 3 files changed, 2 insertions(+), 34 deletions(-) delete mode 100644 tests/plugin/data/__init__.py delete mode 100644 tests/plugin/http/__init__.py diff --git a/tests/plugin/conftest.py b/tests/plugin/conftest.py index 96a9dc3d..2d9de6d6 100644 --- a/tests/plugin/conftest.py +++ b/tests/plugin/conftest.py @@ -54,13 +54,13 @@ def docker_compose(request, prepare, version): exception = None exception_delay = 0 # stdout_dignose, stderr_dignose = None - for _ in range(5): + for _ in range(10): try: prepare() exception = None break except Exception as e: - time.sleep(20) + time.sleep(10) exception_delay += 10 exception = e stdout, stderr = compose.get_logs() diff --git a/tests/plugin/data/__init__.py b/tests/plugin/data/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/data/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/tests/plugin/http/__init__.py b/tests/plugin/http/__init__.py deleted file mode 100644 index b1312a09..00000000 --- a/tests/plugin/http/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# From 4f75ca1cab00e9fe14da1710217ad9d48ac83fc3 Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Thu, 17 Feb 2022 02:20:55 -0500 Subject: [PATCH 09/35] test error intentional Signed-off-by: Superskyyy --- .github/workflows/CI.yaml | 2 +- tests/plugin/web/sw_fastapi/test_fastapi.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index 9539b8fd..c652a7b5 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -59,7 +59,7 @@ jobs: name: Plugin and Unit Tests needs: prep-plugin-and-unit-tests runs-on: ubuntu-latest - timeout-minutes: 60 + timeout-minutes: 20 strategy: matrix: python-version: ["3.10"] diff --git a/tests/plugin/web/sw_fastapi/test_fastapi.py b/tests/plugin/web/sw_fastapi/test_fastapi.py index d19e1152..4628a3a5 100644 --- a/tests/plugin/web/sw_fastapi/test_fastapi.py +++ b/tests/plugin/web/sw_fastapi/test_fastapi.py @@ -27,7 +27,7 @@ @pytest.fixture def prepare(): # type: () -> Callable - return lambda *_: requests.get('http://0.0.11.0:9090/users?test=test1&test=test2&test2=test2') + return lambda *_: requests.get('http://0.0.11.0:9090/users?test=test1&test=test2&test2=test2',timeout=3) class TestPlugin(TestPluginBase): From b3e16277064d21fd5bc4e04d055f3d1e12cdc31d Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Thu, 17 Feb 2022 02:23:08 -0500 Subject: [PATCH 10/35] test error intentional Signed-off-by: Superskyyy --- tests/plugin/web/sw_fastapi/test_fastapi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/plugin/web/sw_fastapi/test_fastapi.py b/tests/plugin/web/sw_fastapi/test_fastapi.py index 4628a3a5..52a499a3 100644 --- a/tests/plugin/web/sw_fastapi/test_fastapi.py +++ b/tests/plugin/web/sw_fastapi/test_fastapi.py @@ -27,7 +27,7 @@ @pytest.fixture def prepare(): # type: () -> Callable - return lambda *_: requests.get('http://0.0.11.0:9090/users?test=test1&test=test2&test2=test2',timeout=3) + return lambda *_: requests.get('http://0.0.11.0:9090/users?test=test1&test=test2&test2=test2', timeout=3) class TestPlugin(TestPluginBase): From 1a6294095dc6362eced27972d3eb4369010183e4 Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Thu, 17 Feb 2022 02:27:55 -0500 Subject: [PATCH 11/35] test error intentional Signed-off-by: Superskyyy --- tests/plugin/data/__init__.py | 16 ++ .../plugin/data/sw_elasticsearch/__init__.py | 16 ++ .../data/sw_elasticsearch/docker-compose.yml | 64 +++++ .../data/sw_elasticsearch/expected.data.yml | 88 +++++++ .../sw_elasticsearch/services/__init__.py | 16 ++ .../sw_elasticsearch/services/consumer.py | 46 ++++ .../sw_elasticsearch/test_elasticsearch.py | 36 +++ tests/plugin/data/sw_kafka/__init__.py | 16 ++ tests/plugin/data/sw_kafka/docker-compose.yml | 109 ++++++++ tests/plugin/data/sw_kafka/expected.data.yml | 86 +++++++ .../plugin/data/sw_kafka/services/__init__.py | 16 ++ .../plugin/data/sw_kafka/services/consumer.py | 32 +++ .../plugin/data/sw_kafka/services/producer.py | 33 +++ tests/plugin/data/sw_kafka/test_kafka.py | 36 +++ tests/plugin/data/sw_mysqlclient/__init__.py | 16 ++ .../data/sw_mysqlclient/docker-compose.yml | 86 +++++++ .../data/sw_mysqlclient/expected.data.yml | 109 ++++++++ .../data/sw_mysqlclient/services/__init__.py | 16 ++ .../data/sw_mysqlclient/services/consumer.py | 32 +++ .../data/sw_mysqlclient/services/provider.py | 39 +++ .../data/sw_mysqlclient/test_mysqlclient.py | 36 +++ tests/plugin/data/sw_psycopg/__init__.py | 16 ++ .../plugin/data/sw_psycopg/docker-compose.yml | 87 +++++++ .../plugin/data/sw_psycopg/expected.data.yml | 110 +++++++++ .../data/sw_psycopg/services/__init__.py | 16 ++ .../data/sw_psycopg/services/consumer.py | 32 +++ .../data/sw_psycopg/services/provider.py | 40 +++ tests/plugin/data/sw_psycopg/test_psycopg.py | 36 +++ tests/plugin/data/sw_psycopg2/__init__.py | 16 ++ .../data/sw_psycopg2/docker-compose.yml | 86 +++++++ .../plugin/data/sw_psycopg2/expected.data.yml | 112 +++++++++ .../data/sw_psycopg2/services/__init__.py | 16 ++ .../data/sw_psycopg2/services/consumer.py | 32 +++ .../data/sw_psycopg2/services/provider.py | 40 +++ .../plugin/data/sw_psycopg2/test_psycopg2.py | 36 +++ tests/plugin/data/sw_pymongo/__init__.py | 16 ++ .../plugin/data/sw_pymongo/docker-compose.yml | 82 ++++++ .../plugin/data/sw_pymongo/expected.data.yml | 233 ++++++++++++++++++ .../data/sw_pymongo/services/__init__.py | 16 ++ .../data/sw_pymongo/services/consumer.py | 34 +++ .../data/sw_pymongo/services/provider.py | 58 +++++ tests/plugin/data/sw_pymongo/test_pymongo.py | 36 +++ tests/plugin/data/sw_pymysql/__init__.py | 16 ++ .../plugin/data/sw_pymysql/docker-compose.yml | 86 +++++++ .../plugin/data/sw_pymysql/expected.data.yml | 109 ++++++++ .../data/sw_pymysql/services/__init__.py | 16 ++ .../data/sw_pymysql/services/consumer.py | 32 +++ .../data/sw_pymysql/services/provider.py | 39 +++ tests/plugin/data/sw_pymysql/test_pymysql.py | 36 +++ tests/plugin/data/sw_rabbitmq/__init__.py | 16 ++ .../data/sw_rabbitmq/docker-compose.yml | 93 +++++++ .../plugin/data/sw_rabbitmq/expected.data.yml | 90 +++++++ .../data/sw_rabbitmq/services/__init__.py | 16 ++ .../data/sw_rabbitmq/services/consumer.py | 45 ++++ .../data/sw_rabbitmq/services/producer.py | 41 +++ .../plugin/data/sw_rabbitmq/test_rabbitmq.py | 36 +++ tests/plugin/data/sw_redis/__init__.py | 16 ++ tests/plugin/data/sw_redis/docker-compose.yml | 79 ++++++ tests/plugin/data/sw_redis/expected.data.yml | 124 ++++++++++ .../plugin/data/sw_redis/services/__init__.py | 16 ++ .../plugin/data/sw_redis/services/consumer.py | 32 +++ .../plugin/data/sw_redis/services/provider.py | 39 +++ tests/plugin/data/sw_redis/test_redis.py | 36 +++ tests/plugin/http/__init__.py | 16 ++ tests/plugin/http/sw_aiohttp/__init__.py | 16 ++ .../plugin/http/sw_aiohttp/docker-compose.yml | 66 +++++ .../plugin/http/sw_aiohttp/expected.data.yml | 89 +++++++ .../http/sw_aiohttp/services/__init__.py | 16 ++ .../http/sw_aiohttp/services/consumer.py | 37 +++ .../http/sw_aiohttp/services/provider.py | 32 +++ tests/plugin/http/sw_aiohttp/test_aiohttp.py | 36 +++ tests/plugin/http/sw_http/__init__.py | 16 ++ tests/plugin/http/sw_http/docker-compose.yml | 66 +++++ tests/plugin/http/sw_http/expected.data.yml | 90 +++++++ .../plugin/http/sw_http/services/__init__.py | 16 ++ .../plugin/http/sw_http/services/consumer.py | 44 ++++ .../plugin/http/sw_http/services/provider.py | 38 +++ tests/plugin/http/sw_http/test_http.py | 33 +++ tests/plugin/http/sw_http_wsgi/__init__.py | 16 ++ .../http/sw_http_wsgi/docker-compose.yml | 66 +++++ .../http/sw_http_wsgi/expected.data.yml | 91 +++++++ .../http/sw_http_wsgi/services/__init__.py | 16 ++ .../http/sw_http_wsgi/services/consumer.py | 43 ++++ .../http/sw_http_wsgi/services/provider.py | 32 +++ .../http/sw_http_wsgi/test_http_wsgi.py | 36 +++ tests/plugin/http/sw_requests/__init__.py | 16 ++ .../http/sw_requests/docker-compose.yml | 66 +++++ .../plugin/http/sw_requests/expected.data.yml | 90 +++++++ .../http/sw_requests/services/__init__.py | 16 ++ .../http/sw_requests/services/consumer.py | 39 +++ .../http/sw_requests/services/provider.py | 38 +++ tests/plugin/http/sw_requests/test_request.py | 36 +++ tests/plugin/http/sw_urllib3/__init__.py | 16 ++ .../plugin/http/sw_urllib3/docker-compose.yml | 66 +++++ .../plugin/http/sw_urllib3/expected.data.yml | 93 +++++++ .../http/sw_urllib3/services/__init__.py | 16 ++ .../http/sw_urllib3/services/consumer.py | 34 +++ .../http/sw_urllib3/services/provider.py | 32 +++ tests/plugin/http/sw_urllib3/test_urllib3.py | 36 +++ tests/plugin/web/sw_django/__init__.py | 16 ++ tests/plugin/web/sw_django/docker-compose.yml | 67 +++++ tests/plugin/web/sw_django/expected.data.yml | 90 +++++++ .../plugin/web/sw_django/services/__init__.py | 16 ++ .../plugin/web/sw_django/services/consumer.py | 45 ++++ .../plugin/web/sw_django/services/provider.py | 45 ++++ tests/plugin/web/sw_django/test_django.py | 36 +++ tests/plugin/web/sw_falcon/__init__.py | 16 ++ tests/plugin/web/sw_falcon/docker-compose.yml | 66 +++++ tests/plugin/web/sw_falcon/expected.data.yml | 85 +++++++ .../plugin/web/sw_falcon/services/__init__.py | 16 ++ .../plugin/web/sw_falcon/services/consumer.py | 27 ++ .../plugin/web/sw_falcon/services/provider.py | 30 +++ tests/plugin/web/sw_falcon/test_falcon.py | 37 +++ tests/plugin/web/sw_flask/__init__.py | 16 ++ tests/plugin/web/sw_flask/docker-compose.yml | 66 +++++ tests/plugin/web/sw_flask/expected.data.yml | 160 ++++++++++++ .../plugin/web/sw_flask/services/__init__.py | 16 ++ .../plugin/web/sw_flask/services/consumer.py | 47 ++++ .../plugin/web/sw_flask/services/provider.py | 33 +++ tests/plugin/web/sw_flask/test_flask.py | 40 +++ tests/plugin/web/sw_pyramid/__init__.py | 16 ++ .../plugin/web/sw_pyramid/docker-compose.yml | 66 +++++ tests/plugin/web/sw_pyramid/expected.data.yml | 91 +++++++ .../web/sw_pyramid/services/__init__.py | 16 ++ .../web/sw_pyramid/services/consumer.py | 42 ++++ .../web/sw_pyramid/services/provider.py | 43 ++++ tests/plugin/web/sw_pyramid/test_pyramid.py | 36 +++ tests/plugin/web/sw_sanic/__init__.py | 16 ++ tests/plugin/web/sw_sanic/docker-compose.yml | 65 +++++ tests/plugin/web/sw_sanic/expected.data.yml | 92 +++++++ .../plugin/web/sw_sanic/services/__init__.py | 16 ++ .../plugin/web/sw_sanic/services/consumer.py | 31 +++ .../plugin/web/sw_sanic/services/provider.py | 33 +++ tests/plugin/web/sw_sanic/test_sanic.py | 36 +++ tests/plugin/web/sw_tornado/__init__.py | 16 ++ .../plugin/web/sw_tornado/docker-compose.yml | 66 +++++ tests/plugin/web/sw_tornado/expected.data.yml | 90 +++++++ .../web/sw_tornado/services/__init__.py | 16 ++ .../web/sw_tornado/services/consumer.py | 35 +++ .../web/sw_tornado/services/provider.py | 37 +++ tests/plugin/web/sw_tornado/test_tornado.py | 36 +++ 141 files changed, 6477 insertions(+) create mode 100644 tests/plugin/data/__init__.py create mode 100644 tests/plugin/data/sw_elasticsearch/__init__.py create mode 100644 tests/plugin/data/sw_elasticsearch/docker-compose.yml create mode 100644 tests/plugin/data/sw_elasticsearch/expected.data.yml create mode 100644 tests/plugin/data/sw_elasticsearch/services/__init__.py create mode 100644 tests/plugin/data/sw_elasticsearch/services/consumer.py create mode 100644 tests/plugin/data/sw_elasticsearch/test_elasticsearch.py create mode 100644 tests/plugin/data/sw_kafka/__init__.py create mode 100644 tests/plugin/data/sw_kafka/docker-compose.yml create mode 100644 tests/plugin/data/sw_kafka/expected.data.yml create mode 100644 tests/plugin/data/sw_kafka/services/__init__.py create mode 100644 tests/plugin/data/sw_kafka/services/consumer.py create mode 100644 tests/plugin/data/sw_kafka/services/producer.py create mode 100644 tests/plugin/data/sw_kafka/test_kafka.py create mode 100644 tests/plugin/data/sw_mysqlclient/__init__.py create mode 100644 tests/plugin/data/sw_mysqlclient/docker-compose.yml create mode 100644 tests/plugin/data/sw_mysqlclient/expected.data.yml create mode 100644 tests/plugin/data/sw_mysqlclient/services/__init__.py create mode 100644 tests/plugin/data/sw_mysqlclient/services/consumer.py create mode 100644 tests/plugin/data/sw_mysqlclient/services/provider.py create mode 100644 tests/plugin/data/sw_mysqlclient/test_mysqlclient.py create mode 100644 tests/plugin/data/sw_psycopg/__init__.py create mode 100644 tests/plugin/data/sw_psycopg/docker-compose.yml create mode 100644 tests/plugin/data/sw_psycopg/expected.data.yml create mode 100644 tests/plugin/data/sw_psycopg/services/__init__.py create mode 100644 tests/plugin/data/sw_psycopg/services/consumer.py create mode 100644 tests/plugin/data/sw_psycopg/services/provider.py create mode 100644 tests/plugin/data/sw_psycopg/test_psycopg.py create mode 100644 tests/plugin/data/sw_psycopg2/__init__.py create mode 100644 tests/plugin/data/sw_psycopg2/docker-compose.yml create mode 100644 tests/plugin/data/sw_psycopg2/expected.data.yml create mode 100644 tests/plugin/data/sw_psycopg2/services/__init__.py create mode 100644 tests/plugin/data/sw_psycopg2/services/consumer.py create mode 100644 tests/plugin/data/sw_psycopg2/services/provider.py create mode 100644 tests/plugin/data/sw_psycopg2/test_psycopg2.py create mode 100644 tests/plugin/data/sw_pymongo/__init__.py create mode 100644 tests/plugin/data/sw_pymongo/docker-compose.yml create mode 100644 tests/plugin/data/sw_pymongo/expected.data.yml create mode 100644 tests/plugin/data/sw_pymongo/services/__init__.py create mode 100644 tests/plugin/data/sw_pymongo/services/consumer.py create mode 100644 tests/plugin/data/sw_pymongo/services/provider.py create mode 100644 tests/plugin/data/sw_pymongo/test_pymongo.py create mode 100644 tests/plugin/data/sw_pymysql/__init__.py create mode 100644 tests/plugin/data/sw_pymysql/docker-compose.yml create mode 100644 tests/plugin/data/sw_pymysql/expected.data.yml create mode 100644 tests/plugin/data/sw_pymysql/services/__init__.py create mode 100644 tests/plugin/data/sw_pymysql/services/consumer.py create mode 100644 tests/plugin/data/sw_pymysql/services/provider.py create mode 100644 tests/plugin/data/sw_pymysql/test_pymysql.py create mode 100644 tests/plugin/data/sw_rabbitmq/__init__.py create mode 100644 tests/plugin/data/sw_rabbitmq/docker-compose.yml create mode 100644 tests/plugin/data/sw_rabbitmq/expected.data.yml create mode 100644 tests/plugin/data/sw_rabbitmq/services/__init__.py create mode 100644 tests/plugin/data/sw_rabbitmq/services/consumer.py create mode 100644 tests/plugin/data/sw_rabbitmq/services/producer.py create mode 100644 tests/plugin/data/sw_rabbitmq/test_rabbitmq.py create mode 100644 tests/plugin/data/sw_redis/__init__.py create mode 100644 tests/plugin/data/sw_redis/docker-compose.yml create mode 100644 tests/plugin/data/sw_redis/expected.data.yml create mode 100644 tests/plugin/data/sw_redis/services/__init__.py create mode 100644 tests/plugin/data/sw_redis/services/consumer.py create mode 100644 tests/plugin/data/sw_redis/services/provider.py create mode 100644 tests/plugin/data/sw_redis/test_redis.py create mode 100644 tests/plugin/http/__init__.py create mode 100644 tests/plugin/http/sw_aiohttp/__init__.py create mode 100644 tests/plugin/http/sw_aiohttp/docker-compose.yml create mode 100644 tests/plugin/http/sw_aiohttp/expected.data.yml create mode 100644 tests/plugin/http/sw_aiohttp/services/__init__.py create mode 100644 tests/plugin/http/sw_aiohttp/services/consumer.py create mode 100644 tests/plugin/http/sw_aiohttp/services/provider.py create mode 100644 tests/plugin/http/sw_aiohttp/test_aiohttp.py create mode 100644 tests/plugin/http/sw_http/__init__.py create mode 100644 tests/plugin/http/sw_http/docker-compose.yml create mode 100644 tests/plugin/http/sw_http/expected.data.yml create mode 100644 tests/plugin/http/sw_http/services/__init__.py create mode 100644 tests/plugin/http/sw_http/services/consumer.py create mode 100644 tests/plugin/http/sw_http/services/provider.py create mode 100644 tests/plugin/http/sw_http/test_http.py create mode 100644 tests/plugin/http/sw_http_wsgi/__init__.py create mode 100644 tests/plugin/http/sw_http_wsgi/docker-compose.yml create mode 100644 tests/plugin/http/sw_http_wsgi/expected.data.yml create mode 100644 tests/plugin/http/sw_http_wsgi/services/__init__.py create mode 100644 tests/plugin/http/sw_http_wsgi/services/consumer.py create mode 100644 tests/plugin/http/sw_http_wsgi/services/provider.py create mode 100644 tests/plugin/http/sw_http_wsgi/test_http_wsgi.py create mode 100644 tests/plugin/http/sw_requests/__init__.py create mode 100644 tests/plugin/http/sw_requests/docker-compose.yml create mode 100644 tests/plugin/http/sw_requests/expected.data.yml create mode 100644 tests/plugin/http/sw_requests/services/__init__.py create mode 100644 tests/plugin/http/sw_requests/services/consumer.py create mode 100644 tests/plugin/http/sw_requests/services/provider.py create mode 100644 tests/plugin/http/sw_requests/test_request.py create mode 100644 tests/plugin/http/sw_urllib3/__init__.py create mode 100644 tests/plugin/http/sw_urllib3/docker-compose.yml create mode 100644 tests/plugin/http/sw_urllib3/expected.data.yml create mode 100644 tests/plugin/http/sw_urllib3/services/__init__.py create mode 100644 tests/plugin/http/sw_urllib3/services/consumer.py create mode 100644 tests/plugin/http/sw_urllib3/services/provider.py create mode 100644 tests/plugin/http/sw_urllib3/test_urllib3.py create mode 100644 tests/plugin/web/sw_django/__init__.py create mode 100644 tests/plugin/web/sw_django/docker-compose.yml create mode 100644 tests/plugin/web/sw_django/expected.data.yml create mode 100644 tests/plugin/web/sw_django/services/__init__.py create mode 100644 tests/plugin/web/sw_django/services/consumer.py create mode 100644 tests/plugin/web/sw_django/services/provider.py create mode 100644 tests/plugin/web/sw_django/test_django.py create mode 100644 tests/plugin/web/sw_falcon/__init__.py create mode 100644 tests/plugin/web/sw_falcon/docker-compose.yml create mode 100644 tests/plugin/web/sw_falcon/expected.data.yml create mode 100644 tests/plugin/web/sw_falcon/services/__init__.py create mode 100644 tests/plugin/web/sw_falcon/services/consumer.py create mode 100644 tests/plugin/web/sw_falcon/services/provider.py create mode 100644 tests/plugin/web/sw_falcon/test_falcon.py create mode 100644 tests/plugin/web/sw_flask/__init__.py create mode 100644 tests/plugin/web/sw_flask/docker-compose.yml create mode 100644 tests/plugin/web/sw_flask/expected.data.yml create mode 100644 tests/plugin/web/sw_flask/services/__init__.py create mode 100644 tests/plugin/web/sw_flask/services/consumer.py create mode 100644 tests/plugin/web/sw_flask/services/provider.py create mode 100644 tests/plugin/web/sw_flask/test_flask.py create mode 100644 tests/plugin/web/sw_pyramid/__init__.py create mode 100644 tests/plugin/web/sw_pyramid/docker-compose.yml create mode 100644 tests/plugin/web/sw_pyramid/expected.data.yml create mode 100644 tests/plugin/web/sw_pyramid/services/__init__.py create mode 100644 tests/plugin/web/sw_pyramid/services/consumer.py create mode 100644 tests/plugin/web/sw_pyramid/services/provider.py create mode 100644 tests/plugin/web/sw_pyramid/test_pyramid.py create mode 100644 tests/plugin/web/sw_sanic/__init__.py create mode 100644 tests/plugin/web/sw_sanic/docker-compose.yml create mode 100644 tests/plugin/web/sw_sanic/expected.data.yml create mode 100644 tests/plugin/web/sw_sanic/services/__init__.py create mode 100644 tests/plugin/web/sw_sanic/services/consumer.py create mode 100644 tests/plugin/web/sw_sanic/services/provider.py create mode 100644 tests/plugin/web/sw_sanic/test_sanic.py create mode 100644 tests/plugin/web/sw_tornado/__init__.py create mode 100644 tests/plugin/web/sw_tornado/docker-compose.yml create mode 100644 tests/plugin/web/sw_tornado/expected.data.yml create mode 100644 tests/plugin/web/sw_tornado/services/__init__.py create mode 100644 tests/plugin/web/sw_tornado/services/consumer.py create mode 100644 tests/plugin/web/sw_tornado/services/provider.py create mode 100644 tests/plugin/web/sw_tornado/test_tornado.py diff --git a/tests/plugin/data/__init__.py b/tests/plugin/data/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/data/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/data/sw_elasticsearch/__init__.py b/tests/plugin/data/sw_elasticsearch/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/data/sw_elasticsearch/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/data/sw_elasticsearch/docker-compose.yml b/tests/plugin/data/sw_elasticsearch/docker-compose.yml new file mode 100644 index 00000000..feb48072 --- /dev/null +++ b/tests/plugin/data/sw_elasticsearch/docker-compose.yml @@ -0,0 +1,64 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +version: '2.1' + +services: + collector: + extends: + service: collector + file: ../../docker-compose.base.yml + + elasticsearch: + image: elasticsearch:6.8.11 + hostname: elasticsearch + expose: + - 9200 + environment: + - cluster.name=docker-node + - xpack.security.enabled=false + - bootstrap.memory_lock=true + - "ES_JAVA_OPTS=-Xms256m -Xmx256m" + - discovery.type=single-node + healthcheck: + test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/9200"] + interval: 5s + timeout: 60s + retries: 120 + networks: + - beyond + + consumer: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9090:9090 + volumes: + - .:/app + command: ['bash', '-c', 'pip install flask && pip install -r /app/requirements.txt && sw-python run python3 /app/services/consumer.py'] + depends_on: + collector: + condition: service_healthy + elasticsearch: + condition: service_healthy + environment: + SW_AGENT_NAME: consumer + SW_AGENT_LOGGING_LEVEL: DEBUG + SW_ELASTICSEARCH_TRACE_DSL: 'True' +networks: + beyond: diff --git a/tests/plugin/data/sw_elasticsearch/expected.data.yml b/tests/plugin/data/sw_elasticsearch/expected.data.yml new file mode 100644 index 00000000..0e1bfd87 --- /dev/null +++ b/tests/plugin/data/sw_elasticsearch/expected.data.yml @@ -0,0 +1,88 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +segmentItems: + - serviceName: consumer + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: Elasticsearch/PUT/test + parentSpanId: 0 + spanId: 1 + spanLayer: Database + startTime: gt 0 + endTime: gt 0 + componentId: 47 + isError: false + spanType: Exit + peer: elasticsearch:9200 + skipAnalysis: false + tags: + - key: db.type + value: Elasticsearch + - key: db.statement + value: '' + - operationName: Elasticsearch/PUT/test/test/1 + parentSpanId: 0 + spanId: 2 + spanLayer: Database + startTime: gt 0 + endTime: gt 0 + componentId: 47 + isError: false + spanType: Exit + peer: elasticsearch:9200 + skipAnalysis: false + tags: + - key: db.type + value: Elasticsearch + - key: db.statement + value: '{''song'': ''Despacito'', ''artist'': ''Luis Fonsi''}' + - operationName: Elasticsearch/GET/test/_doc/1 + parentSpanId: 0 + spanId: 3 + spanLayer: Database + startTime: gt 0 + endTime: gt 0 + componentId: 47 + isError: false + spanType: Exit + peer: elasticsearch:9200 + skipAnalysis: false + tags: + - key: db.type + value: Elasticsearch + - key: db.statement + value: '' + - operationName: /users + parentSpanId: -1 + spanId: 0 + spanLayer: Http + tags: + - key: http.method + value: GET + - key: http.url + value: http://0.0.0.0:9090/users + - key: http.status.code + value: '200' + startTime: gt 0 + endTime: gt 0 + componentId: 7001 + spanType: Entry + peer: not null + skipAnalysis: false diff --git a/tests/plugin/data/sw_elasticsearch/services/__init__.py b/tests/plugin/data/sw_elasticsearch/services/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/data/sw_elasticsearch/services/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/data/sw_elasticsearch/services/consumer.py b/tests/plugin/data/sw_elasticsearch/services/consumer.py new file mode 100644 index 00000000..087d9361 --- /dev/null +++ b/tests/plugin/data/sw_elasticsearch/services/consumer.py @@ -0,0 +1,46 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +from elasticsearch import Elasticsearch + + +if __name__ == '__main__': + from flask import Flask, jsonify + + app = Flask(__name__) + client = Elasticsearch('http://elasticsearch:9200/') + index_name = 'test' + + def create_index(): + client.indices.create(index=index_name, ignore=400) + + def save_index(): + data = {'song': 'Despacito', 'artist': 'Luis Fonsi'} + client.index(index=index_name, doc_type='test', id=1, body=data) + + def search(): + client.get(index=index_name, id=1) + + @app.route('/users', methods=['POST', 'GET']) + def application(): + create_index() + save_index() + search() + return jsonify({'song': 'Despacito', 'artist': 'Luis Fonsi'}) + + PORT = 9090 + app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/data/sw_elasticsearch/test_elasticsearch.py b/tests/plugin/data/sw_elasticsearch/test_elasticsearch.py new file mode 100644 index 00000000..738f626a --- /dev/null +++ b/tests/plugin/data/sw_elasticsearch/test_elasticsearch.py @@ -0,0 +1,36 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from typing import Callable + +import pytest +import requests + +from skywalking.plugins.sw_elasticsearch import support_matrix +from tests.orchestrator import get_test_vector +from tests.plugin.base import TestPluginBase + + +@pytest.fixture +def prepare(): + # type: () -> Callable + return lambda *_: requests.get('http://0.0.0.0:9090/users') + + +class TestPlugin(TestPluginBase): + @pytest.mark.parametrize('version', get_test_vector(lib_name='elasticsearch', support_matrix=support_matrix)) + def test_plugin(self, docker_compose, version): + self.validate() diff --git a/tests/plugin/data/sw_kafka/__init__.py b/tests/plugin/data/sw_kafka/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/data/sw_kafka/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/data/sw_kafka/docker-compose.yml b/tests/plugin/data/sw_kafka/docker-compose.yml new file mode 100644 index 00000000..618aeb52 --- /dev/null +++ b/tests/plugin/data/sw_kafka/docker-compose.yml @@ -0,0 +1,109 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +version: '2.1' + +services: + collector: + extends: + service: collector + file: ../../docker-compose.base.yml + + zookeeper-server: + image: zookeeper:3.4 + hostname: zookeeper-server + ports: + - 2181:2181 + networks: + - beyond + healthcheck: + test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/2181"] + interval: 5s + timeout: 60s + retries: 120 + + kafka-server: + image: bitnami/kafka:2.1.1 + hostname: kafka-server + ports: + - 9092:9092 + environment: + - KAFKA_ZOOKEEPER_CONNECT=zookeeper-server:2181 + - KAFKA_BROKER_ID=1 + - ALLOW_PLAINTEXT_LISTENER=yes + - KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 + networks: + - beyond + healthcheck: + test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/9092"] + interval: 5s + timeout: 60s + retries: 120 + depends_on: + zookeeper-server: + condition: service_healthy + + producer: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9090:9090 + volumes: + - .:/app + command: ['bash', '-c', 'pip install flask && pip install -r /app/requirements.txt && sw-python run python3 /app/services/producer.py'] + healthcheck: + test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/9090"] + interval: 5s + timeout: 60s + retries: 120 + depends_on: + collector: + condition: service_healthy + kafka-server: + condition: service_healthy + consumer: + condition: service_healthy + environment: + SW_AGENT_NAME: producer + SW_AGENT_LOGGING_LEVEL: INFO + + consumer: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9091:9091 + volumes: + - .:/app + command: ['bash', '-c', 'pip install flask && pip install -r /app/requirements.txt && sw-python run python3 /app/services/consumer.py'] + healthcheck: + test: ["CMD", "bash", "-c", "ps -ef | grep /app/services/consumer | grep -v grep"] + interval: 5s + timeout: 60s + retries: 120 + depends_on: + collector: + condition: service_healthy + kafka-server: + condition: service_healthy + environment: + SW_AGENT_NAME: consumer + SW_AGENT_LOGGING_LEVEL: INFO + +networks: + beyond: diff --git a/tests/plugin/data/sw_kafka/expected.data.yml b/tests/plugin/data/sw_kafka/expected.data.yml new file mode 100644 index 00000000..837c390b --- /dev/null +++ b/tests/plugin/data/sw_kafka/expected.data.yml @@ -0,0 +1,86 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +segmentItems: + - serviceName: producer + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: Kafka/skywalking/Producer + parentSpanId: 0 + spanId: 1 + spanLayer: MQ + tags: + - key: mq.broker + value: 'kafka-server:9092' + - key: mq.topic + value: skywalking + startTime: gt 0 + endTime: gt 0 + componentId: 40 + spanType: Exit + peer: kafka-server:9092 + skipAnalysis: false + - operationName: /users + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + tags: + - key: http.method + value: GET + - key: http.url + value: http://0.0.0.0:9090/users + - key: http.status.code + value: '200' + startTime: gt 0 + endTime: gt 0 + componentId: 7001 + spanType: Entry + peer: not null + skipAnalysis: false + - serviceName: consumer + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: Kafka/skywalking/Consumer/skywalking + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: MQ + tags: + - key: mq.broker + value: 'kafka-server:9092' + - key: mq.topic + value: skywalking + refs: + - parentEndpoint: Kafka/skywalking/Producer + networkAddress: 'kafka-server:9092' + refType: CrossProcess + parentSpanId: 1 + parentTraceSegmentId: not null + parentServiceInstance: not null + parentService: producer + traceId: not null + startTime: gt 0 + endTime: gt 0 + componentId: 41 + spanType: Entry + peer: '' + skipAnalysis: false diff --git a/tests/plugin/data/sw_kafka/services/__init__.py b/tests/plugin/data/sw_kafka/services/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/data/sw_kafka/services/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/data/sw_kafka/services/consumer.py b/tests/plugin/data/sw_kafka/services/consumer.py new file mode 100644 index 00000000..71bf36b0 --- /dev/null +++ b/tests/plugin/data/sw_kafka/services/consumer.py @@ -0,0 +1,32 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +if __name__ == '__main__': + topic = 'skywalking' + server_list = ['kafka-server:9092'] + group_id = 'skywalking' + client_id = '0' + + from kafka import KafkaConsumer + from kafka import TopicPartition + consumer = KafkaConsumer(group_id=group_id, + client_id=client_id, + bootstrap_servers=server_list) + partition = TopicPartition(topic, int(client_id)) + consumer.assign([partition]) + for msg in consumer: + print(msg) diff --git a/tests/plugin/data/sw_kafka/services/producer.py b/tests/plugin/data/sw_kafka/services/producer.py new file mode 100644 index 00000000..c5cd8db6 --- /dev/null +++ b/tests/plugin/data/sw_kafka/services/producer.py @@ -0,0 +1,33 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +if __name__ == '__main__': + from flask import Flask, jsonify + from kafka import KafkaProducer + + app = Flask(__name__) + producer = KafkaProducer(bootstrap_servers=['kafka-server:9092'], api_version=(1, 0, 1)) + + @app.route('/users', methods=['POST', 'GET']) + def application(): + producer.send('skywalking', b'some_message_bytes') + + return jsonify({'song': 'Despacito', 'artist': 'Luis Fonsi'}) + + PORT = 9090 + app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/data/sw_kafka/test_kafka.py b/tests/plugin/data/sw_kafka/test_kafka.py new file mode 100644 index 00000000..a383c5a6 --- /dev/null +++ b/tests/plugin/data/sw_kafka/test_kafka.py @@ -0,0 +1,36 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from typing import Callable + +import pytest +import requests + +from skywalking.plugins.sw_kafka import support_matrix +from tests.orchestrator import get_test_vector +from tests.plugin.base import TestPluginBase + + +@pytest.fixture +def prepare(): + # type: () -> Callable + return lambda *_: requests.get('http://0.0.0.0:9090/users') + + +class TestPlugin(TestPluginBase): + @pytest.mark.parametrize('version', get_test_vector(lib_name='kafka-python', support_matrix=support_matrix)) + def test_plugin(self, docker_compose, version): + self.validate() diff --git a/tests/plugin/data/sw_mysqlclient/__init__.py b/tests/plugin/data/sw_mysqlclient/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/data/sw_mysqlclient/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/data/sw_mysqlclient/docker-compose.yml b/tests/plugin/data/sw_mysqlclient/docker-compose.yml new file mode 100644 index 00000000..311ec430 --- /dev/null +++ b/tests/plugin/data/sw_mysqlclient/docker-compose.yml @@ -0,0 +1,86 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +version: '2.1' + +services: + collector: + extends: + service: collector + file: ../../docker-compose.base.yml + + mysql: + image: mysql:5.7 + hostname: mysql + ports: + - 3306:3306 + - 33060:33060 + environment: + - MYSQL_ROOT_PASSWORD=root + - MYSQL_DATABASE=test + healthcheck: + test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/3306"] + interval: 5s + timeout: 60s + retries: 120 + networks: + - beyond + + provider: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9091:9091 + volumes: + - .:/app + command: ['bash', '-c', 'pip install flask && pip install -r /app/requirements.txt && sw-python run python3 /app/services/provider.py'] + depends_on: + collector: + condition: service_healthy + mysql: + condition: service_healthy + healthcheck: + test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/9091"] + interval: 5s + timeout: 60s + retries: 120 + environment: + SW_AGENT_NAME: provider + SW_AGENT_LOGGING_LEVEL: DEBUG + SW_SQL_PARAMETERS_LENGTH: 512 + + consumer: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9090:9090 + volumes: + - .:/app + command: ['bash', '-c', 'pip install flask && sw-python run python3 /app/services/consumer.py'] + depends_on: + collector: + condition: service_healthy + provider: + condition: service_healthy + environment: + SW_AGENT_NAME: consumer + SW_AGENT_LOGGING_LEVEL: DEBUG + +networks: + beyond: diff --git a/tests/plugin/data/sw_mysqlclient/expected.data.yml b/tests/plugin/data/sw_mysqlclient/expected.data.yml new file mode 100644 index 00000000..cae7ce25 --- /dev/null +++ b/tests/plugin/data/sw_mysqlclient/expected.data.yml @@ -0,0 +1,109 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +segmentItems: + - serviceName: provider + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: Mysql/MysqlClient/execute + parentSpanId: 0 + spanId: 1 + spanLayer: Database + tags: + - key: db.type + value: mysql + - key: db.instance + value: mysql + - key: db.statement + value: 'select * from user where user = %s' + - key: db.sql.parameters + value: '[root]' + startTime: gt 0 + endTime: gt 0 + componentId: 7013 + spanType: Exit + peer: mysql:3306 + skipAnalysis: false + - operationName: /users + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + tags: + - key: http.method + value: POST + - key: http.url + value: http://provider:9091/users + - key: http.status.code + value: '200' + refs: + - parentEndpoint: /users + networkAddress: provider:9091 + refType: CrossProcess + parentSpanId: 1 + parentTraceSegmentId: not null + parentServiceInstance: not null + parentService: consumer + traceId: not null + startTime: gt 0 + endTime: gt 0 + componentId: 7001 + spanType: Entry + peer: not null + skipAnalysis: false + - serviceName: consumer + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: /users + parentSpanId: 0 + spanId: 1 + spanLayer: Http + tags: + - key: http.method + value: POST + - key: http.url + value: http://provider:9091/users + - key: http.status.code + value: '200' + startTime: gt 0 + endTime: gt 0 + componentId: 7002 + spanType: Exit + peer: provider:9091 + skipAnalysis: false + - operationName: /users + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + tags: + - key: http.method + value: GET + - key: http.url + value: http://0.0.0.0:9090/users + - key: http.status.code + value: '200' + startTime: gt 0 + endTime: gt 0 + componentId: 7001 + spanType: Entry + peer: not null + skipAnalysis: false \ No newline at end of file diff --git a/tests/plugin/data/sw_mysqlclient/services/__init__.py b/tests/plugin/data/sw_mysqlclient/services/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/data/sw_mysqlclient/services/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/data/sw_mysqlclient/services/consumer.py b/tests/plugin/data/sw_mysqlclient/services/consumer.py new file mode 100644 index 00000000..3085092a --- /dev/null +++ b/tests/plugin/data/sw_mysqlclient/services/consumer.py @@ -0,0 +1,32 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import requests + + +if __name__ == '__main__': + from flask import Flask, jsonify + + app = Flask(__name__) + + @app.route('/users', methods=['POST', 'GET']) + def application(): + res = requests.post('http://provider:9091/users') + return jsonify(res.json()) + + PORT = 9090 + app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/data/sw_mysqlclient/services/provider.py b/tests/plugin/data/sw_mysqlclient/services/provider.py new file mode 100644 index 00000000..8e24f6e0 --- /dev/null +++ b/tests/plugin/data/sw_mysqlclient/services/provider.py @@ -0,0 +1,39 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import time + +if __name__ == '__main__': + from flask import Flask, jsonify + import MySQLdb + + app = Flask(__name__) + + @app.route('/users', methods=['POST', 'GET']) + def application(): + time.sleep(0.5) + connection = MySQLdb.connect(host='mysql', user='root', passwd='root', db='mysql', charset='utf8mb4') + with connection.cursor() as cursor: + sql = 'select * from user where user = %s' + cursor.execute(sql, ('root',)) + + connection.close() + + return jsonify({'song': 'Despacito', 'artist': 'Luis Fonsi'}) + + PORT = 9091 + app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/data/sw_mysqlclient/test_mysqlclient.py b/tests/plugin/data/sw_mysqlclient/test_mysqlclient.py new file mode 100644 index 00000000..f306fb29 --- /dev/null +++ b/tests/plugin/data/sw_mysqlclient/test_mysqlclient.py @@ -0,0 +1,36 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from typing import Callable + +import pytest +import requests + +from skywalking.plugins.sw_mysqlclient import support_matrix +from tests.orchestrator import get_test_vector +from tests.plugin.base import TestPluginBase + + +@pytest.fixture +def prepare(): + # type: () -> Callable + return lambda *_: requests.get('http://0.0.0.0:9090/users') + + +class TestPlugin(TestPluginBase): + @pytest.mark.parametrize('version', get_test_vector(lib_name='mysqlclient', support_matrix=support_matrix)) + def test_plugin(self, docker_compose, version): + self.validate() diff --git a/tests/plugin/data/sw_psycopg/__init__.py b/tests/plugin/data/sw_psycopg/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/data/sw_psycopg/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/data/sw_psycopg/docker-compose.yml b/tests/plugin/data/sw_psycopg/docker-compose.yml new file mode 100644 index 00000000..bc88f5e8 --- /dev/null +++ b/tests/plugin/data/sw_psycopg/docker-compose.yml @@ -0,0 +1,87 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +version: '2.1' + +services: + collector: + extends: + service: collector + file: ../../docker-compose.base.yml + + postgres: + image: postgres:11 + hostname: postgres + ports: + - "5432:5444" + environment: + - POSTGRES_USER=root + - POSTGRES_PASSWORD=root + - POSTGRES_DB=admin + - POSTGRES_PORT=5444 + healthcheck: + test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/5432"] + interval: 5s + timeout: 60s + retries: 120 + networks: + - beyond + + provider: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9091:9091 + volumes: + - .:/app + command: ['bash', '-c', 'pip install flask && pip install -r /app/requirements.txt && sw-python run python3 /app/services/provider.py'] + depends_on: + collector: + condition: service_healthy + postgres: + condition: service_healthy + healthcheck: + test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/9091"] + interval: 5s + timeout: 60s + retries: 120 + environment: + SW_AGENT_NAME: provider + SW_AGENT_LOGGING_LEVEL: DEBUG + SW_SQL_PARAMETERS_LENGTH: 512 + + consumer: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9090:9090 + volumes: + - .:/app + command: ['bash', '-c', 'pip install flask && sw-python run python3 /app/services/consumer.py'] + depends_on: + collector: + condition: service_healthy + provider: + condition: service_healthy + environment: + SW_AGENT_NAME: consumer + SW_AGENT_LOGGING_LEVEL: DEBUG + +networks: + beyond: diff --git a/tests/plugin/data/sw_psycopg/expected.data.yml b/tests/plugin/data/sw_psycopg/expected.data.yml new file mode 100644 index 00000000..2544a3be --- /dev/null +++ b/tests/plugin/data/sw_psycopg/expected.data.yml @@ -0,0 +1,110 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +segmentItems: + - serviceName: provider + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: PostgreSLQ/Psycopg/execute + parentSpanId: 0 + spanId: 1 + spanLayer: Database + tags: + - key: db.type + value: PostgreSQL + - key: db.instance + value: admin + - key: db.statement + value: 'select * from user where user = %s' + - key: db.sql.parameters + value: '[root]' + startTime: gt 0 + endTime: gt 0 + isError: false + componentId: 7010 + spanType: Exit + peer: postgres:5432 + skipAnalysis: false + - operationName: /users + parentSpanId: -1 + spanId: 0 + spanLayer: Http + tags: + - key: http.method + value: POST + - key: http.url + value: http://provider:9091/users + - key: http.status.code + value: '200' + refs: + - parentEndpoint: /users + networkAddress: provider:9091 + refType: CrossProcess + parentSpanId: 1 + parentTraceSegmentId: not null + parentServiceInstance: not null + parentService: consumer + traceId: not null + startTime: gt 0 + endTime: gt 0 + componentId: 7001 + spanType: Entry + peer: not null + skipAnalysis: false + - serviceName: consumer + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: /users + parentSpanId: 0 + spanId: 1 + spanLayer: Http + tags: + - key: http.method + value: POST + - key: http.url + value: http://provider:9091/users + - key: http.status.code + value: '200' + startTime: gt 0 + endTime: gt 0 + componentId: 7002 + isError: false + spanType: Exit + peer: provider:9091 + skipAnalysis: false + - operationName: /users + parentSpanId: -1 + spanId: 0 + spanLayer: Http + tags: + - key: http.method + value: GET + - key: http.url + value: http://0.0.0.0:9090/users + - key: http.status.code + value: '200' + startTime: gt 0 + endTime: gt 0 + componentId: 7001 + isError: false + spanType: Entry + peer: not null + skipAnalysis: false \ No newline at end of file diff --git a/tests/plugin/data/sw_psycopg/services/__init__.py b/tests/plugin/data/sw_psycopg/services/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/data/sw_psycopg/services/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/data/sw_psycopg/services/consumer.py b/tests/plugin/data/sw_psycopg/services/consumer.py new file mode 100644 index 00000000..3085092a --- /dev/null +++ b/tests/plugin/data/sw_psycopg/services/consumer.py @@ -0,0 +1,32 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import requests + + +if __name__ == '__main__': + from flask import Flask, jsonify + + app = Flask(__name__) + + @app.route('/users', methods=['POST', 'GET']) + def application(): + res = requests.post('http://provider:9091/users') + return jsonify(res.json()) + + PORT = 9090 + app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/data/sw_psycopg/services/provider.py b/tests/plugin/data/sw_psycopg/services/provider.py new file mode 100644 index 00000000..29e0325d --- /dev/null +++ b/tests/plugin/data/sw_psycopg/services/provider.py @@ -0,0 +1,40 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import time + + +if __name__ == '__main__': + from flask import Flask, jsonify + import psycopg + + app = Flask(__name__) + + @app.route('/users', methods=['POST', 'GET']) + def application(): + time.sleep(0.5) + connection = psycopg.connect(host='postgres', user='root', password='root', dbname='admin', port=5432) + with connection.cursor() as cursor: + sql = 'select * from user where user = %s' + cursor.execute(sql, ('root',)) + + connection.close() + + return jsonify({'song': 'Despacito', 'artist': 'Luis Fonsi'}) + + PORT = 9091 + app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/data/sw_psycopg/test_psycopg.py b/tests/plugin/data/sw_psycopg/test_psycopg.py new file mode 100644 index 00000000..a8f284dd --- /dev/null +++ b/tests/plugin/data/sw_psycopg/test_psycopg.py @@ -0,0 +1,36 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from typing import Callable + +import pytest +import requests + +from skywalking.plugins.sw_psycopg import support_matrix +from tests.orchestrator import get_test_vector +from tests.plugin.base import TestPluginBase + + +@pytest.fixture +def prepare(): + # type: () -> Callable + return lambda *_: requests.get('http://0.0.0.0:9090/users') + + +class TestPlugin(TestPluginBase): + @pytest.mark.parametrize('version', get_test_vector(lib_name='psycopg[binary]', support_matrix=support_matrix)) + def test_plugin(self, docker_compose, version): + self.validate() diff --git a/tests/plugin/data/sw_psycopg2/__init__.py b/tests/plugin/data/sw_psycopg2/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/data/sw_psycopg2/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/data/sw_psycopg2/docker-compose.yml b/tests/plugin/data/sw_psycopg2/docker-compose.yml new file mode 100644 index 00000000..a564216e --- /dev/null +++ b/tests/plugin/data/sw_psycopg2/docker-compose.yml @@ -0,0 +1,86 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +version: '2.1' + +services: + collector: + extends: + service: collector + file: ../../docker-compose.base.yml + + postgres: + image: postgres:11 + hostname: postgres + ports: + - 5432:5432 + environment: + - POSTGRES_USER=root + - POSTGRES_PASSWORD=root + - POSTGRES_DB=admin + healthcheck: + test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/5432"] + interval: 5s + timeout: 60s + retries: 120 + networks: + - beyond + + provider: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9091:9091 + volumes: + - .:/app + command: ['bash', '-c', 'pip install flask && pip install -r /app/requirements.txt && sw-python run python3 /app/services/provider.py'] + depends_on: + collector: + condition: service_healthy + postgres: + condition: service_healthy + healthcheck: + test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/9091"] + interval: 5s + timeout: 60s + retries: 120 + environment: + SW_AGENT_NAME: provider + SW_AGENT_LOGGING_LEVEL: DEBUG + SW_SQL_PARAMETERS_LENGTH: 512 + + consumer: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9090:9090 + volumes: + - .:/app + command: ['bash', '-c', 'pip install flask && sw-python run python3 /app/services/consumer.py'] + depends_on: + collector: + condition: service_healthy + provider: + condition: service_healthy + environment: + SW_AGENT_NAME: consumer + SW_AGENT_LOGGING_LEVEL: DEBUG + +networks: + beyond: diff --git a/tests/plugin/data/sw_psycopg2/expected.data.yml b/tests/plugin/data/sw_psycopg2/expected.data.yml new file mode 100644 index 00000000..c5a91a11 --- /dev/null +++ b/tests/plugin/data/sw_psycopg2/expected.data.yml @@ -0,0 +1,112 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +segmentItems: + - serviceName: provider + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: PostgreSLQ/Psycopg/execute + parentSpanId: 0 + spanId: 1 + spanLayer: Database + tags: + - key: db.type + value: PostgreSQL + - key: db.instance + value: admin + - key: db.statement + value: 'select * from user where user = %s' + - key: db.sql.parameters + value: '[root]' + startTime: gt 0 + endTime: gt 0 + isError: false + componentId: 7010 + spanType: Exit + peer: postgres:5432 + skipAnalysis: false + - operationName: /users + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + tags: + - key: http.method + value: POST + - key: http.url + value: http://provider:9091/users + - key: http.status.code + value: '200' + refs: + - parentEndpoint: /users + networkAddress: provider:9091 + refType: CrossProcess + parentSpanId: 1 + parentTraceSegmentId: not null + parentServiceInstance: not null + parentService: consumer + traceId: not null + startTime: gt 0 + endTime: gt 0 + componentId: 7001 + spanType: Entry + peer: not null + skipAnalysis: false + - serviceName: consumer + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: /users + parentSpanId: 0 + spanId: 1 + spanLayer: Http + tags: + - key: http.method + value: POST + - key: http.url + value: http://provider:9091/users + - key: http.status.code + value: '200' + startTime: gt 0 + endTime: gt 0 + componentId: 7002 + isError: false + spanType: Exit + peer: provider:9091 + skipAnalysis: false + - operationName: /users + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + tags: + - key: http.method + value: GET + - key: http.url + value: http://0.0.0.0:9090/users + - key: http.status.code + value: '200' + startTime: gt 0 + endTime: gt 0 + componentId: 7001 + isError: false + spanType: Entry + peer: not null + skipAnalysis: false \ No newline at end of file diff --git a/tests/plugin/data/sw_psycopg2/services/__init__.py b/tests/plugin/data/sw_psycopg2/services/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/data/sw_psycopg2/services/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/data/sw_psycopg2/services/consumer.py b/tests/plugin/data/sw_psycopg2/services/consumer.py new file mode 100644 index 00000000..3085092a --- /dev/null +++ b/tests/plugin/data/sw_psycopg2/services/consumer.py @@ -0,0 +1,32 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import requests + + +if __name__ == '__main__': + from flask import Flask, jsonify + + app = Flask(__name__) + + @app.route('/users', methods=['POST', 'GET']) + def application(): + res = requests.post('http://provider:9091/users') + return jsonify(res.json()) + + PORT = 9090 + app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/data/sw_psycopg2/services/provider.py b/tests/plugin/data/sw_psycopg2/services/provider.py new file mode 100644 index 00000000..8a5bed75 --- /dev/null +++ b/tests/plugin/data/sw_psycopg2/services/provider.py @@ -0,0 +1,40 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import time + + +if __name__ == '__main__': + from flask import Flask, jsonify + import psycopg2 + + app = Flask(__name__) + + @app.route('/users', methods=['POST', 'GET']) + def application(): + time.sleep(0.5) + connection = psycopg2.connect(host='postgres', user='root', password='root', dbname='admin') + with connection.cursor() as cursor: + sql = 'select * from user where user = %s' + cursor.execute(sql, ('root',)) + + connection.close() + + return jsonify({'song': 'Despacito', 'artist': 'Luis Fonsi'}) + + PORT = 9091 + app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/data/sw_psycopg2/test_psycopg2.py b/tests/plugin/data/sw_psycopg2/test_psycopg2.py new file mode 100644 index 00000000..d6f954d4 --- /dev/null +++ b/tests/plugin/data/sw_psycopg2/test_psycopg2.py @@ -0,0 +1,36 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from typing import Callable + +import pytest +import requests + +from skywalking.plugins.sw_psycopg2 import support_matrix +from tests.orchestrator import get_test_vector +from tests.plugin.base import TestPluginBase + + +@pytest.fixture +def prepare(): + # type: () -> Callable + return lambda *_: requests.get('http://0.0.0.0:9090/users') + + +class TestPlugin(TestPluginBase): + @pytest.mark.parametrize('version', get_test_vector(lib_name='psycopg2-binary', support_matrix=support_matrix)) + def test_plugin(self, docker_compose, version): + self.validate() diff --git a/tests/plugin/data/sw_pymongo/__init__.py b/tests/plugin/data/sw_pymongo/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/data/sw_pymongo/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/data/sw_pymongo/docker-compose.yml b/tests/plugin/data/sw_pymongo/docker-compose.yml new file mode 100644 index 00000000..588db5b9 --- /dev/null +++ b/tests/plugin/data/sw_pymongo/docker-compose.yml @@ -0,0 +1,82 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +version: '2.1' + +services: + collector: + extends: + service: collector + file: ../../docker-compose.base.yml + + mongo: + image: mongo:4.2 + hostname: mongo + ports: + - 27017:27017 + healthcheck: + test: echo 'db.runCommand("ping").ok' | mongo mongo:27017/test --quiet + interval: 5s + timeout: 60s + retries: 120 + networks: + - beyond + + provider: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9091:9091 + volumes: + - .:/app + command: ['bash', '-c', 'pip install flask && pip install -r /app/requirements.txt && sw-python run python3 /app/services/provider.py'] + depends_on: + collector: + condition: service_healthy + mongo: + condition: service_healthy + healthcheck: + test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/9091"] + interval: 5s + timeout: 60s + retries: 120 + environment: + SW_AGENT_NAME: provider + SW_AGENT_LOGGING_LEVEL: DEBUG + SW_PYMONGO_TRACE_PARAMETERS: 'True' + + consumer: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9090:9090 + volumes: + - .:/app + command: ['bash', '-c', 'pip install flask && sw-python run python3 /app/services/consumer.py'] + depends_on: + collector: + condition: service_healthy + provider: + condition: service_healthy + environment: + SW_AGENT_NAME: consumer + SW_AGENT_LOGGING_LEVEL: DEBUG + +networks: + beyond: diff --git a/tests/plugin/data/sw_pymongo/expected.data.yml b/tests/plugin/data/sw_pymongo/expected.data.yml new file mode 100644 index 00000000..6afd5487 --- /dev/null +++ b/tests/plugin/data/sw_pymongo/expected.data.yml @@ -0,0 +1,233 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +segmentItems: + - serviceName: provider + segmentSize: 3 + segments: + - segmentId: not null + spans: + - operationName: MongoDB/MixedBulkWriteOperation + parentSpanId: 0 + spanId: 1 + spanLayer: Database + startTime: gt 0 + endTime: gt 0 + componentId: 9 + spanType: Exit + peer: not null + skipAnalysis: false + tags: + - key: db.type + value: MongoDB + - key: db.instance + value: test-database + - key: db.statement + value: not null + - operationName: /insert_many + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: gt 0 + endTime: gt 0 + componentId: 7001 + spanType: Entry + peer: not null + skipAnalysis: false + tags: + - key: http.method + value: GET + - key: http.url + value: http://provider:9091/insert_many + - key: http.status.code + value: '200' + refs: + - parentEndpoint: /insert_many + networkAddress: provider:9091 + refType: CrossProcess + parentSpanId: 1 + parentTraceSegmentId: not null + parentServiceInstance: not null + parentService: consumer + traceId: not null + - segmentId: not null + spans: + - operationName: MongoDB/FindOperation + parentSpanId: 0 + spanId: 1 + spanLayer: Database + startTime: gt 0 + endTime: gt 0 + componentId: 9 + spanType: Exit + peer: not null + skipAnalysis: false + tags: + - key: db.type + value: MongoDB + - key: db.instance + value: test-database + - key: db.statement + value: not null + - operationName: /find_one + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: gt 0 + endTime: gt 0 + componentId: 7001 + spanType: Entry + peer: not null + skipAnalysis: false + tags: + - key: http.method + value: GET + - key: http.url + value: http://provider:9091/find_one + - key: http.status.code + value: '200' + refs: + - parentEndpoint: /find_one + networkAddress: provider:9091 + refType: CrossProcess + parentSpanId: 2 + parentTraceSegmentId: not null + parentServiceInstance: not null + parentService: consumer + traceId: not null + - segmentId: not null + spans: + - operationName: MongoDB/DeleteOperation + parentSpanId: 0 + spanId: 1 + spanLayer: Database + startTime: gt 0 + endTime: gt 0 + componentId: 9 + spanType: Exit + peer: not null + skipAnalysis: false + tags: + - key: db.type + value: MongoDB + - key: db.instance + value: test-database + - key: db.statement + value: not null + - operationName: /delete_one + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: gt 0 + endTime: gt 0 + componentId: 7001 + spanType: Entry + peer: not null + skipAnalysis: false + tags: + - key: http.method + value: GET + - key: http.url + value: http://provider:9091/delete_one + - key: http.status.code + value: '200' + refs: + - parentEndpoint: /delete_one + networkAddress: provider:9091 + refType: CrossProcess + parentSpanId: 3 + parentTraceSegmentId: not null + parentServiceInstance: not null + parentService: consumer + traceId: not null + - serviceName: consumer + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: /insert_many + parentSpanId: 0 + spanId: 1 + spanLayer: Http + startTime: gt 0 + endTime: gt 0 + componentId: 7002 + spanType: Exit + peer: provider:9091 + skipAnalysis: false + tags: + - key: http.method + value: GET + - key: http.url + value: http://provider:9091/insert_many + - key: http.status.code + value: '200' + - operationName: /find_one + parentSpanId: 0 + spanId: 2 + spanLayer: Http + startTime: gt 0 + endTime: gt 0 + componentId: 7002 + spanType: Exit + peer: provider:9091 + skipAnalysis: false + tags: + - key: http.method + value: GET + - key: http.url + value: http://provider:9091/find_one + - key: http.status.code + value: '200' + - operationName: /delete_one + parentSpanId: 0 + spanId: 3 + spanLayer: Http + startTime: gt 0 + endTime: gt 0 + componentId: 7002 + spanType: Exit + peer: provider:9091 + skipAnalysis: false + tags: + - key: http.method + value: GET + - key: http.url + value: http://provider:9091/delete_one + - key: http.status.code + value: '200' + - operationName: /users + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: gt 0 + endTime: gt 0 + componentId: 7001 + spanType: Entry + peer: not null + skipAnalysis: false + tags: + - key: http.method + value: GET + - key: http.url + value: http://0.0.0.0:9090/users + - key: http.status.code + value: '200' diff --git a/tests/plugin/data/sw_pymongo/services/__init__.py b/tests/plugin/data/sw_pymongo/services/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/data/sw_pymongo/services/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/data/sw_pymongo/services/consumer.py b/tests/plugin/data/sw_pymongo/services/consumer.py new file mode 100644 index 00000000..610494e5 --- /dev/null +++ b/tests/plugin/data/sw_pymongo/services/consumer.py @@ -0,0 +1,34 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import requests + + +if __name__ == '__main__': + from flask import Flask, jsonify + + app = Flask(__name__) + + @app.route('/users', methods=['POST', 'GET']) + def application(): + requests.get('http://provider:9091/insert_many') + requests.get('http://provider:9091/find_one') + res = requests.get('http://provider:9091/delete_one') + return jsonify(res.json()) + + PORT = 9090 + app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/data/sw_pymongo/services/provider.py b/tests/plugin/data/sw_pymongo/services/provider.py new file mode 100644 index 00000000..67ba9b0f --- /dev/null +++ b/tests/plugin/data/sw_pymongo/services/provider.py @@ -0,0 +1,58 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import time + +from flask import Flask, jsonify +from pymongo import MongoClient + +client = MongoClient('mongodb://mongo:27017/') +db = client['test-database'] +collection = db['test-collection'] + + +app = Flask(__name__) + + +@app.route('/insert_many', methods=['GET']) +def test_insert_many(): + time.sleep(0.5) + new_posts = [{'song': 'Despacito'}, + {'artist': 'Luis Fonsi'}] + result = collection.insert_many(new_posts) + return jsonify({'ok': result.acknowledged}) + + +@app.route('/find_one', methods=['GET']) +def test_find_one(): + time.sleep(0.5) + result = collection.find_one({'song': 'Despacito'}) + # have to get the result and use it. if not lint will report error + print(result) + return jsonify({'song': 'Despacito'}) + + +@app.route('/delete_one', methods=['GET']) +def test_delete_one(): + time.sleep(0.5) + result = collection.delete_one({'song': 'Despacito'}) + return jsonify({'ok': result.acknowledged}) + + +if __name__ == '__main__': + PORT = 9091 + app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/data/sw_pymongo/test_pymongo.py b/tests/plugin/data/sw_pymongo/test_pymongo.py new file mode 100644 index 00000000..3b2b81af --- /dev/null +++ b/tests/plugin/data/sw_pymongo/test_pymongo.py @@ -0,0 +1,36 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from typing import Callable + +import pytest +import requests + +from skywalking.plugins.sw_pymongo import support_matrix +from tests.orchestrator import get_test_vector +from tests.plugin.base import TestPluginBase + + +@pytest.fixture +def prepare(): + # type: () -> Callable + return lambda *_: requests.get('http://0.0.0.0:9090/users') + + +class TestPlugin(TestPluginBase): + @pytest.mark.parametrize('version', get_test_vector(lib_name='pymongo', support_matrix=support_matrix)) + def test_plugin(self, docker_compose, version): + self.validate() diff --git a/tests/plugin/data/sw_pymysql/__init__.py b/tests/plugin/data/sw_pymysql/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/data/sw_pymysql/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/data/sw_pymysql/docker-compose.yml b/tests/plugin/data/sw_pymysql/docker-compose.yml new file mode 100644 index 00000000..311ec430 --- /dev/null +++ b/tests/plugin/data/sw_pymysql/docker-compose.yml @@ -0,0 +1,86 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +version: '2.1' + +services: + collector: + extends: + service: collector + file: ../../docker-compose.base.yml + + mysql: + image: mysql:5.7 + hostname: mysql + ports: + - 3306:3306 + - 33060:33060 + environment: + - MYSQL_ROOT_PASSWORD=root + - MYSQL_DATABASE=test + healthcheck: + test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/3306"] + interval: 5s + timeout: 60s + retries: 120 + networks: + - beyond + + provider: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9091:9091 + volumes: + - .:/app + command: ['bash', '-c', 'pip install flask && pip install -r /app/requirements.txt && sw-python run python3 /app/services/provider.py'] + depends_on: + collector: + condition: service_healthy + mysql: + condition: service_healthy + healthcheck: + test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/9091"] + interval: 5s + timeout: 60s + retries: 120 + environment: + SW_AGENT_NAME: provider + SW_AGENT_LOGGING_LEVEL: DEBUG + SW_SQL_PARAMETERS_LENGTH: 512 + + consumer: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9090:9090 + volumes: + - .:/app + command: ['bash', '-c', 'pip install flask && sw-python run python3 /app/services/consumer.py'] + depends_on: + collector: + condition: service_healthy + provider: + condition: service_healthy + environment: + SW_AGENT_NAME: consumer + SW_AGENT_LOGGING_LEVEL: DEBUG + +networks: + beyond: diff --git a/tests/plugin/data/sw_pymysql/expected.data.yml b/tests/plugin/data/sw_pymysql/expected.data.yml new file mode 100644 index 00000000..901f8eb2 --- /dev/null +++ b/tests/plugin/data/sw_pymysql/expected.data.yml @@ -0,0 +1,109 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +segmentItems: + - serviceName: provider + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: Mysql/PyMsql/execute + parentSpanId: 0 + spanId: 1 + spanLayer: Database + tags: + - key: db.type + value: mysql + - key: db.instance + value: mysql + - key: db.statement + value: 'select * from user where user = %s' + - key: db.sql.parameters + value: '[root]' + startTime: gt 0 + endTime: gt 0 + componentId: 7003 + spanType: Exit + peer: mysql:3306 + skipAnalysis: false + - operationName: /users + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + tags: + - key: http.method + value: POST + - key: http.url + value: http://provider:9091/users + - key: http.status.code + value: '200' + refs: + - parentEndpoint: /users + networkAddress: provider:9091 + refType: CrossProcess + parentSpanId: 1 + parentTraceSegmentId: not null + parentServiceInstance: not null + parentService: consumer + traceId: not null + startTime: gt 0 + endTime: gt 0 + componentId: 7001 + spanType: Entry + peer: not null + skipAnalysis: false + - serviceName: consumer + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: /users + parentSpanId: 0 + spanId: 1 + spanLayer: Http + tags: + - key: http.method + value: POST + - key: http.url + value: http://provider:9091/users + - key: http.status.code + value: '200' + startTime: gt 0 + endTime: gt 0 + componentId: 7002 + spanType: Exit + peer: provider:9091 + skipAnalysis: false + - operationName: /users + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + tags: + - key: http.method + value: GET + - key: http.url + value: http://0.0.0.0:9090/users + - key: http.status.code + value: '200' + startTime: gt 0 + endTime: gt 0 + componentId: 7001 + spanType: Entry + peer: not null + skipAnalysis: false \ No newline at end of file diff --git a/tests/plugin/data/sw_pymysql/services/__init__.py b/tests/plugin/data/sw_pymysql/services/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/data/sw_pymysql/services/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/data/sw_pymysql/services/consumer.py b/tests/plugin/data/sw_pymysql/services/consumer.py new file mode 100644 index 00000000..3085092a --- /dev/null +++ b/tests/plugin/data/sw_pymysql/services/consumer.py @@ -0,0 +1,32 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import requests + + +if __name__ == '__main__': + from flask import Flask, jsonify + + app = Flask(__name__) + + @app.route('/users', methods=['POST', 'GET']) + def application(): + res = requests.post('http://provider:9091/users') + return jsonify(res.json()) + + PORT = 9090 + app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/data/sw_pymysql/services/provider.py b/tests/plugin/data/sw_pymysql/services/provider.py new file mode 100644 index 00000000..3486016d --- /dev/null +++ b/tests/plugin/data/sw_pymysql/services/provider.py @@ -0,0 +1,39 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import time + +if __name__ == '__main__': + from flask import Flask, jsonify + import pymysql.cursors + + app = Flask(__name__) + + @app.route('/users', methods=['POST', 'GET']) + def application(): + time.sleep(0.5) + connection = pymysql.connect(host='mysql', user='root', password='root', db='mysql', charset='utf8mb4') + with connection.cursor() as cursor: + sql = 'select * from user where user = %s' + cursor.execute(sql, ('root',)) + + connection.close() + + return jsonify({'song': 'Despacito', 'artist': 'Luis Fonsi'}) + + PORT = 9091 + app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/data/sw_pymysql/test_pymysql.py b/tests/plugin/data/sw_pymysql/test_pymysql.py new file mode 100644 index 00000000..12ca1660 --- /dev/null +++ b/tests/plugin/data/sw_pymysql/test_pymysql.py @@ -0,0 +1,36 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from typing import Callable + +import pytest +import requests + +from skywalking.plugins.sw_pymysql import support_matrix +from tests.orchestrator import get_test_vector +from tests.plugin.base import TestPluginBase + + +@pytest.fixture +def prepare(): + # type: () -> Callable + return lambda *_: requests.get('http://0.0.0.0:9090/users') + + +class TestPlugin(TestPluginBase): + @pytest.mark.parametrize('version', get_test_vector(lib_name='pymysql', support_matrix=support_matrix)) + def test_plugin(self, docker_compose, version): + self.validate() diff --git a/tests/plugin/data/sw_rabbitmq/__init__.py b/tests/plugin/data/sw_rabbitmq/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/data/sw_rabbitmq/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/data/sw_rabbitmq/docker-compose.yml b/tests/plugin/data/sw_rabbitmq/docker-compose.yml new file mode 100644 index 00000000..66d49ddd --- /dev/null +++ b/tests/plugin/data/sw_rabbitmq/docker-compose.yml @@ -0,0 +1,93 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +version: '2.1' + +services: + collector: + extends: + service: collector + file: ../../docker-compose.base.yml + + rabbitmq-server: + image: rabbitmq:3.8.18 + hostname: rabbitmq-server + ports: + - 5672:5672 + - 15672:15672 + environment: + - RABBITMQ_DEFAULT_PASS=admin + - RABBITMQ_DEFAULT_USER=admin + - RABBITMQ_DEFAULT_VHOST=/ + networks: + - beyond + healthcheck: + test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/5672"] + interval: 5s + timeout: 60s + retries: 120 + + producer: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9090:9090 + volumes: + - .:/app + command: ['bash', '-c', 'pip install flask && pip install -r /app/requirements.txt && sw-python run python3 /app/services/producer.py'] + healthcheck: + test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/9090"] + interval: 5s + timeout: 60s + retries: 120 + depends_on: + collector: + condition: service_healthy + rabbitmq-server: + condition: service_healthy + consumer: + condition: service_healthy + environment: + SW_AGENT_NAME: producer + SW_AGENT_LOGGING_LEVEL: INFO + + consumer: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9091:9091 + volumes: + - .:/app + command: ['bash', '-c', 'pip install flask && pip install -r /app/requirements.txt && sw-python run python3 /app/services/consumer.py'] + healthcheck: + test: ["CMD", "bash", "-c", "ps -ef | grep /app/services/consumer | grep -v grep"] + interval: 5s + timeout: 60s + retries: 120 + depends_on: + collector: + condition: service_healthy + rabbitmq-server: + condition: service_healthy + environment: + SW_AGENT_NAME: consumer + SW_AGENT_LOGGING_LEVEL: INFO + +networks: + beyond: diff --git a/tests/plugin/data/sw_rabbitmq/expected.data.yml b/tests/plugin/data/sw_rabbitmq/expected.data.yml new file mode 100644 index 00000000..e5e9a79b --- /dev/null +++ b/tests/plugin/data/sw_rabbitmq/expected.data.yml @@ -0,0 +1,90 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +segmentItems: + - serviceName: producer + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: RabbitMQ/Topic/test/Queue/test/Producer + parentSpanId: 0 + spanId: 1 + spanLayer: MQ + tags: + - key: mq.broker + value: 'rabbitmq-server:5672' + - key: mq.topic + value: test + - key: mq.queue + value: test + startTime: gt 0 + endTime: gt 0 + componentId: 52 + spanType: Exit + peer: rabbitmq-server:5672 + skipAnalysis: false + - operationName: /users + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + tags: + - key: http.method + value: GET + - key: http.url + value: http://0.0.0.0:9090/users + - key: http.status.code + value: '200' + startTime: gt 0 + endTime: gt 0 + componentId: 7001 + spanType: Entry + peer: not null + skipAnalysis: false + - serviceName: consumer + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: RabbitMQ/Topic/test/Queue/test/Consumer + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: MQ + tags: + - key: mq.broker + value: 'rabbitmq-server:5672' + - key: mq.topic + value: test + - key: mq.queue + value: test + refs: + - parentEndpoint: RabbitMQ/Topic/test/Queue/test/Producer + networkAddress: 'rabbitmq-server:5672' + refType: CrossProcess + parentSpanId: 1 + parentTraceSegmentId: not null + parentServiceInstance: not null + parentService: producer + traceId: not null + startTime: gt 0 + endTime: gt 0 + componentId: 53 + spanType: Entry + peer: '' + skipAnalysis: false diff --git a/tests/plugin/data/sw_rabbitmq/services/__init__.py b/tests/plugin/data/sw_rabbitmq/services/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/data/sw_rabbitmq/services/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/data/sw_rabbitmq/services/consumer.py b/tests/plugin/data/sw_rabbitmq/services/consumer.py new file mode 100644 index 00000000..d6e0dea3 --- /dev/null +++ b/tests/plugin/data/sw_rabbitmq/services/consumer.py @@ -0,0 +1,45 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +if __name__ == '__main__': + import pika + + parameters = (pika.URLParameters('amqp://admin:admin@rabbitmq-server:5672/%2F')) + + connection = pika.BlockingConnection(parameters) + + channel = connection.channel() + channel.queue_declare('test') + channel.exchange_declare('test') + channel.queue_bind(exchange='test', queue='test', routing_key='test') + for method_frame, properties, body in channel.consume('test'): + # Display the message parts and acknowledge the message + print(method_frame, properties, body) + channel.basic_ack(method_frame.delivery_tag) + + # Escape out of the loop after 10 messages + if method_frame.delivery_tag == 10: + break + + try: + # Loop so we can communicate with RabbitMQ + connection.ioloop.start() + except KeyboardInterrupt: + # Gracefully close the connection + connection.close() + # Loop until we're fully closed, will stop on its own + connection.ioloop.start() diff --git a/tests/plugin/data/sw_rabbitmq/services/producer.py b/tests/plugin/data/sw_rabbitmq/services/producer.py new file mode 100644 index 00000000..66a7dc09 --- /dev/null +++ b/tests/plugin/data/sw_rabbitmq/services/producer.py @@ -0,0 +1,41 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +if __name__ == '__main__': + from flask import Flask, jsonify + app = Flask(__name__) + import pika + parameters = (pika.URLParameters('amqp://admin:admin@rabbitmq-server:5672/%2F')) + + @app.route('/users', methods=['POST', 'GET']) + def application(): + connection = pika.BlockingConnection(parameters) + channel = connection.channel() + channel.queue_declare('test') + channel.exchange_declare('test') + channel.queue_bind(exchange='test', queue='test', routing_key='test') + channel.basic_publish( + exchange='test', routing_key='test', + properties=pika.BasicProperties(headers={'key': 'value'}), + body=b'Test message.') + connection.close() + + return jsonify({'song': 'Despacito', 'artist': 'Luis Fonsi'}) + + PORT = 9090 + app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/data/sw_rabbitmq/test_rabbitmq.py b/tests/plugin/data/sw_rabbitmq/test_rabbitmq.py new file mode 100644 index 00000000..e9ab3812 --- /dev/null +++ b/tests/plugin/data/sw_rabbitmq/test_rabbitmq.py @@ -0,0 +1,36 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from typing import Callable + +import pytest +import requests + +from skywalking.plugins.sw_rabbitmq import support_matrix +from tests.orchestrator import get_test_vector +from tests.plugin.base import TestPluginBase + + +@pytest.fixture +def prepare(): + # type: () -> Callable + return lambda *_: requests.get('http://0.0.0.0:9090/users') + + +class TestPlugin(TestPluginBase): + @pytest.mark.parametrize('version', get_test_vector(lib_name='pika', support_matrix=support_matrix)) + def test_plugin(self, docker_compose, version): + self.validate() diff --git a/tests/plugin/data/sw_redis/__init__.py b/tests/plugin/data/sw_redis/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/data/sw_redis/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/data/sw_redis/docker-compose.yml b/tests/plugin/data/sw_redis/docker-compose.yml new file mode 100644 index 00000000..468cf64e --- /dev/null +++ b/tests/plugin/data/sw_redis/docker-compose.yml @@ -0,0 +1,79 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +version: '2.1' + +services: + collector: + extends: + service: collector + file: ../../docker-compose.base.yml + + redis: + image: redis:3.2.9-alpine + hostname: redis + ports: + - 6379:6379 + healthcheck: + test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/6379"] + interval: 5s + timeout: 60s + retries: 120 + networks: + - beyond + + provider: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9091:9091 + volumes: + - .:/app + command: ['bash', '-c', 'pip install flask && pip install -r /app/requirements.txt && sw-python run python3 /app/services/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 + environment: + SW_AGENT_NAME: provider + SW_AGENT_LOGGING_LEVEL: DEBUG + + consumer: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9090:9090 + volumes: + - .:/app + command: ['bash', '-c', 'pip install flask && sw-python run python3 /app/services/consumer.py'] + depends_on: + collector: + condition: service_healthy + provider: + condition: service_healthy + environment: + SW_AGENT_NAME: consumer + SW_AGENT_LOGGING_LEVEL: DEBUG + +networks: + beyond: diff --git a/tests/plugin/data/sw_redis/expected.data.yml b/tests/plugin/data/sw_redis/expected.data.yml new file mode 100644 index 00000000..cbf57ada --- /dev/null +++ b/tests/plugin/data/sw_redis/expected.data.yml @@ -0,0 +1,124 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +segmentItems: + - serviceName: provider + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: Redis/SET + parentSpanId: 0 + spanId: 1 + spanLayer: Cache + tags: + - key: db.type + value: Redis + - key: db.instance + value: '0' + - key: db.statement + value: 'SET' + startTime: gt 0 + endTime: gt 0 + componentId: 7 + spanType: Exit + peer: redis:6379 + skipAnalysis: false + - operationName: Redis/GET + parentSpanId: 0 + spanId: 2 + spanLayer: Cache + tags: + - key: db.type + value: Redis + - key: db.instance + value: '0' + - key: db.statement + value: 'GET' + startTime: gt 0 + endTime: gt 0 + componentId: 7 + spanType: Exit + peer: redis:6379 + skipAnalysis: false + - operationName: /users + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + tags: + - key: http.method + value: POST + - key: http.url + value: http://provider:9091/users + - key: http.status.code + value: '200' + refs: + - parentEndpoint: /users + networkAddress: provider:9091 + refType: CrossProcess + parentSpanId: 1 + parentTraceSegmentId: not null + parentServiceInstance: not null + parentService: consumer + traceId: not null + startTime: gt 0 + endTime: gt 0 + componentId: 7001 + spanType: Entry + peer: not null + skipAnalysis: false + - serviceName: consumer + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: /users + parentSpanId: 0 + spanId: 1 + spanLayer: Http + tags: + - key: http.method + value: POST + - key: http.url + value: http://provider:9091/users + - key: http.status.code + value: '200' + startTime: gt 0 + endTime: gt 0 + componentId: 7002 + spanType: Exit + peer: provider:9091 + skipAnalysis: false + - operationName: /users + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + tags: + - key: http.method + value: GET + - key: http.url + value: http://0.0.0.0:9090/users + - key: http.status.code + value: '200' + startTime: gt 0 + endTime: gt 0 + componentId: 7001 + spanType: Entry + peer: not null + skipAnalysis: false \ No newline at end of file diff --git a/tests/plugin/data/sw_redis/services/__init__.py b/tests/plugin/data/sw_redis/services/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/data/sw_redis/services/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/data/sw_redis/services/consumer.py b/tests/plugin/data/sw_redis/services/consumer.py new file mode 100644 index 00000000..3085092a --- /dev/null +++ b/tests/plugin/data/sw_redis/services/consumer.py @@ -0,0 +1,32 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import requests + + +if __name__ == '__main__': + from flask import Flask, jsonify + + app = Flask(__name__) + + @app.route('/users', methods=['POST', 'GET']) + def application(): + res = requests.post('http://provider:9091/users') + return jsonify(res.json()) + + PORT = 9090 + app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/data/sw_redis/services/provider.py b/tests/plugin/data/sw_redis/services/provider.py new file mode 100644 index 00000000..2e02461e --- /dev/null +++ b/tests/plugin/data/sw_redis/services/provider.py @@ -0,0 +1,39 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import time + + +if __name__ == '__main__': + from flask import Flask, jsonify + import redis + + app = Flask(__name__) + + @app.route('/users', methods=['POST', 'GET']) + def application(): + time.sleep(0.5) + + r = redis.StrictRedis(host='redis', port=6379, db=0) + + r.set('foo', 'bar') + r.get('foo') + + return jsonify({'song': 'Despacito', 'artist': 'Luis Fonsi'}) + + PORT = 9091 + app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/data/sw_redis/test_redis.py b/tests/plugin/data/sw_redis/test_redis.py new file mode 100644 index 00000000..a3ca1b98 --- /dev/null +++ b/tests/plugin/data/sw_redis/test_redis.py @@ -0,0 +1,36 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from typing import Callable + +import pytest +import requests + +from skywalking.plugins.sw_redis import support_matrix +from tests.orchestrator import get_test_vector +from tests.plugin.base import TestPluginBase + + +@pytest.fixture +def prepare(): + # type: () -> Callable + return lambda *_: requests.get('http://0.0.0.0:9090/users') + + +class TestPlugin(TestPluginBase): + @pytest.mark.parametrize('version', get_test_vector(lib_name='redis', support_matrix=support_matrix)) + def test_plugin(self, docker_compose, version): + self.validate() diff --git a/tests/plugin/http/__init__.py b/tests/plugin/http/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/http/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/http/sw_aiohttp/__init__.py b/tests/plugin/http/sw_aiohttp/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/http/sw_aiohttp/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/http/sw_aiohttp/docker-compose.yml b/tests/plugin/http/sw_aiohttp/docker-compose.yml new file mode 100644 index 00000000..ad9f832f --- /dev/null +++ b/tests/plugin/http/sw_aiohttp/docker-compose.yml @@ -0,0 +1,66 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +version: '2.1' + +services: + collector: + extends: + service: collector + file: ../../docker-compose.base.yml + + provider: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9091:9091 + volumes: + - .:/app + command: ['bash', '-c', 'pip install -r /app/requirements.txt && sw-python run sw-python run python3 /app/services/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 + environment: + SW_AGENT_NAME: provider + SW_AGENT_LOGGING_LEVEL: DEBUG + + consumer: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9090:9090 + volumes: + - .:/app + command: ['bash', '-c', 'pip install -r /app/requirements.txt && sw-python run sw-python run python3 /app/services/consumer.py'] + depends_on: + collector: + condition: service_healthy + provider: + condition: service_healthy + environment: + SW_AGENT_NAME: consumer + SW_AGENT_LOGGING_LEVEL: DEBUG + +networks: + beyond: diff --git a/tests/plugin/http/sw_aiohttp/expected.data.yml b/tests/plugin/http/sw_aiohttp/expected.data.yml new file mode 100644 index 00000000..60e2e760 --- /dev/null +++ b/tests/plugin/http/sw_aiohttp/expected.data.yml @@ -0,0 +1,89 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +segmentItems: + - serviceName: provider + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: /skywalking + parentSpanId: -1 + spanId: 0 + spanLayer: Http + tags: + - key: http.method + value: GET + - key: http.url + value: http://provider:9091/skywalking + - key: http.status.code + value: '200' + refs: + - parentEndpoint: /skywalking + networkAddress: provider:9091 + refType: CrossProcess + parentSpanId: 1 + parentTraceSegmentId: not null + parentServiceInstance: not null + parentService: consumer + traceId: not null + startTime: gt 0 + endTime: gt 0 + componentId: 7008 + spanType: Entry + peer: not null + skipAnalysis: false + - serviceName: consumer + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: /skywalking + parentSpanId: 0 + spanId: 1 + spanLayer: Http + tags: + - key: http.method + value: GET + - key: http.url + value: http://provider:9091/skywalking + - key: http.status.code + value: '200' + startTime: gt 0 + endTime: gt 0 + componentId: 7008 + spanType: Exit + peer: provider:9091 + skipAnalysis: false + - operationName: /skywalking + parentSpanId: -1 + spanId: 0 + spanLayer: Http + tags: + - key: http.method + value: GET + - key: http.url + value: http://0.0.0.0:9090/skywalking + - key: http.status.code + value: '200' + startTime: gt 0 + endTime: gt 0 + componentId: 7008 + spanType: Entry + peer: not null + skipAnalysis: false + diff --git a/tests/plugin/http/sw_aiohttp/services/__init__.py b/tests/plugin/http/sw_aiohttp/services/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/http/sw_aiohttp/services/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/http/sw_aiohttp/services/consumer.py b/tests/plugin/http/sw_aiohttp/services/consumer.py new file mode 100644 index 00000000..8869b864 --- /dev/null +++ b/tests/plugin/http/sw_aiohttp/services/consumer.py @@ -0,0 +1,37 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import time + +import aiohttp +from aiohttp import web + + +async def handle(request): + name = request.match_info.get('name', 'Anonymous') + + async with aiohttp.ClientSession() as session: + async with session.get(f'http://user:pass@provider:9091/{name}') as response: + time.sleep(.5) + json = await response.json() + return web.Response(text=str(json)) + + +app = web.Application() +app.add_routes([web.get('/', handle), web.get('/{name}', handle)]) + +if __name__ == '__main__': + web.run_app(app, port=9090) diff --git a/tests/plugin/http/sw_aiohttp/services/provider.py b/tests/plugin/http/sw_aiohttp/services/provider.py new file mode 100644 index 00000000..165d551e --- /dev/null +++ b/tests/plugin/http/sw_aiohttp/services/provider.py @@ -0,0 +1,32 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +from aiohttp import web + + +async def handle(request): + name = request.match_info.get('name', 'Anonymous') + return web.json_response({ + name: name, + }) + + +app = web.Application() +app.add_routes([web.get('/', handle), web.get('/{name}', handle)]) + +if __name__ == '__main__': + web.run_app(app, port=9091) diff --git a/tests/plugin/http/sw_aiohttp/test_aiohttp.py b/tests/plugin/http/sw_aiohttp/test_aiohttp.py new file mode 100644 index 00000000..1e72a89f --- /dev/null +++ b/tests/plugin/http/sw_aiohttp/test_aiohttp.py @@ -0,0 +1,36 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from typing import Callable + +import pytest +import requests + +from skywalking.plugins.sw_aiohttp import support_matrix +from tests.orchestrator import get_test_vector +from tests.plugin.base import TestPluginBase + + +@pytest.fixture # pyre-ignore +def prepare(): + # type: () -> Callable + return lambda *_: requests.get('http://0.0.0.0:9090/skywalking') + + +class TestPlugin(TestPluginBase): + @pytest.mark.parametrize('version', get_test_vector(lib_name='aiohttp', support_matrix=support_matrix)) + def test_plugin(self, docker_compose, version): + self.validate() diff --git a/tests/plugin/http/sw_http/__init__.py b/tests/plugin/http/sw_http/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/http/sw_http/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/http/sw_http/docker-compose.yml b/tests/plugin/http/sw_http/docker-compose.yml new file mode 100644 index 00000000..f5c5fb3d --- /dev/null +++ b/tests/plugin/http/sw_http/docker-compose.yml @@ -0,0 +1,66 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +version: '2.1' + +services: + collector: + extends: + service: collector + file: ../../docker-compose.base.yml + + provider: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9091:9091 + volumes: + - .:/app + command: [ 'bash', '-c', 'sw-python run python3 /app/services/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 + environment: + SW_AGENT_NAME: provider + SW_AGENT_LOGGING_LEVEL: DEBUG + + consumer: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9090:9090 + volumes: + - .:/app + command: [ 'bash', '-c', 'sw-python run python3 /app/services/consumer.py' ] + depends_on: + collector: + condition: service_healthy + provider: + condition: service_healthy + environment: + SW_AGENT_NAME: consumer + SW_AGENT_LOGGING_LEVEL: DEBUG + +networks: + beyond: diff --git a/tests/plugin/http/sw_http/expected.data.yml b/tests/plugin/http/sw_http/expected.data.yml new file mode 100644 index 00000000..16adce86 --- /dev/null +++ b/tests/plugin/http/sw_http/expected.data.yml @@ -0,0 +1,90 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +segmentItems: + - serviceName: provider + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: /users + parentSpanId: -1 + spanId: 0 + spanLayer: Http + tags: + - key: http.method + value: POST + - key: http.url + value: http://provider:9091/users + - key: http.status.code + value: '200' + refs: + - parentEndpoint: /users + networkAddress: provider:9091 + refType: CrossProcess + parentSpanId: 1 + parentTraceSegmentId: not null + parentServiceInstance: not null + parentService: consumer + traceId: not null + startTime: gt 0 + endTime: gt 0 + componentId: 7000 + spanType: Entry + peer: not null + skipAnalysis: false + - serviceName: consumer + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: /users + parentSpanId: 0 + spanId: 1 + spanLayer: Http + tags: + - key: http.method + value: POST + - key: http.url + value: http://provider:9091/users + - key: http.status.code + value: '200' + startTime: gt 0 + endTime: gt 0 + componentId: 7000 + spanType: Exit + peer: provider:9091 + skipAnalysis: false + - operationName: / + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + tags: + - key: http.method + value: POST + - key: http.url + value: http://0.0.0.0:9090/ + - key: http.status.code + value: '200' + startTime: gt 0 + endTime: gt 0 + componentId: 7000 + spanType: Entry + peer: not null + skipAnalysis: false + diff --git a/tests/plugin/http/sw_http/services/__init__.py b/tests/plugin/http/sw_http/services/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/http/sw_http/services/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/http/sw_http/services/consumer.py b/tests/plugin/http/sw_http/services/consumer.py new file mode 100644 index 00000000..bd9e769e --- /dev/null +++ b/tests/plugin/http/sw_http/services/consumer.py @@ -0,0 +1,44 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +from urllib import request + + +if __name__ == '__main__': + + import socketserver + from http.server import BaseHTTPRequestHandler + + class SimpleHTTPRequestHandler(BaseHTTPRequestHandler): + def do_POST(self): # noqa + self.send_response(200) + self.send_header('Content-Type', 'application/json; charset=utf-8') + self.end_headers() + + data = '{"name": "whatever"}'.encode('utf8') + req = request.Request('http://provider:9091/users') + req.add_header('Content-Type', 'application/json; charset=utf-8') + req.add_header('Content-Length', str(len(data))) + with request.urlopen(req, data): + self.wfile.write(data) + + PORT = 9090 + Handler = SimpleHTTPRequestHandler + + with socketserver.TCPServer(('', PORT), Handler) as httpd: + print('serving at port', PORT) + httpd.serve_forever() diff --git a/tests/plugin/http/sw_http/services/provider.py b/tests/plugin/http/sw_http/services/provider.py new file mode 100644 index 00000000..d57d7e0d --- /dev/null +++ b/tests/plugin/http/sw_http/services/provider.py @@ -0,0 +1,38 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import time + + +if __name__ == '__main__': + import socketserver + from http.server import BaseHTTPRequestHandler + + class SimpleHTTPRequestHandler(BaseHTTPRequestHandler): + + def do_POST(self): # noqa + time.sleep(0.5) + self.send_response(200) + self.send_header('Content-Type', 'application/json') + self.end_headers() + self.wfile.write('{"song": "Despacito", "artist": "Luis Fonsi"}'.encode('ascii')) + + PORT = 9091 + Handler = SimpleHTTPRequestHandler + + with socketserver.TCPServer(('', PORT), Handler) as httpd: + httpd.serve_forever() diff --git a/tests/plugin/http/sw_http/test_http.py b/tests/plugin/http/sw_http/test_http.py new file mode 100644 index 00000000..d9317baa --- /dev/null +++ b/tests/plugin/http/sw_http/test_http.py @@ -0,0 +1,33 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from typing import Callable + +import pytest +import requests + +from tests.plugin.base import TestPluginBase + + +@pytest.fixture +def prepare(): + # type: () -> Callable + return lambda *_: requests.post('http://0.0.0.0:9090') + + +class TestPlugin(TestPluginBase): + def test_plugin(self, docker_compose, version): + self.validate() diff --git a/tests/plugin/http/sw_http_wsgi/__init__.py b/tests/plugin/http/sw_http_wsgi/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/http/sw_http_wsgi/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/http/sw_http_wsgi/docker-compose.yml b/tests/plugin/http/sw_http_wsgi/docker-compose.yml new file mode 100644 index 00000000..99f19505 --- /dev/null +++ b/tests/plugin/http/sw_http_wsgi/docker-compose.yml @@ -0,0 +1,66 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +version: '2.1' + +services: + collector: + extends: + service: collector + file: ../../docker-compose.base.yml + + provider: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9091:9091 + volumes: + - .:/app + command: ['bash', '-c', 'pip install -r /app/requirements.txt && sw-python run python3 /app/services/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 + environment: + SW_AGENT_NAME: provider + SW_AGENT_LOGGING_LEVEL: DEBUG + + consumer: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9090:9090 + volumes: + - .:/app + command: ['bash', '-c', 'pip install -r /app/requirements.txt && sw-python run python3 /app/services/consumer.py'] + depends_on: + collector: + condition: service_healthy + provider: + condition: service_healthy + environment: + SW_AGENT_NAME: consumer + SW_AGENT_LOGGING_LEVEL: DEBUG + +networks: + beyond: diff --git a/tests/plugin/http/sw_http_wsgi/expected.data.yml b/tests/plugin/http/sw_http_wsgi/expected.data.yml new file mode 100644 index 00000000..9ccfec5f --- /dev/null +++ b/tests/plugin/http/sw_http_wsgi/expected.data.yml @@ -0,0 +1,91 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +segmentItems: + - serviceName: provider + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: /users + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + tags: + - key: http.method + value: POST + - key: http.url + value: http://provider:9091/users + - key: http.status.code + value: '200' + refs: + - parentEndpoint: /users + networkAddress: provider:9091 + refType: CrossProcess + parentSpanId: 1 + parentTraceSegmentId: not null + parentServiceInstance: not null + parentService: consumer + traceId: not null + startTime: gt 0 + endTime: gt 0 + componentId: 7000 + spanType: Entry + peer: not null + skipAnalysis: false + - serviceName: consumer + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: /users + parentSpanId: 0 + spanId: 1 + spanLayer: Http + tags: + - key: http.method + value: POST + - key: http.url + value: http://provider:9091/users + - key: http.status.code + value: '200' + startTime: gt 0 + endTime: gt 0 + componentId: 7000 + spanType: Exit + peer: provider:9091 + skipAnalysis: false + - operationName: / + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + tags: + - key: http.method + value: POST + - key: http.url + value: http://0.0.0.0:9090/ + - key: http.status.code + value: '200' + startTime: gt 0 + endTime: gt 0 + componentId: 7000 + spanType: Entry + peer: not null + skipAnalysis: false + diff --git a/tests/plugin/http/sw_http_wsgi/services/__init__.py b/tests/plugin/http/sw_http_wsgi/services/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/http/sw_http_wsgi/services/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/http/sw_http_wsgi/services/consumer.py b/tests/plugin/http/sw_http_wsgi/services/consumer.py new file mode 100644 index 00000000..41e5e4f0 --- /dev/null +++ b/tests/plugin/http/sw_http_wsgi/services/consumer.py @@ -0,0 +1,43 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +from urllib import request + + +if __name__ == '__main__': + import socketserver + from http.server import BaseHTTPRequestHandler + + class SimpleHTTPRequestHandler(BaseHTTPRequestHandler): + def do_POST(self): # noqa + self.send_response(200) + self.send_header('Content-Type', 'application/json; charset=utf-8') + self.end_headers() + + data = '{"name": "whatever"}'.encode('utf8') + req = request.Request('http://provider:9091/users') + req.add_header('Content-Type', 'application/json; charset=utf-8') + req.add_header('Content-Length', str(len(data))) + with request.urlopen(req, data): + self.wfile.write(data) + + PORT = 9090 + Handler = SimpleHTTPRequestHandler + + with socketserver.TCPServer(('', PORT), Handler) as httpd: + print('serving at port', PORT) + httpd.serve_forever() diff --git a/tests/plugin/http/sw_http_wsgi/services/provider.py b/tests/plugin/http/sw_http_wsgi/services/provider.py new file mode 100644 index 00000000..b28377dc --- /dev/null +++ b/tests/plugin/http/sw_http_wsgi/services/provider.py @@ -0,0 +1,32 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import time + + +if __name__ == '__main__': + from werkzeug import Request, Response + + @Request.application + def application(request): + time.sleep(0.5) + return Response('{"song": "Despacito", "artist": "Luis Fonsi"}') + + from werkzeug.serving import run_simple + + PORT = 9091 + run_simple('', PORT, application) diff --git a/tests/plugin/http/sw_http_wsgi/test_http_wsgi.py b/tests/plugin/http/sw_http_wsgi/test_http_wsgi.py new file mode 100644 index 00000000..4a2a1f13 --- /dev/null +++ b/tests/plugin/http/sw_http_wsgi/test_http_wsgi.py @@ -0,0 +1,36 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from typing import Callable + +import pytest +import requests + +from skywalking.plugins.sw_http_server import support_matrix +from tests.orchestrator import get_test_vector +from tests.plugin.base import TestPluginBase + + +@pytest.fixture +def prepare(): + # type: () -> Callable + return lambda *_: requests.post('http://0.0.0.0:9090') + + +class TestPlugin(TestPluginBase): + @pytest.mark.parametrize('version', get_test_vector(lib_name='werkzeug', support_matrix=support_matrix)) + def test_plugin(self, docker_compose, version): + self.validate() diff --git a/tests/plugin/http/sw_requests/__init__.py b/tests/plugin/http/sw_requests/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/http/sw_requests/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/http/sw_requests/docker-compose.yml b/tests/plugin/http/sw_requests/docker-compose.yml new file mode 100644 index 00000000..0b66033f --- /dev/null +++ b/tests/plugin/http/sw_requests/docker-compose.yml @@ -0,0 +1,66 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +version: '2.1' + +services: + collector: + extends: + service: collector + file: ../../docker-compose.base.yml + + provider: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9091:9091 + volumes: + - .:/app + depends_on: + collector: + condition: service_healthy + command: ['bash', '-c', 'pip install -r /app/requirements.txt && sw-python run python3 /app/services/provider.py'] + healthcheck: + test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/9091"] + interval: 5s + timeout: 60s + retries: 120 + environment: + SW_AGENT_NAME: provider + SW_AGENT_LOGGING_LEVEL: DEBUG + + consumer: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9090:9090 + volumes: + - .:/app + command: ['bash', '-c', 'pip install -r /app/requirements.txt && sw-python run python3 /app/services/consumer.py'] + depends_on: + collector: + condition: service_healthy + provider: + condition: service_healthy + environment: + SW_AGENT_NAME: consumer + SW_AGENT_LOGGING_LEVEL: DEBUG + +networks: + beyond: diff --git a/tests/plugin/http/sw_requests/expected.data.yml b/tests/plugin/http/sw_requests/expected.data.yml new file mode 100644 index 00000000..5cee8ed6 --- /dev/null +++ b/tests/plugin/http/sw_requests/expected.data.yml @@ -0,0 +1,90 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +segmentItems: + - serviceName: provider + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: /users + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + tags: + - key: http.method + value: POST + - key: http.url + value: http://provider:9091/users + - key: http.status.code + value: '200' + refs: + - parentEndpoint: /users + networkAddress: provider:9091 + refType: CrossProcess + parentSpanId: 1 + parentTraceSegmentId: not null + parentServiceInstance: not null + parentService: consumer + traceId: not null + startTime: gt 0 + endTime: gt 0 + componentId: 7000 + spanType: Entry + peer: not null + skipAnalysis: false + - serviceName: consumer + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: /users + parentSpanId: 0 + spanId: 1 + spanLayer: Http + tags: + - key: http.method + value: POST + - key: http.url + value: http://provider:9091/users + - key: http.status.code + value: '200' + startTime: gt 0 + endTime: gt 0 + componentId: 7002 + spanType: Exit + peer: provider:9091 + skipAnalysis: false + - operationName: / + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + tags: + - key: http.method + value: POST + - key: http.url + value: http://0.0.0.0:9090/ + - key: http.status.code + value: '200' + startTime: gt 0 + endTime: gt 0 + componentId: 7000 + spanType: Entry + peer: not null + skipAnalysis: false \ No newline at end of file diff --git a/tests/plugin/http/sw_requests/services/__init__.py b/tests/plugin/http/sw_requests/services/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/http/sw_requests/services/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/http/sw_requests/services/consumer.py b/tests/plugin/http/sw_requests/services/consumer.py new file mode 100644 index 00000000..db0d10e9 --- /dev/null +++ b/tests/plugin/http/sw_requests/services/consumer.py @@ -0,0 +1,39 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import requests + + +if __name__ == '__main__': + import socketserver + from http.server import BaseHTTPRequestHandler + + class SimpleHTTPRequestHandler(BaseHTTPRequestHandler): + def do_POST(self): # noqa + self.send_response(200) + self.send_header('Content-Type', 'application/json; charset=utf-8') + self.end_headers() + + res = requests.post('http://provider:9091/users') + self.wfile.write(str(res.json()).encode('utf8')) + + PORT = 9090 + Handler = SimpleHTTPRequestHandler + + with socketserver.TCPServer(('', PORT), Handler) as httpd: + print('serving at port', PORT) + httpd.serve_forever() diff --git a/tests/plugin/http/sw_requests/services/provider.py b/tests/plugin/http/sw_requests/services/provider.py new file mode 100644 index 00000000..d57d7e0d --- /dev/null +++ b/tests/plugin/http/sw_requests/services/provider.py @@ -0,0 +1,38 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import time + + +if __name__ == '__main__': + import socketserver + from http.server import BaseHTTPRequestHandler + + class SimpleHTTPRequestHandler(BaseHTTPRequestHandler): + + def do_POST(self): # noqa + time.sleep(0.5) + self.send_response(200) + self.send_header('Content-Type', 'application/json') + self.end_headers() + self.wfile.write('{"song": "Despacito", "artist": "Luis Fonsi"}'.encode('ascii')) + + PORT = 9091 + Handler = SimpleHTTPRequestHandler + + with socketserver.TCPServer(('', PORT), Handler) as httpd: + httpd.serve_forever() diff --git a/tests/plugin/http/sw_requests/test_request.py b/tests/plugin/http/sw_requests/test_request.py new file mode 100644 index 00000000..81083269 --- /dev/null +++ b/tests/plugin/http/sw_requests/test_request.py @@ -0,0 +1,36 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from typing import Callable + +import pytest +import requests + +from skywalking.plugins.sw_requests import support_matrix +from tests.orchestrator import get_test_vector +from tests.plugin.base import TestPluginBase + + +@pytest.fixture +def prepare(): + # type: () -> Callable + return lambda *_: requests.post('http://0.0.0.0:9090') + + +class TestPlugin(TestPluginBase): + @pytest.mark.parametrize('version', get_test_vector(lib_name='requests', support_matrix=support_matrix)) + def test_plugin(self, docker_compose, version): + self.validate() diff --git a/tests/plugin/http/sw_urllib3/__init__.py b/tests/plugin/http/sw_urllib3/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/http/sw_urllib3/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/http/sw_urllib3/docker-compose.yml b/tests/plugin/http/sw_urllib3/docker-compose.yml new file mode 100644 index 00000000..e3dac0a2 --- /dev/null +++ b/tests/plugin/http/sw_urllib3/docker-compose.yml @@ -0,0 +1,66 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +version: '2.1' + +services: + collector: + extends: + service: collector + file: ../../docker-compose.base.yml + + provider: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9091:9091 + volumes: + - .:/app + command: ['bash', '-c', 'pip install flask && sw-python run python3 /app/services/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 + environment: + SW_AGENT_NAME: provider + SW_AGENT_LOGGING_LEVEL: DEBUG + + consumer: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9090:9090 + volumes: + - .:/app + command: ['bash', '-c', 'pip install flask && pip install -r /app/requirements.txt && sw-python run python3 /app/services/consumer.py'] + depends_on: + collector: + condition: service_healthy + provider: + condition: service_healthy + environment: + SW_AGENT_NAME: consumer + SW_AGENT_LOGGING_LEVEL: DEBUG + +networks: + beyond: diff --git a/tests/plugin/http/sw_urllib3/expected.data.yml b/tests/plugin/http/sw_urllib3/expected.data.yml new file mode 100644 index 00000000..d67762ec --- /dev/null +++ b/tests/plugin/http/sw_urllib3/expected.data.yml @@ -0,0 +1,93 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +segmentItems: + - serviceName: provider + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: /users + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + tags: + - key: http.method + value: POST + - key: http.url + value: http://provider:9091/users + - key: http.status.code + value: '200' + refs: + - parentEndpoint: /users + networkAddress: 'provider:9091' + refType: CrossProcess + parentSpanId: 1 + parentTraceSegmentId: not null + parentServiceInstance: not null + parentService: consumer + traceId: not null + startTime: gt 0 + endTime: gt 0 + componentId: 7001 + spanType: Entry + peer: not null + skipAnalysis: false + - serviceName: consumer + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: /users + parentSpanId: 0 + spanId: 1 + spanLayer: Http + startTime: gt 0 + endTime: gt 0 + componentId: 7006 + isError: false + spanType: Exit + peer: not null + skipAnalysis: false + tags: + - key: http.method + value: POST + - key: http.url + value: 'http://provider:9091/users' + - key: http.status.code + value: '200' + - operationName: /users + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: gt 0 + endTime: gt 0 + componentId: 7001 + isError: false + spanType: Entry + peer: not null + skipAnalysis: false + tags: + - key: http.method + value: GET + - key: http.url + value: 'http://0.0.0.0:9090/users' + - key: http.status.code + value: '200' \ No newline at end of file diff --git a/tests/plugin/http/sw_urllib3/services/__init__.py b/tests/plugin/http/sw_urllib3/services/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/http/sw_urllib3/services/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/http/sw_urllib3/services/consumer.py b/tests/plugin/http/sw_urllib3/services/consumer.py new file mode 100644 index 00000000..c2522004 --- /dev/null +++ b/tests/plugin/http/sw_urllib3/services/consumer.py @@ -0,0 +1,34 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import json + + +if __name__ == '__main__': + from flask import Flask, jsonify + + app = Flask(__name__) + import urllib3 + + @app.route('/users', methods=['POST', 'GET']) + def application(): + http = urllib3.PoolManager() + res = http.request('POST', 'http://provider:9091/users') + + return jsonify(json.loads(res.data.decode('utf-8'))) + + PORT = 9090 + app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/http/sw_urllib3/services/provider.py b/tests/plugin/http/sw_urllib3/services/provider.py new file mode 100644 index 00000000..dba7163d --- /dev/null +++ b/tests/plugin/http/sw_urllib3/services/provider.py @@ -0,0 +1,32 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import time + + +if __name__ == '__main__': + from flask import Flask, jsonify + + app = Flask(__name__) + + @app.route('/users', methods=['POST', 'GET']) + def application(): + time.sleep(0.5) + return jsonify({'song': 'Despacito', 'artist': 'Luis Fonsi'}) + + PORT = 9091 + app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/http/sw_urllib3/test_urllib3.py b/tests/plugin/http/sw_urllib3/test_urllib3.py new file mode 100644 index 00000000..9316d1ed --- /dev/null +++ b/tests/plugin/http/sw_urllib3/test_urllib3.py @@ -0,0 +1,36 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from typing import Callable + +import pytest +import requests + +from skywalking.plugins.sw_urllib3 import support_matrix +from tests.orchestrator import get_test_vector +from tests.plugin.base import TestPluginBase + + +@pytest.fixture +def prepare(): + # type: () -> Callable + return lambda *_: requests.get('http://0.0.0.0:9090/users') + + +class TestPlugin(TestPluginBase): + @pytest.mark.parametrize('version', get_test_vector(lib_name='urllib3', support_matrix=support_matrix)) + def test_plugin(self, docker_compose, version): + self.validate() diff --git a/tests/plugin/web/sw_django/__init__.py b/tests/plugin/web/sw_django/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/web/sw_django/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/web/sw_django/docker-compose.yml b/tests/plugin/web/sw_django/docker-compose.yml new file mode 100644 index 00000000..242d2342 --- /dev/null +++ b/tests/plugin/web/sw_django/docker-compose.yml @@ -0,0 +1,67 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +version: '2.1' + +services: + collector: + extends: + service: collector + file: ../../docker-compose.base.yml + + provider: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9091:9091 + volumes: + - .:/app + command: ['bash', '-c', 'pip install -r /app/requirements.txt && sw-python run python3 /app/services/provider.py runserver 0.0.0.0:9091'] + 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 + environment: + SW_AGENT_NAME: provider + SW_AGENT_LOGGING_LEVEL: DEBUG + + consumer: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9090:9090 + volumes: + - .:/app + command: ['bash', '-c', 'pip install -r /app/requirements.txt && sw-python run python3 /app/services/consumer.py runserver 0.0.0.0:9090'] + depends_on: + collector: + condition: service_healthy + provider: + condition: service_healthy + environment: + SW_AGENT_NAME: consumer + SW_AGENT_LOGGING_LEVEL: DEBUG + SW_DJANGO_COLLECT_HTTP_PARAMS: 'True' + +networks: + beyond: diff --git a/tests/plugin/web/sw_django/expected.data.yml b/tests/plugin/web/sw_django/expected.data.yml new file mode 100644 index 00000000..9222ce0f --- /dev/null +++ b/tests/plugin/web/sw_django/expected.data.yml @@ -0,0 +1,90 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +segmentItems: + - serviceName: provider + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: /users + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: gt 0 + endTime: gt 0 + componentId: 7004 + spanType: Entry + peer: not null + skipAnalysis: false + tags: + - key: http.method + value: POST + - key: http.url + value: http://provider:9091/users + - key: http.status.code + value: '200' + refs: + - parentEndpoint: /users + networkAddress: provider:9091 + refType: CrossProcess + parentSpanId: 1 + parentTraceSegmentId: not null + parentServiceInstance: not null + parentService: consumer + traceId: not null + - serviceName: consumer + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: /users + parentSpanId: 0 + spanId: 1 + spanLayer: Http + startTime: gt 0 + endTime: gt 0 + componentId: 7002 + spanType: Exit + peer: provider:9091 + skipAnalysis: false + tags: + - key: http.method + value: POST + - key: http.url + value: http://provider:9091/users + - key: http.status.code + value: '200' + - operationName: /users + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: gt 0 + endTime: gt 0 + componentId: 7004 + spanType: Entry + peer: not null + skipAnalysis: false + tags: + - key: http.method + value: GET + - key: http.url + value: http://0.0.0.0:9090/users + - key: http.params + value: "test=[test1,test2]\ntest2=[test2]" + - key: http.status.code + value: '200' diff --git a/tests/plugin/web/sw_django/services/__init__.py b/tests/plugin/web/sw_django/services/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/web/sw_django/services/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/web/sw_django/services/consumer.py b/tests/plugin/web/sw_django/services/consumer.py new file mode 100644 index 00000000..43ef0de7 --- /dev/null +++ b/tests/plugin/web/sw_django/services/consumer.py @@ -0,0 +1,45 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import sys + +import requests +from django.conf import settings +from django.conf.urls import url +from django.http import JsonResponse + +settings.configure( + DEBUG=True, + ROOT_URLCONF=__name__, + ALLOWED_HOSTS=['*'], +) + + +def index(request): + res = requests.post('http://provider:9091/users') + return JsonResponse(res.json()) + + +urlpatterns = ( + url('users', index), +) + + +if __name__ == '__main__': + from django.core.management import execute_from_command_line + + execute_from_command_line(sys.argv) diff --git a/tests/plugin/web/sw_django/services/provider.py b/tests/plugin/web/sw_django/services/provider.py new file mode 100644 index 00000000..5ae277d9 --- /dev/null +++ b/tests/plugin/web/sw_django/services/provider.py @@ -0,0 +1,45 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import sys +import time + +from django.conf import settings +from django.conf.urls import url +from django.http import JsonResponse + +settings.configure( + DEBUG=True, + ROOT_URLCONF=__name__, + ALLOWED_HOSTS=['*'], +) + + +def index(request): + time.sleep(0.5) + return JsonResponse({'song': 'Despacito', 'artist': 'Luis Fonsi'}) + + +urlpatterns = ( + url('users', index), +) + + +if __name__ == '__main__': + from django.core.management import execute_from_command_line + + execute_from_command_line(sys.argv) diff --git a/tests/plugin/web/sw_django/test_django.py b/tests/plugin/web/sw_django/test_django.py new file mode 100644 index 00000000..0ef92a60 --- /dev/null +++ b/tests/plugin/web/sw_django/test_django.py @@ -0,0 +1,36 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from typing import Callable + +import pytest +import requests + +from skywalking.plugins.sw_django import support_matrix +from tests.orchestrator import get_test_vector +from tests.plugin.base import TestPluginBase + + +@pytest.fixture +def prepare(): + # type: () -> Callable + return lambda *_: requests.get('http://0.0.0.0:9090/users?test=test1&test=test2&test2=test2') + + +class TestPlugin(TestPluginBase): + @pytest.mark.parametrize('version', get_test_vector(lib_name='django', support_matrix=support_matrix)) + def test_plugin(self, docker_compose, version): + self.validate() diff --git a/tests/plugin/web/sw_falcon/__init__.py b/tests/plugin/web/sw_falcon/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/web/sw_falcon/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/web/sw_falcon/docker-compose.yml b/tests/plugin/web/sw_falcon/docker-compose.yml new file mode 100644 index 00000000..6cdba022 --- /dev/null +++ b/tests/plugin/web/sw_falcon/docker-compose.yml @@ -0,0 +1,66 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +version: '2.1' + +services: + collector: + extends: + service: collector + file: ../../docker-compose.base.yml + + provider: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9091:9091 + volumes: + - .:/app + command: [ 'bash', '-c', 'pip install hug && pip install -r /app/requirements.txt && sw-python run hug -f /app/services/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 + environment: + SW_AGENT_NAME: provider + SW_AGENT_LOGGING_LEVEL: DEBUG + + consumer: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9090:9090 + volumes: + - .:/app + command: [ 'bash', '-c', 'pip install hug && pip install -r /app/requirements.txt && sw-python run hug -f /app/services/consumer.py' ] + depends_on: + collector: + condition: service_healthy + provider: + condition: service_healthy + environment: + SW_AGENT_NAME: consumer + SW_AGENT_LOGGING_LEVEL: DEBUG + +networks: + beyond: diff --git a/tests/plugin/web/sw_falcon/expected.data.yml b/tests/plugin/web/sw_falcon/expected.data.yml new file mode 100644 index 00000000..23f74400 --- /dev/null +++ b/tests/plugin/web/sw_falcon/expected.data.yml @@ -0,0 +1,85 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +segmentItems: +- segmentSize: 1 + segments: + - segmentId: not null + spans: + - componentId: 7012 + endTime: gt 0 + isError: false + operationName: /users + parentSpanId: -1 + peer: not null + skipAnalysis: false + spanId: 0 + spanLayer: Http + spanType: Entry + startTime: gt 0 + tags: + - key: http.method + value: GET + - key: http.url + value: http://provider:9091/users + - key: http.status.code + value: '200' + - key: http.status.msg + value: OK + serviceName: provider +- segmentSize: 1 + segments: + - segmentId: not null + spans: + - componentId: 7002 + endTime: gt 0 + isError: false + operationName: /users + parentSpanId: 0 + peer: provider:9091 + skipAnalysis: false + spanId: 1 + spanLayer: Http + spanType: Exit + startTime: gt 0 + tags: + - key: http.method + value: GET + - key: http.url + value: http://provider:9091/users + - key: http.status.code + value: '200' + - componentId: 7012 + endTime: gt 0 + isError: false + operationName: /users + parentSpanId: -1 + peer: not null + skipAnalysis: false + spanId: 0 + spanLayer: Http + spanType: Entry + startTime: gt 0 + tags: + - key: http.method + value: GET + - key: http.url + value: http://0.0.0.0:9090/users + - key: http.status.code + value: '200' + - key: http.status.msg + value: OK + serviceName: consumer \ No newline at end of file diff --git a/tests/plugin/web/sw_falcon/services/__init__.py b/tests/plugin/web/sw_falcon/services/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/web/sw_falcon/services/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/web/sw_falcon/services/consumer.py b/tests/plugin/web/sw_falcon/services/consumer.py new file mode 100644 index 00000000..49cbf7d9 --- /dev/null +++ b/tests/plugin/web/sw_falcon/services/consumer.py @@ -0,0 +1,27 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import hug +import requests + + +@hug.get('/users') +def get(): + res = requests.get('http://provider:9091/users') + return res.json() + + +hug.API(__name__).http.serve(port=9090) diff --git a/tests/plugin/web/sw_falcon/services/provider.py b/tests/plugin/web/sw_falcon/services/provider.py new file mode 100644 index 00000000..c87f187b --- /dev/null +++ b/tests/plugin/web/sw_falcon/services/provider.py @@ -0,0 +1,30 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import json +import time + +import hug + + +@hug.get('/users') +def get(): + time.sleep(0.5) + return json.dumps({'song': 'Despacito', 'artist': 'Luis Fonsi'}) + + +hug.API(__name__).http.serve(port=9091) diff --git a/tests/plugin/web/sw_falcon/test_falcon.py b/tests/plugin/web/sw_falcon/test_falcon.py new file mode 100644 index 00000000..17aa61fc --- /dev/null +++ b/tests/plugin/web/sw_falcon/test_falcon.py @@ -0,0 +1,37 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +from typing import Callable + +import pytest +import requests + +from skywalking.plugins.sw_falcon import support_matrix +from tests.orchestrator import get_test_vector +from tests.plugin.base import TestPluginBase + + +@pytest.fixture +def prepare(): + # type: () -> Callable + return lambda *_: requests.get('http://0.0.0.0:9090/users') + + +class TestPlugin(TestPluginBase): + @pytest.mark.parametrize('version', get_test_vector(lib_name='hug', support_matrix=support_matrix)) + def test_plugin(self, docker_compose, version): + self.validate() diff --git a/tests/plugin/web/sw_flask/__init__.py b/tests/plugin/web/sw_flask/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/web/sw_flask/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/web/sw_flask/docker-compose.yml b/tests/plugin/web/sw_flask/docker-compose.yml new file mode 100644 index 00000000..bb6961fd --- /dev/null +++ b/tests/plugin/web/sw_flask/docker-compose.yml @@ -0,0 +1,66 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +version: '2.1' + +services: + collector: + extends: + service: collector + file: ../../docker-compose.base.yml + + provider: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9091:9091 + volumes: + - .:/app + command: ['bash', '-c', 'pip install flask && pip install -r /app/requirements.txt && sw-python run python3 /app/services/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 + environment: + SW_AGENT_NAME: provider + SW_AGENT_LOGGING_LEVEL: DEBUG + + consumer: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9090:9090 + volumes: + - .:/app + command: ['bash', '-c', 'pip install flask && pip install -r /app/requirements.txt && sw-python run python3 /app/services/consumer.py'] + depends_on: + collector: + condition: service_healthy + provider: + condition: service_healthy + environment: + SW_AGENT_NAME: consumer + SW_AGENT_LOGGING_LEVEL: DEBUG + SW_FLASK_COLLECT_HTTP_PARAMS: 'True' +networks: + beyond: diff --git a/tests/plugin/web/sw_flask/expected.data.yml b/tests/plugin/web/sw_flask/expected.data.yml new file mode 100644 index 00000000..6d4dcf94 --- /dev/null +++ b/tests/plugin/web/sw_flask/expected.data.yml @@ -0,0 +1,160 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +segmentItems: + - serviceName: provider + segmentSize: 2 + segments: + - segmentId: not null + spans: + - operationName: /users + parentSpanId: -1 + spanId: 0 + spanLayer: Http + tags: + - key: http.method + value: POST + - key: http.url + value: http://provider:9091/users + - key: http.status.code + value: '200' + refs: + - parentEndpoint: /users + networkAddress: 'provider:9091' + refType: CrossProcess + parentSpanId: 1 + parentTraceSegmentId: not null + parentServiceInstance: not null + parentService: consumer + traceId: not null + startTime: gt 0 + endTime: gt 0 + componentId: 7001 + spanType: Entry + peer: not null + skipAnalysis: false + - segmentId: not null + spans: + - operationName: /users + parentSpanId: -1 + spanId: 0 + spanLayer: Http + tags: + - key: http.method + value: POST + - key: http.url + value: http://provider:9091/users + - key: http.status.code + value: '200' + refs: + - parentEndpoint: /users + networkAddress: 'provider:9091' + refType: CrossProcess + parentSpanId: 1 + parentTraceSegmentId: not null + parentServiceInstance: not null + parentService: consumer + traceId: not null + startTime: gt 0 + endTime: gt 0 + componentId: 7001 + spanType: Entry + peer: not null + skipAnalysis: false + - serviceName: consumer + segmentSize: 2 + segments: + - segmentId: not null + spans: + - operationName: /users + parentSpanId: 0 + spanId: 1 + spanLayer: Http + startTime: gt 0 + endTime: gt 0 + componentId: 7002 + isError: false + spanType: Exit + peer: provider:9091 + skipAnalysis: false + tags: + - key: http.method + value: POST + - key: http.url + value: 'http://provider:9091/users' + - key: http.status.code + value: '200' + - operationName: /test + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Unknown + startTime: gt 0 + endTime: gt 0 + componentId: 0 + isError: false + spanType: Local + peer: '' + skipAnalysis: false + refs: + - parentEndpoint: /users + networkAddress: '' + refType: CrossThread + parentSpanId: 0 + parentTraceSegmentId: not null + parentServiceInstance: not null + parentService: consumer + traceId: not null + - segmentId: not null + spans: + - operationName: /users + parentSpanId: 0 + spanId: 1 + spanLayer: Http + tags: + - key: http.method + value: POST + - key: http.url + value: http://provider:9091/users + - key: http.status.code + value: '200' + startTime: gt 0 + endTime: gt 0 + componentId: 7002 + spanType: Exit + peer: provider:9091 + skipAnalysis: false + - operationName: /users + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + tags: + - key: http.method + value: GET + - key: http.url + value: http://0.0.0.0:9090/users + - key: http.params + value: "test=[test1,test2]\ntest2=[test2]" + - key: http.status.code + value: '200' + startTime: gt 0 + endTime: gt 0 + componentId: 7001 + spanType: Entry + peer: not null + skipAnalysis: false diff --git a/tests/plugin/web/sw_flask/services/__init__.py b/tests/plugin/web/sw_flask/services/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/web/sw_flask/services/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/web/sw_flask/services/consumer.py b/tests/plugin/web/sw_flask/services/consumer.py new file mode 100644 index 00000000..7e0a4f03 --- /dev/null +++ b/tests/plugin/web/sw_flask/services/consumer.py @@ -0,0 +1,47 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import requests + +from skywalking.decorators import runnable + +if __name__ == '__main__': + from flask import Flask, jsonify + + app = Flask(__name__) + + @app.route('/users', methods=['POST', 'GET']) + def application(): + from skywalking.trace.context import get_context + get_context().put_correlation('correlation', 'correlation') + + @runnable(op='/test') + def post(): + requests.post('http://provider:9091/users') + + from threading import Thread + t = Thread(target=post) + t.start() + + res = requests.post('http://provider:9091/users') + + t.join() + + return jsonify(res.json()) + + PORT = 9090 + app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/web/sw_flask/services/provider.py b/tests/plugin/web/sw_flask/services/provider.py new file mode 100644 index 00000000..43f6d49f --- /dev/null +++ b/tests/plugin/web/sw_flask/services/provider.py @@ -0,0 +1,33 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import time + + +if __name__ == '__main__': + from flask import Flask, jsonify + + app = Flask(__name__) + + @app.route('/users', methods=['POST', 'GET']) + def application(): + from skywalking.trace.context import get_context + time.sleep(0.5) + return jsonify({'correlation': get_context().get_correlation('correlation')}) + + PORT = 9091 + app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/web/sw_flask/test_flask.py b/tests/plugin/web/sw_flask/test_flask.py new file mode 100644 index 00000000..f2524382 --- /dev/null +++ b/tests/plugin/web/sw_flask/test_flask.py @@ -0,0 +1,40 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from typing import Callable + +import pytest +import requests + +from skywalking.plugins.sw_flask import support_matrix +from tests.orchestrator import get_test_vector +from tests.plugin.base import TestPluginBase + + +@pytest.fixture +def prepare(): + # type: () -> Callable + return lambda *_: requests.get('http://0.0.0.0:9090/users?test=test1&test=test2&test2=test2') + + +class TestPlugin(TestPluginBase): + @pytest.mark.parametrize('version', get_test_vector(lib_name='flask', support_matrix=support_matrix)) + def test_plugin(self, docker_compose, version): + self.validate() + + response = requests.get('http://0.0.0.0:9090/users') + assert response.status_code == 200 + assert response.json()['correlation'] == 'correlation' diff --git a/tests/plugin/web/sw_pyramid/__init__.py b/tests/plugin/web/sw_pyramid/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/web/sw_pyramid/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/web/sw_pyramid/docker-compose.yml b/tests/plugin/web/sw_pyramid/docker-compose.yml new file mode 100644 index 00000000..99f19505 --- /dev/null +++ b/tests/plugin/web/sw_pyramid/docker-compose.yml @@ -0,0 +1,66 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +version: '2.1' + +services: + collector: + extends: + service: collector + file: ../../docker-compose.base.yml + + provider: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9091:9091 + volumes: + - .:/app + command: ['bash', '-c', 'pip install -r /app/requirements.txt && sw-python run python3 /app/services/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 + environment: + SW_AGENT_NAME: provider + SW_AGENT_LOGGING_LEVEL: DEBUG + + consumer: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9090:9090 + volumes: + - .:/app + command: ['bash', '-c', 'pip install -r /app/requirements.txt && sw-python run python3 /app/services/consumer.py'] + depends_on: + collector: + condition: service_healthy + provider: + condition: service_healthy + environment: + SW_AGENT_NAME: consumer + SW_AGENT_LOGGING_LEVEL: DEBUG + +networks: + beyond: diff --git a/tests/plugin/web/sw_pyramid/expected.data.yml b/tests/plugin/web/sw_pyramid/expected.data.yml new file mode 100644 index 00000000..b68b0ed2 --- /dev/null +++ b/tests/plugin/web/sw_pyramid/expected.data.yml @@ -0,0 +1,91 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +segmentItems: + - serviceName: provider + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: /pyramid + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + tags: + - key: http.method + value: POST + - key: http.url + value: http://provider:9091/pyramid + - key: http.status.code + value: '200' + refs: + - parentEndpoint: /pyramid + networkAddress: provider:9091 + refType: CrossProcess + parentSpanId: 1 + parentTraceSegmentId: not null + parentServiceInstance: not null + parentService: consumer + traceId: not null + startTime: gt 0 + endTime: gt 0 + componentId: 7009 + spanType: Entry + peer: not null + skipAnalysis: false + - serviceName: consumer + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: /pyramid + parentSpanId: 0 + spanId: 1 + spanLayer: Http + tags: + - key: http.method + value: POST + - key: http.url + value: http://provider:9091/pyramid + - key: http.status.code + value: '200' + startTime: gt 0 + endTime: gt 0 + componentId: 7000 + spanType: Exit + peer: provider:9091 + skipAnalysis: false + - operationName: /pyramid + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + tags: + - key: http.method + value: GET + - key: http.url + value: http://0.0.0.0:9090/pyramid + - key: http.status.code + value: '200' + startTime: gt 0 + endTime: gt 0 + componentId: 7009 + spanType: Entry + peer: not null + skipAnalysis: false + diff --git a/tests/plugin/web/sw_pyramid/services/__init__.py b/tests/plugin/web/sw_pyramid/services/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/web/sw_pyramid/services/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/web/sw_pyramid/services/consumer.py b/tests/plugin/web/sw_pyramid/services/consumer.py new file mode 100644 index 00000000..64c63786 --- /dev/null +++ b/tests/plugin/web/sw_pyramid/services/consumer.py @@ -0,0 +1,42 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from urllib import request +from wsgiref.simple_server import make_server + +from pyramid.config import Configurator +from pyramid.response import Response + + +def index(req): + data = '{"name": "whatever"}'.encode('utf8') + req = request.Request(f'http://provider:9091/{req.path.lstrip("/")}') + req.add_header('Content-Type', 'application/json; charset=utf-8') + req.add_header('Content-Length', str(len(data))) + with request.urlopen(req, data): + return Response(data) + + +if __name__ == '__main__': + with Configurator() as config: + config.add_route('pyramid', '/pyramid') + config.add_view(index, route_name='pyramid') + + app = config.make_wsgi_app() + + server = make_server('0.0.0.0', 9090, app) + + server.serve_forever() diff --git a/tests/plugin/web/sw_pyramid/services/provider.py b/tests/plugin/web/sw_pyramid/services/provider.py new file mode 100644 index 00000000..cef6af2d --- /dev/null +++ b/tests/plugin/web/sw_pyramid/services/provider.py @@ -0,0 +1,43 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +from wsgiref.simple_server import make_server + +from pyramid.config import Configurator +from pyramid.response import Response + + +def index(request): + return Response('Hello World!') + + +def error(request): + raise Exception('Error!') + + +if __name__ == '__main__': + with Configurator() as config: + config.add_route('pyramid', '/pyramid') + config.add_route('error', '/error') + config.add_view(index, route_name='pyramid') + config.add_view(error, route_name='error') + + app = config.make_wsgi_app() + + server = make_server('0.0.0.0', 9091, app) + + server.serve_forever() diff --git a/tests/plugin/web/sw_pyramid/test_pyramid.py b/tests/plugin/web/sw_pyramid/test_pyramid.py new file mode 100644 index 00000000..95b1d9f1 --- /dev/null +++ b/tests/plugin/web/sw_pyramid/test_pyramid.py @@ -0,0 +1,36 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from typing import Callable + +import pytest +import requests + +from skywalking.plugins.sw_pyramid import support_matrix +from tests.orchestrator import get_test_vector +from tests.plugin.base import TestPluginBase + + +@pytest.fixture +def prepare(): + # type: () -> Callable + return lambda *_: requests.get('http://0.0.0.0:9090/pyramid') + + +class TestPlugin(TestPluginBase): + @pytest.mark.parametrize('version', get_test_vector(lib_name='pyramid', support_matrix=support_matrix)) + def test_plugin(self, docker_compose, version): + self.validate() diff --git a/tests/plugin/web/sw_sanic/__init__.py b/tests/plugin/web/sw_sanic/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/web/sw_sanic/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/web/sw_sanic/docker-compose.yml b/tests/plugin/web/sw_sanic/docker-compose.yml new file mode 100644 index 00000000..0d311bc1 --- /dev/null +++ b/tests/plugin/web/sw_sanic/docker-compose.yml @@ -0,0 +1,65 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +version: '2.1' + +services: + collector: + extends: + service: collector + file: ../../docker-compose.base.yml + + provider: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9091:9091 + volumes: + - .:/app + command: ['bash', '-c', 'pip install sanic && pip install -r /app/requirements.txt && sw-python run python3 /app/services/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 + environment: + SW_AGENT_NAME: provider + SW_AGENT_LOGGING_LEVEL: DEBUG + consumer: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9090:9090 + volumes: + - .:/app + command: ['bash', '-c', 'pip install sanic && pip install -r /app/requirements.txt && sw-python run python3 /app/services/consumer.py'] + depends_on: + collector: + condition: service_healthy + provider: + condition: service_healthy + environment: + SW_AGENT_NAME: consumer + SW_AGENT_LOGGING_LEVEL: DEBUG + SW_SANIC_COLLECT_HTTP_PARAMS: 'True' +networks: + beyond: diff --git a/tests/plugin/web/sw_sanic/expected.data.yml b/tests/plugin/web/sw_sanic/expected.data.yml new file mode 100644 index 00000000..3c4ca4c1 --- /dev/null +++ b/tests/plugin/web/sw_sanic/expected.data.yml @@ -0,0 +1,92 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +segmentItems: + - serviceName: provider + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: /users + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + tags: + - key: http.method + value: GET + - key: http.url + value: http://provider:9091/users + - key: http.status.code + value: '200' + refs: + - parentEndpoint: /users + networkAddress: provider:9091 + refType: CrossProcess + parentSpanId: 1 + parentTraceSegmentId: not null + parentServiceInstance: not null + parentService: consumer + traceId: not null + startTime: gt 0 + endTime: gt 0 + componentId: 7007 + spanType: Entry + peer: not null + skipAnalysis: false + - serviceName: consumer + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: /users + parentSpanId: 0 + spanId: 1 + spanLayer: Http + tags: + - key: http.method + value: GET + - key: http.url + value: http://provider:9091/users + - key: http.status.code + value: '200' + startTime: gt 0 + endTime: gt 0 + componentId: 7002 + spanType: Exit + peer: provider:9091 + skipAnalysis: false + - operationName: /users + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + tags: + - key: http.method + value: GET + - key: http.url + value: http://0.0.0.0:9090/users + - key: http.params + value: "test=[test1,test2]\ntest2=[test2]" + - key: http.status.code + value: '200' + startTime: gt 0 + endTime: gt 0 + componentId: 7007 + spanType: Entry + peer: not null + skipAnalysis: false \ No newline at end of file diff --git a/tests/plugin/web/sw_sanic/services/__init__.py b/tests/plugin/web/sw_sanic/services/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/web/sw_sanic/services/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/web/sw_sanic/services/consumer.py b/tests/plugin/web/sw_sanic/services/consumer.py new file mode 100644 index 00000000..a2ae35bb --- /dev/null +++ b/tests/plugin/web/sw_sanic/services/consumer.py @@ -0,0 +1,31 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import requests + +if __name__ == '__main__': + from sanic import Sanic, response + + app = Sanic(__name__) + + @app.route('/users', methods=['GET']) + async def application(req): + res = requests.get('http://provider:9091/users') + return response.json(res.json()) + + PORT = 9090 + app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/web/sw_sanic/services/provider.py b/tests/plugin/web/sw_sanic/services/provider.py new file mode 100644 index 00000000..2cc7ba92 --- /dev/null +++ b/tests/plugin/web/sw_sanic/services/provider.py @@ -0,0 +1,33 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import time + +if __name__ == '__main__': + from sanic import Sanic, response + + app = Sanic(__name__) + + @app.route('/users', methods=['GET']) + async def application(req): + time.sleep(0.5) + return response.json( + {'song': 'Despacito', 'artist': 'Luis Fonsi'} + ) + + PORT = 9091 + app.run(host='0.0.0.0', port=PORT, debug=True) diff --git a/tests/plugin/web/sw_sanic/test_sanic.py b/tests/plugin/web/sw_sanic/test_sanic.py new file mode 100644 index 00000000..3413f4a9 --- /dev/null +++ b/tests/plugin/web/sw_sanic/test_sanic.py @@ -0,0 +1,36 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from typing import Callable + +import pytest +import requests + +from skywalking.plugins.sw_sanic import support_matrix +from tests.orchestrator import get_test_vector +from tests.plugin.base import TestPluginBase + + +@pytest.fixture +def prepare(): + # type: () -> Callable + return lambda *_: requests.get('http://0.0.0.0:9090/users?test=test1&test=test2&test2=test2') + + +class TestPlugin(TestPluginBase): + @pytest.mark.parametrize('version', get_test_vector(lib_name='sanic', support_matrix=support_matrix)) + def test_plugin(self, docker_compose, version): + self.validate() diff --git a/tests/plugin/web/sw_tornado/__init__.py b/tests/plugin/web/sw_tornado/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/web/sw_tornado/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/web/sw_tornado/docker-compose.yml b/tests/plugin/web/sw_tornado/docker-compose.yml new file mode 100644 index 00000000..424c7c6a --- /dev/null +++ b/tests/plugin/web/sw_tornado/docker-compose.yml @@ -0,0 +1,66 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +version: '2.1' + +services: + collector: + extends: + service: collector + file: ../../docker-compose.base.yml + + provider: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9091:9091 + volumes: + - .:/app + command: ['bash', '-c', 'pip3 install -r /app/requirements.txt && sw-python run python3 /app/services/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 + environment: + SW_AGENT_NAME: provider + SW_AGENT_LOGGING_LEVEL: DEBUG + + consumer: + extends: + service: agent + file: ../../docker-compose.base.yml + ports: + - 9090:9090 + volumes: + - .:/app + command: ['bash', '-c', 'pip3 install -r /app/requirements.txt && sw-python run python3 /app/services/consumer.py'] + depends_on: + collector: + condition: service_healthy + provider: + condition: service_healthy + environment: + SW_AGENT_NAME: consumer + SW_AGENT_LOGGING_LEVEL: DEBUG + +networks: + beyond: diff --git a/tests/plugin/web/sw_tornado/expected.data.yml b/tests/plugin/web/sw_tornado/expected.data.yml new file mode 100644 index 00000000..c2bb860d --- /dev/null +++ b/tests/plugin/web/sw_tornado/expected.data.yml @@ -0,0 +1,90 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +segmentItems: + - serviceName: provider + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: /users + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + tags: + - key: http.method + value: GET + - key: http.url + value: http://provider:9091/users + - key: http.status.code + value: '200' + refs: + - parentEndpoint: /users + networkAddress: provider:9091 + refType: CrossProcess + parentSpanId: 1 + parentTraceSegmentId: not null + parentServiceInstance: not null + parentService: consumer + traceId: not null + startTime: gt 0 + endTime: gt 0 + componentId: 7005 + spanType: Entry + peer: not null + skipAnalysis: false + - serviceName: consumer + segmentSize: 1 + segments: + - segmentId: not null + spans: + - operationName: /users + parentSpanId: 0 + spanId: 1 + spanLayer: Http + tags: + - key: http.method + value: GET + - key: http.url + value: http://provider:9091/users + - key: http.status.code + value: '200' + startTime: gt 0 + endTime: gt 0 + componentId: 7002 + spanType: Exit + peer: provider:9091 + skipAnalysis: false + - operationName: /users + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + tags: + - key: http.method + value: GET + - key: http.url + value: http://0.0.0.0:9090/users + - key: http.status.code + value: '200' + startTime: gt 0 + endTime: gt 0 + componentId: 7005 + spanType: Entry + peer: not null + skipAnalysis: false \ No newline at end of file diff --git a/tests/plugin/web/sw_tornado/services/__init__.py b/tests/plugin/web/sw_tornado/services/__init__.py new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/tests/plugin/web/sw_tornado/services/__init__.py @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/plugin/web/sw_tornado/services/consumer.py b/tests/plugin/web/sw_tornado/services/consumer.py new file mode 100644 index 00000000..bc2c2e32 --- /dev/null +++ b/tests/plugin/web/sw_tornado/services/consumer.py @@ -0,0 +1,35 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +if __name__ == '__main__': + import requests + import tornado.ioloop + import tornado.web + + class MainHandler(tornado.web.RequestHandler): + def get(self): + res = requests.get('http://provider:9091/users') + self.write(res.text) + + def make_app(): + return tornado.web.Application([ + (r'/users', MainHandler), + ]) + + app = make_app() + app.listen(9090, '0.0.0.0') + tornado.ioloop.IOLoop.current().start() diff --git a/tests/plugin/web/sw_tornado/services/provider.py b/tests/plugin/web/sw_tornado/services/provider.py new file mode 100644 index 00000000..c36beb54 --- /dev/null +++ b/tests/plugin/web/sw_tornado/services/provider.py @@ -0,0 +1,37 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +if __name__ == '__main__': + import json + import time + + import tornado.ioloop + import tornado.web + + class MainHandler(tornado.web.RequestHandler): + def get(self): + time.sleep(0.5) + self.write(json.dumps({'song': 'Despacito', 'artist': 'Luis Fonsi'})) + + def make_app(): + return tornado.web.Application([ + (r'/users', MainHandler), + ]) + + app = make_app() + app.listen(9091, '0.0.0.0') + tornado.ioloop.IOLoop.current().start() diff --git a/tests/plugin/web/sw_tornado/test_tornado.py b/tests/plugin/web/sw_tornado/test_tornado.py new file mode 100644 index 00000000..15693af8 --- /dev/null +++ b/tests/plugin/web/sw_tornado/test_tornado.py @@ -0,0 +1,36 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from typing import Callable + +import pytest +import requests + +from skywalking.plugins.sw_tornado import support_matrix +from tests.orchestrator import get_test_vector +from tests.plugin.base import TestPluginBase + + +@pytest.fixture +def prepare(): + # type: () -> Callable + return lambda *_: requests.get('http://0.0.0.0:9090/users') + + +class TestPlugin(TestPluginBase): + @pytest.mark.parametrize('version', get_test_vector(lib_name='tornado', support_matrix=support_matrix)) + def test_plugin(self, docker_compose, version): + self.validate() From e3cffe283130cb2f9dabbf1949a704fdf8c66208 Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Thu, 17 Feb 2022 04:01:58 -0500 Subject: [PATCH 12/35] Updated submodule protocol --- protocol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocol b/protocol index 21492e49..29552022 160000 --- a/protocol +++ b/protocol @@ -1 +1 @@ -Subproject commit 21492e496b797567d0e127f4510509baf73e10fd +Subproject commit 29552022b01a55ec197641f569f19c1648d49acd From b475c41f43aecfff1a39ead609e1ccc2ab2064b7 Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Thu, 17 Feb 2022 04:02:43 -0500 Subject: [PATCH 13/35] test error intentional Signed-off-by: Superskyyy --- tests/plugin/docker-compose.base.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/plugin/docker-compose.base.yml b/tests/plugin/docker-compose.base.yml index 5afb4576..be09e146 100644 --- a/tests/plugin/docker-compose.base.yml +++ b/tests/plugin/docker-compose.base.yml @@ -19,7 +19,7 @@ version: '2.1' services: collector: - image: ghcr.io/apache/skywalking-agent-test-tool/mock-collector:5acb890f225ca37ee60675ce3e330545e23e3cbc + image: ghcr.io/apache/skywalking-agent-test-tool/mock-collector:092c6a3c753684b5a301baf5bcb1965f2dfaf79d ports: - 19876:19876 - 12800:12800 From bd5111b6a3d0f901a4232f1018c7434decb6300c Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Thu, 17 Feb 2022 04:20:29 -0500 Subject: [PATCH 14/35] test error intentional Signed-off-by: Superskyyy --- skywalking/config.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/skywalking/config.py b/skywalking/config.py index c07ff970..db9c78ae 100644 --- a/skywalking/config.py +++ b/skywalking/config.py @@ -69,8 +69,9 @@ # profile configs get_profile_task_interval = int(os.getenv('SW_PROFILE_TASK_QUERY_INTERVAL') or '20') # type: int -profile_active = False if os.getenv('SW_AGENT_PROFILE_ACTIVE') and \ - os.getenv('SW_AGENT_PROFILE_ACTIVE') == 'False' else True # type: bool +# profile_active = False if os.getenv('SW_AGENT_PROFILE_ACTIVE') and \ +# os.getenv('SW_AGENT_PROFILE_ACTIVE') == 'False' else True # type: bool +profile_active = False profile_max_parallel = int(os.getenv('SW_AGENT_PROFILE_MAX_PARALLEL') or '5') # type: int profile_duration = int(os.getenv('SW_AGENT_PROFILE_DURATION') or '10') # type: int profile_dump_max_stack_depth = int(os.getenv('SW_AGENT_PROFILE_DUMP_MAX_STACK_DEPTH') or '500') # type: int From d4e49fa2c1ba735ada912e6b51035505aa0f0f5f Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Thu, 17 Feb 2022 11:32:09 -0500 Subject: [PATCH 15/35] test error intentional Signed-off-by: Superskyyy --- skywalking/plugins/__init__.py | 4 +++- tests/plugin/conftest.py | 9 +++++---- tests/plugin/docker-compose.base.yml | 1 + 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/skywalking/plugins/__init__.py b/skywalking/plugins/__init__.py index d8298cfd..9cb9eacc 100644 --- a/skywalking/plugins/__init__.py +++ b/skywalking/plugins/__init__.py @@ -59,7 +59,9 @@ def install(): plugin.install() logger.debug('Successfully installed plugin %s', modname) except Exception: - logger.warning('failed to install plugin %s', modname) + logger.warning( + 'plugin %s was not installed, this usually means the package was not present in your project env', + modname) traceback.print_exc() if logger.isEnabledFor(logging.DEBUG) else None diff --git a/tests/plugin/conftest.py b/tests/plugin/conftest.py index 2d9de6d6..eb7c74de 100644 --- a/tests/plugin/conftest.py +++ b/tests/plugin/conftest.py @@ -53,8 +53,8 @@ def docker_compose(request, prepare, version): with DockerCompose(filepath=cwd) as compose: exception = None exception_delay = 0 - # stdout_dignose, stderr_dignose = None - for _ in range(10): + stdout, stderr = None + for i in range(10): try: prepare() exception = None @@ -63,12 +63,13 @@ def docker_compose(request, prepare, version): time.sleep(10) exception_delay += 10 exception = e + print(f'failed time {i} for test ==================') stdout, stderr = compose.get_logs() if exception: compose.stop() print(f'STDOUT:\n{stdout.decode("utf-8")}') - print('====================================') + print('==================================') print(f'STDERR:\n{stderr.decode("utf-8")}') raise Exception(f"""Wait time exceeded {exception_delay} secs. Exception {exception}""") @@ -76,4 +77,4 @@ def docker_compose(request, prepare, version): yield compose - compose.stop() + # compose.stop() diff --git a/tests/plugin/docker-compose.base.yml b/tests/plugin/docker-compose.base.yml index be09e146..51dbeaca 100644 --- a/tests/plugin/docker-compose.base.yml +++ b/tests/plugin/docker-compose.base.yml @@ -40,6 +40,7 @@ services: environment: SW_AGENT_COLLECTOR_BACKEND_SERVICES: collector:19876 SW_AGENT_LOGGING_LEVEL: DEBUG + SW_AGENT_PROFILE_ACTIVE: False # agent test tool does not support profiling networks: - beyond command: ['python3', '/entrypoint.py'] From fa21700980b8f137c1b3c92e127a0b85fa6a6009 Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Thu, 17 Feb 2022 11:38:21 -0500 Subject: [PATCH 16/35] test error intentional Signed-off-by: Superskyyy --- tests/plugin/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/plugin/conftest.py b/tests/plugin/conftest.py index eb7c74de..5ee9d0e6 100644 --- a/tests/plugin/conftest.py +++ b/tests/plugin/conftest.py @@ -53,7 +53,7 @@ def docker_compose(request, prepare, version): with DockerCompose(filepath=cwd) as compose: exception = None exception_delay = 0 - stdout, stderr = None + stdout, stderr = None, None for i in range(10): try: prepare() From 2b52b720dec4ec407d76131244717dccf6ce43d2 Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Thu, 17 Feb 2022 12:44:25 -0500 Subject: [PATCH 17/35] test error intentional Signed-off-by: Superskyyy --- tests/plugin/docker-compose.base.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/plugin/docker-compose.base.yml b/tests/plugin/docker-compose.base.yml index 51dbeaca..1628d375 100644 --- a/tests/plugin/docker-compose.base.yml +++ b/tests/plugin/docker-compose.base.yml @@ -40,7 +40,7 @@ services: environment: SW_AGENT_COLLECTOR_BACKEND_SERVICES: collector:19876 SW_AGENT_LOGGING_LEVEL: DEBUG - SW_AGENT_PROFILE_ACTIVE: False # agent test tool does not support profiling + SW_AGENT_PROFILE_ACTIVE: 'False' # agent test tool does not support profiling networks: - beyond command: ['python3', '/entrypoint.py'] From 4f1bb043ae63817985fc9f3f4680815e8adff408 Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Thu, 17 Feb 2022 12:54:12 -0500 Subject: [PATCH 18/35] test error intentional Signed-off-by: Superskyyy --- tests/plugin/conftest.py | 6 ++---- tests/plugin/docker-compose.base.yml | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/plugin/conftest.py b/tests/plugin/conftest.py index 5ee9d0e6..7df4e6b6 100644 --- a/tests/plugin/conftest.py +++ b/tests/plugin/conftest.py @@ -40,9 +40,7 @@ def prepare(): @pytest.fixture -def docker_compose(request, prepare, version): - # type: (FixtureRequest, Callable, str) -> None - +def docker_compose(request: FixtureRequest, prepare: Callable, version: str) -> None: module = request.module cwd = dirname(inspect.getfile(module)) @@ -67,7 +65,7 @@ def docker_compose(request, prepare, version): stdout, stderr = compose.get_logs() if exception: - compose.stop() + # compose.stop() print(f'STDOUT:\n{stdout.decode("utf-8")}') print('==================================') print(f'STDERR:\n{stderr.decode("utf-8")}') diff --git a/tests/plugin/docker-compose.base.yml b/tests/plugin/docker-compose.base.yml index 1628d375..e101cd67 100644 --- a/tests/plugin/docker-compose.base.yml +++ b/tests/plugin/docker-compose.base.yml @@ -40,7 +40,8 @@ services: environment: SW_AGENT_COLLECTOR_BACKEND_SERVICES: collector:19876 SW_AGENT_LOGGING_LEVEL: DEBUG - SW_AGENT_PROFILE_ACTIVE: 'False' # agent test tool does not support profiling + # Agent test tool does not support profiling, TODO: address in e2e ref: #155 + SW_AGENT_PROFILE_ACTIVE: 'False' networks: - beyond command: ['python3', '/entrypoint.py'] From c7522d4d8cc632e4cbaabcefbf9cdaf37ae21888 Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Thu, 17 Feb 2022 13:21:32 -0500 Subject: [PATCH 19/35] test error intentional Signed-off-by: Superskyyy --- tests/plugin/conftest.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/plugin/conftest.py b/tests/plugin/conftest.py index 7df4e6b6..54bd28f5 100644 --- a/tests/plugin/conftest.py +++ b/tests/plugin/conftest.py @@ -65,14 +65,11 @@ def docker_compose(request: FixtureRequest, prepare: Callable, version: str) -> stdout, stderr = compose.get_logs() if exception: - # compose.stop() 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}""") - + else: + raise Exception('just some random exception to see time delays') yield compose - - - # compose.stop() From 254b0ee1d80cc8f971f6e1fb0bee4b6c80540d82 Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Thu, 17 Feb 2022 13:43:34 -0500 Subject: [PATCH 20/35] test error intentional Signed-off-by: Superskyyy --- skywalking/plugins/__init__.py | 5 +++-- tests/plugin/conftest.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/skywalking/plugins/__init__.py b/skywalking/plugins/__init__.py index 9cb9eacc..cbc12253 100644 --- a/skywalking/plugins/__init__.py +++ b/skywalking/plugins/__init__.py @@ -60,8 +60,9 @@ def install(): logger.debug('Successfully installed plugin %s', modname) except Exception: logger.warning( - 'plugin %s was not installed, this usually means the package was not present in your project env', - modname) + 'plugin %s installation failed, please ignore the warning if the package was not used in your project', + modname + ) traceback.print_exc() if logger.isEnabledFor(logging.DEBUG) else None diff --git a/tests/plugin/conftest.py b/tests/plugin/conftest.py index 54bd28f5..7bba1782 100644 --- a/tests/plugin/conftest.py +++ b/tests/plugin/conftest.py @@ -38,7 +38,6 @@ def prepare(): # type: () -> Callable return lambda *_: None - @pytest.fixture def docker_compose(request: FixtureRequest, prepare: Callable, version: str) -> None: module = request.module @@ -54,6 +53,8 @@ def docker_compose(request: FixtureRequest, prepare: Callable, version: str) -> stdout, stderr = None, None for i in range(10): try: + compose.wait_for('0.0.11.0:9090') + #time.sleep(10) # time for container setup prepare() exception = None break From 1d26acef498250311c3db730c6e4b28acfb059ec Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Thu, 17 Feb 2022 13:46:34 -0500 Subject: [PATCH 21/35] test error intentional Signed-off-by: Superskyyy --- tests/plugin/conftest.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/plugin/conftest.py b/tests/plugin/conftest.py index 7bba1782..186c6cff 100644 --- a/tests/plugin/conftest.py +++ b/tests/plugin/conftest.py @@ -38,6 +38,7 @@ def prepare(): # type: () -> Callable return lambda *_: None + @pytest.fixture def docker_compose(request: FixtureRequest, prepare: Callable, version: str) -> None: module = request.module @@ -54,7 +55,7 @@ def docker_compose(request: FixtureRequest, prepare: Callable, version: str) -> for i in range(10): try: compose.wait_for('0.0.11.0:9090') - #time.sleep(10) # time for container setup + # time.sleep(10) # time for container setup prepare() exception = None break From 327dfababd108e7eef9a2278fdf8bc04b9f49cb4 Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Thu, 17 Feb 2022 13:46:48 -0500 Subject: [PATCH 22/35] test error intentional Signed-off-by: Superskyyy --- tests/plugin/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/plugin/conftest.py b/tests/plugin/conftest.py index 186c6cff..e0940f37 100644 --- a/tests/plugin/conftest.py +++ b/tests/plugin/conftest.py @@ -54,7 +54,7 @@ def docker_compose(request: FixtureRequest, prepare: Callable, version: str) -> stdout, stderr = None, None for i in range(10): try: - compose.wait_for('0.0.11.0:9090') + compose.wait_for('0.0.0.0:9090') # time.sleep(10) # time for container setup prepare() exception = None From 0640b206a5938e44e3b0511061f9203470c51a4b Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Thu, 17 Feb 2022 14:22:49 -0500 Subject: [PATCH 23/35] test error intentional Signed-off-by: Superskyyy --- tests/plugin/conftest.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/plugin/conftest.py b/tests/plugin/conftest.py index e0940f37..7b931223 100644 --- a/tests/plugin/conftest.py +++ b/tests/plugin/conftest.py @@ -24,6 +24,7 @@ import pytest from _pytest.fixtures import FixtureRequest from testcontainers.compose import DockerCompose +from testcontainers.core.waiting_utils import wait_container_is_ready @pytest.fixture @@ -54,9 +55,10 @@ def docker_compose(request: FixtureRequest, prepare: Callable, version: str) -> stdout, stderr = None, None for i in range(10): try: - compose.wait_for('0.0.0.0:9090') + #compose.wait_for('0.0.0.0:9090') + wait_container_is_ready(prepare)() # time.sleep(10) # time for container setup - prepare() + #prepare() exception = None break except Exception as e: From 3b0226665e04502ae3336956ad9bea0caf47c4c7 Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Thu, 17 Feb 2022 14:22:55 -0500 Subject: [PATCH 24/35] test error intentional Signed-off-by: Superskyyy --- tests/plugin/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/plugin/conftest.py b/tests/plugin/conftest.py index 7b931223..dce9fc88 100644 --- a/tests/plugin/conftest.py +++ b/tests/plugin/conftest.py @@ -56,7 +56,7 @@ def docker_compose(request: FixtureRequest, prepare: Callable, version: str) -> for i in range(10): try: #compose.wait_for('0.0.0.0:9090') - wait_container_is_ready(prepare)() + wait_container_is_ready(prepare) # time.sleep(10) # time for container setup #prepare() exception = None From 4ac50b0e29d963ace2f8009d478691c54b47436c Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Thu, 17 Feb 2022 14:30:34 -0500 Subject: [PATCH 25/35] test error intentional Signed-off-by: Superskyyy --- tests/plugin/conftest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/plugin/conftest.py b/tests/plugin/conftest.py index dce9fc88..0a39a592 100644 --- a/tests/plugin/conftest.py +++ b/tests/plugin/conftest.py @@ -55,10 +55,10 @@ def docker_compose(request: FixtureRequest, prepare: Callable, version: str) -> stdout, stderr = None, None for i in range(10): try: - #compose.wait_for('0.0.0.0:9090') + # compose.wait_for('0.0.0.0:9090') wait_container_is_ready(prepare) # time.sleep(10) # time for container setup - #prepare() + # prepare() exception = None break except Exception as e: From 63fcab45704e17664f076a18aedd378af0ee2df9 Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Thu, 17 Feb 2022 14:55:58 -0500 Subject: [PATCH 26/35] test error intentional Signed-off-by: Superskyyy --- tests/plugin/conftest.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/plugin/conftest.py b/tests/plugin/conftest.py index 0a39a592..32708d48 100644 --- a/tests/plugin/conftest.py +++ b/tests/plugin/conftest.py @@ -24,7 +24,6 @@ import pytest from _pytest.fixtures import FixtureRequest from testcontainers.compose import DockerCompose -from testcontainers.core.waiting_utils import wait_container_is_ready @pytest.fixture @@ -55,10 +54,8 @@ def docker_compose(request: FixtureRequest, prepare: Callable, version: str) -> stdout, stderr = None, None for i in range(10): try: - # compose.wait_for('0.0.0.0:9090') - wait_container_is_ready(prepare) - # time.sleep(10) # time for container setup - # prepare() + time.sleep(10) + prepare() exception = None break except Exception as e: From 1fe92ca5cac72a49a51a599361c95da707339dac Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Thu, 17 Feb 2022 15:16:35 -0500 Subject: [PATCH 27/35] test error intentional Signed-off-by: Superskyyy --- tests/plugin/conftest.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/plugin/conftest.py b/tests/plugin/conftest.py index 32708d48..6a447b81 100644 --- a/tests/plugin/conftest.py +++ b/tests/plugin/conftest.py @@ -59,7 +59,6 @@ def docker_compose(request: FixtureRequest, prepare: Callable, version: str) -> exception = None break except Exception as e: - time.sleep(10) exception_delay += 10 exception = e print(f'failed time {i} for test ==================') @@ -71,6 +70,5 @@ def docker_compose(request: FixtureRequest, prepare: Callable, version: str) -> print(f'STDERR:\n{stderr.decode("utf-8")}') raise Exception(f"""Wait time exceeded {exception_delay} secs. Exception {exception}""") - else: - raise Exception('just some random exception to see time delays') + yield compose From f37229703a4b0de4e044da6a1a457782c56e7955 Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Thu, 17 Feb 2022 15:38:13 -0500 Subject: [PATCH 28/35] test error intentional Signed-off-by: Superskyyy --- tests/plugin/conftest.py | 1 - tests/plugin/web/sw_fastapi/test_fastapi.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/plugin/conftest.py b/tests/plugin/conftest.py index 6a447b81..2e592e2f 100644 --- a/tests/plugin/conftest.py +++ b/tests/plugin/conftest.py @@ -61,7 +61,6 @@ def docker_compose(request: FixtureRequest, prepare: Callable, version: str) -> except Exception as e: exception_delay += 10 exception = e - print(f'failed time {i} for test ==================') stdout, stderr = compose.get_logs() if exception: diff --git a/tests/plugin/web/sw_fastapi/test_fastapi.py b/tests/plugin/web/sw_fastapi/test_fastapi.py index 52a499a3..e5df9357 100644 --- a/tests/plugin/web/sw_fastapi/test_fastapi.py +++ b/tests/plugin/web/sw_fastapi/test_fastapi.py @@ -27,7 +27,7 @@ @pytest.fixture def prepare(): # type: () -> Callable - return lambda *_: requests.get('http://0.0.11.0:9090/users?test=test1&test=test2&test2=test2', timeout=3) + return lambda *_: requests.get('http://0.0.1.0:9090/users?test=test1&test=test2&test2=test2') class TestPlugin(TestPluginBase): From 67b7a877821a18ff8e82dbee104c21249b1ab7b0 Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Thu, 17 Feb 2022 16:15:25 -0500 Subject: [PATCH 29/35] test error intentional Signed-off-by: Superskyyy --- tests/plugin/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/plugin/conftest.py b/tests/plugin/conftest.py index 2e592e2f..5a3bb18a 100644 --- a/tests/plugin/conftest.py +++ b/tests/plugin/conftest.py @@ -52,7 +52,7 @@ def docker_compose(request: FixtureRequest, prepare: Callable, version: str) -> exception = None exception_delay = 0 stdout, stderr = None, None - for i in range(10): + for _ in range(10): try: time.sleep(10) prepare() From 5110236c4309d6c4c64fbc4491ca4db1000f3790 Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Thu, 17 Feb 2022 16:30:30 -0500 Subject: [PATCH 30/35] test error intentional Signed-off-by: Superskyyy --- .github/workflows/CI.yaml | 4 ++-- skywalking/config.py | 5 ++--- tests/plugin/web/sw_fastapi/test_fastapi.py | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index c652a7b5..12a0de38 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -59,10 +59,10 @@ jobs: name: Plugin and Unit Tests needs: prep-plugin-and-unit-tests runs-on: ubuntu-latest - timeout-minutes: 20 + timeout-minutes: 30 strategy: matrix: - python-version: ["3.10"] + python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"] test-path: ${{fromJson(needs.prep-plugin-and-unit-tests.outputs.matrix)}} fail-fast: false env: diff --git a/skywalking/config.py b/skywalking/config.py index db9c78ae..c07ff970 100644 --- a/skywalking/config.py +++ b/skywalking/config.py @@ -69,9 +69,8 @@ # profile configs get_profile_task_interval = int(os.getenv('SW_PROFILE_TASK_QUERY_INTERVAL') or '20') # type: int -# profile_active = False if os.getenv('SW_AGENT_PROFILE_ACTIVE') and \ -# os.getenv('SW_AGENT_PROFILE_ACTIVE') == 'False' else True # type: bool -profile_active = False +profile_active = False if os.getenv('SW_AGENT_PROFILE_ACTIVE') and \ + os.getenv('SW_AGENT_PROFILE_ACTIVE') == 'False' else True # type: bool profile_max_parallel = int(os.getenv('SW_AGENT_PROFILE_MAX_PARALLEL') or '5') # type: int profile_duration = int(os.getenv('SW_AGENT_PROFILE_DURATION') or '10') # type: int profile_dump_max_stack_depth = int(os.getenv('SW_AGENT_PROFILE_DUMP_MAX_STACK_DEPTH') or '500') # type: int diff --git a/tests/plugin/web/sw_fastapi/test_fastapi.py b/tests/plugin/web/sw_fastapi/test_fastapi.py index e5df9357..8304c202 100644 --- a/tests/plugin/web/sw_fastapi/test_fastapi.py +++ b/tests/plugin/web/sw_fastapi/test_fastapi.py @@ -27,7 +27,7 @@ @pytest.fixture def prepare(): # type: () -> Callable - return lambda *_: requests.get('http://0.0.1.0:9090/users?test=test1&test=test2&test2=test2') + return lambda *_: requests.get('http://0.0.0.0:9090/users?test=test1&test=test2&test2=test2',timeout=3) class TestPlugin(TestPluginBase): From c066bdae83e75cf8d03da1993434ff009aff4899 Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Thu, 17 Feb 2022 16:33:22 -0500 Subject: [PATCH 31/35] test error intentional Signed-off-by: Superskyyy --- tests/plugin/web/sw_fastapi/test_fastapi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/plugin/web/sw_fastapi/test_fastapi.py b/tests/plugin/web/sw_fastapi/test_fastapi.py index 8304c202..db79f769 100644 --- a/tests/plugin/web/sw_fastapi/test_fastapi.py +++ b/tests/plugin/web/sw_fastapi/test_fastapi.py @@ -27,7 +27,7 @@ @pytest.fixture def prepare(): # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/users?test=test1&test=test2&test2=test2',timeout=3) + return lambda *_: requests.get('http://0.0.0.0:9090/users?test=test1&test=test2&test2=test2', timeout=5) class TestPlugin(TestPluginBase): From 082e92ea3b88c4bc4095497309354d3ba6de506a Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Thu, 17 Feb 2022 16:50:51 -0500 Subject: [PATCH 32/35] test error intentional Signed-off-by: Superskyyy --- tests/plugin/web/sw_fastapi/test_fastapi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/plugin/web/sw_fastapi/test_fastapi.py b/tests/plugin/web/sw_fastapi/test_fastapi.py index db79f769..c0c95b3b 100644 --- a/tests/plugin/web/sw_fastapi/test_fastapi.py +++ b/tests/plugin/web/sw_fastapi/test_fastapi.py @@ -27,7 +27,7 @@ @pytest.fixture def prepare(): # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/users?test=test1&test=test2&test2=test2', timeout=5) + return lambda *_: requests.get('http://0.0.0.1:9090/users?test=test1&test=test2&test2=test2', timeout=5) class TestPlugin(TestPluginBase): From f82beaed94f4a3717a114246874b11e18ec368c8 Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Thu, 17 Feb 2022 17:07:07 -0500 Subject: [PATCH 33/35] add timeout to requests bassed connections Signed-off-by: Superskyyy --- tests/plugin/data/sw_elasticsearch/test_elasticsearch.py | 2 +- tests/plugin/data/sw_kafka/test_kafka.py | 2 +- tests/plugin/data/sw_mysqlclient/services/consumer.py | 2 +- tests/plugin/data/sw_mysqlclient/test_mysqlclient.py | 2 +- tests/plugin/data/sw_psycopg/services/consumer.py | 2 +- tests/plugin/data/sw_psycopg/test_psycopg.py | 2 +- tests/plugin/data/sw_psycopg2/services/consumer.py | 2 +- tests/plugin/data/sw_psycopg2/test_psycopg2.py | 2 +- tests/plugin/data/sw_pymongo/services/consumer.py | 6 +++--- tests/plugin/data/sw_pymongo/test_pymongo.py | 2 +- tests/plugin/data/sw_pymysql/services/consumer.py | 2 +- tests/plugin/data/sw_pymysql/test_pymysql.py | 2 +- tests/plugin/data/sw_rabbitmq/test_rabbitmq.py | 2 +- tests/plugin/data/sw_redis/services/consumer.py | 2 +- tests/plugin/data/sw_redis/test_redis.py | 2 +- tests/plugin/http/sw_aiohttp/test_aiohttp.py | 2 +- tests/plugin/http/sw_http/test_http.py | 2 +- tests/plugin/http/sw_http_wsgi/test_http_wsgi.py | 2 +- tests/plugin/http/sw_requests/services/consumer.py | 2 +- tests/plugin/http/sw_requests/test_request.py | 2 +- tests/plugin/http/sw_urllib3/test_urllib3.py | 2 +- tests/plugin/web/sw_django/services/consumer.py | 2 +- tests/plugin/web/sw_django/test_django.py | 2 +- tests/plugin/web/sw_falcon/services/consumer.py | 2 +- tests/plugin/web/sw_falcon/test_falcon.py | 2 +- tests/plugin/web/sw_fastapi/services/consumer.py | 2 +- tests/plugin/web/sw_flask/services/consumer.py | 4 ++-- tests/plugin/web/sw_flask/test_flask.py | 4 ++-- tests/plugin/web/sw_pyramid/test_pyramid.py | 2 +- tests/plugin/web/sw_sanic/services/consumer.py | 2 +- tests/plugin/web/sw_sanic/test_sanic.py | 2 +- tests/plugin/web/sw_tornado/services/consumer.py | 2 +- tests/plugin/web/sw_tornado/test_tornado.py | 2 +- 33 files changed, 37 insertions(+), 37 deletions(-) diff --git a/tests/plugin/data/sw_elasticsearch/test_elasticsearch.py b/tests/plugin/data/sw_elasticsearch/test_elasticsearch.py index 738f626a..0709ec09 100644 --- a/tests/plugin/data/sw_elasticsearch/test_elasticsearch.py +++ b/tests/plugin/data/sw_elasticsearch/test_elasticsearch.py @@ -27,7 +27,7 @@ @pytest.fixture def prepare(): # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/users') + return lambda *_: requests.get('http://0.0.0.0:9090/users', timeout=5) class TestPlugin(TestPluginBase): diff --git a/tests/plugin/data/sw_kafka/test_kafka.py b/tests/plugin/data/sw_kafka/test_kafka.py index a383c5a6..30f9f020 100644 --- a/tests/plugin/data/sw_kafka/test_kafka.py +++ b/tests/plugin/data/sw_kafka/test_kafka.py @@ -27,7 +27,7 @@ @pytest.fixture def prepare(): # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/users') + return lambda *_: requests.get('http://0.0.0.0:9090/users', timeout=5) class TestPlugin(TestPluginBase): diff --git a/tests/plugin/data/sw_mysqlclient/services/consumer.py b/tests/plugin/data/sw_mysqlclient/services/consumer.py index 3085092a..a86b6e17 100644 --- a/tests/plugin/data/sw_mysqlclient/services/consumer.py +++ b/tests/plugin/data/sw_mysqlclient/services/consumer.py @@ -25,7 +25,7 @@ @app.route('/users', methods=['POST', 'GET']) def application(): - res = requests.post('http://provider:9091/users') + res = requests.post('http://provider:9091/users', timeout=5) return jsonify(res.json()) PORT = 9090 diff --git a/tests/plugin/data/sw_mysqlclient/test_mysqlclient.py b/tests/plugin/data/sw_mysqlclient/test_mysqlclient.py index f306fb29..130b3db7 100644 --- a/tests/plugin/data/sw_mysqlclient/test_mysqlclient.py +++ b/tests/plugin/data/sw_mysqlclient/test_mysqlclient.py @@ -27,7 +27,7 @@ @pytest.fixture def prepare(): # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/users') + return lambda *_: requests.get('http://0.0.0.0:9090/users', timeout=5) class TestPlugin(TestPluginBase): diff --git a/tests/plugin/data/sw_psycopg/services/consumer.py b/tests/plugin/data/sw_psycopg/services/consumer.py index 3085092a..a86b6e17 100644 --- a/tests/plugin/data/sw_psycopg/services/consumer.py +++ b/tests/plugin/data/sw_psycopg/services/consumer.py @@ -25,7 +25,7 @@ @app.route('/users', methods=['POST', 'GET']) def application(): - res = requests.post('http://provider:9091/users') + res = requests.post('http://provider:9091/users', timeout=5) return jsonify(res.json()) PORT = 9090 diff --git a/tests/plugin/data/sw_psycopg/test_psycopg.py b/tests/plugin/data/sw_psycopg/test_psycopg.py index a8f284dd..a07c9878 100644 --- a/tests/plugin/data/sw_psycopg/test_psycopg.py +++ b/tests/plugin/data/sw_psycopg/test_psycopg.py @@ -27,7 +27,7 @@ @pytest.fixture def prepare(): # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/users') + return lambda *_: requests.get('http://0.0.0.0:9090/users', timeout=5) class TestPlugin(TestPluginBase): diff --git a/tests/plugin/data/sw_psycopg2/services/consumer.py b/tests/plugin/data/sw_psycopg2/services/consumer.py index 3085092a..a86b6e17 100644 --- a/tests/plugin/data/sw_psycopg2/services/consumer.py +++ b/tests/plugin/data/sw_psycopg2/services/consumer.py @@ -25,7 +25,7 @@ @app.route('/users', methods=['POST', 'GET']) def application(): - res = requests.post('http://provider:9091/users') + res = requests.post('http://provider:9091/users', timeout=5) return jsonify(res.json()) PORT = 9090 diff --git a/tests/plugin/data/sw_psycopg2/test_psycopg2.py b/tests/plugin/data/sw_psycopg2/test_psycopg2.py index d6f954d4..8d17c932 100644 --- a/tests/plugin/data/sw_psycopg2/test_psycopg2.py +++ b/tests/plugin/data/sw_psycopg2/test_psycopg2.py @@ -27,7 +27,7 @@ @pytest.fixture def prepare(): # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/users') + return lambda *_: requests.get('http://0.0.0.0:9090/users', timeout=5) class TestPlugin(TestPluginBase): diff --git a/tests/plugin/data/sw_pymongo/services/consumer.py b/tests/plugin/data/sw_pymongo/services/consumer.py index 610494e5..04eafbca 100644 --- a/tests/plugin/data/sw_pymongo/services/consumer.py +++ b/tests/plugin/data/sw_pymongo/services/consumer.py @@ -25,9 +25,9 @@ @app.route('/users', methods=['POST', 'GET']) def application(): - requests.get('http://provider:9091/insert_many') - requests.get('http://provider:9091/find_one') - res = requests.get('http://provider:9091/delete_one') + requests.get('http://provider:9091/insert_many', timeout=5) + requests.get('http://provider:9091/find_one', timeout=5) + res = requests.get('http://provider:9091/delete_one', timeout=5) return jsonify(res.json()) PORT = 9090 diff --git a/tests/plugin/data/sw_pymongo/test_pymongo.py b/tests/plugin/data/sw_pymongo/test_pymongo.py index 3b2b81af..1b81139b 100644 --- a/tests/plugin/data/sw_pymongo/test_pymongo.py +++ b/tests/plugin/data/sw_pymongo/test_pymongo.py @@ -27,7 +27,7 @@ @pytest.fixture def prepare(): # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/users') + return lambda *_: requests.get('http://0.0.0.0:9090/users', timeout=5) class TestPlugin(TestPluginBase): diff --git a/tests/plugin/data/sw_pymysql/services/consumer.py b/tests/plugin/data/sw_pymysql/services/consumer.py index 3085092a..a86b6e17 100644 --- a/tests/plugin/data/sw_pymysql/services/consumer.py +++ b/tests/plugin/data/sw_pymysql/services/consumer.py @@ -25,7 +25,7 @@ @app.route('/users', methods=['POST', 'GET']) def application(): - res = requests.post('http://provider:9091/users') + res = requests.post('http://provider:9091/users', timeout=5) return jsonify(res.json()) PORT = 9090 diff --git a/tests/plugin/data/sw_pymysql/test_pymysql.py b/tests/plugin/data/sw_pymysql/test_pymysql.py index 12ca1660..24eac28d 100644 --- a/tests/plugin/data/sw_pymysql/test_pymysql.py +++ b/tests/plugin/data/sw_pymysql/test_pymysql.py @@ -27,7 +27,7 @@ @pytest.fixture def prepare(): # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/users') + return lambda *_: requests.get('http://0.0.0.0:9090/users', timeout=5) class TestPlugin(TestPluginBase): diff --git a/tests/plugin/data/sw_rabbitmq/test_rabbitmq.py b/tests/plugin/data/sw_rabbitmq/test_rabbitmq.py index e9ab3812..4debe6fc 100644 --- a/tests/plugin/data/sw_rabbitmq/test_rabbitmq.py +++ b/tests/plugin/data/sw_rabbitmq/test_rabbitmq.py @@ -27,7 +27,7 @@ @pytest.fixture def prepare(): # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/users') + return lambda *_: requests.get('http://0.0.0.0:9090/users', timeout=5) class TestPlugin(TestPluginBase): diff --git a/tests/plugin/data/sw_redis/services/consumer.py b/tests/plugin/data/sw_redis/services/consumer.py index 3085092a..a86b6e17 100644 --- a/tests/plugin/data/sw_redis/services/consumer.py +++ b/tests/plugin/data/sw_redis/services/consumer.py @@ -25,7 +25,7 @@ @app.route('/users', methods=['POST', 'GET']) def application(): - res = requests.post('http://provider:9091/users') + res = requests.post('http://provider:9091/users', timeout=5) return jsonify(res.json()) PORT = 9090 diff --git a/tests/plugin/data/sw_redis/test_redis.py b/tests/plugin/data/sw_redis/test_redis.py index a3ca1b98..a28c8f2f 100644 --- a/tests/plugin/data/sw_redis/test_redis.py +++ b/tests/plugin/data/sw_redis/test_redis.py @@ -27,7 +27,7 @@ @pytest.fixture def prepare(): # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/users') + return lambda *_: requests.get('http://0.0.0.0:9090/users', timeout=5) class TestPlugin(TestPluginBase): diff --git a/tests/plugin/http/sw_aiohttp/test_aiohttp.py b/tests/plugin/http/sw_aiohttp/test_aiohttp.py index 1e72a89f..3e932762 100644 --- a/tests/plugin/http/sw_aiohttp/test_aiohttp.py +++ b/tests/plugin/http/sw_aiohttp/test_aiohttp.py @@ -27,7 +27,7 @@ @pytest.fixture # pyre-ignore def prepare(): # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/skywalking') + return lambda *_: requests.get('http://0.0.0.0:9090/skywalking', timeout=5) class TestPlugin(TestPluginBase): diff --git a/tests/plugin/http/sw_http/test_http.py b/tests/plugin/http/sw_http/test_http.py index d9317baa..13895f88 100644 --- a/tests/plugin/http/sw_http/test_http.py +++ b/tests/plugin/http/sw_http/test_http.py @@ -25,7 +25,7 @@ @pytest.fixture def prepare(): # type: () -> Callable - return lambda *_: requests.post('http://0.0.0.0:9090') + return lambda *_: requests.post('http://0.0.0.0:9090', timeout=5) class TestPlugin(TestPluginBase): diff --git a/tests/plugin/http/sw_http_wsgi/test_http_wsgi.py b/tests/plugin/http/sw_http_wsgi/test_http_wsgi.py index 4a2a1f13..2bf98ccf 100644 --- a/tests/plugin/http/sw_http_wsgi/test_http_wsgi.py +++ b/tests/plugin/http/sw_http_wsgi/test_http_wsgi.py @@ -27,7 +27,7 @@ @pytest.fixture def prepare(): # type: () -> Callable - return lambda *_: requests.post('http://0.0.0.0:9090') + return lambda *_: requests.post('http://0.0.0.0:9090', timeout=5) class TestPlugin(TestPluginBase): diff --git a/tests/plugin/http/sw_requests/services/consumer.py b/tests/plugin/http/sw_requests/services/consumer.py index db0d10e9..a6db1424 100644 --- a/tests/plugin/http/sw_requests/services/consumer.py +++ b/tests/plugin/http/sw_requests/services/consumer.py @@ -28,7 +28,7 @@ def do_POST(self): # noqa self.send_header('Content-Type', 'application/json; charset=utf-8') self.end_headers() - res = requests.post('http://provider:9091/users') + res = requests.post('http://provider:9091/users', timeout=5) self.wfile.write(str(res.json()).encode('utf8')) PORT = 9090 diff --git a/tests/plugin/http/sw_requests/test_request.py b/tests/plugin/http/sw_requests/test_request.py index 81083269..19b2c23f 100644 --- a/tests/plugin/http/sw_requests/test_request.py +++ b/tests/plugin/http/sw_requests/test_request.py @@ -27,7 +27,7 @@ @pytest.fixture def prepare(): # type: () -> Callable - return lambda *_: requests.post('http://0.0.0.0:9090') + return lambda *_: requests.post('http://0.0.0.0:9090', timeout=5) class TestPlugin(TestPluginBase): diff --git a/tests/plugin/http/sw_urllib3/test_urllib3.py b/tests/plugin/http/sw_urllib3/test_urllib3.py index 9316d1ed..082cd33b 100644 --- a/tests/plugin/http/sw_urllib3/test_urllib3.py +++ b/tests/plugin/http/sw_urllib3/test_urllib3.py @@ -27,7 +27,7 @@ @pytest.fixture def prepare(): # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/users') + return lambda *_: requests.get('http://0.0.0.0:9090/users', timeout=5) class TestPlugin(TestPluginBase): diff --git a/tests/plugin/web/sw_django/services/consumer.py b/tests/plugin/web/sw_django/services/consumer.py index 43ef0de7..77272ca0 100644 --- a/tests/plugin/web/sw_django/services/consumer.py +++ b/tests/plugin/web/sw_django/services/consumer.py @@ -30,7 +30,7 @@ def index(request): - res = requests.post('http://provider:9091/users') + res = requests.post('http://provider:9091/users', timeout=5) return JsonResponse(res.json()) diff --git a/tests/plugin/web/sw_django/test_django.py b/tests/plugin/web/sw_django/test_django.py index 0ef92a60..e719090f 100644 --- a/tests/plugin/web/sw_django/test_django.py +++ b/tests/plugin/web/sw_django/test_django.py @@ -27,7 +27,7 @@ @pytest.fixture def prepare(): # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/users?test=test1&test=test2&test2=test2') + return lambda *_: requests.get('http://0.0.0.0:9090/users?test=test1&test=test2&test2=test2', timeout=5) class TestPlugin(TestPluginBase): diff --git a/tests/plugin/web/sw_falcon/services/consumer.py b/tests/plugin/web/sw_falcon/services/consumer.py index 49cbf7d9..7575ec75 100644 --- a/tests/plugin/web/sw_falcon/services/consumer.py +++ b/tests/plugin/web/sw_falcon/services/consumer.py @@ -20,7 +20,7 @@ @hug.get('/users') def get(): - res = requests.get('http://provider:9091/users') + res = requests.get('http://provider:9091/users', timeout=5) return res.json() diff --git a/tests/plugin/web/sw_falcon/test_falcon.py b/tests/plugin/web/sw_falcon/test_falcon.py index 17aa61fc..9d93407a 100644 --- a/tests/plugin/web/sw_falcon/test_falcon.py +++ b/tests/plugin/web/sw_falcon/test_falcon.py @@ -28,7 +28,7 @@ @pytest.fixture def prepare(): # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/users') + return lambda *_: requests.get('http://0.0.0.0:9090/users', timeout=5) class TestPlugin(TestPluginBase): diff --git a/tests/plugin/web/sw_fastapi/services/consumer.py b/tests/plugin/web/sw_fastapi/services/consumer.py index d4dfd93f..91fe5247 100644 --- a/tests/plugin/web/sw_fastapi/services/consumer.py +++ b/tests/plugin/web/sw_fastapi/services/consumer.py @@ -25,7 +25,7 @@ @app.get('/users') async def application(): - res = requests.get('http://provider:9091/users') + res = requests.get('http://provider:9091/users', timeout=5) return res.json() uvicorn.run(app, host='0.0.0.0', port=9090) diff --git a/tests/plugin/web/sw_flask/services/consumer.py b/tests/plugin/web/sw_flask/services/consumer.py index 7e0a4f03..ce1cbfa8 100644 --- a/tests/plugin/web/sw_flask/services/consumer.py +++ b/tests/plugin/web/sw_flask/services/consumer.py @@ -31,13 +31,13 @@ def application(): @runnable(op='/test') def post(): - requests.post('http://provider:9091/users') + requests.post('http://provider:9091/users', timeout=5) from threading import Thread t = Thread(target=post) t.start() - res = requests.post('http://provider:9091/users') + res = requests.post('http://provider:9091/users', timeout=5) t.join() diff --git a/tests/plugin/web/sw_flask/test_flask.py b/tests/plugin/web/sw_flask/test_flask.py index f2524382..13a5e791 100644 --- a/tests/plugin/web/sw_flask/test_flask.py +++ b/tests/plugin/web/sw_flask/test_flask.py @@ -27,7 +27,7 @@ @pytest.fixture def prepare(): # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/users?test=test1&test=test2&test2=test2') + return lambda *_: requests.get('http://0.0.0.0:9090/users?test=test1&test=test2&test2=test2', timeout=5) class TestPlugin(TestPluginBase): @@ -35,6 +35,6 @@ class TestPlugin(TestPluginBase): def test_plugin(self, docker_compose, version): self.validate() - response = requests.get('http://0.0.0.0:9090/users') + response = requests.get('http://0.0.0.0:9090/users', timeout=5) assert response.status_code == 200 assert response.json()['correlation'] == 'correlation' diff --git a/tests/plugin/web/sw_pyramid/test_pyramid.py b/tests/plugin/web/sw_pyramid/test_pyramid.py index 95b1d9f1..822e11ba 100644 --- a/tests/plugin/web/sw_pyramid/test_pyramid.py +++ b/tests/plugin/web/sw_pyramid/test_pyramid.py @@ -27,7 +27,7 @@ @pytest.fixture def prepare(): # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/pyramid') + return lambda *_: requests.get('http://0.0.0.0:9090/pyramid', timeout=5) class TestPlugin(TestPluginBase): diff --git a/tests/plugin/web/sw_sanic/services/consumer.py b/tests/plugin/web/sw_sanic/services/consumer.py index a2ae35bb..92259237 100644 --- a/tests/plugin/web/sw_sanic/services/consumer.py +++ b/tests/plugin/web/sw_sanic/services/consumer.py @@ -24,7 +24,7 @@ @app.route('/users', methods=['GET']) async def application(req): - res = requests.get('http://provider:9091/users') + res = requests.get('http://provider:9091/users', timeout=5) return response.json(res.json()) PORT = 9090 diff --git a/tests/plugin/web/sw_sanic/test_sanic.py b/tests/plugin/web/sw_sanic/test_sanic.py index 3413f4a9..857e5b71 100644 --- a/tests/plugin/web/sw_sanic/test_sanic.py +++ b/tests/plugin/web/sw_sanic/test_sanic.py @@ -27,7 +27,7 @@ @pytest.fixture def prepare(): # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/users?test=test1&test=test2&test2=test2') + return lambda *_: requests.get('http://0.0.0.0:9090/users?test=test1&test=test2&test2=test2', timeout=5) class TestPlugin(TestPluginBase): diff --git a/tests/plugin/web/sw_tornado/services/consumer.py b/tests/plugin/web/sw_tornado/services/consumer.py index bc2c2e32..5e672f54 100644 --- a/tests/plugin/web/sw_tornado/services/consumer.py +++ b/tests/plugin/web/sw_tornado/services/consumer.py @@ -22,7 +22,7 @@ class MainHandler(tornado.web.RequestHandler): def get(self): - res = requests.get('http://provider:9091/users') + res = requests.get('http://provider:9091/users', timeout=5) self.write(res.text) def make_app(): diff --git a/tests/plugin/web/sw_tornado/test_tornado.py b/tests/plugin/web/sw_tornado/test_tornado.py index 15693af8..80fd7c77 100644 --- a/tests/plugin/web/sw_tornado/test_tornado.py +++ b/tests/plugin/web/sw_tornado/test_tornado.py @@ -27,7 +27,7 @@ @pytest.fixture def prepare(): # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.0:9090/users') + return lambda *_: requests.get('http://0.0.0.0:9090/users', timeout=5) class TestPlugin(TestPluginBase): From ca9e99501c266e230356cb17ba24c985be056000 Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Thu, 17 Feb 2022 17:07:57 -0500 Subject: [PATCH 34/35] add timeout to requests bassed connections Signed-off-by: Superskyyy --- tests/plugin/web/sw_fastapi/test_fastapi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/plugin/web/sw_fastapi/test_fastapi.py b/tests/plugin/web/sw_fastapi/test_fastapi.py index c0c95b3b..db79f769 100644 --- a/tests/plugin/web/sw_fastapi/test_fastapi.py +++ b/tests/plugin/web/sw_fastapi/test_fastapi.py @@ -27,7 +27,7 @@ @pytest.fixture def prepare(): # type: () -> Callable - return lambda *_: requests.get('http://0.0.0.1:9090/users?test=test1&test=test2&test2=test2', timeout=5) + return lambda *_: requests.get('http://0.0.0.0:9090/users?test=test1&test=test2&test2=test2', timeout=5) class TestPlugin(TestPluginBase): From 41b542a82d8e301fb7c7a4a235e750a072fd3b10 Mon Sep 17 00:00:00 2001 From: Superskyyy Date: Thu, 17 Feb 2022 17:17:21 -0500 Subject: [PATCH 35/35] add timeout to requests bassed connections Signed-off-by: Superskyyy --- skywalking/plugins/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/skywalking/plugins/__init__.py b/skywalking/plugins/__init__.py index cbc12253..55b22d3f 100644 --- a/skywalking/plugins/__init__.py +++ b/skywalking/plugins/__init__.py @@ -60,7 +60,8 @@ def install(): logger.debug('Successfully installed plugin %s', modname) except Exception: logger.warning( - 'plugin %s installation failed, please ignore the warning if the package was not used in your project', + 'plugin %s failed to install, please disregard this warning ' + 'if the corresponding package was not used in your project', modname ) traceback.print_exc() if logger.isEnabledFor(logging.DEBUG) else None