You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ke...@apache.org on 2020/07/02 13:44:15 UTC

[skywalking-python] 12/12: Fix test

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

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

commit d4167fba2c857227f8b43712907c9ebcd224a6f7
Author: kezhenxu94 <ke...@163.com>
AuthorDate: Thu Jul 2 15:04:39 2020 +0800

    Fix test
---
 tests/plugin/sw_flask/docker-compose.yml   | 40 ++++++++----------------------
 tests/plugin/sw_flask/expected.data.yml    | 14 ++++++++---
 tests/plugin/sw_flask/services/consumer.py |  3 +--
 tests/plugin/sw_flask/services/provider.py |  2 +-
 tests/plugin/sw_flask/test_flask.py        |  4 +--
 5 files changed, 25 insertions(+), 38 deletions(-)

diff --git a/tests/plugin/sw_flask/docker-compose.yml b/tests/plugin/sw_flask/docker-compose.yml
index 3f0d305..d84ab67 100644
--- a/tests/plugin/sw_flask/docker-compose.yml
+++ b/tests/plugin/sw_flask/docker-compose.yml
@@ -19,33 +19,19 @@ version: '2.1'
 
 services:
   collector:
-    build:
-      context: ../docker
-      dockerfile: Dockerfile.tool
-    ports:
-      - 19876:19876
-      - 12800:12800
-    networks:
-      - beyond
-    healthcheck:
-      test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/12800"]
-      interval: 5s
-      timeout: 60s
-      retries: 120
+    extends:
+      service: collector
+      file: ../docker/docker-compose.base.yml
 
   provider:
-    build:
-      context: ../../../
-      dockerfile: tests/plugin/docker/Dockerfile.agent
-    networks:
-      - beyond
+    extends:
+      service: provider
+      file: ../docker/docker-compose.base.yml
     ports:
       - 9091:9091
     volumes:
       - ./services/provider.py:/app/provider.py
-    environment:
-      SW_AGENT_COLLECTOR_BACKEND_SERVICES: collector:19876
-    command: ['python3', '/app/provider.py']
+    command: ['bash', '-c', 'pip install flask && python3 /app/provider.py']
     depends_on:
       collector:
         condition: service_healthy
@@ -56,18 +42,14 @@ services:
       retries: 120
 
   consumer:
-    build:
-      context: ../../../
-      dockerfile: tests/plugin/docker/Dockerfile.agent
-    networks:
-      - beyond
+    extends:
+      service: consumer
+      file: ../docker/docker-compose.base.yml
     ports:
       - 9090:9090
     volumes:
       - ./services/consumer.py:/app/consumer.py
-    environment:
-      SW_AGENT_COLLECTOR_BACKEND_SERVICES: collector:19876
-    command: ['python3', '/app/consumer.py']
+    command: ['bash', '-c', 'pip install flask && python3 /app/consumer.py']
     depends_on:
       collector:
         condition: service_healthy
diff --git a/tests/plugin/sw_flask/expected.data.yml b/tests/plugin/sw_flask/expected.data.yml
index 1ed97c5..aa3d2dc 100644
--- a/tests/plugin/sw_flask/expected.data.yml
+++ b/tests/plugin/sw_flask/expected.data.yml
@@ -29,6 +29,10 @@ segmentItems:
             tags:
               - key: http.method
                 value: POST
+              - key: url
+                value: http://provider:9091/users
+              - key: status.code
+                value: '200'
             refs:
               - parentEndpoint: /users
                 networkAddress: provider:9091
@@ -40,7 +44,7 @@ segmentItems:
                 traceId: not null
             startTime: gt 0
             endTime: gt 0
-            componentId: 7000
+            componentId: 7001
             spanType: Entry
             peer: not null
             skipAnalysis: false
@@ -74,10 +78,14 @@ segmentItems:
             spanLayer: Http
             tags:
               - key: http.method
-                value: POST
+                value: GET
+              - key: url
+                value: http://0.0.0.0:9090/users
+              - key: status.code
+                value: '200'
             startTime: gt 0
             endTime: gt 0
-            componentId: 7000
+            componentId: 7001
             spanType: Entry
             peer: not null
             skipAnalysis: false
\ No newline at end of file
diff --git a/tests/plugin/sw_flask/services/consumer.py b/tests/plugin/sw_flask/services/consumer.py
index 58f02a6..c942f91 100644
--- a/tests/plugin/sw_flask/services/consumer.py
+++ b/tests/plugin/sw_flask/services/consumer.py
@@ -30,9 +30,8 @@ if __name__ == '__main__':
 
     @app.route("/users", methods=["POST", "GET"])
     def application():
-
         res = requests.post("http://provider:9091/users")
         return jsonify(res.json())
 
     PORT = 9090
-    app.run(port=PORT)
+    app.run(host='0.0.0.0', port=PORT, debug=True)
diff --git a/tests/plugin/sw_flask/services/provider.py b/tests/plugin/sw_flask/services/provider.py
index 2507cea..11f2c0b 100644
--- a/tests/plugin/sw_flask/services/provider.py
+++ b/tests/plugin/sw_flask/services/provider.py
@@ -34,4 +34,4 @@ if __name__ == '__main__':
         return jsonify({"song": "Despacito", "artist": "Luis Fonsi"})
 
     PORT = 9091
-    app.run(port=PORT)
+    app.run(host='0.0.0.0', port=PORT, debug=True)
diff --git a/tests/plugin/sw_flask/test_flask.py b/tests/plugin/sw_flask/test_flask.py
index d61e923..21a191a 100644
--- a/tests/plugin/sw_flask/test_flask.py
+++ b/tests/plugin/sw_flask/test_flask.py
@@ -32,11 +32,9 @@ class TestRequestPlugin(BasePluginTest):
         cls.compose = DockerCompose(filepath=dirname(abspath(__file__)))
         cls.compose.start()
 
-        cls.compose.wait_for(cls.url(cls.collector_address()))
+        cls.compose.wait_for(cls.url(('consumer', '9090'), 'users'))
 
     def test_request_plugin(self):
-        print('traffic: ', requests.post(url=self.url(('consumer', '9090'), "users")))
-
         time.sleep(3)
 
         self.validate(expected_file_name=os.path.join(dirname(abspath(__file__)), 'expected.data.yml'))