You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by al...@apache.org on 2020/08/23 04:52:39 UTC
[skywalking-python] 03/05: update test case
This is an automated email from the ASF dual-hosted git repository.
alonelaval pushed a commit to branch kubernetes
in repository https://gitbox.apache.org/repos/asf/skywalking-python.git
commit 6e00ee575ec95af448bb4df3a1ad5c1cde776f50
Author: huawei <hu...@bit-s.cn>
AuthorDate: Sun Aug 23 12:40:54 2020 +0800
update test case
---
docs/Plugins.md | 1 +
setup.py | 2 +-
tests/plugin/sw_kubernates/docker-compose.yml | 22 +---
tests/plugin/sw_kubernates/expected.data.yml | 148 ++++++++----------------
tests/plugin/sw_kubernates/services/consumer.py | 16 +--
5 files changed, 63 insertions(+), 126 deletions(-)
diff --git a/docs/Plugins.md b/docs/Plugins.md
index b55ba24..7a579c0 100644
--- a/docs/Plugins.md
+++ b/docs/Plugins.md
@@ -31,6 +31,7 @@ Library | Versions | Plugin Name
| [pika](https://pika.readthedocs.io/en/stable/) | 1.1.0 | `sw_rabbitmq` |
| [pymongo](https://pymongo.readthedocs.io/en/stable/) | 3.11.0 | `sw_pymongo` |
| [elasticsearch](https://github.com/elastic/elasticsearch-py) | 7.9.0 | `sw_elasticsearch` |
+| [kubernetes](https://github.com/kubernetes-client/python) | 11.0.0 | `sw_kubernetes` |
The column `Versions` only indicates that the versions are tested, if you found the newer versions are also supported, welcome to add the newer version into the table.
>>>>>>> master
diff --git a/setup.py b/setup.py
index 8555b53..98a00c2 100644
--- a/setup.py
+++ b/setup.py
@@ -54,7 +54,7 @@ setup(
"pika",
"pymongo",
"elasticsearch",
- "kubernetes"
+ "kubernetes",
"pytest",
],
},
diff --git a/tests/plugin/sw_kubernates/docker-compose.yml b/tests/plugin/sw_kubernates/docker-compose.yml
index 61f3be7..4d2bb8d 100644
--- a/tests/plugin/sw_kubernates/docker-compose.yml
+++ b/tests/plugin/sw_kubernates/docker-compose.yml
@@ -23,24 +23,6 @@ services:
service: collector
file: ../docker/docker-compose.base.yml
- provider:
- extends:
- service: agent
- file: ../docker/docker-compose.base.yml
- ports:
- - 9091:9091
- volumes:
- - ./services/provider.py:/app/provider.py
- command: ['bash', '-c', 'pip install flask && python3 /app/provider.py']
- depends_on:
- collector:
- condition: service_healthy
- healthcheck:
- test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/9091"]
- interval: 5s
- timeout: 60s
- retries: 120
-
consumer:
extends:
service: agent
@@ -49,12 +31,10 @@ services:
- 9090:9090
volumes:
- ./services/consumer.py:/app/consumer.py
- command: ['bash', '-c', 'pip install flask && python3 /app/consumer.py']
+ command: ['bash', '-c', 'pip install flask && pip install kubernetes && python3 /app/consumer.py']
depends_on:
collector:
condition: service_healthy
- provider:
- condition: service_healthy
networks:
beyond:
diff --git a/tests/plugin/sw_kubernates/expected.data.yml b/tests/plugin/sw_kubernates/expected.data.yml
index add2226..8ce92f7 100644
--- a/tests/plugin/sw_kubernates/expected.data.yml
+++ b/tests/plugin/sw_kubernates/expected.data.yml
@@ -16,149 +16,103 @@
#
segmentItems:
- - serviceName: provider
- segmentSize: 2
+ - serviceName: consumer
+ segmentSize: 1
segments:
- segmentId: not null
spans:
- - operationName: /users
+ - operationName: /api/v1/namespaces
operationId: 0
- parentSpanId: -1
- spanId: 0
+ parentSpanId: 0
+ spanId: 1
spanLayer: Http
- tags:
- - key: http.method
- value: POST
- - key: url
- value: http://provider:9091/users
- - key: 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
+ componentId: 96
+ isError: false
+ spanType: Exit
peer: not null
skipAnalysis: false
- - segmentId: not null
- spans:
- - operationName: /users
- operationId: 0
- parentSpanId: -1
- spanId: 0
- spanLayer: Http
tags:
- key: http.method
- value: POST
+ value: GET
- key: url
- value: http://provider:9091/users
+ value: not null
- key: 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
+ - operationName: /api/v1/pods
operationId: 0
parentSpanId: 0
- spanId: 1
+ spanId: 2
spanLayer: Http
- startTime: gt 0
- endTime: gt 0
- componentId: 7002
+ startTime: gt 0
+ endTime: gt 0
+ componentId: 96
isError: false
spanType: Exit
- peer: provider:9091
+ peer: not null
skipAnalysis: false
tags:
- key: http.method
- value: POST
+ value: GET
- key: url
- value: 'http://provider:9091/users'
+ value: not null
- key: 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
+ - operationName: /apis/apps/v1/deployments
operationId: 0
parentSpanId: 0
- spanId: 1
+ spanId: 3
spanLayer: Http
+ startTime: gt 0
+ endTime: gt 0
+ componentId: 96
+ isError: false
+ spanType: Exit
+ peer: not null
+ skipAnalysis: false
tags:
- key: http.method
- value: POST
+ value: GET
- key: url
- value: http://provider:9091/users
+ value: not null
- key: status.code
value: '200'
+ - operationName: /apis/networking.k8s.io/v1beta1/ingresses
+ operationId: 0
+ parentSpanId: 0
+ spanId: 4
+ spanLayer: Http
startTime: gt 0
endTime: gt 0
- componentId: 7002
+ componentId: 96
+ isError: false
spanType: Exit
- peer: provider:9091
+ peer: not null
skipAnalysis: false
- - operationName: /users
- operationId: 0
- parentSpanId: -1
- spanId: 0
- spanLayer: Http
tags:
- key: http.method
value: GET
- key: url
- value: http://0.0.0.0:9090/users
- - key: http.params
- value: "test=[test1,test2]\ntest2=[test2]"
+ value: not null
- key: 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: url
+ value: 'http://0.0.0.0:9090/users'
+ - key: status.code
+ value: '200'
diff --git a/tests/plugin/sw_kubernates/services/consumer.py b/tests/plugin/sw_kubernates/services/consumer.py
index 3a384b8..4b160c0 100644
--- a/tests/plugin/sw_kubernates/services/consumer.py
+++ b/tests/plugin/sw_kubernates/services/consumer.py
@@ -17,7 +17,7 @@
from skywalking import agent, config
-import kubernetes.config as kube_config
+
if __name__ == '__main__':
config.service_name = 'consumer'
@@ -25,18 +25,20 @@ if __name__ == '__main__':
agent.start()
from flask import Flask, jsonify
- from kubernetes import client
- app = Flask(__name__)
- kube_config.load_kube_config()
- core_conn = client.CoreV1Api()
- apps_conn = client.AppsV1Api()
- net_conn = client.NetworkingV1beta1Api()
+ app = Flask(__name__)
@app.route("/users", methods=["POST", "GET"])
def application():
+ from kubernetes import client
+ import kubernetes.config as kube_config
+ kube_config.load_kube_config()
+ core_conn = client.CoreV1Api()
+ apps_conn = client.AppsV1Api()
+ net_conn = client.NetworkingV1beta1Api()
+
core_conn.list_namespace()
core_conn.list_pod_for_all_namespaces()
apps_conn.list_deployment_for_all_namespaces()