From bdffdfcaf1a1df5566f14e18fe292075fca8f974 Mon Sep 17 00:00:00 2001 From: mrproliu <741550557@qq.com> Date: Thu, 28 Dec 2023 16:07:41 +0800 Subject: [PATCH] Remove scanner process discovery (#109) --- .github/workflows/rover.yaml | 179 +++++-- CHANGES.md | 1 + configs/rover_configs.yaml | 29 +- pkg/accesslog/common/connection.go | 5 +- pkg/process/api/process.go | 5 +- pkg/process/config.go | 4 - pkg/process/finders/register.go | 2 - pkg/process/finders/scanner/config.go | 76 --- pkg/process/finders/scanner/finder.go | 506 ------------------ pkg/process/finders/scanner/process.go | 150 ------ pkg/process/finders/scanner/template.go | 56 -- pkg/process/module.go | 3 +- scripts/debug/nodejs/tls_gen_offsets.sh | 2 +- test/e2e/base/base-compose.yml | 59 -- test/e2e/base/env | 4 +- .../c/docker-compose.yml => base/kind.yaml} | 35 +- .../kubernetes-values.yaml} | 15 +- test/e2e/base/scripts/gen-selfsigned-ssl.sh | 5 +- test/e2e/base/scripts/update-signed-ssl.sh | 29 + .../agent_sensor/golang/Dockerfile.go2sky | 37 -- .../agent_sensor/golang/docker-compose.yml | 60 --- .../process/agent_sensor/golang/e2e.yaml | 42 -- .../agent_sensor/golang/expected/instance.yml | 34 -- .../agent_sensor/golang/expected/process.yml | 38 -- test/e2e/cases/process/istio/e2e.yaml | 29 +- test/e2e/cases/process/istio/kind.yaml | 12 + test/e2e/cases/process/istio/rover.yaml | 10 +- .../http_avg_response_time/docker-compose.yml | 54 -- .../http_avg_response_time/e2e.yaml | 60 ++- .../expected/process.yml | 7 +- .../expected/service.yml | 2 +- .../http_error_rate/docker-compose.yml | 54 -- .../continuous/http_error_rate/e2e.yaml | 60 ++- .../http_error_rate/expected/process.yml | 5 +- .../http_error_rate/expected/service.yml | 2 +- .../kind.yaml} | 37 +- .../continuous/process_cpu/Dockerfile | 2 +- .../continuous/process_cpu/docker-compose.yml | 50 -- .../profiling/continuous/process_cpu/e2e.yaml | 55 +- .../process_cpu/expected/process.yml | 5 +- .../process_cpu/expected/service.yml | 2 +- .../process_thread_count/Dockerfile | 2 +- .../process_thread_count/docker-compose.yml | 50 -- .../continuous/process_thread_count/e2e.yaml | 55 +- .../process_thread_count/expected/process.yml | 5 +- .../process_thread_count/expected/service.yml | 2 +- .../e2e/cases/profiling/continuous/rover.yaml | 105 ++++ .../service-with-entry.yaml} | 65 ++- .../service.yaml} | 44 +- .../profiling/task/network/base-cases.yaml | 30 +- .../task/network/base/Dockerfile.nginx | 2 + .../task/network/base/docker-compose.yml | 76 --- .../profiling/task/network/base/nginx.conf | 6 +- .../task/network/base/rover_configs.yaml | 168 ------ .../network/base/ssl/gen-selfsigned-ssl.sh | 80 --- .../network/c_plus_plus/docker-compose.yml | 61 --- .../task/network/c_plus_plus/e2e.yaml | 49 +- .../task/network/expected/process.yml | 7 +- .../task/network/expected/service.yml | 4 +- .../task/network/golang/docker-compose.yml | 66 --- .../profiling/task/network/golang/e2e.yaml | 52 +- .../task/network/golang/service.yaml | 103 ++++ .../task/network/http1-metrics-cases.yaml | 12 +- .../network/http1-sampled-traces-cases.yaml | 22 +- .../profiling/task/network/http2/Dockerfile | 15 +- .../task/network/http2/docker-compose.yml | 64 --- .../profiling/task/network/http2/e2e.yaml | 49 +- .../profiling/task/network/http2/grpc.go | 2 +- .../cases/profiling/task/network/kind.yaml | 25 + .../task/network/kubernetes-values.yaml | 205 +++++++ .../task/network/nodejs/docker-compose.yml | 64 --- .../profiling/task/network/nodejs/e2e.yaml | 49 +- .../task/network/python/docker-compose.yml | 64 --- .../profiling/task/network/python/e2e.yaml | 46 +- .../cases/profiling/task/network/rover.yaml | 107 ++++ .../cases/profiling/task/network/service.yaml | 110 ++++ .../cases/profiling/task/offcpu/c++/e2e.yaml | 51 +- .../task/offcpu/c/docker-compose.yml | 45 -- .../cases/profiling/task/offcpu/c/e2e.yaml | 51 +- .../task/offcpu/expected/process.yml | 7 +- .../expected/profiling-schedule-list.yml | 7 +- .../offcpu/expected/profiling-task-list.yml | 5 +- .../task/offcpu/expected/service.yml | 2 +- .../task/offcpu/golang/docker-compose.yml | 45 -- .../profiling/task/offcpu/golang/e2e.yaml | 51 +- .../task/offcpu/profiling-cases.yaml | 14 +- .../cases/profiling/task/offcpu/rover.yaml | 105 ++++ .../task/offcpu/rust/docker-compose.yml | 45 -- .../cases/profiling/task/offcpu/rust/e2e.yaml | 51 +- .../cases/profiling/task/offcpu/service.yaml | 32 ++ .../task/oncpu/c++/docker-compose.yml | 42 -- .../cases/profiling/task/oncpu/c++/e2e.yaml | 51 +- .../e2e/cases/profiling/task/oncpu/c/e2e.yaml | 51 +- .../profiling/task/oncpu/expected/process.yml | 7 +- .../expected/profiling-create-prepare.yml | 5 +- .../expected/profiling-schedule-list.yml | 7 +- .../oncpu/expected/profiling-task-list.yml | 5 +- .../profiling/task/oncpu/expected/service.yml | 2 +- .../profiling/task/oncpu/golang/e2e.yaml | 51 +- .../profiling/task/oncpu/profiling-cases.yaml | 18 +- .../e2e/cases/profiling/task/oncpu/rover.yaml | 105 ++++ .../cases/profiling/task/oncpu/rust/e2e.yaml | 51 +- .../cases/profiling/task/oncpu/service.yaml | 32 ++ 103 files changed, 2094 insertions(+), 2532 deletions(-) delete mode 100644 pkg/process/finders/scanner/config.go delete mode 100644 pkg/process/finders/scanner/finder.go delete mode 100644 pkg/process/finders/scanner/process.go delete mode 100644 pkg/process/finders/scanner/template.go delete mode 100644 test/e2e/base/base-compose.yml rename test/e2e/{cases/profiling/task/oncpu/c/docker-compose.yml => base/kind.yaml} (65%) rename test/e2e/{cases/process/agent_sensor/golang/expected/service.yml => base/kubernetes-values.yaml} (77%) mode change 100644 => 100755 test/e2e/base/scripts/gen-selfsigned-ssl.sh create mode 100755 test/e2e/base/scripts/update-signed-ssl.sh delete mode 100644 test/e2e/cases/process/agent_sensor/golang/Dockerfile.go2sky delete mode 100644 test/e2e/cases/process/agent_sensor/golang/docker-compose.yml delete mode 100644 test/e2e/cases/process/agent_sensor/golang/e2e.yaml delete mode 100644 test/e2e/cases/process/agent_sensor/golang/expected/instance.yml delete mode 100644 test/e2e/cases/process/agent_sensor/golang/expected/process.yml delete mode 100644 test/e2e/cases/profiling/continuous/http_avg_response_time/docker-compose.yml delete mode 100644 test/e2e/cases/profiling/continuous/http_error_rate/docker-compose.yml rename test/e2e/cases/profiling/{task/oncpu/golang/docker-compose.yml => continuous/kind.yaml} (65%) delete mode 100644 test/e2e/cases/profiling/continuous/process_cpu/docker-compose.yml delete mode 100644 test/e2e/cases/profiling/continuous/process_thread_count/docker-compose.yml create mode 100644 test/e2e/cases/profiling/continuous/rover.yaml rename test/e2e/cases/profiling/{task/offcpu/c++/docker-compose.yml => continuous/service-with-entry.yaml} (53%) rename test/e2e/cases/profiling/{task/oncpu/rust/docker-compose.yml => continuous/service.yaml} (65%) delete mode 100644 test/e2e/cases/profiling/task/network/base/docker-compose.yml delete mode 100644 test/e2e/cases/profiling/task/network/base/rover_configs.yaml delete mode 100755 test/e2e/cases/profiling/task/network/base/ssl/gen-selfsigned-ssl.sh delete mode 100644 test/e2e/cases/profiling/task/network/c_plus_plus/docker-compose.yml delete mode 100644 test/e2e/cases/profiling/task/network/golang/docker-compose.yml create mode 100644 test/e2e/cases/profiling/task/network/golang/service.yaml delete mode 100644 test/e2e/cases/profiling/task/network/http2/docker-compose.yml create mode 100644 test/e2e/cases/profiling/task/network/kind.yaml create mode 100644 test/e2e/cases/profiling/task/network/kubernetes-values.yaml delete mode 100644 test/e2e/cases/profiling/task/network/nodejs/docker-compose.yml delete mode 100644 test/e2e/cases/profiling/task/network/python/docker-compose.yml create mode 100644 test/e2e/cases/profiling/task/network/rover.yaml create mode 100644 test/e2e/cases/profiling/task/network/service.yaml delete mode 100644 test/e2e/cases/profiling/task/offcpu/c/docker-compose.yml delete mode 100644 test/e2e/cases/profiling/task/offcpu/golang/docker-compose.yml create mode 100644 test/e2e/cases/profiling/task/offcpu/rover.yaml delete mode 100644 test/e2e/cases/profiling/task/offcpu/rust/docker-compose.yml create mode 100644 test/e2e/cases/profiling/task/offcpu/service.yaml delete mode 100644 test/e2e/cases/profiling/task/oncpu/c++/docker-compose.yml create mode 100644 test/e2e/cases/profiling/task/oncpu/rover.yaml create mode 100644 test/e2e/cases/profiling/task/oncpu/service.yaml diff --git a/.github/workflows/rover.yaml b/.github/workflows/rover.yaml index 54515330..f1ab03fe 100644 --- a/.github/workflows/rover.yaml +++ b/.github/workflows/rover.yaml @@ -76,43 +76,78 @@ jobs: matrix: test: - name: Golang On CPU Profiling - config: test/e2e/cases/profiling/task/oncpu/golang/e2e.yaml + base: test/e2e/cases/profiling/task/oncpu/golang + config: e2e.yaml + docker: + file: Dockerfile.sqrt + name: test/oncpu-golang:test - name: C++ On CPU Profiling - config: test/e2e/cases/profiling/task/oncpu/c++/e2e.yaml + base: test/e2e/cases/profiling/task/oncpu/c++ + config: e2e.yaml + docker: + file: Dockerfile.sqrt + name: test/oncpu-c_plus_plus:test - name: C On CPU Profiling - config: test/e2e/cases/profiling/task/oncpu/c/e2e.yaml + base: test/e2e/cases/profiling/task/oncpu/c + config: e2e.yaml + docker: + file: Dockerfile.sqrt + name: test/oncpu-c:test - name: Rust On CPU Profiling - config: test/e2e/cases/profiling/task/oncpu/rust/e2e.yaml + base: test/e2e/cases/profiling/task/oncpu/rust + config: e2e.yaml + docker: + file: Dockerfile.sqrt + name: test/oncpu-rust:test - name: Golang Off CPU Profiling - config: test/e2e/cases/profiling/task/offcpu/golang/e2e.yaml + base: test/e2e/cases/profiling/task/offcpu/golang + config: e2e.yaml + docker: + file: Dockerfile.file + name: test/offcpu-golang:test - name: C++ Off CPU Profiling - config: test/e2e/cases/profiling/task/offcpu/c++/e2e.yaml + base: test/e2e/cases/profiling/task/offcpu/c++ + config: e2e.yaml + docker: + file: Dockerfile.file + name: test/offcpu-c_plus_plus:test - name: C Off CPU Profiling - config: test/e2e/cases/profiling/task/offcpu/c/e2e.yaml + base: test/e2e/cases/profiling/task/offcpu/c + config: e2e.yaml + docker: + file: Dockerfile.file + name: test/offcpu-c:test - name: Rust Off CPU Profiling - config: test/e2e/cases/profiling/task/offcpu/rust/e2e.yaml - - - name: go2sky Agent Sensor - config: test/e2e/cases/process/agent_sensor/golang/e2e.yaml + base: test/e2e/cases/profiling/task/offcpu/rust + config: e2e.yaml + docker: + file: Dockerfile.file + name: test/offcpu-rust:test - name: Istio Process Finder 1.8.2 - config: test/e2e/cases/process/istio/e2e.yaml + base: test/e2e/cases/process/istio + config: e2e.yaml env: ISTIO_VERSION=1.8.2 - name: Istio Process Finder 1.9.1 - config: test/e2e/cases/process/istio/e2e.yaml + base: test/e2e/cases/process/istio + config: e2e.yaml env: ISTIO_VERSION=1.9.1 - name: Istio Process Finder 1.10.3 - config: test/e2e/cases/process/istio/e2e.yaml + base: test/e2e/cases/process/istio + config: e2e.yaml env: ISTIO_VERSION=1.10.3 - name: Istio Process Finder 1.11.4 - config: test/e2e/cases/process/istio/e2e.yaml + base: test/e2e/cases/process/istio + config: e2e.yaml env: ISTIO_VERSION=1.11.4 - name: Istio Process Finder 1.12.0 - config: test/e2e/cases/process/istio/e2e.yaml + base: test/e2e/cases/process/istio + config: e2e.yaml env: ISTIO_VERSION=1.12.0 - name: Istio Process Finder 1.13.1 - config: test/e2e/cases/process/istio/e2e.yaml + base: test/e2e/cases/process/istio + config: e2e.yaml env: ISTIO_VERSION=1.13.1 steps: - uses: actions/checkout@v3 @@ -127,10 +162,13 @@ jobs: run: find docker-images -name "*.tar" -exec docker load -i {} \; - name: Set env var run: echo "${{ matrix.test.env }}" >> $GITHUB_ENV + - name: Build test image + if: matrix.test.docker != null + run: docker build -t ${{ matrix.test.docker.name }} -f ${{ matrix.test.base }}/${{ matrix.test.docker.file }} ${{ matrix.test.base }} - name: ${{ matrix.test.name }} uses: apache/skywalking-infra-e2e@c3eb3241f649289465eda12af8214ca60aaaaa5f with: - e2e-file: $GITHUB_WORKSPACE/${{ matrix.test.config }} + e2e-file: $GITHUB_WORKSPACE/${{ matrix.test.base }}/${{ matrix.test.config }} - uses: actions/upload-artifact@v2 if: ${{ failure() }} name: Upload Logs @@ -138,10 +176,38 @@ jobs: name: logs path: "${{ env.SW_INFRA_E2E_LOG_DIR }}" + network-profiling-https-e2e-test-prepare: + name: Prepare Network Profiling HTTPS E2E test + needs: [ docker ] + runs-on: ubuntu-22.04 + timeout-minutes: 60 + steps: + - uses: actions/checkout@v3 + with: + submodules: true + - name: Setup SSL Certs + run: | + mkdir -p $(pwd)/test/e2e/cases/profiling/task/network/base/ssl/ + bash test/e2e/base/scripts/gen-selfsigned-ssl.sh service $(pwd)/test/e2e/cases/profiling/task/network/base/ssl/ + bash test/e2e/base/scripts/gen-selfsigned-ssl.sh proxy $(pwd)/test/e2e/cases/profiling/task/network/base/ssl/ + - name: Build nginx docker image + run: | + docker build -t test/test-nginx:test -f test/e2e/cases/profiling/task/network/base/Dockerfile.nginx test/e2e/cases/profiling/task/network/base/ + docker save -o docker-images-nginx.tar test/test-nginx:test + - name: Upload SSL Certs + uses: actions/upload-artifact@v2 + with: + name: network-ssl-data + path: test/e2e/cases/profiling/task/network/base/ssl + - name: Upload docker images + uses: actions/upload-artifact@v2 + with: + name: docker-images-test-nginx + path: docker-images-nginx.tar network-profiling-https-e2e-test: name: Network Profiling HTTPS E2E test - needs: [ docker ] + needs: [ network-profiling-https-e2e-test-prepare ] runs-on: ubuntu-22.04 timeout-minutes: 60 strategy: @@ -149,39 +215,63 @@ jobs: matrix: test: - name: Golang Profiling - config: test/e2e/cases/profiling/task/network/golang/e2e.yaml - - name: Python Profiling - config: test/e2e/cases/profiling/task/network/golang/e2e.yaml + config: golang/e2e.yaml + docker: + file: golang/Dockerfile + name: test/network-golang:test - name: Envoy Profiling - config: test/e2e/cases/profiling/task/network/envoy/e2e.yaml + config: envoy/e2e.yaml env: ISTIO_VERSION=1.13.1 - name: C++ Profiling - config: test/e2e/cases/profiling/task/network/c_plus_plus/e2e.yaml + config: c_plus_plus/e2e.yaml + docker: + file: c_plus_plus/Dockerfile + name: test/network-c_plus_plus:test - name: Nodejs Profiling - config: test/e2e/cases/profiling/task/network/nodejs/e2e.yaml + config: nodejs/e2e.yaml + docker: + file: nodejs/Dockerfile + name: test/network-nodejs:test - name: HTTP2 Profiling - config: test/e2e/cases/profiling/task/network/http2/e2e.yaml + config: http2/e2e.yaml + docker: + file: http2/Dockerfile + name: test/network-http2:test steps: - uses: actions/checkout@v3 with: submodules: true - uses: actions/download-artifact@v2 - name: Download docker images + name: Download rover docker image with: name: docker-images-skywalking-rover path: docker-images + - uses: actions/download-artifact@v2 + name: Download nginx docker image + with: + name: docker-images-test-nginx + path: docker-images + - uses: actions/download-artifact@v2 + name: Download SSL Data + with: + name: network-ssl-data + path: test/e2e/cases/profiling/task/network/base/ssl/ - name: Load docker images run: find docker-images -name "*.tar" -exec docker load -i {} \; - name: Set env var run: echo "${{ matrix.test.env }}" >> $GITHUB_ENV - - name: Setup SSL Certs + - name: Build test image + if: matrix.test.docker != null + run: docker build -t ${{ matrix.test.docker.name }} -f test/e2e/cases/profiling/task/network/${{ matrix.test.docker.file }} test/e2e/cases/profiling/task/network + - name: Copy SSL Cert to the absolute host path and trust it run: | - bash test/e2e/base/scripts/gen-selfsigned-ssl.sh service $(pwd)/test/e2e/cases/profiling/task/network/base/ssl/ - bash test/e2e/base/scripts/gen-selfsigned-ssl.sh proxy $(pwd)/test/e2e/cases/profiling/task/network/base/ssl/ + cp -r test/e2e/cases/profiling/task/network/base/ssl/ /tmp/ssl_data + bash test/e2e/base/scripts/update-signed-ssl.sh service /tmp/ssl_data + bash test/e2e/base/scripts/update-signed-ssl.sh proxy /tmp/ssl_data - name: ${{ matrix.test.name }} uses: apache/skywalking-infra-e2e@c3eb3241f649289465eda12af8214ca60aaaaa5f with: - e2e-file: $GITHUB_WORKSPACE/${{ matrix.test.config }} + e2e-file: $GITHUB_WORKSPACE/test/e2e/cases/profiling/task/network/${{ matrix.test.config }} - uses: actions/upload-artifact@v2 if: ${{ failure() }} name: Upload Logs @@ -199,13 +289,25 @@ jobs: matrix: test: - name: HTTP Avg Response Time - config: test/e2e/cases/profiling/continuous/http_avg_response_time/e2e.yaml + config: http_avg_response_time/e2e.yaml + docker: + file: http_avg_response_time/Dockerfile + name: test/continuous-http_avg_response_time:test - name: HTTP Error Rate - config: test/e2e/cases/profiling/continuous/http_error_rate/e2e.yaml + config: http_error_rate/e2e.yaml + docker: + file: http_error_rate/Dockerfile + name: test/continuous-http_error_rate:test - name: Process CPU - config: test/e2e/cases/profiling/continuous/process_cpu/e2e.yaml + config: process_cpu/e2e.yaml + docker: + file: process_cpu/Dockerfile + name: test/continuous-process_cpu:test - name: Process Thread Count - config: test/e2e/cases/profiling/continuous/process_thread_count/e2e.yaml + config: process_thread_count/e2e.yaml + docker: + file: process_thread_count/Dockerfile + name: test/continuous-process_thread_count:test steps: - uses: actions/checkout@v3 with: @@ -222,11 +324,16 @@ jobs: - name: Setup SSL Certs run: | mkdir -p $(pwd)/test/e2e/cases/profiling/continuous/ssl/ + mkdir -p /tmp/ssl_data bash test/e2e/base/scripts/gen-selfsigned-ssl.sh service $(pwd)/test/e2e/cases/profiling/continuous/ssl/ + cp $(pwd)/test/e2e/cases/profiling/continuous/ssl/* /tmp/ssl_data + - name: Build test image + if: matrix.test.docker != null + run: docker build -t ${{ matrix.test.docker.name }} -f test/e2e/cases/profiling/continuous/${{ matrix.test.docker.file }} test/e2e/cases/profiling/continuous - name: ${{ matrix.test.name }} uses: apache/skywalking-infra-e2e@c3eb3241f649289465eda12af8214ca60aaaaa5f with: - e2e-file: $GITHUB_WORKSPACE/${{ matrix.test.config }} + e2e-file: $GITHUB_WORKSPACE/test/e2e/cases/profiling/continuous/${{ matrix.test.config }} - uses: actions/upload-artifact@v2 if: ${{ failure() }} name: Upload Logs diff --git a/CHANGES.md b/CHANGES.md index cc9b3238..fd5d0574 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,7 @@ Release Notes. * Publish the `latest` Docker image tag. * Improve the stability of Off CPU Profiling. * Support collecting the access log from Kubernetes. +* Remove the scanner mode in the process discovery module. #### Bug Fixes diff --git a/configs/rover_configs.yaml b/configs/rover_configs.yaml index 05859b0f..2d3814ce 100644 --- a/configs/rover_configs.yaml +++ b/configs/rover_configs.yaml @@ -43,36 +43,9 @@ process_discovery: heartbeat_period: ${ROVER_PROCESS_DISCOVERY_HEARTBEAT_PERIOD:20s} # The agent sends the process properties to the backend every: heartbeart period * properties report period properties_report_period: ${ROVER_PROCESS_DISCOVERY_PROPERTIES_REPORT_PERIOD:10} - # Scan process from linux - scanner: - # The period to detect the process - period: ${ROVER_PROCESS_DISCOVERY_SCAN_PERIOD:3s} - # The process detection modes of the scanner. Support "REGEX", "AGENT_SENSOR" - mode: ${ROVER_PROCESS_DISCOVERY_SCAN_MODE:AGENT_SENSOR} - agent: - # Set the agent refresh period - process_status_refresh_period: ${ROVER_PROCESS_DISCOVERY_AGENT_PROCESS_STATUS_REFRESH_PERIOD:1m} - regex: - # Use regex string to locate the processes - # Duplicate entities cannot be reported. If multiple entity are generated, only one process will be report - # If the multiple finders could match the same one process, only the first finder could be selected and report - - match_cmd: ${ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_MATCH_CMD:} - # The Layer need to relate to the process entity - layer: ${ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_LAYER:OS_LINUX} - # The Service Name need to relate to the process entity - service_name: ${ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_SERVICE_NAME:} - # The Service Instance Name need to relate to the process entity - # By default the instance name is the host IP v4 address from "en0" net interface - instance_name: ${ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_INSTANCE_NAME:{{.Rover.HostIPV4 "en0"}}} - # The Process Name need to relate to the process entity - # By default, the process name is the executable name of the process - process_name: ${ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_PROCESS_NAME:{{.Process.ExeName}}} - # The Process Labels, used to aggregate similar process from service entity - # Multiple labels split by "," - labels: ${ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_LABELS:} kubernetes: # Is active the kubernetes process detector - active: ${ROVER_PROCESS_DISCOVERY_KUBERNETES_ACTIVE:false} + active: ${ROVER_PROCESS_DISCOVERY_KUBERNETES_ACTIVE:true} # Current node name in kubernetes environment node_name: ${ROVER_PROCESS_DISCOVERY_KUBERNETES_NODE_NAME:} # include namespaces, multiple namespace split by ",", if empty means including all namespaces diff --git a/pkg/accesslog/common/connection.go b/pkg/accesslog/common/connection.go index 519f5e53..91987e00 100644 --- a/pkg/accesslog/common/connection.go +++ b/pkg/accesslog/common/connection.go @@ -163,9 +163,12 @@ func (c *ConnectionManager) Find(event events.Event) *ConnectionInfo { if ok && remoteAddressInfo != nil { address := remoteAddressInfo.(*addressInfo) remoteAddress = c.buildAddressFromLocalKubernetesProcess(address.pid, socket.DestPort, address.processType) - } else { + } else if c.isLocalTarget(socket) != addressProcessTypeLocal { remoteAddress = c.buildAddressFromRemote(socket.DestIP, socket.DestPort) } + if localAddress == nil || remoteAddress == nil { + return nil + } connection := c.buildConnection(e, socket, localAddress, remoteAddress) c.connections.Set(connectionKey, connection) return connection diff --git a/pkg/process/api/process.go b/pkg/process/api/process.go index ad776441..aed6d181 100644 --- a/pkg/process/api/process.go +++ b/pkg/process/api/process.go @@ -30,14 +30,11 @@ type ProcessDetectType int8 const ( _ ProcessDetectType = iota - Scanner Kubernetes ) func (d ProcessDetectType) Name() string { - if d == Scanner { - return "Scanner" - } else if d == Kubernetes { + if d == Kubernetes { return "Kubernetes" } return "not matched" diff --git a/pkg/process/config.go b/pkg/process/config.go index 24defe98..572c79b1 100644 --- a/pkg/process/config.go +++ b/pkg/process/config.go @@ -20,7 +20,6 @@ package process import ( "github.com/apache/skywalking-rover/pkg/module" "github.com/apache/skywalking-rover/pkg/process/finders/kubernetes" - "github.com/apache/skywalking-rover/pkg/process/finders/scanner" ) type Config struct { @@ -32,9 +31,6 @@ type Config struct { // sends properties to the backend period PropertiesReportPeriod int `mapstructure:"properties_report_period"` - // Scanner process from Linux - Scanner *scanner.Config `mapstructure:"scanner"` - Kubernetes *kubernetes.Config `mapstructure:"kubernetes"` } diff --git a/pkg/process/finders/register.go b/pkg/process/finders/register.go index a764c278..a243576f 100644 --- a/pkg/process/finders/register.go +++ b/pkg/process/finders/register.go @@ -23,13 +23,11 @@ import ( "github.com/apache/skywalking-rover/pkg/process/finders/kubernetes" "github.com/apache/skywalking-rover/pkg/process/finders/base" - "github.com/apache/skywalking-rover/pkg/process/finders/scanner" ) var finders = make(map[reflect.Type]base.ProcessFinder) func init() { - registerFinder(reflect.TypeOf(&scanner.Config{}), &scanner.ProcessFinder{}) registerFinder(reflect.TypeOf(&kubernetes.Config{}), &kubernetes.ProcessFinder{}) } diff --git a/pkg/process/finders/scanner/config.go b/pkg/process/finders/scanner/config.go deleted file mode 100644 index 29e65ad1..00000000 --- a/pkg/process/finders/scanner/config.go +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to Apache Software Foundation (ASF) under one or more contributor -// license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright -// ownership. Apache Software Foundation (ASF) licenses this file to you under -// the Apache License, Version 2.0 (the "License"); you may -// not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package scanner - -import ( - "regexp" - "time" - - "github.com/apache/skywalking-rover/pkg/process/finders/base" -) - -type Mode string - -var ( - Agent Mode = "AGENT_SENSOR" - Regex Mode = "REGEX" -) - -type Config struct { - base.FinderBaseConfig - - // Scan Period - Period string `mapstructure:"period"` - - ScanMode Mode `mapstructure:"mode"` - - // Agent process finder - Agent *AgentFinder `mapstructure:"agent"` - - // Regex process finders - RegexFinders []*RegexFinder `mapstructure:"regex"` -} - -type RegexFinder struct { - // Use command line to match the processes - MatchCommandRegex string `mapstructure:"match_cmd"` - - // entity - Layer string `mapstructure:"layer"` // process layer - ServiceName string `mapstructure:"service_name"` // process entity service name - InstanceName string `mapstructure:"instance_name"` // process entity service instance name - ProcessName string `mapstructure:"process_name"` // process entity process name - LabelsStr string `mapstructure:"labels"` // process labels for aggregate similar processes - - // pre-build for build the process - commandlineRegex *regexp.Regexp - serviceNameBuilder *base.TemplateBuilder - instanceNameBuilder *base.TemplateBuilder - processNameBuilder *base.TemplateBuilder - ParsedLabels []string -} - -type AgentFinder struct { - ProcessStatusRefreshPeriod string `mapstructure:"process_status_refresh_period"` // match recent keep alive time - - ProcessStatusRefreshPeriodDuration time.Duration -} - -func (c *Config) ActiveFinder() bool { - return true -} diff --git a/pkg/process/finders/scanner/finder.go b/pkg/process/finders/scanner/finder.go deleted file mode 100644 index e932fbf4..00000000 --- a/pkg/process/finders/scanner/finder.go +++ /dev/null @@ -1,506 +0,0 @@ -// Licensed to Apache Software Foundation (ASF) under one or more contributor -// license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright -// ownership. Apache Software Foundation (ASF) licenses this file to you under -// the Apache License, Version 2.0 (the "License"); you may -// not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package scanner - -import ( - "bufio" - "bytes" - "context" - "fmt" - "os" - "path" - "strconv" - "strings" - "time" - - "github.com/spf13/viper" - - commonv3 "skywalking.apache.org/repo/goapi/collect/common/v3" - v3 "skywalking.apache.org/repo/goapi/collect/ebpf/profiling/process/v3" - - "github.com/shirou/gopsutil/process" - - "github.com/apache/skywalking-rover/pkg/logger" - "github.com/apache/skywalking-rover/pkg/process/api" - "github.com/apache/skywalking-rover/pkg/process/finders/base" - "github.com/apache/skywalking-rover/pkg/tools/host" -) - -var log = logger.GetLogger("process", "finder", "scanner") - -type ProcessFinder struct { - conf *Config - - manager base.ProcessManager - ctx context.Context - cancelCtx context.CancelFunc - - period time.Duration -} - -func (p *ProcessFinder) Init(ctx context.Context, conf base.FinderBaseConfig, manager base.ProcessManager) error { - if err := validateConfig(conf.(*Config)); err != nil { - return err - } - - p.conf = conf.(*Config) - p.manager = manager - p.ctx, p.cancelCtx = context.WithCancel(ctx) - - period, err := time.ParseDuration(p.conf.Period) - if err != nil { - return err - } - p.period = period - return nil -} - -func (p *ProcessFinder) Start() { - go p.startWatch() -} - -func (p *ProcessFinder) Stop() error { - p.cancelCtx() - return nil -} - -func (p *ProcessFinder) DetectType() api.ProcessDetectType { - return api.Scanner -} - -func (p *ProcessFinder) ShouldMonitor(pid int32) bool { - curProcess, err := process.NewProcess(pid) - if err != nil { - return false - } - var buildProcess *Process - if p.conf.ScanMode == Regex { - buildProcess = p.regexBuildProcess(curProcess) - } - if buildProcess != nil { - p.manager.AddDetectedProcess([]api.DetectedProcess{buildProcess}) - return true - } - return false -} - -func (p *ProcessFinder) ValidateProcessIsSame(p1, p2 api.DetectedProcess) bool { - vm1 := p1.(*Process) - vm2 := p2.(*Process) - return p1.Pid() == p2.Pid() && vm1.cmd == vm2.cmd && p1.Entity().SameWith(p2.Entity()) -} - -func (p *ProcessFinder) BuildEBPFProcess(ctx *base.BuildEBPFProcessContext, ps api.DetectedProcess) *v3.EBPFProcessProperties { - hostProcess := &v3.EBPFHostProcessMetadata{} - hostProcess.Pid = ps.Pid() - hostProcess.Entity = &v3.EBPFProcessEntityMetadata{ - Layer: ps.Entity().Layer, - ServiceName: ps.Entity().ServiceName, - InstanceName: ps.Entity().InstanceName, - ProcessName: ps.Entity().ProcessName, - Labels: ps.Entity().Labels, - } - hostProcess.Properties = []*commonv3.KeyStringValuePair{ - { - Key: "host_ip", - Value: ctx.HostIP, - }, - { - Key: "pid", - Value: strconv.FormatInt(int64(ps.Pid()), 10), - }, - { - Key: "command_line", - Value: ps.(*Process).cmd, - }, - } - hostProcess.Properties = append(hostProcess.Properties, p.BuildNecessaryProperties(ps)...) - properties := &v3.EBPFProcessProperties{Metadata: &v3.EBPFProcessProperties_HostProcess{ - HostProcess: hostProcess, - }} - return properties -} - -func (p *ProcessFinder) BuildNecessaryProperties(ps api.DetectedProcess) []*commonv3.KeyStringValuePair { - return []*commonv3.KeyStringValuePair{ - { - Key: "support_ebpf_profiling", - Value: strconv.FormatBool(ps.ProfilingStat() != nil), - }, - } -} - -func (p *ProcessFinder) ParseProcessID(ps api.DetectedProcess, downstream *v3.EBPFProcessDownstream) string { - if downstream.GetHostProcess() == nil { - return "" - } - if ps.Pid() == downstream.GetHostProcess().GetPid() && - base.EntityIsSameWithProtocol(ps.Entity(), downstream.GetHostProcess().GetEntityMetadata()) { - return downstream.ProcessId - } - return "" -} - -func (p *ProcessFinder) startWatch() { - // find one time - p.findAndReportProcesses() - // schedule - ticker := time.NewTicker(p.period) - for { - select { - case <-ticker.C: - p.findAndReportProcesses() - case <-p.ctx.Done(): - return - } - } -} - -func (p *ProcessFinder) findAndReportProcesses() { - var detectFunc func() ([]api.DetectedProcess, error) - if p.conf.ScanMode == Regex { - detectFunc = p.regexFindProcesses - } else if p.conf.ScanMode == Agent { - detectFunc = p.agentFindProcesses - } - - if processes, err := detectFunc(); err != nil { - log.Warnf("list process failure, %v", err) - } else { - p.manager.SyncAllProcessInFinder(processes) - } -} - -func (p *ProcessFinder) regexFindProcesses() ([]api.DetectedProcess, error) { - // find all process - processes, err := p.regexFindMatchedProcesses() - if err != nil { - return nil, err - } - - // report to the manager - psList := make([]api.DetectedProcess, 0) - for _, ps := range processes { - psList = append(psList, ps) - } - return psList, nil -} - -func (p *ProcessFinder) getProcessTempDir(pro *process.Process) (string, error) { - tmpDir := host.GetFileInHost(fmt.Sprintf("/proc/%d/root/tmp", pro.Pid)) - environ, err := pro.Environ() - if err != nil { - log.Warnf("could not query the environments from the process, pid: %d, error: %v", pro.Pid, err) - } - - prefix := "TMPDIR=" - for _, env := range environ { - if strings.HasPrefix(env, prefix) { - dir := host.GetFileInHost(fmt.Sprintf("/proc/%d/root/%s", pro.Pid, strings.TrimPrefix(env, prefix))) - if pathExists(dir, nil) { - return dir, nil - } - } - } - - if pathExists(tmpDir, nil) { - return tmpDir, nil - } - return "", fmt.Errorf("could not found tmp directory for pid: %d", pro.Pid) -} - -func (p *ProcessFinder) agentFindProcesses() ([]api.DetectedProcess, error) { - // all system processes - processes, err := process.ProcessesWithContext(p.ctx) - if err != nil { - return nil, err - } - // find all matches processes - findedProcesses := make([]api.DetectedProcess, 0) - for _, pro := range processes { - // already contains the processes - pid := pro.Pid - - // if we cannot get temp directory, just ignore it - // May have some system process - tmpDir, err := p.getProcessTempDir(pro) - if err != nil { - continue - } - - metadataFilePath, metadataFile, err := p.tryingToGetAgentMetadataFile(pro, tmpDir) - if err != nil { - continue - } - - // modify time + recent > now - // means the metadata file is acceptable - if metadataFile.ModTime().Add(p.conf.Agent.ProcessStatusRefreshPeriodDuration).Before(time.Now()) { - continue - } - - // build agent process - agentProcess, err := p.buildProcessFromAgentMetadata(pro, metadataFilePath) - if err != nil { - log.Warnf("could not parsing metadata, pid: %d, error: %v", pid, err) - continue - } - - findedProcesses = append(findedProcesses, agentProcess) - } - return findedProcesses, nil -} - -func (p *ProcessFinder) tryingToGetAgentMetadataFile(pro *process.Process, tmpDir string) (string, os.FileInfo, error) { - // get from the local machine - if f, info, err := p.tryingToGetAgentMetadataFileByPid(int64(pro.Pid), tmpDir); err == nil { - return f, info, nil - } - - // get from the child ns(container) - processStatusFilePath := host.GetFileInHost(fmt.Sprintf("/proc/%d/status", pro.Pid)) - processStatusFile, err := os.Open(processStatusFilePath) - if err != nil { - return "", nil, err - } - defer processStatusFile.Close() - scanner := bufio.NewScanner(processStatusFile) - for scanner.Scan() { - infos := strings.SplitN(scanner.Text(), "\t", 2) - if len(infos) < 2 { - continue - } - if strings.TrimRight(infos[0], ":") == "NSpid" { - pids := strings.Split(infos[1], "\t") - if len(pids) <= 1 { - break - } - nspidStr := pids[len(pids)-1] - nspid, err := strconv.ParseInt(nspidStr, 10, 10) - if err != nil { - return "", nil, fmt.Errorf("could not parse the nspid: %s, %v", nspidStr, err) - } - if f, info, err := p.tryingToGetAgentMetadataFileByPid(nspid, tmpDir); err == nil { - return f, info, nil - } - } - } - - return "", nil, fmt.Errorf("could not found") -} - -func (p *ProcessFinder) tryingToGetAgentMetadataFileByPid(pid int64, tmpDir string) (string, os.FileInfo, error) { - metadataFile := path.Join(tmpDir, "apache_skywalking", "process", strconv.FormatInt(pid, 10), "metadata.properties") - f, err := os.Stat(metadataFile) - if err != nil { - return "", nil, err - } - return metadataFile, f, nil -} - -func (p *ProcessFinder) buildProcessFromAgentMetadata(pro *process.Process, metaFilePath string) (*Process, error) { - metadata, err := os.ReadFile(metaFilePath) - if err != nil { - return nil, err - } - - v := viper.New() - v.SetConfigType("properties") - if err1 := v.ReadConfig(bytes.NewReader(metadata)); err1 != nil { - return nil, err1 - } - - // parse agent data - agent := &AgentMetadata{} - if err1 := v.Unmarshal(agent); err1 != nil { - return nil, err1 - } - - cmdline, err := pro.Cmdline() - if err != nil { - return nil, err - } - - return NewProcessByAgent(pro, cmdline, agent) -} - -func (p *ProcessFinder) regexBuildProcess(pro *process.Process) *Process { - finderConfig, cmdline, err := p.findMatchesFinder(pro) - if err != nil { - log.Warnf("failed to match process %d, reason: %v", pro.Pid, err) - return nil - } - if finderConfig == nil { - return nil - } - - // build the linux process and add to the list - ps := NewProcessByRegex(pro, cmdline, finderConfig) - ps.entity.Layer = finderConfig.Layer - ps.entity.ServiceName, err = p.buildEntity(err, ps, finderConfig.serviceNameBuilder) - ps.entity.InstanceName, err = p.buildEntity(err, ps, finderConfig.instanceNameBuilder) - ps.entity.ProcessName, err = p.buildEntity(err, ps, finderConfig.processNameBuilder) - ps.entity.Labels = finderConfig.ParsedLabels - if err != nil { - log.Warnf("failed to build the process data for pid: %d, reason: %v", pro.Pid, err) - return nil - } - return ps -} - -func (p *ProcessFinder) regexFindMatchedProcesses() ([]*Process, error) { - // all system processes - processes, err := process.ProcessesWithContext(p.ctx) - if err != nil { - return nil, err - } - // find all matches processes - findedProcesses := make([]*Process, 0) - for _, pro := range processes { - if curProcess := p.regexBuildProcess(pro); curProcess != nil { - findedProcesses = append(findedProcesses, curProcess) - } - } - if len(findedProcesses) == 0 { - return nil, nil - } - // remove duplicated(identity) process - identity2Processes := make(map[string][]*Process) - for _, ps := range findedProcesses { - id := ps.BuildIdentity() - if identity2Processes[id] == nil { - identity2Processes[id] = make([]*Process, 0) - } - identity2Processes[id] = append(identity2Processes[id], ps) - } - result := make([]*Process, 0) - for _, psList := range identity2Processes { - reportProcess := psList[0] - if len(psList) > 1 { - pidList := make([]int32, 0) - for _, ps := range psList { - pidList = append(pidList, ps.pid) - } - log.WithField("command_line", reportProcess.cmd). - WithField("service_name", reportProcess.entity.ServiceName). - WithField("instance_name", reportProcess.entity.InstanceName). - WithField("process_name", reportProcess.entity.ProcessName). - WithField("labels", reportProcess.entity.Labels). - WithField("pid_list", pidList). - Warnf("find multiple similar process in Scanner, " + - "only report the first of these processes. " + - "please update the name of process to identity them more clear.") - } - result = append(result, reportProcess) - } - return result, nil -} - -func (p *ProcessFinder) buildEntity(err error, ps *Process, entity *base.TemplateBuilder) (string, error) { - if err != nil { - return "", err - } - return renderTemplate(entity, ps, p) -} - -func (p *ProcessFinder) findMatchesFinder(ps *process.Process) (*RegexFinder, string, error) { - // verify the process exists, if not exists just return - if exists, err := process.PidExists(ps.Pid); err != nil { - return nil, "", err - } else if !exists { - return nil, "", nil - } - - cmdline, err := ps.Cmdline() - if err != nil { - return nil, "", fmt.Errorf("query command line failure: %v", err) - } - var matched *RegexFinder - for _, finder := range p.conf.RegexFinders { - if finder.commandlineRegex.MatchString(cmdline) { - if matched == nil { - matched = finder - } else { - log.Warnf("found multiple finder for the process %d, command line: %s, choose the first one mached to build process", - ps.Pid, cmdline) - return matched, cmdline, nil - } - } - } - return matched, cmdline, nil -} - -func validateConfig(conf *Config) error { - if conf.ScanMode == Agent { - var err error - conf.Agent.ProcessStatusRefreshPeriodDuration, err = base.DurationMustNotNull(err, "process_status_refresh_period", - conf.Agent.ProcessStatusRefreshPeriod) - return err - } else if conf.ScanMode != Regex { - return fmt.Errorf("could not found mode: %s", conf.ScanMode) - } - if len(conf.RegexFinders) == 0 { - return fmt.Errorf("must have one Scanner process finder") - } - - // validate config - for _, f := range conf.RegexFinders { - var err error - err = base.StringMustNotNull(err, "layer", f.Layer) - f.commandlineRegex, err = base.RegexMustNotNull(err, "match_cmd_regex", f.MatchCommandRegex) - f.serviceNameBuilder, err = base.TemplateMustNotNull(err, "service_name", f.ServiceName) - f.instanceNameBuilder, err = base.TemplateMustNotNull(err, "instance_name", f.InstanceName) - f.processNameBuilder, err = base.TemplateMustNotNull(err, "process_name", f.ProcessName) - f.ParsedLabels = parseLabels(f.LabelsStr) - - if err != nil { - return err - } - } - - return nil -} - -func parseLabels(labelStr string) []string { - tmp := strings.Split(labelStr, ",") - result := make([]string, 0) - for _, s := range tmp { - if s != "" { - result = append(result, s) - } - } - return result -} - -func pathExists(exe string, err error) bool { - if err != nil { - return false - } - _, e := os.Stat(exe) - return !os.IsNotExist(e) -} - -type AgentMetadata struct { - Layer string `mapstructure:"layer"` - ServiceName string `mapstructure:"service_name"` - InstanceName string `mapstructure:"instance_name"` - ProcessName string `mapstructure:"process_name"` - Properties string `mapstructure:"properties"` - Labels string `mapstructure:"labels"` - Language string `mapstructure:"language"` -} diff --git a/pkg/process/finders/scanner/process.go b/pkg/process/finders/scanner/process.go deleted file mode 100644 index 87eeb3cf..00000000 --- a/pkg/process/finders/scanner/process.go +++ /dev/null @@ -1,150 +0,0 @@ -// Licensed to Apache Software Foundation (ASF) under one or more contributor -// license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright -// ownership. Apache Software Foundation (ASF) licenses this file to you under -// the Apache License, Version 2.0 (the "License"); you may -// not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package scanner - -import ( - "fmt" - "strings" - - "github.com/shirou/gopsutil/process" - - "github.com/apache/skywalking-rover/pkg/process/api" - "github.com/apache/skywalking-rover/pkg/process/finders/base" - "github.com/apache/skywalking-rover/pkg/tools/profiling" -) - -var listenStatus = "LISTEN" - -type Process struct { - // original reference - original *process.Process - finderConfig *RegexFinder - - // process data - pid int32 - cmd string - profiling *profiling.Info - - // entity for backend - entity *api.ProcessEntity -} - -func NewProcessByRegex(p *process.Process, cmdline string, config *RegexFinder) *Process { - stat, _ := base.BuildProfilingStat(p) - return &Process{original: p, pid: p.Pid, cmd: cmdline, finderConfig: config, profiling: stat, entity: &api.ProcessEntity{}} -} - -func NewProcessByAgent(p *process.Process, cmdline string, agent *AgentMetadata) (*Process, error) { - // basic data check - var err error - err = requiredNotNull(err, "layer", agent.Layer) - err = requiredNotNull(err, "service name", agent.ServiceName) - err = requiredNotNull(err, "instance name", agent.InstanceName) - err = requiredNotNull(err, "process name", agent.ProcessName) - if err != nil { - return nil, err - } - - // labels getter - labels := make([]string, 0) - if agent.Labels != "" { - labels = strings.Split(agent.Labels, ",") - } - - // profiling status - stat, _ := base.BuildProfilingStat(p) - - // build result - return &Process{ - original: p, - pid: p.Pid, - cmd: cmdline, - profiling: stat, - entity: &api.ProcessEntity{ - Layer: agent.Layer, - ServiceName: agent.ServiceName, - InstanceName: agent.InstanceName, - ProcessName: agent.ProcessName, - Labels: labels, - }, - }, nil -} - -func (p *Process) Pid() int32 { - return p.pid -} - -func (p *Process) Entity() *api.ProcessEntity { - return p.entity -} - -func (p *Process) DetectType() api.ProcessDetectType { - return api.Scanner -} - -func (p *Process) OriginalProcess() *process.Process { - return p.original -} - -func (p *Process) ProfilingStat() *profiling.Info { - return p.profiling -} - -// BuildIdentity without pid -func (p *Process) BuildIdentity() string { - return fmt.Sprintf("%s_%s_%s_%s", p.entity.Layer, p.entity.ServiceName, - p.entity.InstanceName, p.entity.ProcessName) -} - -func (p *Process) ExposePorts() []int { - connections, err := p.original.Connections() - if err != nil { - log.Warnf("error getting the process connections, pid: %d, error: %v", p.pid, err) - } - ports := make([]int, 0) - for _, con := range connections { - if con.Status == listenStatus { - ports = append(ports, int(con.Laddr.Port)) - } - } - return ports -} - -func (p *Process) ExposeHosts() []string { - connections, err := p.original.Connections() - if err != nil { - log.Warnf("error getting the process connections, pid: %d, error: %v", p.pid, err) - } - hosts := make([]string, 0) - for _, con := range connections { - if con.Status == listenStatus { - hosts = append(hosts, con.Laddr.IP) - } - } - return hosts -} - -func requiredNotNull(err error, key, value string) error { - if err != nil { - return err - } - if value == "" { - return fmt.Errorf("the %s could not be null", key) - } - return nil -} diff --git a/pkg/process/finders/scanner/template.go b/pkg/process/finders/scanner/template.go deleted file mode 100644 index f6297448..00000000 --- a/pkg/process/finders/scanner/template.go +++ /dev/null @@ -1,56 +0,0 @@ -// Licensed to Apache Software Foundation (ASF) under one or more contributor -// license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright -// ownership. Apache Software Foundation (ASF) licenses this file to you under -// the Apache License, Version 2.0 (the "License"); you may -// not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package scanner - -import ( - "fmt" - - "github.com/apache/skywalking-rover/pkg/process/finders/base" -) - -func renderTemplate(builder *base.TemplateBuilder, process *Process, finder *ProcessFinder) (string, error) { - moduleManager := finder.manager.GetModuleManager() - return builder.Execute(&TemplateContext{ - Rover: base.NewTemplateRover(moduleManager), - Process: base.NewTemplateProcess(moduleManager, process.OriginalProcess()), - Finder: &TemplateFinder{finder: finder, process: process}, - }) -} - -type TemplateContext struct { - Rover *base.TemplateRover - Process *base.TemplateProcess - Finder *TemplateFinder -} - -type TemplateFinder struct { - finder *ProcessFinder - process *Process -} - -func (t *TemplateFinder) Layer() string { - return t.process.finderConfig.Layer -} - -func (t *TemplateFinder) RegexMatchGroup(inx int) (string, error) { - submatch := t.process.finderConfig.commandlineRegex.FindStringSubmatch(t.process.cmd) - if len(submatch) == 0 || inx+1 >= len(submatch) { - return "", fmt.Errorf("could not find match") - } - return submatch[inx], nil -} diff --git a/pkg/process/module.go b/pkg/process/module.go index 3a8903f3..648b8f69 100644 --- a/pkg/process/module.go +++ b/pkg/process/module.go @@ -56,8 +56,7 @@ func (m *Module) Start(ctx context.Context, mgr *module.Manager) error { if err != nil { return err } - processManager, err := finders.NewProcessManager(ctx, mgr, period, m.config.PropertiesReportPeriod, - m.config.Scanner, m.config.Kubernetes) + processManager, err := finders.NewProcessManager(ctx, mgr, period, m.config.PropertiesReportPeriod, m.config.Kubernetes) if err != nil { return err } diff --git a/scripts/debug/nodejs/tls_gen_offsets.sh b/scripts/debug/nodejs/tls_gen_offsets.sh index aa2922b0..e481603e 100755 --- a/scripts/debug/nodejs/tls_gen_offsets.sh +++ b/scripts/debug/nodejs/tls_gen_offsets.sh @@ -36,7 +36,7 @@ tar -xf node.tar.gz --strip 1 && rm node.tar.gz NODE_PATH="$WORK_DIR/out/Debug/node" # generate ssl certs and start https server -bash $ROVER_DIR/test/e2e/cases/profiling/network/base/ssl/gen-selfsigned-ssl.sh service +bash $ROVER_DIR/test/e2e/base/scripts/gen-selfsigned-ssl.sh service $ROVER_DIR/test/e2e/cases/profiling/network/base/ssl/ $NODE_PATH # run the go program diff --git a/test/e2e/base/base-compose.yml b/test/e2e/base/base-compose.yml deleted file mode 100644 index d3b13cbc..00000000 --- a/test/e2e/base/base-compose.yml +++ /dev/null @@ -1,59 +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: - oap: - image: ghcr.io/apache/skywalking/oap:${SW_OAP_COMMIT} - expose: - - 11800 - - 12800 - - 10051 - networks: - - e2e - healthcheck: - test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/11800"] - interval: 5s - timeout: 60s - retries: 120 - - rover: - image: apache/skywalking-rover:latest - networks: - - e2e - privileged: true - pid: host - environment: - ROVER_HOST_MAPPING: /host - ROVER_BACKEND_ADDR: oap:11800 - ROVER_PROCESS_DISCOVERY_HEARTBEAT_PERIOD: 2s - ROVER_PROCESS_DISCOVERY_SCAN_PERIOD: 3s - ROVER_PROCESS_DISCOVERY_SCAN_MODE: "REGEX" - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_MATCH_CMD: sqrt - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_LAYER: OS_LINUX - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_SERVICE_NAME: sqrt - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_INSTANCE_NAME: test-instance - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_PROCESS_NAME: "{{.Process.ExeName}}" - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_LABELS: e2e-label1,e2e-label2 - ROVER_PROFILING_ACTIVE: "true" - ROVER_PROFILING_CHECK_INTERVAL: 2s - ROVER_PROFILING_FLUSH_INTERVAL: 5s - ROVER_PROFILING_TASK_ON_CPU_DUMP_PERIOD: 9ms - volumes: - - /:/host - -networks: - e2e: \ No newline at end of file diff --git a/test/e2e/base/env b/test/e2e/base/env index 28cd9f0b..e417340c 100644 --- a/test/e2e/base/env +++ b/test/e2e/base/env @@ -14,7 +14,7 @@ # limitations under the License. SW_CTL_COMMIT=6b2eb0011e38b630db6af7203db215806bd141ed -SW_OAP_COMMIT=43668b7655ce4c5a95b87267be4c3b962d1eea38 -SW_KUBERNETES_COMMIT_SHA=0f3ec68e5a7e1608cec8688716b848ed15e971e5 +SW_OAP_COMMIT=9ba0ad299139eeb4bb4e274c500cec1deaf84f79 +SW_KUBERNETES_COMMIT_SHA=a14f386063fffc61ed9b396e1328b76d33239aba SW_AGENT_GO_COMMIT=216f122d942cb683f48578d3014cc5ea83637582 diff --git a/test/e2e/cases/profiling/task/oncpu/c/docker-compose.yml b/test/e2e/base/kind.yaml similarity index 65% rename from test/e2e/cases/profiling/task/oncpu/c/docker-compose.yml rename to test/e2e/base/kind.yaml index 97b8ee5c..20a3fc74 100644 --- a/test/e2e/cases/profiling/task/oncpu/c/docker-compose.yml +++ b/test/e2e/base/kind.yaml @@ -13,30 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -version: '2.1' - -services: - oap: - extends: - file: ../../../../../base/base-compose.yml - service: oap - ports: - - 12800:12800 - - rover: - extends: - file: ../../../../../base/base-compose.yml - service: rover - depends_on: - oap: - condition: service_healthy - - sqrt_c: - build: - context: . - dockerfile: Dockerfile.sqrt - networks: - - e2e - -networks: - e2e: +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +nodes: + - role: control-plane + image: kindest/node:v1.25.11@sha256:227fa11ce74ea76a0474eeefb84cb75d8dad1b08638371ecf0e86259b35be0c8 + extraMounts: + - hostPath: / + containerPath: /host \ No newline at end of file diff --git a/test/e2e/cases/process/agent_sensor/golang/expected/service.yml b/test/e2e/base/kubernetes-values.yaml similarity index 77% rename from test/e2e/cases/process/agent_sensor/golang/expected/service.yml rename to test/e2e/base/kubernetes-values.yaml index 5b244c03..95b16dcc 100644 --- a/test/e2e/cases/process/agent_sensor/golang/expected/service.yml +++ b/test/e2e/base/kubernetes-values.yaml @@ -13,12 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -{{- contains . }} -- id: {{ b64enc "go2sky" }}.1 - name: go2sky - group: "" - shortname: go2sky - layers: - - GENERAL - normal: true -{{- end }} \ No newline at end of file +elasticsearch: + esConfig: + elasticsearch.yml: | + cluster.routing.allocation.disk.watermark.low: 90% + cluster.routing.allocation.disk.watermark.high: 99% + cluster.routing.allocation.disk.watermark.flood_stage: 99% \ No newline at end of file diff --git a/test/e2e/base/scripts/gen-selfsigned-ssl.sh b/test/e2e/base/scripts/gen-selfsigned-ssl.sh old mode 100644 new mode 100755 index 1d45fd33..5288fccb --- a/test/e2e/base/scripts/gen-selfsigned-ssl.sh +++ b/test/e2e/base/scripts/gen-selfsigned-ssl.sh @@ -20,7 +20,7 @@ set -e HOST=${1:-localhost} PASSWORD=test -TARGET_DIR="$(cd "$(dirname "$0")" && pwd)" +CURRENT_DIR="$(cd "$(dirname "$0")" && pwd)" TARGET_DIR=$2 root_key="$TARGET_DIR/root_${HOST}.key" @@ -77,5 +77,4 @@ EOF openssl x509 -req -days 365 -sha256 -CA $root_crt -CAkey $root_key -CAcreateserial -in $csr -out $crt -passin pass:$PASSWORD -extfile <(printf "subjectAltName=DNS:$HOST,DNS:localhost,IP:127.0.0.1") # adding trusted root certificates to the server -sudo cp $root_crt $crt /usr/local/share/ca-certificates/ -sudo update-ca-certificates \ No newline at end of file +bash $CURRENT_DIR/update-signed-ssl.sh $HOST $TARGET_DIR \ No newline at end of file diff --git a/test/e2e/base/scripts/update-signed-ssl.sh b/test/e2e/base/scripts/update-signed-ssl.sh new file mode 100755 index 00000000..6ba48dff --- /dev/null +++ b/test/e2e/base/scripts/update-signed-ssl.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +set -e + +HOST=${1:-localhost} +TARGET_DIR=$2 + +root_crt="$TARGET_DIR/root_${HOST}.crt" +crt="$TARGET_DIR/${HOST}.crt" + +# adding trusted root certificates to the server +sudo cp $root_crt $crt /usr/local/share/ca-certificates/ +sudo update-ca-certificates \ No newline at end of file diff --git a/test/e2e/cases/process/agent_sensor/golang/Dockerfile.go2sky b/test/e2e/cases/process/agent_sensor/golang/Dockerfile.go2sky deleted file mode 100644 index 24e30abd..00000000 --- a/test/e2e/cases/process/agent_sensor/golang/Dockerfile.go2sky +++ /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 golang:1.13 AS builder - -ARG SW_AGENT_GO_COMMIT -ARG GO2SKY_CODE=${SW_AGENT_GO_COMMIT}.tar.gz -ARG GO2SKY_CODE_URL=https://github.com/SkyAPM/go2sky/archive/${GO2SKY_CODE} - -ENV CGO_ENABLED=0 -ENV GO111MODULE=on - -WORKDIR /go2sky - -ADD ${GO2SKY_CODE_URL} . -RUN tar -xf ${GO2SKY_CODE} --strip 1 -RUN rm ${GO2SKY_CODE} - -WORKDIR /go2sky/test/e2e/example-server -RUN go build -o main - -FROM alpine:3.10 - -COPY --from=builder /go2sky/test/e2e/example-server/main . -ENTRYPOINT ["/main"] diff --git a/test/e2e/cases/process/agent_sensor/golang/docker-compose.yml b/test/e2e/cases/process/agent_sensor/golang/docker-compose.yml deleted file mode 100644 index 55834221..00000000 --- a/test/e2e/cases/process/agent_sensor/golang/docker-compose.yml +++ /dev/null @@ -1,60 +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: - oap: - extends: - file: ../../../../base/base-compose.yml - service: oap - ports: - - 12800:12800 - - rover: - extends: - file: ../../../../base/base-compose.yml - service: rover - environment: - ROVER_PROCESS_DISCOVERY_SCAN_MODE: AGENT_SENSOR - depends_on: - oap: - condition: service_healthy - - go2sky: - build: - context: . - dockerfile: Dockerfile.go2sky - args: - - SW_AGENT_GO_COMMIT=${SW_AGENT_GO_COMMIT} - networks: - - e2e - depends_on: - oap: - condition: service_healthy - command: [ '--grpc', '--oap-server', 'oap:11800'] - environment: - SW_AGENT_PROCESS_STATUS_HOOK_ENABLE: "true" - SW_AGENT_PROCESS_LABELS: e2e-label - SW_AGENT_NAME: go2sky - SW_AGENT_INSTANCE_NAME: go2sky-instance - healthcheck: - test: [ "CMD", "sh", "-c", "nc -z 127.0.0.1 8080" ] - interval: 5s - timeout: 60s - retries: 120 - -networks: - e2e: \ No newline at end of file diff --git a/test/e2e/cases/process/agent_sensor/golang/e2e.yaml b/test/e2e/cases/process/agent_sensor/golang/e2e.yaml deleted file mode 100644 index 4289916a..00000000 --- a/test/e2e/cases/process/agent_sensor/golang/e2e.yaml +++ /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. - -setup: - env: compose - file: docker-compose.yml - timeout: 20m - init-system-environment: ../../../../base/env - steps: - - name: set PATH - command: export PATH=/tmp/skywalking-infra-e2e/bin:$PATH - - name: install yq - command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh yq - - name: install swctl - command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh swctl - -verify: - # verify with retry strategy - retry: - # max retry count - count: 20 - # the interval between two retries, in millisecond. - interval: 10s - cases: - - query: swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml service ls - expected: expected/service.yml - - query: swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml instance ls --service-name go2sky - expected: expected/instance.yml - - query: swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml process ls --service-name go2sky --instance-name go2sky-instance - expected: expected/process.yml \ No newline at end of file diff --git a/test/e2e/cases/process/agent_sensor/golang/expected/instance.yml b/test/e2e/cases/process/agent_sensor/golang/expected/instance.yml deleted file mode 100644 index 8d76343e..00000000 --- a/test/e2e/cases/process/agent_sensor/golang/expected/instance.yml +++ /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. - -{{- contains . }} -- id: {{ b64enc "go2sky" }}.1_{{ b64enc "go2sky-instance" }} - name: go2sky-instance - attributes: - {{- contains .attributes }} - - name: Process No. - value: "1" - - name: hostname - value: {{ notEmpty .value }} - - name: OS Name - value: linux - - name: processLabels - value: e2e-label - - name: ipv4s - value: {{ notEmpty .value }} - {{- end }} - language: GO - instanceuuid: {{ notEmpty .instanceuuid }} -{{- end }} \ No newline at end of file diff --git a/test/e2e/cases/process/agent_sensor/golang/expected/process.yml b/test/e2e/cases/process/agent_sensor/golang/expected/process.yml deleted file mode 100644 index 959009c3..00000000 --- a/test/e2e/cases/process/agent_sensor/golang/expected/process.yml +++ /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. - -{{- contains . }} -- id: {{ notEmpty .id }} - name: go2sky-instance - serviceid: {{ b64enc "go2sky" }}.1 - servicename: go2sky - instanceid: {{ b64enc "go2sky" }}.1_{{ b64enc "go2sky-instance" }} - instancename: go2sky-instance - agentid: {{ notEmpty .agentid }} - detecttype: VM - attributes: - {{- contains .attributes }} - - name: host_ip - value: {{ notEmpty .value }} - - name: pid - value: {{ notEmpty .value }} - - name: command_line - value: /main --grpc --oap-server oap:11800 - - name: support_ebpf_profiling - value: true - {{- end }} - labels: - - e2e-label -{{- end }} \ No newline at end of file diff --git a/test/e2e/cases/process/istio/e2e.yaml b/test/e2e/cases/process/istio/e2e.yaml index e29ae983..ece64c9d 100644 --- a/test/e2e/cases/process/istio/e2e.yaml +++ b/test/e2e/cases/process/istio/e2e.yaml @@ -42,22 +42,19 @@ setup: command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh helm - name: Install SkyWalking command: | - rm -rf skywalking-kubernetes && git clone https://github.com/apache/skywalking-kubernetes.git - cd skywalking-kubernetes - git reset --hard $SW_KUBERNETES_COMMIT_SHA - cd chart - helm dep up skywalking - helm -n istio-system install skywalking skywalking \ - --set fullnameOverride=skywalking \ - --set elasticsearch.replicas=1 \ - --set elasticsearch.minimumMasterNodes=1 \ - --set elasticsearch.imageTag=7.5.1 \ - --set oap.replicas=1 \ - --set ui.image.repository=ghcr.io/apache/skywalking/ui \ - --set ui.image.tag=${SW_OAP_COMMIT} \ - --set oap.image.tag=${SW_OAP_COMMIT} \ - --set oap.image.repository=ghcr.io/apache/skywalking/oap \ - --set oap.storageType=elasticsearch + helm -n istio-system install skywalking \ + oci://ghcr.io/apache/skywalking-helm/skywalking-helm \ + --version "0.0.0-${SW_KUBERNETES_COMMIT_SHA}" \ + --set fullnameOverride=skywalking \ + --set elasticsearch.replicas=1 \ + --set elasticsearch.minimumMasterNodes=1 \ + --set oap.replicas=1 \ + --set ui.image.repository=ghcr.io/apache/skywalking/ui \ + --set ui.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.repository=ghcr.io/apache/skywalking/oap \ + --set oap.storageType=elasticsearch \ + -f test/e2e/base/kubernetes-values.yaml wait: - namespace: istio-system resource: deployments/skywalking-oap diff --git a/test/e2e/cases/process/istio/kind.yaml b/test/e2e/cases/process/istio/kind.yaml index f832efd1..18faa3c9 100644 --- a/test/e2e/cases/process/istio/kind.yaml +++ b/test/e2e/cases/process/istio/kind.yaml @@ -21,10 +21,22 @@ nodes: # the control plane node config - role: control-plane image: kindest/node:v1.21.1 + extraMounts: + - hostPath: / + containerPath: /host # the three workers - role: worker image: kindest/node:v1.21.1 + extraMounts: + - hostPath: / + containerPath: /host - role: worker image: kindest/node:v1.21.1 + extraMounts: + - hostPath: / + containerPath: /host - role: worker image: kindest/node:v1.21.1 + extraMounts: + - hostPath: / + containerPath: /host diff --git a/test/e2e/cases/process/istio/rover.yaml b/test/e2e/cases/process/istio/rover.yaml index cf769db4..6380c89e 100644 --- a/test/e2e/cases/process/istio/rover.yaml +++ b/test/e2e/cases/process/istio/rover.yaml @@ -74,6 +74,8 @@ spec: env: - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_ACTIVE value: "true" + - name: ROVER_LOGGER_LEVEL + value: "DEBUG" - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_NODE_NAME valueFrom: fieldRef: @@ -81,13 +83,19 @@ spec: - name: ROVER_BACKEND_ADDR # backend OAP address value: skywalking-oap.istio-system:11800 + - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_ISTIO_ENVOY_ACTIVE + value: "true" + - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_ISTIO_APPLICATION_ACTIVE + value: "true" - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_K8S_SERVICE_ACTIVE value: "false" + - name: ROVER_HOST_MAPPING + value: /host hostPID: true hostNetwork: true dnsPolicy: ClusterFirstWithHostNet volumes: - name: host hostPath: - path: / + path: /host type: Directory \ No newline at end of file diff --git a/test/e2e/cases/profiling/continuous/http_avg_response_time/docker-compose.yml b/test/e2e/cases/profiling/continuous/http_avg_response_time/docker-compose.yml deleted file mode 100644 index 1c0bc746..00000000 --- a/test/e2e/cases/profiling/continuous/http_avg_response_time/docker-compose.yml +++ /dev/null @@ -1,54 +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: - service: - build: - context: ../ - dockerfile: http_avg_response_time/Dockerfile - ports: - - 10443:10443 - volumes: - - ../ssl:/ssl_data - healthcheck: - test: [ "CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/10443" ] - interval: 5s - timeout: 60s - retries: 120 - - oap: - extends: - file: ../../../../base/base-compose.yml - service: oap - ports: - - 12800:12800 - - rover: - extends: - file: ../../../../base/base-compose.yml - service: rover - environment: - ROVER_LOGGER_LEVEL: "DEBUG" - ROVER_PROCESS_DISCOVERY_SCAN_MODE: "REGEX" - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_MATCH_CMD: response_timeout - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_LAYER: OS_LINUX - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_SERVICE_NAME: test-continuous - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_INSTANCE_NAME: test-instance - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_PROCESS_NAME: "{{.Process.ExeName}}" - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_LABELS: "" -networks: - e2e: \ No newline at end of file diff --git a/test/e2e/cases/profiling/continuous/http_avg_response_time/e2e.yaml b/test/e2e/cases/profiling/continuous/http_avg_response_time/e2e.yaml index 2a517cb9..fd1e103e 100644 --- a/test/e2e/cases/profiling/continuous/http_avg_response_time/e2e.yaml +++ b/test/e2e/cases/profiling/continuous/http_avg_response_time/e2e.yaml @@ -14,10 +14,21 @@ # limitations under the License. setup: - env: compose - file: docker-compose.yml + env: kind + file: ../kind.yaml timeout: 20m init-system-environment: ../../../../base/env + kind: + import-images: + - apache/skywalking-rover:latest + - test/continuous-http_avg_response_time:test + expose-ports: + - namespace: istio-system + resource: service/skywalking-ui + port: 80 + - namespace: default + resource: service/service + port: 10443 steps: - name: set PATH command: export PATH=/tmp/skywalking-infra-e2e/bin:$PATH @@ -25,12 +36,41 @@ setup: command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh yq - name: install swctl command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh swctl + - name: Install SkyWalking + command: | + kubectl create namespace istio-system + helm -n istio-system install skywalking \ + oci://ghcr.io/apache/skywalking-helm/skywalking-helm \ + --version "0.0.0-${SW_KUBERNETES_COMMIT_SHA}" \ + --set fullnameOverride=skywalking \ + --set elasticsearch.replicas=1 \ + --set elasticsearch.minimumMasterNodes=1 \ + --set oap.replicas=1 \ + --set ui.image.repository=ghcr.io/apache/skywalking/ui \ + --set ui.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.repository=ghcr.io/apache/skywalking/oap \ + --set oap.storageType=elasticsearch \ + -f test/e2e/base/kubernetes-values.yaml + wait: + - namespace: istio-system + resource: deployments/skywalking-oap + for: condition=available + - name: Deploy services + command: | + export IMAGE_NAME=test/continuous-http_avg_response_time:test + envsubst < test/e2e/cases/profiling/continuous/service-with-entry.yaml | kubectl apply -f - + envsubst < test/e2e/cases/profiling/continuous/rover.yaml | kubectl apply -f - + wait: + - namespace: default + resource: pod + for: condition=Ready trigger: action: http interval: 3s times: 10 - url: https://${service_host}:${service_10443}/provider + url: https://${service_service_host}:${service_service_10443}/provider method: GET verify: @@ -42,27 +82,27 @@ verify: interval: 10s cases: # metadata - - query: swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml service ls + - query: swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml service ls expected: expected/service.yml - - query: swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml instance ls --service-name test-continuous + - query: swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml instance ls --service-name test-continuous expected: expected/instance.yml - - query: swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml process ls --service-name test-continuous --instance-name test-instance + - query: swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml process ls --service-name test-continuous --instance-name test-instance expected: expected/process.yml # policy setting - query: | - swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling continuous set --service-name test-continuous --config test/e2e/cases/profiling/continuous/http_avg_response_time/policy.yaml + swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling continuous set --service-name test-continuous --config test/e2e/cases/profiling/continuous/http_avg_response_time/policy.yaml expected: expected/policy-set.yml - - query: swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling continuous ls --service-name test-continuous + - query: swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling continuous ls --service-name test-continuous expected: expected/query-policy.yml # check profiling metrics - query: | - swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml metrics multiple-linear \ + swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml metrics multiple-linear \ --service-name test-continuous --instance-name test-instance --process-name response_timeout --name continuous_profiling_http_avg_response_time |yq e 'to_entries | with(.[] ; .value=(.value | to_entries))' - expected: expected/metrics-has-value-labeld.yml # check triggered profiling task - query: | - swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf list --service-name test-continuous --trigger CONTINUOUS_PROFILING + swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf list --service-name test-continuous --trigger CONTINUOUS_PROFILING expected: expected/trigger-task.yml diff --git a/test/e2e/cases/profiling/continuous/http_avg_response_time/expected/process.yml b/test/e2e/cases/profiling/continuous/http_avg_response_time/expected/process.yml index 1331630e..df44658a 100644 --- a/test/e2e/cases/profiling/continuous/http_avg_response_time/expected/process.yml +++ b/test/e2e/cases/profiling/continuous/http_avg_response_time/expected/process.yml @@ -21,7 +21,7 @@ instanceid: {{ b64enc "test-continuous" }}.1_{{ b64enc "test-instance" }} instancename: test-instance agentid: {{ notEmpty .agentid }} - detecttype: VM + detecttype: KUBERNETES attributes: {{- contains .attributes }} - name: host_ip @@ -31,5 +31,6 @@ - name: command_line value: /service/response_timeout {{- end }} - labels: [] -{{- end }} \ No newline at end of file + labels: + - k8s-service +{{- end }} diff --git a/test/e2e/cases/profiling/continuous/http_avg_response_time/expected/service.yml b/test/e2e/cases/profiling/continuous/http_avg_response_time/expected/service.yml index 09f58745..b96be6a4 100644 --- a/test/e2e/cases/profiling/continuous/http_avg_response_time/expected/service.yml +++ b/test/e2e/cases/profiling/continuous/http_avg_response_time/expected/service.yml @@ -19,6 +19,6 @@ group: "" shortname: test-continuous layers: - - OS_LINUX + - K8S_SERVICE normal: true {{- end }} \ No newline at end of file diff --git a/test/e2e/cases/profiling/continuous/http_error_rate/docker-compose.yml b/test/e2e/cases/profiling/continuous/http_error_rate/docker-compose.yml deleted file mode 100644 index 64484339..00000000 --- a/test/e2e/cases/profiling/continuous/http_error_rate/docker-compose.yml +++ /dev/null @@ -1,54 +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: - service: - build: - context: ../ - dockerfile: http_error_rate/Dockerfile - ports: - - 10443:10443 - volumes: - - ../ssl:/ssl_data - healthcheck: - test: [ "CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/10443" ] - interval: 5s - timeout: 60s - retries: 120 - - oap: - extends: - file: ../../../../base/base-compose.yml - service: oap - ports: - - 12800:12800 - - rover: - extends: - file: ../../../../base/base-compose.yml - service: rover - environment: - ROVER_LOGGER_LEVEL: "DEBUG" - ROVER_PROCESS_DISCOVERY_SCAN_MODE: "REGEX" - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_MATCH_CMD: response_error - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_LAYER: OS_LINUX - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_SERVICE_NAME: test-continuous - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_INSTANCE_NAME: test-instance - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_PROCESS_NAME: "{{.Process.ExeName}}" - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_LABELS: "" -networks: - e2e: \ No newline at end of file diff --git a/test/e2e/cases/profiling/continuous/http_error_rate/e2e.yaml b/test/e2e/cases/profiling/continuous/http_error_rate/e2e.yaml index 5c163b0b..02941684 100644 --- a/test/e2e/cases/profiling/continuous/http_error_rate/e2e.yaml +++ b/test/e2e/cases/profiling/continuous/http_error_rate/e2e.yaml @@ -14,10 +14,21 @@ # limitations under the License. setup: - env: compose - file: docker-compose.yml + env: kind + file: ../kind.yaml timeout: 20m init-system-environment: ../../../../base/env + kind: + import-images: + - apache/skywalking-rover:latest + - test/continuous-http_error_rate:test + expose-ports: + - namespace: istio-system + resource: service/skywalking-ui + port: 80 + - namespace: default + resource: service/service + port: 10443 steps: - name: set PATH command: export PATH=/tmp/skywalking-infra-e2e/bin:$PATH @@ -25,12 +36,41 @@ setup: command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh yq - name: install swctl command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh swctl + - name: Install SkyWalking + command: | + kubectl create namespace istio-system + helm -n istio-system install skywalking \ + oci://ghcr.io/apache/skywalking-helm/skywalking-helm \ + --version "0.0.0-${SW_KUBERNETES_COMMIT_SHA}" \ + --set fullnameOverride=skywalking \ + --set elasticsearch.replicas=1 \ + --set elasticsearch.minimumMasterNodes=1 \ + --set oap.replicas=1 \ + --set ui.image.repository=ghcr.io/apache/skywalking/ui \ + --set ui.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.repository=ghcr.io/apache/skywalking/oap \ + --set oap.storageType=elasticsearch \ + -f test/e2e/base/kubernetes-values.yaml + wait: + - namespace: istio-system + resource: deployments/skywalking-oap + for: condition=available + - name: Deploy services + command: | + export IMAGE_NAME=test/continuous-http_error_rate:test + envsubst < test/e2e/cases/profiling/continuous/service-with-entry.yaml | kubectl apply -f - + envsubst < test/e2e/cases/profiling/continuous/rover.yaml | kubectl apply -f - + wait: + - namespace: default + resource: pod + for: condition=Ready trigger: action: http interval: 3s times: 10 - url: https://${service_host}:${service_10443}/provider + url: https://${service_service_host}:${service_service_10443}/provider method: GET verify: @@ -42,27 +82,27 @@ verify: interval: 10s cases: # metadata - - query: swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml service ls + - query: swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml service ls expected: expected/service.yml - - query: swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml instance ls --service-name test-continuous + - query: swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml instance ls --service-name test-continuous expected: expected/instance.yml - - query: swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml process ls --service-name test-continuous --instance-name test-instance + - query: swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml process ls --service-name test-continuous --instance-name test-instance expected: expected/process.yml # policy setting - query: | - swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling continuous set --service-name test-continuous --config test/e2e/cases/profiling/continuous/http_error_rate/policy.yaml + swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling continuous set --service-name test-continuous --config test/e2e/cases/profiling/continuous/http_error_rate/policy.yaml expected: expected/policy-set.yml - - query: swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling continuous ls --service-name test-continuous + - query: swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling continuous ls --service-name test-continuous expected: expected/query-policy.yml # check profiling metrics - query: | - swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml metrics multiple-linear \ + swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml metrics multiple-linear \ --service-name test-continuous --instance-name test-instance --process-name response_error --name continuous_profiling_http_error_rate |yq e 'to_entries | with(.[] ; .value=(.value | to_entries))' - expected: expected/metrics-has-value-labeld.yml # check triggered profiling task - query: | - swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf list --service-name test-continuous --trigger CONTINUOUS_PROFILING + swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf list --service-name test-continuous --trigger CONTINUOUS_PROFILING expected: expected/trigger-task.yml diff --git a/test/e2e/cases/profiling/continuous/http_error_rate/expected/process.yml b/test/e2e/cases/profiling/continuous/http_error_rate/expected/process.yml index 9cd75664..be7cf632 100644 --- a/test/e2e/cases/profiling/continuous/http_error_rate/expected/process.yml +++ b/test/e2e/cases/profiling/continuous/http_error_rate/expected/process.yml @@ -21,7 +21,7 @@ instanceid: {{ b64enc "test-continuous" }}.1_{{ b64enc "test-instance" }} instancename: test-instance agentid: {{ notEmpty .agentid }} - detecttype: VM + detecttype: KUBERNETES attributes: {{- contains .attributes }} - name: host_ip @@ -31,5 +31,6 @@ - name: command_line value: /service/response_error {{- end }} - labels: [] + labels: + - k8s-service {{- end }} \ No newline at end of file diff --git a/test/e2e/cases/profiling/continuous/http_error_rate/expected/service.yml b/test/e2e/cases/profiling/continuous/http_error_rate/expected/service.yml index 09f58745..b96be6a4 100644 --- a/test/e2e/cases/profiling/continuous/http_error_rate/expected/service.yml +++ b/test/e2e/cases/profiling/continuous/http_error_rate/expected/service.yml @@ -19,6 +19,6 @@ group: "" shortname: test-continuous layers: - - OS_LINUX + - K8S_SERVICE normal: true {{- end }} \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/oncpu/golang/docker-compose.yml b/test/e2e/cases/profiling/continuous/kind.yaml similarity index 65% rename from test/e2e/cases/profiling/task/oncpu/golang/docker-compose.yml rename to test/e2e/cases/profiling/continuous/kind.yaml index 89645efe..10349744 100644 --- a/test/e2e/cases/profiling/task/oncpu/golang/docker-compose.yml +++ b/test/e2e/cases/profiling/continuous/kind.yaml @@ -13,30 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -version: '2.1' - -services: - oap: - extends: - file: ../../../../../base/base-compose.yml - service: oap - ports: - - 12800:12800 - - rover: - extends: - file: ../../../../../base/base-compose.yml - service: rover - depends_on: - oap: - condition: service_healthy - - sqrt_go: - build: - context: . - dockerfile: Dockerfile.sqrt - networks: - - e2e - -networks: - e2e: \ No newline at end of file +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +nodes: + - role: control-plane + image: kindest/node:v1.25.11@sha256:227fa11ce74ea76a0474eeefb84cb75d8dad1b08638371ecf0e86259b35be0c8 + extraMounts: + - hostPath: / + containerPath: /host + - hostPath: /tmp/ssl_data + containerPath: /ssl_data \ No newline at end of file diff --git a/test/e2e/cases/profiling/continuous/process_cpu/Dockerfile b/test/e2e/cases/profiling/continuous/process_cpu/Dockerfile index 432e6961..5be30072 100644 --- a/test/e2e/cases/profiling/continuous/process_cpu/Dockerfile +++ b/test/e2e/cases/profiling/continuous/process_cpu/Dockerfile @@ -17,7 +17,7 @@ FROM golang:1.17 WORKDIR / -COPY sqrt.go /sqrt.go +COPY process_cpu/sqrt.go /sqrt.go RUN go build -o sqrt sqrt.go CMD ["/sqrt"] \ No newline at end of file diff --git a/test/e2e/cases/profiling/continuous/process_cpu/docker-compose.yml b/test/e2e/cases/profiling/continuous/process_cpu/docker-compose.yml deleted file mode 100644 index 5717b7d9..00000000 --- a/test/e2e/cases/profiling/continuous/process_cpu/docker-compose.yml +++ /dev/null @@ -1,50 +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: - oap: - extends: - file: ../../../../base/base-compose.yml - service: oap - ports: - - 12800:12800 - - rover: - extends: - file: ../../../../base/base-compose.yml - service: rover - depends_on: - oap: - condition: service_healthy - environment: - ROVER_PROCESS_DISCOVERY_SCAN_MODE: "REGEX" - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_MATCH_CMD: sqrt - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_LAYER: OS_LINUX - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_SERVICE_NAME: test-continuous - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_INSTANCE_NAME: test-instance - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_PROCESS_NAME: "{{.Process.ExeName}}" - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_LABELS: "" - - continuous_process_cpu: - build: - context: . - dockerfile: Dockerfile - networks: - - e2e - -networks: - e2e: \ No newline at end of file diff --git a/test/e2e/cases/profiling/continuous/process_cpu/e2e.yaml b/test/e2e/cases/profiling/continuous/process_cpu/e2e.yaml index b6be9a20..d3ecb853 100644 --- a/test/e2e/cases/profiling/continuous/process_cpu/e2e.yaml +++ b/test/e2e/cases/profiling/continuous/process_cpu/e2e.yaml @@ -14,10 +14,18 @@ # limitations under the License. setup: - env: compose - file: docker-compose.yml + env: kind + file: ../kind.yaml timeout: 20m init-system-environment: ../../../../base/env + kind: + import-images: + - apache/skywalking-rover:latest + - test/continuous-process_cpu:test + expose-ports: + - namespace: istio-system + resource: service/skywalking-ui + port: 80 steps: - name: set PATH command: export PATH=/tmp/skywalking-infra-e2e/bin:$PATH @@ -25,6 +33,35 @@ setup: command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh yq - name: install swctl command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh swctl + - name: Install SkyWalking + command: | + kubectl create namespace istio-system + helm -n istio-system install skywalking \ + oci://ghcr.io/apache/skywalking-helm/skywalking-helm \ + --version "0.0.0-${SW_KUBERNETES_COMMIT_SHA}" \ + --set fullnameOverride=skywalking \ + --set elasticsearch.replicas=1 \ + --set elasticsearch.minimumMasterNodes=1 \ + --set oap.replicas=1 \ + --set ui.image.repository=ghcr.io/apache/skywalking/ui \ + --set ui.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.repository=ghcr.io/apache/skywalking/oap \ + --set oap.storageType=elasticsearch \ + -f test/e2e/base/kubernetes-values.yaml + wait: + - namespace: istio-system + resource: deployments/skywalking-oap + for: condition=available + - name: Deploy services + command: | + export IMAGE_NAME=test/continuous-process_cpu:test + envsubst < test/e2e/cases/profiling/continuous/service.yaml | kubectl apply -f - + envsubst < test/e2e/cases/profiling/continuous/rover.yaml | kubectl apply -f - + wait: + - namespace: default + resource: pod + for: condition=Ready verify: # verify with retry strategy @@ -35,27 +72,27 @@ verify: interval: 10s cases: # metadata - - query: swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml service ls + - query: swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml service ls expected: expected/service.yml - - query: swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml instance ls --service-name test-continuous + - query: swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml instance ls --service-name test-continuous expected: expected/instance.yml - - query: swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml process ls --service-name test-continuous --instance-name test-instance + - query: swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml process ls --service-name test-continuous --instance-name test-instance expected: expected/process.yml # policy setting - query: | - swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling continuous set --service-name test-continuous --config test/e2e/cases/profiling/continuous/process_cpu/policy.yaml + swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling continuous set --service-name test-continuous --config test/e2e/cases/profiling/continuous/process_cpu/policy.yaml expected: expected/policy-set.yml - - query: swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling continuous ls --service-name test-continuous + - query: swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling continuous ls --service-name test-continuous expected: expected/query-policy.yml # check profiling metrics - query: | - swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml metrics linear \ + swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml metrics linear \ --service-name test-continuous --instance-name test-instance --process-name sqrt --name continuous_profiling_process_cpu |yq e 'to_entries' - expected: expected/metrics-has-value.yml # check triggered profiling task - query: | - swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf list --service-name test-continuous --trigger CONTINUOUS_PROFILING + swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf list --service-name test-continuous --trigger CONTINUOUS_PROFILING expected: expected/trigger-task.yml diff --git a/test/e2e/cases/profiling/continuous/process_cpu/expected/process.yml b/test/e2e/cases/profiling/continuous/process_cpu/expected/process.yml index c73cff5f..a3e54391 100644 --- a/test/e2e/cases/profiling/continuous/process_cpu/expected/process.yml +++ b/test/e2e/cases/profiling/continuous/process_cpu/expected/process.yml @@ -21,7 +21,7 @@ instanceid: {{ b64enc "test-continuous" }}.1_{{ b64enc "test-instance" }} instancename: test-instance agentid: {{ notEmpty .agentid }} - detecttype: VM + detecttype: KUBERNETES attributes: {{- contains .attributes }} - name: host_ip @@ -31,5 +31,6 @@ - name: command_line value: /sqrt {{- end }} - labels: [] + labels: + - k8s-service {{- end }} \ No newline at end of file diff --git a/test/e2e/cases/profiling/continuous/process_cpu/expected/service.yml b/test/e2e/cases/profiling/continuous/process_cpu/expected/service.yml index 09f58745..b96be6a4 100644 --- a/test/e2e/cases/profiling/continuous/process_cpu/expected/service.yml +++ b/test/e2e/cases/profiling/continuous/process_cpu/expected/service.yml @@ -19,6 +19,6 @@ group: "" shortname: test-continuous layers: - - OS_LINUX + - K8S_SERVICE normal: true {{- end }} \ No newline at end of file diff --git a/test/e2e/cases/profiling/continuous/process_thread_count/Dockerfile b/test/e2e/cases/profiling/continuous/process_thread_count/Dockerfile index 42bca1e3..35b5bc1e 100644 --- a/test/e2e/cases/profiling/continuous/process_thread_count/Dockerfile +++ b/test/e2e/cases/profiling/continuous/process_thread_count/Dockerfile @@ -17,7 +17,7 @@ FROM eclipse-temurin:11-jdk WORKDIR / -COPY MultiThread.java / +COPY process_thread_count/MultiThread.java / RUN javac /MultiThread.java diff --git a/test/e2e/cases/profiling/continuous/process_thread_count/docker-compose.yml b/test/e2e/cases/profiling/continuous/process_thread_count/docker-compose.yml deleted file mode 100644 index 0373a564..00000000 --- a/test/e2e/cases/profiling/continuous/process_thread_count/docker-compose.yml +++ /dev/null @@ -1,50 +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: - oap: - extends: - file: ../../../../base/base-compose.yml - service: oap - ports: - - 12800:12800 - - rover: - extends: - file: ../../../../base/base-compose.yml - service: rover - depends_on: - oap: - condition: service_healthy - environment: - ROVER_PROCESS_DISCOVERY_SCAN_MODE: "REGEX" - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_MATCH_CMD: MultiThread - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_LAYER: OS_LINUX - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_SERVICE_NAME: test-continuous - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_INSTANCE_NAME: test-instance - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_PROCESS_NAME: "{{.Process.ExeName}}" - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_LABELS: "" - - continuous_process_thread: - build: - context: . - dockerfile: Dockerfile - networks: - - e2e - -networks: - e2e: \ No newline at end of file diff --git a/test/e2e/cases/profiling/continuous/process_thread_count/e2e.yaml b/test/e2e/cases/profiling/continuous/process_thread_count/e2e.yaml index c6111af4..edf729fd 100644 --- a/test/e2e/cases/profiling/continuous/process_thread_count/e2e.yaml +++ b/test/e2e/cases/profiling/continuous/process_thread_count/e2e.yaml @@ -14,10 +14,18 @@ # limitations under the License. setup: - env: compose - file: docker-compose.yml + env: kind + file: ../kind.yaml timeout: 20m init-system-environment: ../../../../base/env + kind: + import-images: + - apache/skywalking-rover:latest + - test/continuous-process_thread_count:test + expose-ports: + - namespace: istio-system + resource: service/skywalking-ui + port: 80 steps: - name: set PATH command: export PATH=/tmp/skywalking-infra-e2e/bin:$PATH @@ -25,6 +33,35 @@ setup: command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh yq - name: install swctl command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh swctl + - name: Install SkyWalking + command: | + kubectl create namespace istio-system + helm -n istio-system install skywalking \ + oci://ghcr.io/apache/skywalking-helm/skywalking-helm \ + --version "0.0.0-${SW_KUBERNETES_COMMIT_SHA}" \ + --set fullnameOverride=skywalking \ + --set elasticsearch.replicas=1 \ + --set elasticsearch.minimumMasterNodes=1 \ + --set oap.replicas=1 \ + --set ui.image.repository=ghcr.io/apache/skywalking/ui \ + --set ui.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.repository=ghcr.io/apache/skywalking/oap \ + --set oap.storageType=elasticsearch \ + -f test/e2e/base/kubernetes-values.yaml + wait: + - namespace: istio-system + resource: deployments/skywalking-oap + for: condition=available + - name: Deploy services + command: | + export IMAGE_NAME=test/continuous-process_thread_count:test + envsubst < test/e2e/cases/profiling/continuous/service.yaml | kubectl apply -f - + envsubst < test/e2e/cases/profiling/continuous/rover.yaml | kubectl apply -f - + wait: + - namespace: default + resource: pod + for: condition=Ready verify: # verify with retry strategy @@ -35,27 +72,27 @@ verify: interval: 10s cases: # metadata - - query: swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml service ls + - query: swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml service ls expected: expected/service.yml - - query: swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml instance ls --service-name test-continuous + - query: swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml instance ls --service-name test-continuous expected: expected/instance.yml - - query: swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml process ls --service-name test-continuous --instance-name test-instance + - query: swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml process ls --service-name test-continuous --instance-name test-instance expected: expected/process.yml # policy setting - query: | - swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling continuous set --service-name test-continuous --config test/e2e/cases/profiling/continuous/process_thread_count/policy.yaml + swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling continuous set --service-name test-continuous --config test/e2e/cases/profiling/continuous/process_thread_count/policy.yaml expected: expected/policy-set.yml - - query: swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling continuous ls --service-name test-continuous + - query: swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling continuous ls --service-name test-continuous expected: expected/query-policy.yml # check profiling metrics - query: | - swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml metrics linear \ + swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml metrics linear \ --service-name test-continuous --instance-name test-instance --process-name java --name continuous_profiling_process_thread_count |yq e 'to_entries' - expected: expected/metrics-has-value.yml # check triggered profiling task - query: | - swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf list --service-name test-continuous --trigger CONTINUOUS_PROFILING + swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf list --service-name test-continuous --trigger CONTINUOUS_PROFILING expected: expected/trigger-task.yml diff --git a/test/e2e/cases/profiling/continuous/process_thread_count/expected/process.yml b/test/e2e/cases/profiling/continuous/process_thread_count/expected/process.yml index b6d26ae3..68cda8b9 100644 --- a/test/e2e/cases/profiling/continuous/process_thread_count/expected/process.yml +++ b/test/e2e/cases/profiling/continuous/process_thread_count/expected/process.yml @@ -21,7 +21,7 @@ instanceid: {{ b64enc "test-continuous" }}.1_{{ b64enc "test-instance" }} instancename: test-instance agentid: {{ notEmpty .agentid }} - detecttype: VM + detecttype: KUBERNETES attributes: {{- contains .attributes }} - name: host_ip @@ -29,5 +29,6 @@ - name: pid value: {{ notEmpty .value }} {{- end }} - labels: [] + labels: + - k8s-service {{- end }} \ No newline at end of file diff --git a/test/e2e/cases/profiling/continuous/process_thread_count/expected/service.yml b/test/e2e/cases/profiling/continuous/process_thread_count/expected/service.yml index 09f58745..b96be6a4 100644 --- a/test/e2e/cases/profiling/continuous/process_thread_count/expected/service.yml +++ b/test/e2e/cases/profiling/continuous/process_thread_count/expected/service.yml @@ -19,6 +19,6 @@ group: "" shortname: test-continuous layers: - - OS_LINUX + - K8S_SERVICE normal: true {{- end }} \ No newline at end of file diff --git a/test/e2e/cases/profiling/continuous/rover.yaml b/test/e2e/cases/profiling/continuous/rover.yaml new file mode 100644 index 00000000..2b32bf2b --- /dev/null +++ b/test/e2e/cases/profiling/continuous/rover.yaml @@ -0,0 +1,105 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: v1 +kind: ServiceAccount +metadata: + name: skywalking-rover +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: skywalking-rover +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: skywalking-rover +subjects: + - kind: ServiceAccount + name: skywalking-rover + namespace: default +--- +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: skywalking-rover +rules: + - apiGroups: [""] + resources: ["pods", "nodes", "services"] + verbs: ["get", "watch", "list"] +--- + +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: skywalking-rover +spec: + selector: + matchLabels: + name: skywalking-rover + template: + metadata: + labels: + name: skywalking-rover + spec: + serviceAccountName: skywalking-rover + serviceAccount: skywalking-rover + containers: + - name: skywalking-rover + # SkyWalking Rover image path + image: apache/skywalking-rover:latest + imagePullPolicy: IfNotPresent + securityContext: + capabilities: + add: + - SYS_PTRACE + - SYS_ADMIN + privileged: true + volumeMounts: + - name: host + mountPath: /host + readOnly: true + env: + - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_ACTIVE + value: "true" + - name: ROVER_LOGGER_LEVEL + value: "DEBUG" + - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: ROVER_BACKEND_ADDR + # backend OAP address + value: skywalking-oap.istio-system:11800 + - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_ISTIO_ENVOY_ACTIVE + value: "false" + - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_ISTIO_APPLICATION_ACTIVE + value: "false" + - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_K8S_SERVICE_HAS_SERVICE + value: '.Pod.HasContainer "test-continuous"' + - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_K8S_SERVICE_NAME + value: "test-continuous" + - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_K8S_SERVICE_INSTANCE_NAME + value: "test-instance" + - name: ROVER_HOST_MAPPING + value: /host + hostPID: true + hostNetwork: true + dnsPolicy: ClusterFirstWithHostNet + volumes: + - name: host + hostPath: + path: /host + type: Directory \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/offcpu/c++/docker-compose.yml b/test/e2e/cases/profiling/continuous/service-with-entry.yaml similarity index 53% rename from test/e2e/cases/profiling/task/offcpu/c++/docker-compose.yml rename to test/e2e/cases/profiling/continuous/service-with-entry.yaml index 6839a91e..48282055 100644 --- a/test/e2e/cases/profiling/task/offcpu/c++/docker-compose.yml +++ b/test/e2e/cases/profiling/continuous/service-with-entry.yaml @@ -13,33 +13,42 @@ # See the License for the specific language governing permissions and # limitations under the License. -version: '2.1' +apiVersion: apps/v1 +kind: Deployment +metadata: + name: continuous-deployment +spec: + replicas: 1 + selector: + matchLabels: + app: continuous + template: + metadata: + labels: + app: continuous + spec: + containers: + - name: test-continuous + image: ${IMAGE_NAME} + volumeMounts: + - name: ssl-volume + mountPath: /ssl_data + volumes: + - name: ssl-volume + hostPath: + path: /ssl_data + type: Directory -services: - oap: - extends: - file: ../../../../../base/base-compose.yml - service: oap - ports: - - 12800:12800 +--- - rover: - extends: - file: ../../../../../base/base-compose.yml - service: rover - environment: - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_MATCH_CMD: /file - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_SERVICE_NAME: file - depends_on: - oap: - condition: service_healthy - - file_c_plus_plus: - build: - context: . - dockerfile: Dockerfile.file - networks: - - e2e - -networks: - e2e: \ No newline at end of file +apiVersion: v1 +kind: Service +metadata: + name: service +spec: + selector: + app: continuous + ports: + - protocol: TCP + port: 10443 + targetPort: 10443 diff --git a/test/e2e/cases/profiling/task/oncpu/rust/docker-compose.yml b/test/e2e/cases/profiling/continuous/service.yaml similarity index 65% rename from test/e2e/cases/profiling/task/oncpu/rust/docker-compose.yml rename to test/e2e/cases/profiling/continuous/service.yaml index b9b5ee00..e95c733b 100644 --- a/test/e2e/cases/profiling/task/oncpu/rust/docker-compose.yml +++ b/test/e2e/cases/profiling/continuous/service.yaml @@ -13,30 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License. -version: '2.1' - -services: - oap: - extends: - file: ../../../../../base/base-compose.yml - service: oap - ports: - - 12800:12800 - - rover: - extends: - file: ../../../../../base/base-compose.yml - service: rover - depends_on: - oap: - condition: service_healthy - - sqrt_rust: - build: - context: . - dockerfile: Dockerfile.sqrt - networks: - - e2e - -networks: - e2e: \ No newline at end of file +apiVersion: apps/v1 +kind: Deployment +metadata: + name: continuous-deployment +spec: + replicas: 1 + selector: + matchLabels: + app: continuous + template: + metadata: + labels: + app: continuous + spec: + containers: + - name: test-continuous + image: ${IMAGE_NAME} \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/network/base-cases.yaml b/test/e2e/cases/profiling/task/network/base-cases.yaml index a52484b2..2a068ea0 100644 --- a/test/e2e/cases/profiling/task/network/base-cases.yaml +++ b/test/e2e/cases/profiling/task/network/base-cases.yaml @@ -15,47 +15,47 @@ cases: # service list - - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql service ls + - query: swctl --display yaml --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql service ls expected: expected/service.yml # service instance list - - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql instance list --service-name=service + - query: swctl --display yaml --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql instance list --service-name=service expected: expected/instance.yml - - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql process list --service-name=service --instance-name=test + - query: swctl --display yaml --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql process list --service-name=service --instance-name=test expected: expected/process.yml # create network profiling task - - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql profiling ebpf create network --service-name=service --instance-name=test --sampling-config=test/e2e/cases/profiling/task/network/sampling.yaml + - query: swctl --display yaml --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql profiling ebpf create network --service-name=service --instance-name=test --sampling-config=test/e2e/cases/profiling/task/network/sampling.yaml expected: expected/profiling-create.yml - - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql dep process --service-name service --instance-name=test + - query: swctl --display yaml --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql dep process --service-name service --instance-name=test expected: expected/dependency-processs.yml # single value of process relation, client/server side read/write - query: | - swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear \ + swctl --display yaml --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql metrics linear \ --service-name service --instance-name test --process-name service \ --dest-service-name service --dest-instance-name test --dest-process-name UNKNOWN_REMOTE \ --name process_relation_client_write_cpm|yq e 'to_entries' - expected: expected/metrics-has-value.yml - query: | - swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear \ + swctl --display yaml --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql metrics linear \ --service-name service --instance-name test --process-name service \ --dest-service-name service --dest-instance-name test --dest-process-name UNKNOWN_REMOTE \ --name process_relation_client_write_total_bytes|yq e 'to_entries' - expected: expected/metrics-has-value.yml - query: | - swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear \ + swctl --display yaml --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql metrics linear \ --service-name service --instance-name test --process-name service \ --dest-service-name service --dest-instance-name test --dest-process-name UNKNOWN_REMOTE \ --name process_relation_client_write_avg_exe_time|yq e 'to_entries' - expected: expected/metrics-has-value.yml - query: | - swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear \ + swctl --display yaml --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql metrics linear \ --service-name service --instance-name test --process-name service \ --dest-service-name service --dest-instance-name test --dest-process-name UNKNOWN_REMOTE \ --name process_relation_client_read_cpm|yq e 'to_entries' - expected: expected/metrics-has-value.yml - query: | - swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear \ + swctl --display yaml --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql metrics linear \ --service-name service --instance-name test --process-name UNKNOWN_REMOTE \ --dest-service-name service --dest-instance-name test --dest-process-name service \ --name process_relation_server_write_cpm|yq e 'to_entries' - @@ -63,31 +63,31 @@ cases: # histogram value of process relation, client side write_rtt/write_exe/read time - query: | - swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics multiple-linear \ + swctl --display yaml --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql metrics multiple-linear \ --service-name service --instance-name test --process-name service \ --dest-service-name service --dest-instance-name test --dest-process-name UNKNOWN_REMOTE \ --name=process_relation_client_write_rtt_time_percentile|yq e 'to_entries | with(.[] ; .value=(.value | to_entries))' - expected: expected/metrics-has-value-label.yml - query: | - swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics multiple-linear \ + swctl --display yaml --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql metrics multiple-linear \ --service-name service --instance-name test --process-name service \ --dest-service-name service --dest-instance-name test --dest-process-name UNKNOWN_REMOTE \ --name=process_relation_client_write_exe_time_percentile|yq e 'to_entries | with(.[] ; .value=(.value | to_entries))' - expected: expected/metrics-has-value-label.yml - query: | - swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics multiple-linear \ + swctl --display yaml --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql metrics multiple-linear \ --service-name service --instance-name test --process-name UNKNOWN_REMOTE \ --dest-service-name service --dest-instance-name test --dest-process-name service \ --name=process_relation_server_write_rtt_time_percentile|yq e 'to_entries | with(.[] ; .value=(.value | to_entries))' - expected: expected/metrics-has-value-label.yml - query: | - swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics multiple-linear \ + swctl --display yaml --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql metrics multiple-linear \ --service-name service --instance-name test --process-name UNKNOWN_REMOTE \ --dest-service-name service --dest-instance-name test --dest-process-name service \ --name=process_relation_server_write_exe_time_percentile|yq e 'to_entries | with(.[] ; .value=(.value | to_entries))' - expected: expected/metrics-has-value-label.yml - query: | - swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics multiple-linear \ + swctl --display yaml --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql metrics multiple-linear \ --service-name service --instance-name test --process-name UNKNOWN_REMOTE \ --dest-service-name service --dest-instance-name test --dest-process-name service \ --name=process_relation_server_write_exe_time_percentile|yq e 'to_entries | with(.[] ; .value=(.value | to_entries))' - diff --git a/test/e2e/cases/profiling/task/network/base/Dockerfile.nginx b/test/e2e/cases/profiling/task/network/base/Dockerfile.nginx index e36cf383..1730ab18 100644 --- a/test/e2e/cases/profiling/task/network/base/Dockerfile.nginx +++ b/test/e2e/cases/profiling/task/network/base/Dockerfile.nginx @@ -18,3 +18,5 @@ FROM nginx COPY ssl /usr/local/share/ca-certificates/ssl RUN update-ca-certificates + +ADD nginx.conf /etc/nginx/nginx.conf \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/network/base/docker-compose.yml b/test/e2e/cases/profiling/task/network/base/docker-compose.yml deleted file mode 100644 index 0e3b5287..00000000 --- a/test/e2e/cases/profiling/task/network/base/docker-compose.yml +++ /dev/null @@ -1,76 +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: - proxy: - build: - context: . - dockerfile: Dockerfile.nginx - networks: - - e2e - volumes: - - ./ssl:/ssl_data - - ./nginx.conf:/etc/nginx/nginx.conf - expose: - - 443 - healthcheck: - test: [ "CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/80" ] - interval: 5s - timeout: 60s - retries: 120 - - service: - build: - context: . - dockerfile: Dockerfile - networks: - - e2e - volumes: - - ./ssl:/ssl_data - ports: - - 10443:10443 - healthcheck: - test: [ "CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/10443" ] - interval: 5s - timeout: 60s - retries: 120 - - oap: - extends: - file: ../../../../../base/base-compose.yml - service: oap - environment: - SW_METER_ANALYZER_ACTIVE_FILES: network-profiling - SW_LOG_LAL_FILES: slow-trace-lal - SW_RECEIVER_ZIPKIN: default - SW_QUERY_ZIPKIN: default - volumes: - - ./network-profiling.yaml:/skywalking/config/meter-analyzer-config/network-profiling.yaml - - ./slow-trace-lal.yaml:/skywalking/config/lal/slow-trace-lal.yaml - ports: - - 12800:12800 - - 9411:9411 - - 9412:9412 - - rover: - extends: - file: ../../../../../base/base-compose.yml - service: rover - volumes: - - ./rover_configs.yaml:/skywalking/configs/rover_configs.yaml -networks: - e2e: \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/network/base/nginx.conf b/test/e2e/cases/profiling/task/network/base/nginx.conf index 57d8cfe8..b9a7d6c3 100644 --- a/test/e2e/cases/profiling/task/network/base/nginx.conf +++ b/test/e2e/cases/profiling/task/network/base/nginx.conf @@ -28,12 +28,12 @@ http { ssl_certificate_key /ssl_data/proxy.key; location /provider { - proxy_pass https://service:10443/provider; + proxy_pass https://service.default:10443/provider; proxy_http_version 1.1; } location /provider-zipkin { - proxy_pass https://service:10443/provider-zipkin; + proxy_pass https://service.default:10443/provider-zipkin; proxy_http_version 1.1; } } @@ -48,7 +48,7 @@ http { ssl_certificate_key /ssl_data/proxy.key; location / { - grpc_pass grpcs://service:9000; + grpc_pass grpcs://service.default:9000; } } } \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/network/base/rover_configs.yaml b/test/e2e/cases/profiling/task/network/base/rover_configs.yaml deleted file mode 100644 index 1f0def52..00000000 --- a/test/e2e/cases/profiling/task/network/base/rover_configs.yaml +++ /dev/null @@ -1,168 +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. -# - -logger: - # The lowest level of printing allowed. - level: ${ROVER_LOGGER_LEVEL:DEBUG} - -core: - backend: - # The backend server address - addr: ${ROVER_BACKEND_ADDR:localhost:11800} - # The TLS switch - enable_TLS: ${ROVER_BACKEND_ENABLE_TLS:false} - # The file path of client.pem. The config only works when opening the TLS switch. - client_pem_path: ${ROVER_BACKEND_PEM_PATH:"client.pem"} - # The file path of client.key. The config only works when opening the TLS switch. - client_key_path: ${ROVER_BACKEND_KEY_PATH:"client.key"} - # InsecureSkipVerify controls whether a client verifies the server's certificate chain and host name. - insecure_skip_verify: ${ROVER_BACKEND_INSECURE_SKIP_VERIFY:false} - # The file path oca.pem. The config only works when opening the TLS switch. - ca_pem_path: ${ROVER_BACKEND_CA_PEM_PATH:"ca.pem"} - # How frequently to check the connection(second) - check_period: ${ROVER_BACKEND_CHECK_PERIOD:5} - # The auth value when send request - authentication: ${ROVER_BACKEND_AUTHENTICATION:""} - -process_discovery: - # The period of report or keep alive process(second) - heartbeat_period: ${ROVER_PROCESS_DISCOVERY_HEARTBEAT_PERIOD:20s} - # The agent sends the process properties to the backend every: heartbeart period * properties report period - properties_report_period: ${ROVER_PROCESS_DISCOVERY_PROPERTIES_REPORT_PERIOD:10} - # Scan process from linux - scanner: - # The period to detect the process - period: ${ROVER_PROCESS_DISCOVERY_SCAN_PERIOD:3s} - # The process detection modes of the scanner. Support "REGEX", "AGENT_SENSOR" - mode: ${ROVER_PROCESS_DISCOVERY_SCAN_MODE:REGEX} - agent: - # Set the agent refresh period - process_status_refresh_period: ${ROVER_PROCESS_DISCOVERY_AGENT_PROCESS_STATUS_REFRESH_PERIOD:1m} - regex: - # Use regex string to locate the processes - # Duplicate entities cannot be reported. If multiple entity are generated, only one process will be report - # If the multiple finders could match the same one process, only the first finder could be selected and report - - match_cmd: ${ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_MATCH_CMD1:nginx} - # The Layer need to relate to the process entity - layer: ${ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_LAYER1:OS_LINUX} - # The Service Name need to relate to the process entity - service_name: ${ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_SERVICE_NAME1:nginx} - # The Service Instance Name need to relate to the process entity - # By default the instance name is the host IP v4 address from "en0" net interface - instance_name: ${ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_INSTANCE_NAME1:test} - # The Process Name need to relate to the process entity - # By default, the process name is the executable name of the process - process_name: ${ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_PROCESS_NAME1:{{.Process.ExeName}}-{{.Process.Pid}}} - # The Process Labels, used to aggregate similar process from service entity - # Multiple labels split by "," - labels: ${ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_LABELS:} - - match_cmd: ${ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_MATCH_CMD2:/service$} - # The Layer need to relate to the process entity - layer: ${ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_LAYER2:OS_LINUX} - # The Service Name need to relate to the process entity - service_name: ${ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_SERVICE_NAME2:service} - # The Service Instance Name need to relate to the process entity - # By default the instance name is the host IP v4 address from "en0" net interface - instance_name: ${ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_INSTANCE_NAME2:test} - # The Process Name need to relate to the process entity - # By default, the process name is the executable name of the process - process_name: ${ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_PROCESS_NAME2:{{.Process.ExeName}}} - # The Process Labels, used to aggregate similar process from service entity - # Multiple labels split by "," - labels: ${ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_LABELS:} - kubernetes: - # Is active the kubernetes process detector - active: ${ROVER_PROCESS_DISCOVERY_KUBERNETES_ACTIVE:false} - # Current node name in kubernetes environment - node_name: ${ROVER_PROCESS_DISCOVERY_KUBERNETES_NODE_NAME:} - # include namespaces, multiple namespace split by ",", if empty means including all namespaces - namespaces: ${ROVER_PROCESS_DISCOVERY_KUBERNETES_NAMESPACES:} - analyzers: - - active: ${ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_ISTIO_ENVOY_ACTIVE:true} - filters: - - ${ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_ISTIO_ENVOY_HAS_ENVOY:.Pod.HasContainer "istio-proxy"} - - ${ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_ISTIO_ENVOY_CONTAINER_IS_ENVOY:eq .Container.Name "istio-proxy"} - layer: ${ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_ISTIO_ENVOY_LAYER:MESH_DP} - service_name: ${ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_ISTIO_ENVOY_SERVICE_NAME:{{.Pod.Namespace}}::{{.Pod.LabelValue "service.istio.io/canonical-name,app.kubernetes.io/name,app" ""}}} - instance_name: ${ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_ISTIO_ENVOY_INSTANCE_NAME:{{.Pod.Name}}} - process_name: ${ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_ISTIO_ENVOY_PROCESS_NAME:{{.Process.ExeName}}} - labels: ${ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_ISTIO_ENVOY_LABELS:mesh-envoy} - - active: ${ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_ISTIO_APPLICATION_ACTIVE:true} - filters: - - ${ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_ISTIO_APPLICATION_HAS_ENVOY:.Pod.HasContainer "istio-proxy"} - - ${ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_ISTIO_APPLICATION_CONTAINER_NOT_ENVOY:ne .Container.Name "istio-proxy"} - layer: ${ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_ISTIO_APPLICATION_LAYER:MESH} - service_name: ${ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_ISTIO_APPLICATION_SERVICE_NAME:{{.Pod.Namespace}}::{{.Pod.LabelValue "service.istio.io/canonical-name,app.kubernetes.io/name,app" ""}}} - instance_name: ${ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_ISTIO_APPLICATION_INSTANCE_NAME:{{.Pod.Name}}} - process_name: ${ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_ISTIO_APPLICATION_PROCESS_NAME:{{.Process.ExeName}}} - labels: ${ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_ISTIO_APPLICATION_LABELS:mesh-application} - - active: ${ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_K8S_SERVICE_ACTIVE:true} - filters: - - ${ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_K8S_SERVICE_HAS_SERVICE:.Pod.HasServiceName} - layer: ${ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_K8S_SERVICE_LAYER:K8S_SERVICE} - service_name: ${ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_K8S_SERVICE_NAME:{{.Pod.Namespace}}::{{.Pod.ServiceName}}} - instance_name: ${ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_K8S_SERVICE_INSTANCE_NAME:{{.Pod.Name}}} - process_name: ${ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_K8S_SERVICE_PROCESS_NAME:{{.Process.ExeName}}} - labels: ${ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_K8S_SERVICE_LABLES:k8s-service} - -profiling: - # Is active the process profiling - active: ${ROVER_PROFILING_ACTIVE:true} - # Check the profiling task interval - check_interval: ${ROVER_PROFILING_CHECK_INTERVAL:10s} - # Combine existing profiling data and report to the backend interval - flush_interval: ${ROVER_PROFILING_FLUSH_INTERVAL:5s} - # Customize profiling task config - task: - # The config when executing ON_CPU profiling task - on_cpu: - # The profiling stack dump period - dump_period: ${ROVER_PROFILING_TASK_ON_CPU_DUMP_PERIOD:9ms} - network: - # The interval of send metrics to the backend - report_interval: ${ROVER_PROFILING_TASK_NETWORK_TOPOLOGY_REPORT_INTERVAL:2s} - # The prefix of network profiling metrics name - meter_prefix: ${ROVER_PROFILING_TASK_NETWORK_TOPOLOGY_METER_PREFIX:rover_net_p} - # The protocol analyzer config for 7-Layer - protocol_analyze: - # The size of socket data buffer on each CPU - per_cpu_buffer: ${ROVER_PROFILING_TASK_NETWORK_PROTOCOL_ANALYZE_PER_CPU_BUFFER:400KB} - # The count of parallel protocol analyzer - parallels: ${ROVER_PROFILING_TASK_NETWORK_PROTOCOL_ANALYZE_PARALLELS:2} - # The size of per paralleled analyzer queue - queue_size: ${ROVER_PROFILING_TASK_NETWORK_PROTOCOL_ANALYZE_QUEUE_SIZE:5000} - # The profiling config of the protocols - sampling: - # The HTTP/1.x and HTTP/2.x profiling config - http: - # The default body encoding when sampling the request - default_request_encoding: ${ROVER_PROFILING_TASK_NETWORK_PROTOCOL_ANALYZE_SAMPLING_HTTP_DEFAULT_REQUEST_ENCODING:UTF-8} - # The default body encoding when sampling the response - default_response_encoding: ${ROVER_PROFILING_TASK_NETWORK_PROTOCOL_ANALYZE_SAMPLING_HTTP_DEFAULT_RESPONSE_ENCODING:UTF-8} - # continuous profiling config - continuous: - # continuous related meters prefix name - meter_prefix: ${ROVER_PROFILING_CONTINUOUS_METER_PREFIX:rover_con_p} - # The interval of fetch metrics from the system, such as Process CPU, System Load, etc. - fetch_interval: ${ROVER_PROFILING_CONTINUOUS_FETCH_INTERVAL:1s} - # The interval of check metrics is reach the thresholds - check_interval: ${ROVER_PROFILING_CONTINUOUS_CHECK_INTERVAL:5s} - trigger: - # the duration of the profiling task - execute_duration: ${ROVER_PROFILING_CONTINUOUS_TRIGGER_EXECUTE_DURATION:10m} - # the minimal duration between the execution of the same profiling task - silence_duration: ${ROVER_PROFILING_CONTINUOUS_TRIGGER_SILENCE_DURATION:20m} \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/network/base/ssl/gen-selfsigned-ssl.sh b/test/e2e/cases/profiling/task/network/base/ssl/gen-selfsigned-ssl.sh deleted file mode 100755 index 18735325..00000000 --- a/test/e2e/cases/profiling/task/network/base/ssl/gen-selfsigned-ssl.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/bash -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -set -e - -HOST=${1:-localhost} -PASSWORD=test -CUR_DIR="$(cd "$(dirname "$0")" && pwd)" - -root_key="$CUR_DIR/root_${HOST}.key" -root_csr="$CUR_DIR/root_${HOST}.csr" -root_crt="$CUR_DIR/root_${HOST}.crt" - -key="$CUR_DIR/${HOST}.key" -csr="$CUR_DIR/${HOST}.csr" -crt="$CUR_DIR/${HOST}.crt" - -CountryName=CN -StateORProvinceName=beijing -LocalityName=beijing -OrgName=sky -OrgUnitName=sky -CommonName=$HOST -Email=xx@gmail.com -ChallengePwd=. -OptionalComName=. - -# root ca -openssl genrsa -des3 -out $root_key -passout pass:$PASSWORD 2048 - -openssl req -new -key $root_key -out $root_csr -passin pass:$PASSWORD -passout pass:$PASSWORD < /dev/tcp/127.0.0.1/10443" ] - interval: 5s - timeout: 60s - retries: 120 - - proxy: - extends: - file: ../base/docker-compose.yml - service: proxy - networks: - - e2e - depends_on: - service: - condition: service_healthy - - oap: - extends: - file: ../base/docker-compose.yml - service: oap - ports: - - 12800:12800 - - rover: - extends: - file: ../base/docker-compose.yml - service: rover - depends_on: - oap: - condition: service_healthy - -networks: - e2e: \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/network/c_plus_plus/e2e.yaml b/test/e2e/cases/profiling/task/network/c_plus_plus/e2e.yaml index e12faa2d..5e167eb2 100644 --- a/test/e2e/cases/profiling/task/network/c_plus_plus/e2e.yaml +++ b/test/e2e/cases/profiling/task/network/c_plus_plus/e2e.yaml @@ -14,10 +14,22 @@ # limitations under the License. setup: - env: compose - file: docker-compose.yml + env: kind + file: ../kind.yaml timeout: 20m init-system-environment: ../../../../../base/env + kind: + import-images: + - apache/skywalking-rover:latest + - test/network-c_plus_plus:test + - test/test-nginx:test + expose-ports: + - namespace: istio-system + resource: service/skywalking-ui + port: 80 + - namespace: default + resource: service/service + port: 10443 steps: - name: set PATH command: export PATH=/tmp/skywalking-infra-e2e/bin:$PATH @@ -25,12 +37,43 @@ setup: command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh yq - name: install swctl command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh swctl + - name: Install SkyWalking + command: | + kubectl create namespace istio-system + helm -n istio-system install skywalking \ + oci://ghcr.io/apache/skywalking-helm/skywalking-helm \ + --version "0.0.0-${SW_KUBERNETES_COMMIT_SHA}" \ + --set fullnameOverride=skywalking \ + --set elasticsearch.replicas=1 \ + --set elasticsearch.minimumMasterNodes=1 \ + --set oap.replicas=1 \ + --set ui.image.repository=ghcr.io/apache/skywalking/ui \ + --set ui.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.repository=ghcr.io/apache/skywalking/oap \ + --set oap.storageType=elasticsearch \ + --set oap.ports.zipkinreceiver=9411 \ + --set oap.ports.zipkinquery=9412 \ + -f test/e2e/cases/profiling/task/network/kubernetes-values.yaml + wait: + - namespace: istio-system + resource: deployments/skywalking-oap + for: condition=available + - name: Deploy services + command: | + export IMAGE_NAME=test/network-c_plus_plus:test + envsubst < test/e2e/cases/profiling/task/network/service.yaml | kubectl apply -f - + envsubst < test/e2e/cases/profiling/task/network/rover.yaml | kubectl apply -f - + wait: + - namespace: default + resource: pod + for: condition=Ready trigger: action: http interval: 3s times: 10 - url: https://${service_host}:${service_10443}/consumer + url: https://${service_service_host}:${service_service_10443}/consumer method: GET verify: diff --git a/test/e2e/cases/profiling/task/network/expected/process.yml b/test/e2e/cases/profiling/task/network/expected/process.yml index 869ae068..d24a4e86 100644 --- a/test/e2e/cases/profiling/task/network/expected/process.yml +++ b/test/e2e/cases/profiling/task/network/expected/process.yml @@ -21,7 +21,7 @@ instanceid: {{ b64enc "service" }}.1_{{ b64enc "test" }} instancename: test agentid: {{ notEmpty .agentid }} - detecttype: VM + detecttype: KUBERNETES attributes: {{- contains .attributes }} - name: host_ip @@ -32,8 +32,5 @@ value: {{ notEmpty .value }} {{- end }} labels: - {{- contains .labels }} - - e2e-label1 - - e2e-label2 - {{- end }} + - k8s-service {{- end }} \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/network/expected/service.yml b/test/e2e/cases/profiling/task/network/expected/service.yml index 23e629f1..8d4feea1 100644 --- a/test/e2e/cases/profiling/task/network/expected/service.yml +++ b/test/e2e/cases/profiling/task/network/expected/service.yml @@ -19,13 +19,13 @@ group: "" shortname: nginx layers: - - OS_LINUX + - K8S_SERVICE normal: true - id: {{ b64enc "service" }}.1 name: service group: "" shortname: service layers: - - OS_LINUX + - K8S_SERVICE normal: true {{- end }} \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/network/golang/docker-compose.yml b/test/e2e/cases/profiling/task/network/golang/docker-compose.yml deleted file mode 100644 index dc154f2b..00000000 --- a/test/e2e/cases/profiling/task/network/golang/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: - service: - build: - context: ../ - dockerfile: golang/Dockerfile - networks: - - e2e - volumes: - - ./../base/ssl:/ssl_data - environment: - OAP_BACKEND_ADDR: oap:11800 - ZIPKIN_BACKEND_ADDR: http://oap:9411/api/v2/spans - ports: - - 10443:10443 - healthcheck: - test: [ "CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/10443" ] - interval: 5s - timeout: 60s - retries: 120 - - proxy: - extends: - file: ../base/docker-compose.yml - service: proxy - networks: - - e2e - depends_on: - service: - condition: service_healthy - - oap: - extends: - file: ../base/docker-compose.yml - service: oap - ports: - - 12800:12800 - - 9411:9411 - - 9412:9412 - - rover: - extends: - file: ../base/docker-compose.yml - service: rover - depends_on: - oap: - condition: service_healthy - -networks: - e2e: \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/network/golang/e2e.yaml b/test/e2e/cases/profiling/task/network/golang/e2e.yaml index 30b1b0e0..ba85ee6c 100644 --- a/test/e2e/cases/profiling/task/network/golang/e2e.yaml +++ b/test/e2e/cases/profiling/task/network/golang/e2e.yaml @@ -14,10 +14,22 @@ # limitations under the License. setup: - env: compose - file: docker-compose.yml + env: kind + file: ../kind.yaml timeout: 20m init-system-environment: ../../../../../base/env + kind: + import-images: + - apache/skywalking-rover:latest + - test/network-golang:test + - test/test-nginx:test + expose-ports: + - namespace: istio-system + resource: service/skywalking-ui + port: 80 + - namespace: default + resource: service/service + port: 10443 steps: - name: set PATH command: export PATH=/tmp/skywalking-infra-e2e/bin:$PATH @@ -25,12 +37,43 @@ setup: command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh yq - name: install swctl command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh swctl + - name: Install SkyWalking + command: | + kubectl create namespace istio-system + helm -n istio-system install skywalking \ + oci://ghcr.io/apache/skywalking-helm/skywalking-helm \ + --version "0.0.0-${SW_KUBERNETES_COMMIT_SHA}" \ + --set fullnameOverride=skywalking \ + --set elasticsearch.replicas=1 \ + --set elasticsearch.minimumMasterNodes=1 \ + --set oap.replicas=1 \ + --set ui.image.repository=ghcr.io/apache/skywalking/ui \ + --set ui.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.repository=ghcr.io/apache/skywalking/oap \ + --set oap.storageType=elasticsearch \ + --set oap.ports.zipkinreceiver=9411 \ + --set oap.ports.zipkinquery=9412 \ + -f test/e2e/cases/profiling/task/network/kubernetes-values.yaml + wait: + - namespace: istio-system + resource: deployments/skywalking-oap + for: condition=available + - name: Deploy services + command: | + export IMAGE_NAME=test/network-golang:test + envsubst < test/e2e/cases/profiling/task/network/golang/service.yaml | kubectl apply -f - + envsubst < test/e2e/cases/profiling/task/network/rover.yaml | kubectl apply -f - + wait: + - namespace: default + resource: pod + for: condition=Ready trigger: action: http interval: 3s times: 10 - url: https://${service_host}:${service_10443}/consumer + url: https://${service_service_host}:${service_service_10443}/consumer method: GET verify: @@ -43,5 +86,4 @@ verify: cases: - includes: - ../base-cases.yaml - - ../http1-metrics-cases.yaml - - ../http1-sampled-traces-cases.yaml \ No newline at end of file + - ../http1-metrics-cases.yaml \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/network/golang/service.yaml b/test/e2e/cases/profiling/task/network/golang/service.yaml new file mode 100644 index 00000000..50c231c5 --- /dev/null +++ b/test/e2e/cases/profiling/task/network/golang/service.yaml @@ -0,0 +1,103 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: service-deployment +spec: + replicas: 1 + selector: + matchLabels: + app: service + template: + metadata: + labels: + app: service + spec: + containers: + - name: service + image: ${IMAGE_NAME} + env: + - name: OAP_BACKEND_ADDR + value: skywalking-oap.istio-system:11800 + - name: ZIPKIN_BACKEND_ADDR + value: http://skywalking-oap.istio-system:9411/api/v2/spans + volumeMounts: + - name: ssl-volume + mountPath: /ssl_data + volumes: + - name: ssl-volume + hostPath: + path: /ssl_data + type: Directory + +--- + +apiVersion: v1 +kind: Service +metadata: + name: service +spec: + selector: + app: service + ports: + - name: entry + protocol: TCP + port: 10443 + targetPort: 10443 + +--- + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-deployment +spec: + replicas: 1 + selector: + matchLabels: + app: nginx + template: + metadata: + labels: + app: nginx + spec: + containers: + - name: nginx + image: test/test-nginx:test + volumeMounts: + - name: ssl-volume + mountPath: /ssl_data + volumes: + - name: ssl-volume + hostPath: + path: /ssl_data + type: Directory + +--- + +apiVersion: v1 +kind: Service +metadata: + name: proxy +spec: + selector: + app: nginx + ports: + - name: proxy-entry + protocol: TCP + port: 443 + targetPort: 443 \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/network/http1-metrics-cases.yaml b/test/e2e/cases/profiling/task/network/http1-metrics-cases.yaml index 8ba8c050..511d0b19 100644 --- a/test/e2e/cases/profiling/task/network/http1-metrics-cases.yaml +++ b/test/e2e/cases/profiling/task/network/http1-metrics-cases.yaml @@ -16,37 +16,37 @@ # HTTP1 verify cases: - query: | - swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear \ + swctl --display yaml --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql metrics linear \ --service-name service --instance-name test --process-name service \ --dest-service-name service --dest-instance-name test --dest-process-name UNKNOWN_REMOTE \ --name process_relation_http1_request_cpm|yq e 'to_entries' - expected: expected/metrics-has-value.yml - query: | - swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear \ + swctl --display yaml --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql metrics linear \ --service-name service --instance-name test --process-name service \ --dest-service-name service --dest-instance-name test --dest-process-name UNKNOWN_REMOTE \ --name process_relation_http1_request_package_size|yq e 'to_entries' - expected: expected/metrics-has-value.yml - query: | - swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear \ + swctl --display yaml --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql metrics linear \ --service-name service --instance-name test --process-name service \ --dest-service-name service --dest-instance-name test --dest-process-name UNKNOWN_REMOTE \ --name process_relation_http1_response_package_size|yq e 'to_entries' - expected: expected/metrics-has-value.yml - query: | - swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics multiple-linear \ + swctl --display yaml --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql metrics multiple-linear \ --service-name service --instance-name test --process-name service \ --dest-service-name service --dest-instance-name test --dest-process-name UNKNOWN_REMOTE \ --name process_relation_http1_request_package_size_percentile|yq e 'to_entries | with(.[] ; .value=(.value | to_entries))' - expected: expected/metrics-has-value-label.yml - query: | - swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics multiple-linear \ + swctl --display yaml --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql metrics multiple-linear \ --service-name service --instance-name test --process-name service \ --dest-service-name service --dest-instance-name test --dest-process-name UNKNOWN_REMOTE \ --name process_relation_http1_response_package_size_percentile|yq e 'to_entries | with(.[] ; .value=(.value | to_entries))' - expected: expected/metrics-has-value-label.yml - query: | - swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear \ + swctl --display yaml --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql metrics linear \ --service-name service --instance-name test --process-name service \ --dest-service-name service --dest-instance-name test --dest-process-name UNKNOWN_REMOTE \ --name process_relation_http1_client_duration|yq e 'to_entries' - diff --git a/test/e2e/cases/profiling/task/network/http1-sampled-traces-cases.yaml b/test/e2e/cases/profiling/task/network/http1-sampled-traces-cases.yaml index d441ebd3..f037a394 100644 --- a/test/e2e/cases/profiling/task/network/http1-sampled-traces-cases.yaml +++ b/test/e2e/cases/profiling/task/network/http1-sampled-traces-cases.yaml @@ -17,40 +17,40 @@ cases: # slow traces - query: | - curl -s -k https://${service_host}:${service_10443}/consumer-zipkin > /dev/null; + curl -s -k https://${service_service_host}:${service_service_10443}/consumer-zipkin > /dev/null; sleep 5; - swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql records list \ + swctl --display yaml --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql records list \ --name=sampled_slow_trace_record --service-name service --instance-name test --process-name service \ --dest-service-name service --dest-instance-name test --dest-process-name UNKNOWN_REMOTE 20 expected: expected/slow-traces.yml # zipkin trace # - query: | -# curl -s https://${service_host}:${service_10443}/consumer-zipkin > /dev/null; +# curl -s https://${service_service_host}:${service_service_10443}/consumer-zipkin > /dev/null; # sleep 3; -# traceid=$(swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql records list \ +# traceid=$(swctl --display yaml --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql records list \ # --name=sampled_slow_trace_record --service-name service --instance-name test --process-name service \ # --dest-service-name service --dest-instance-name test --dest-process-name UNKNOWN_REMOTE 100 | yq e '. | map(select(.name == "zipkin-/provider-zipkin")).[0].id' -); -# curl http://${oap_host}:${oap_9412}/zipkin/api/v2/trace/${traceid} | yq e -| yq e 'del(.[].tags)' - +# curl http://${service_skywalking_ui_host}:${oap_9412}/zipkin/api/v2/trace/${traceid} | yq e -| yq e 'del(.[].tags)' - # expected: expected/zipkin-trace.yml # skywalking trace - query: | - traceid=$(swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql records list \ + traceid=$(swctl --display yaml --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql records list \ --name=sampled_slow_trace_record --service-name service --instance-name test --process-name service \ --dest-service-name service --dest-instance-name test --dest-process-name UNKNOWN_REMOTE 100 | yq e '. | map(select(.name == "skywalking-/provider")).[0].id' -); - swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql trace $traceid + swctl --display yaml --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql trace $traceid expected: expected/skywalking-trace.yml # not founds - query: | - curl -s -k https://${service_host}:${service_10443}/consumer?type=notfound > /dev/null; + curl -s -k https://${service_service_host}:${service_service_10443}/consumer?type=notfound > /dev/null; sleep 5; - swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql records list \ + swctl --display yaml --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql records list \ --name=sampled_status_4xx_trace_record --service-name service --instance-name test --process-name service \ --dest-service-name service --dest-instance-name test --dest-process-name UNKNOWN_REMOTE 20 expected: expected/status-4xx-traces.yml - query: | - curl -s -k https://${service_host}:${service_10443}/consumer?type=error > /dev/null; + curl -s -k https://${service_service_host}:${service_service_10443}/consumer?type=error > /dev/null; sleep 5; - swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql records list \ + swctl --display yaml --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql records list \ --name=sampled_status_5xx_trace_record --service-name service --instance-name test --process-name service \ --dest-service-name service --dest-instance-name test --dest-process-name UNKNOWN_REMOTE 20 expected: expected/status-5xx-traces.yml \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/network/http2/Dockerfile b/test/e2e/cases/profiling/task/network/http2/Dockerfile index b72b7b3e..b08d0686 100644 --- a/test/e2e/cases/profiling/task/network/http2/Dockerfile +++ b/test/e2e/cases/profiling/task/network/http2/Dockerfile @@ -14,22 +14,19 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM golang:1.17 +FROM golang:1.18 COPY http2/ /service WORKDIR / -RUN apt update && apt install -y zip && \ - mkdir protoc && cd protoc && \ - curl -sL https://github.com/protocolbuffers/protobuf/releases/download/v21.5/protoc-21.5-linux-x86_64.zip -o protoc.zip && \ - unzip protoc.zip +RUN apt update && apt install -y protobuf-compiler WORKDIR /service -RUN go get -u google.golang.org/protobuf/cmd/protoc-gen-go@v1.26.0 && \ - go get -u google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1.0 && \ - go get google.golang.org/grpc/internal/transport@v1.44.0 && \ - /protoc/bin/protoc --go_out=. --go-grpc_out=. service.proto && \ +RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28 && \ + go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2 && \ + protoc --go_out=. --go-grpc_out=. service.proto && \ + go mod tidy && \ go build . COPY base/ssl /usr/local/share/ca-certificates diff --git a/test/e2e/cases/profiling/task/network/http2/docker-compose.yml b/test/e2e/cases/profiling/task/network/http2/docker-compose.yml deleted file mode 100644 index 6b944432..00000000 --- a/test/e2e/cases/profiling/task/network/http2/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: - service: - build: - context: ../ - dockerfile: http2/Dockerfile - volumes: - - ./../base/ssl:/ssl_data - networks: - - e2e - ports: - - 8080:8080 - healthcheck: - test: [ "CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/8080" ] - interval: 5s - timeout: 60s - retries: 120 - - proxy: - extends: - file: ../base/docker-compose.yml - service: proxy - networks: - - e2e - depends_on: - service: - condition: service_healthy - - oap: - extends: - file: ../base/docker-compose.yml - service: oap - ports: - - 12800:12800 - - rover: - extends: - file: ../base/docker-compose.yml - service: rover - environment: - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_MATCH_CMD2: service/test - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_PROCESS_NAME2: service - depends_on: - oap: - condition: service_healthy - -networks: - e2e: \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/network/http2/e2e.yaml b/test/e2e/cases/profiling/task/network/http2/e2e.yaml index 452b8ed8..07071c6a 100644 --- a/test/e2e/cases/profiling/task/network/http2/e2e.yaml +++ b/test/e2e/cases/profiling/task/network/http2/e2e.yaml @@ -14,10 +14,22 @@ # limitations under the License. setup: - env: compose - file: docker-compose.yml + env: kind + file: ../kind.yaml timeout: 20m init-system-environment: ../../../../../base/env + kind: + import-images: + - apache/skywalking-rover:latest + - test/network-http2:test + - test/test-nginx:test + expose-ports: + - namespace: istio-system + resource: service/skywalking-ui + port: 80 + - namespace: default + resource: service/service + port: 8080 steps: - name: set PATH command: export PATH=/tmp/skywalking-infra-e2e/bin:$PATH @@ -25,12 +37,43 @@ setup: command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh yq - name: install swctl command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh swctl + - name: Install SkyWalking + command: | + kubectl create namespace istio-system + helm -n istio-system install skywalking \ + oci://ghcr.io/apache/skywalking-helm/skywalking-helm \ + --version "0.0.0-${SW_KUBERNETES_COMMIT_SHA}" \ + --set fullnameOverride=skywalking \ + --set elasticsearch.replicas=1 \ + --set elasticsearch.minimumMasterNodes=1 \ + --set oap.replicas=1 \ + --set ui.image.repository=ghcr.io/apache/skywalking/ui \ + --set ui.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.repository=ghcr.io/apache/skywalking/oap \ + --set oap.storageType=elasticsearch \ + --set oap.ports.zipkinreceiver=9411 \ + --set oap.ports.zipkinquery=9412 \ + -f test/e2e/cases/profiling/task/network/kubernetes-values.yaml + wait: + - namespace: istio-system + resource: deployments/skywalking-oap + for: condition=available + - name: Deploy services + command: | + export IMAGE_NAME=test/network-http2:test + envsubst < test/e2e/cases/profiling/task/network/service.yaml | kubectl apply -f - + envsubst < test/e2e/cases/profiling/task/network/rover.yaml | kubectl apply -f - + wait: + - namespace: default + resource: pod + for: condition=Ready trigger: action: http interval: 3s times: 10 - url: http://${service_host}:${service_8080}/singleCall + url: http://${service_service_host}:${service_service_8080}/singleCall method: GET verify: diff --git a/test/e2e/cases/profiling/task/network/http2/grpc.go b/test/e2e/cases/profiling/task/network/http2/grpc.go index 34bf54f7..643ae065 100644 --- a/test/e2e/cases/profiling/task/network/http2/grpc.go +++ b/test/e2e/cases/profiling/task/network/http2/grpc.go @@ -49,7 +49,7 @@ func singleCall(w http.ResponseWriter, req *http.Request) { log.Fatalf("credentials.NewClientTLSFromFile err: %v", err) } - dial, err := grpc.Dial(fmt.Sprintf("proxy:%d", gRPCPort), grpc.WithTransportCredentials(c)) + dial, err := grpc.Dial(fmt.Sprintf("proxy.default:%d", gRPCPort), grpc.WithTransportCredentials(c)) if err != nil { log.Printf("init gRPC client failure: %v", err) _, _ = w.Write([]byte("error")) diff --git a/test/e2e/cases/profiling/task/network/kind.yaml b/test/e2e/cases/profiling/task/network/kind.yaml new file mode 100644 index 00000000..10349744 --- /dev/null +++ b/test/e2e/cases/profiling/task/network/kind.yaml @@ -0,0 +1,25 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +nodes: + - role: control-plane + image: kindest/node:v1.25.11@sha256:227fa11ce74ea76a0474eeefb84cb75d8dad1b08638371ecf0e86259b35be0c8 + extraMounts: + - hostPath: / + containerPath: /host + - hostPath: /tmp/ssl_data + containerPath: /ssl_data \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/network/kubernetes-values.yaml b/test/e2e/cases/profiling/task/network/kubernetes-values.yaml new file mode 100644 index 00000000..81ac1867 --- /dev/null +++ b/test/e2e/cases/profiling/task/network/kubernetes-values.yaml @@ -0,0 +1,205 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +oap: + env: + SW_METER_ANALYZER_ACTIVE_FILES: network-profiling + SW_LOG_LAL_FILES: slow-trace-lal + config: + lal: + slow-trace-lal.yaml: | + rules: + - name: network-profiling-slow-trace + layer: K8S_SERVICE + dsl: | + filter { + json{ + } + extractor{ + if (tag("LOG_KIND") == "NET_PROFILING_SAMPLED_TRACE") { + sampledTrace { + latency parsed.latency as Long + uri ((parsed.trace_provider as String) + "-" + (parsed.uri as String)) + reason parsed.reason as String + + if (parsed.client_process.process_id as String != "") { + processId parsed.client_process.process_id as String + } else if (parsed.client_process.local as Boolean + || (parsed.client_process.address as String).split(":")[0].endsWith('.1') + || (parsed.client_process.address as String).split(":")[1] == "53") { + processId ProcessRegistry.generateVirtualLocalProcess(parsed.service as String, parsed.serviceInstance as String) as String + } else { + processId ProcessRegistry.generateVirtualProcess(parsed.service as String, parsed.serviceInstance as String, 'UNKNOWN_REMOTE') as String + } + + if (parsed.server_process.process_id as String != "") { + destProcessId parsed.server_process.process_id as String + } else if (parsed.server_process.local as Boolean + || (parsed.server_process.address as String).split(":")[0].endsWith('.1') + || (parsed.server_process.address as String).split(":")[1] == "53") { + destProcessId ProcessRegistry.generateVirtualLocalProcess(parsed.service as String, parsed.serviceInstance as String) as String + } else { + destProcessId ProcessRegistry.generateVirtualProcess(parsed.service as String, parsed.serviceInstance as String, 'UNKNOWN_REMOTE') as String + } + + detectPoint parsed.detect_point as String + + if (parsed.component as String == "http" && parsed.ssl as Boolean) { + componentId 129 + } else if (parsed.component as String == "http") { + componentId 49 + } else if (parsed.ssl as Boolean) { + componentId 130 + } else { + componentId 110 + } + } + } + } + } + + meter-analyzer-config: + network-profiling.yaml: | + expSuffix: |- + processRelation('side', ['service'], ['instance'], 'client_process_id', 'server_process_id', 'component') + expPrefix: |- + forEach(['client', 'server'], { prefix, tags -> + if (tags[prefix + '_process_id'] != null) { + return + } + // only care about the nginx + if (tags[prefix + '_local'] == 'true' + || tags[prefix + '_address'].split(':')[0].endsWith('.1') // local data + || tags[prefix + '_address'].split(':')[1] == '11800' // oap + || tags[prefix + '_address'].split(':')[1] == '53') { // dns + tags[prefix + '_process_id'] = ProcessRegistry.generateVirtualLocalProcess(tags.service, tags.instance) + return + } + tags[prefix + '_process_id'] = ProcessRegistry.generateVirtualProcess(tags.service, tags.instance, 'UNKNOWN_REMOTE') + }) + .forEach(['component'], { key, tags -> + String result = "" + // protocol are defined in the component-libraries.yml + String protocol = tags['protocol'] + String ssl = tags['is_ssl'] + if (protocol == 'http' && ssl == 'true') { + result = '129' // https + } else if (protocol == 'http') { + result = '49' // http + } else if (ssl == 'true') { + result = '130' // tls + } else { + result = '110' // tcp + } + tags[key] = result + }) + metricPrefix: process_relation + metricsRules: + # TCP Metrics: client side + - name: client_write_cpm + exp: rover_net_p_client_write_counts_counter.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component']).downsampling(SUM_PER_MIN) + - name: client_write_total_bytes + exp: rover_net_p_client_write_bytes_counter.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component']).downsampling(SUM_PER_MIN) + - name: client_write_avg_exe_time + exp: rover_net_p_client_write_exe_time_counter.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component']) + - name: client_read_cpm + exp: rover_net_p_client_read_counts_counter.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component']).downsampling(SUM_PER_MIN) + - name: client_read_total_bytes + exp: rover_net_p_client_read_bytes_counter.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component']).downsampling(SUM_PER_MIN) + - name: client_read_avg_exe_time + exp: rover_net_p_client_read_exe_time_counter.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component']) + - name: client_write_avg_rtt_time + exp: rover_net_p_client_write_rtt_exe_time_counter.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component']) + - name: client_connect_cpm + exp: rover_net_p_client_connect_counts_counter.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component']).downsampling(SUM_PER_MIN) + - name: client_connect_exe_time + exp: rover_net_p_client_connect_exe_time_counter.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component']) + - name: client_close_cpm + exp: rover_net_p_client_close_counts_counter.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component']).downsampling(SUM_PER_MIN) + - name: client_close_avg_exe_time + exp: rover_net_p_client_close_exe_time_counter.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component']) + - name: client_retransmit_cpm + exp: rover_net_p_client_retransmit_counts_counter.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component']).downsampling(SUM_PER_MIN) + - name: client_drop_cpm + exp: rover_net_p_client_drop_counts_counter.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component']).downsampling(SUM_PER_MIN) + - name: client_write_rtt_time_percentile + exp: rover_net_p_client_write_rtt_histogram.histogram().histogram_percentile([50,70,90,99]).downsampling(SUM) + - name: client_write_exe_time_percentile + exp: rover_net_p_client_write_exe_time_histogram.histogram().histogram_percentile([50,70,90,99]).downsampling(SUM) + - name: client_read_exe_time_percentile + exp: rover_net_p_client_read_exe_time_histogram.histogram().histogram_percentile([50,70,90,99]).downsampling(SUM) + + # TCP Metrics: server side + - name: server_write_cpm + exp: rover_net_p_server_write_counts_counter.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component']).downsampling(SUM_PER_MIN) + - name: server_write_total_bytes + exp: rover_net_p_server_write_bytes_counter.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component']).downsampling(SUM_PER_MIN) + - name: server_write_avg_exe_time + exp: rover_net_p_server_write_exe_time_counter.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component']) + - name: server_read_cpm + exp: rover_net_p_server_read_counts_counter.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component']).downsampling(SUM_PER_MIN) + - name: server_read_total_bytes + exp: rover_net_p_server_read_bytes_counter.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component']).downsampling(SUM_PER_MIN) + - name: server_read_avg_exe_time + exp: rover_net_p_server_read_exe_time_counter.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component']) + - name: server_write_avg_rtt_time + exp: rover_net_p_server_write_rtt_exe_time_counter.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component']) + - name: server_connect_cpm + exp: rover_net_p_server_connect_counts_counter.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component']).downsampling(SUM_PER_MIN) + - name: server_connect_avg_exe_time + exp: rover_net_p_server_connect_exe_time_counter.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component']) + - name: server_close_cpm + exp: rover_net_p_server_close_counts_counter.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component']).downsampling(SUM_PER_MIN) + - name: server_close_avg_exe_time + exp: rover_net_p_server_close_exe_time_counter.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component']) + - name: server_retransmit_cpm + exp: rover_net_p_server_retransmit_counts_counter.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component']).downsampling(SUM_PER_MIN) + - name: server_drop_cpm + exp: rover_net_p_server_drop_counts_counter.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component']).downsampling(SUM_PER_MIN) + - name: server_write_rtt_time_percentile + exp: rover_net_p_server_write_rtt_histogram.histogram().histogram_percentile([50,70,90,99]).downsampling(SUM) + - name: server_write_exe_time_percentile + exp: rover_net_p_server_write_exe_time_histogram.histogram().histogram_percentile([50,70,90,99]).downsampling(SUM) + - name: server_read_exe_time_percentile + exp: rover_net_p_server_read_exe_time_histogram.histogram().histogram_percentile([50,70,90,99]).downsampling(SUM) + + # HTTP/1.x Metrics + - name: http1_request_cpm + exp: rover_net_p_http1_request_counter.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component']).downsampling(SUM_PER_MIN) + - name: http1_response_status_cpm + exp: rover_net_p_http1_response_status_counter.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component', 'code']).downsampling(SUM_PER_MIN) + - name: http1_request_package_size + exp: rover_net_p_http1_request_package_size_avg.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component']) + - name: http1_response_package_size + exp: rover_net_p_http1_response_package_size_avg.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component']) + - name: http1_request_package_size_percentile + exp: rover_net_p_http1_request_package_size_histogram.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component', 'le']).histogram().histogram_percentile([50,70,90,99]).downsampling(SUM) + - name: http1_response_package_size_percentile + exp: rover_net_p_http1_response_package_size_histogram.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component', 'le']).histogram().histogram_percentile([50,70,90,99]).downsampling(SUM) + - name: http1_client_duration + exp: rover_net_p_http1_client_duration_avg.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component']) + - name: http1_server_duration + exp: rover_net_p_http1_server_duration_avg.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component']) + - name: http1_client_duration_percentile + exp: rover_net_p_http1_client_duration_histogram.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component', 'le']).histogram().histogram_percentile([50,70,90,99]).downsampling(SUM) + - name: http1_server_duration_percentile + exp: rover_net_p_http1_server_duration_histogram.sum(['service', 'instance', 'side', 'client_process_id', 'server_process_id', 'component', 'le']).histogram().histogram_percentile([50,70,90,99]).downsampling(SUM) + +elasticsearch: + esConfig: + elasticsearch.yml: | + cluster.routing.allocation.disk.watermark.low: 90% + cluster.routing.allocation.disk.watermark.high: 99% + cluster.routing.allocation.disk.watermark.flood_stage: 99% \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/network/nodejs/docker-compose.yml b/test/e2e/cases/profiling/task/network/nodejs/docker-compose.yml deleted file mode 100644 index f941ace1..00000000 --- a/test/e2e/cases/profiling/task/network/nodejs/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: - service: - build: - context: ../ - dockerfile: nodejs/Dockerfile - networks: - - e2e - volumes: - - ./../base/ssl:/ssl_data - ports: - - 10443:10443 - healthcheck: - test: [ "CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/10443" ] - interval: 5s - timeout: 60s - retries: 120 - - proxy: - extends: - file: ../base/docker-compose.yml - service: proxy - networks: - - e2e - depends_on: - service: - condition: service_healthy - - oap: - extends: - file: ../base/docker-compose.yml - service: oap - ports: - - 12800:12800 - - rover: - extends: - file: ../base/docker-compose.yml - service: rover - environment: - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_MATCH_CMD2: service.js - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_PROCESS_NAME2: service - depends_on: - oap: - condition: service_healthy - -networks: - e2e: \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/network/nodejs/e2e.yaml b/test/e2e/cases/profiling/task/network/nodejs/e2e.yaml index e12faa2d..53bb9d1d 100644 --- a/test/e2e/cases/profiling/task/network/nodejs/e2e.yaml +++ b/test/e2e/cases/profiling/task/network/nodejs/e2e.yaml @@ -14,10 +14,22 @@ # limitations under the License. setup: - env: compose - file: docker-compose.yml + env: kind + file: ../kind.yaml timeout: 20m init-system-environment: ../../../../../base/env + kind: + import-images: + - apache/skywalking-rover:latest + - test/network-nodejs:test + - test/test-nginx:test + expose-ports: + - namespace: istio-system + resource: service/skywalking-ui + port: 80 + - namespace: default + resource: service/service + port: 10443 steps: - name: set PATH command: export PATH=/tmp/skywalking-infra-e2e/bin:$PATH @@ -25,12 +37,43 @@ setup: command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh yq - name: install swctl command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh swctl + - name: Install SkyWalking + command: | + kubectl create namespace istio-system + helm -n istio-system install skywalking \ + oci://ghcr.io/apache/skywalking-helm/skywalking-helm \ + --version "0.0.0-${SW_KUBERNETES_COMMIT_SHA}" \ + --set fullnameOverride=skywalking \ + --set elasticsearch.replicas=1 \ + --set elasticsearch.minimumMasterNodes=1 \ + --set oap.replicas=1 \ + --set ui.image.repository=ghcr.io/apache/skywalking/ui \ + --set ui.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.repository=ghcr.io/apache/skywalking/oap \ + --set oap.storageType=elasticsearch \ + --set oap.ports.zipkinreceiver=9411 \ + --set oap.ports.zipkinquery=9412 \ + -f test/e2e/cases/profiling/task/network/kubernetes-values.yaml + wait: + - namespace: istio-system + resource: deployments/skywalking-oap + for: condition=available + - name: Deploy services + command: | + export IMAGE_NAME=test/network-nodejs:test + envsubst < test/e2e/cases/profiling/task/network/service.yaml | kubectl apply -f - + envsubst < test/e2e/cases/profiling/task/network/rover.yaml | kubectl apply -f - + wait: + - namespace: default + resource: pod + for: condition=Ready trigger: action: http interval: 3s times: 10 - url: https://${service_host}:${service_10443}/consumer + url: https://${service_service_host}:${service_service_10443}/consumer method: GET verify: diff --git a/test/e2e/cases/profiling/task/network/python/docker-compose.yml b/test/e2e/cases/profiling/task/network/python/docker-compose.yml deleted file mode 100644 index 5e0e576c..00000000 --- a/test/e2e/cases/profiling/task/network/python/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: - service: - build: - context: ../ - dockerfile: python/Dockerfile - networks: - - e2e - volumes: - - ./../base/ssl:/ssl_data - ports: - - 10443:10443 - healthcheck: - test: [ "CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/10443" ] - interval: 5s - timeout: 60s - retries: 120 - - proxy: - extends: - file: ../base/docker-compose.yml - service: proxy - networks: - - e2e - depends_on: - service: - condition: service_healthy - - oap: - extends: - file: ../base/docker-compose.yml - service: oap - ports: - - 12800:12800 - - rover: - extends: - file: ../base/docker-compose.yml - service: rover - environment: - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_MATCH_CMD2: service.py - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_PROCESS_NAME2: service - depends_on: - oap: - condition: service_healthy - -networks: - e2e: \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/network/python/e2e.yaml b/test/e2e/cases/profiling/task/network/python/e2e.yaml index e12faa2d..31c5294b 100644 --- a/test/e2e/cases/profiling/task/network/python/e2e.yaml +++ b/test/e2e/cases/profiling/task/network/python/e2e.yaml @@ -14,10 +14,19 @@ # limitations under the License. setup: - env: compose - file: docker-compose.yml + env: kind + file: ../kind.yaml timeout: 20m init-system-environment: ../../../../../base/env + kind: + import-images: + - apache/skywalking-rover:latest + - test/network-python:test + - test/test-nginx:test + expose-ports: + - namespace: istio-system + resource: service/skywalking-ui + port: 80 steps: - name: set PATH command: export PATH=/tmp/skywalking-infra-e2e/bin:$PATH @@ -25,12 +34,43 @@ setup: command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh yq - name: install swctl command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh swctl + - name: Install SkyWalking + command: | + kubectl create namespace istio-system + helm -n istio-system install skywalking \ + oci://ghcr.io/apache/skywalking-helm/skywalking-helm \ + --version "0.0.0-${SW_KUBERNETES_COMMIT_SHA}" \ + --set fullnameOverride=skywalking \ + --set elasticsearch.replicas=1 \ + --set elasticsearch.minimumMasterNodes=1 \ + --set oap.replicas=1 \ + --set ui.image.repository=ghcr.io/apache/skywalking/ui \ + --set ui.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.repository=ghcr.io/apache/skywalking/oap \ + --set oap.storageType=elasticsearch \ + --set oap.ports.zipkinreceiver=9411 \ + --set oap.ports.zipkinquery=9412 \ + -f test/e2e/cases/profiling/task/network/kubernetes-values.yaml + wait: + - namespace: istio-system + resource: deployments/skywalking-oap + for: condition=available + - name: Deploy services + command: | + export IMAGE_NAME=test/network-python:test + envsubst < test/e2e/cases/profiling/task/network/service.yaml | kubectl apply -f - + envsubst < test/e2e/cases/profiling/task/network/rover.yaml | kubectl apply -f - + wait: + - namespace: default + resource: pod + for: condition=Ready trigger: action: http interval: 3s times: 10 - url: https://${service_host}:${service_10443}/consumer + url: https://${service_service_host}:${service_service_10443}/consumer method: GET verify: diff --git a/test/e2e/cases/profiling/task/network/rover.yaml b/test/e2e/cases/profiling/task/network/rover.yaml new file mode 100644 index 00000000..1c543d54 --- /dev/null +++ b/test/e2e/cases/profiling/task/network/rover.yaml @@ -0,0 +1,107 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: v1 +kind: ServiceAccount +metadata: + name: skywalking-rover +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: skywalking-rover +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: skywalking-rover +subjects: + - kind: ServiceAccount + name: skywalking-rover + namespace: default +--- +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: skywalking-rover +rules: + - apiGroups: [""] + resources: ["pods", "nodes", "services"] + verbs: ["get", "watch", "list"] +--- + +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: skywalking-rover +spec: + selector: + matchLabels: + name: skywalking-rover + template: + metadata: + labels: + name: skywalking-rover + spec: + serviceAccountName: skywalking-rover + serviceAccount: skywalking-rover + containers: + - name: skywalking-rover + # SkyWalking Rover image path + image: apache/skywalking-rover:latest + imagePullPolicy: IfNotPresent + securityContext: + capabilities: + add: + - SYS_PTRACE + - SYS_ADMIN + privileged: true + volumeMounts: + - name: host + mountPath: /host + readOnly: true + env: + - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_ACTIVE + value: "true" + - name: ROVER_LOGGER_LEVEL + value: "DEBUG" + - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: ROVER_BACKEND_ADDR + # backend OAP address + value: skywalking-oap.istio-system:11800 + - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_ISTIO_ENVOY_ACTIVE + value: "false" + - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_ISTIO_APPLICATION_ACTIVE + value: "false" + - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_K8S_SERVICE_HAS_SERVICE + value: 'or (.Pod.HasContainer "service") (.Pod.HasContainer "nginx")' + - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_K8S_SERVICE_NAME + value: "{{.Container.Name}}" + - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_K8S_SERVICE_INSTANCE_NAME + value: test + - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_K8S_SERVICE_PROCESS_NAME + value: service + - name: ROVER_HOST_MAPPING + value: /host + hostPID: true + hostNetwork: true + dnsPolicy: ClusterFirstWithHostNet + volumes: + - name: host + hostPath: + path: /host + type: Directory \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/network/service.yaml b/test/e2e/cases/profiling/task/network/service.yaml new file mode 100644 index 00000000..b180683c --- /dev/null +++ b/test/e2e/cases/profiling/task/network/service.yaml @@ -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. + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: service-deployment +spec: + replicas: 1 + selector: + matchLabels: + app: service + template: + metadata: + labels: + app: service + spec: + containers: + - name: service + image: ${IMAGE_NAME} + volumeMounts: + - name: ssl-volume + mountPath: /ssl_data + volumes: + - name: ssl-volume + hostPath: + path: /ssl_data + type: Directory + +--- + +apiVersion: v1 +kind: Service +metadata: + name: service +spec: + selector: + app: service + ports: + - name: service-https-entry + protocol: TCP + port: 10443 + targetPort: 10443 + - name: service-http-entry + protocol: TCP + port: 8080 + targetPort: 8080 + - name: service-http2-entry + protocol: TCP + port: 9000 + targetPort: 9000 + +--- + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-deployment +spec: + replicas: 1 + selector: + matchLabels: + app: nginx + template: + metadata: + labels: + app: nginx + spec: + containers: + - name: nginx + image: test/test-nginx:test + volumeMounts: + - name: ssl-volume + mountPath: /ssl_data + volumes: + - name: ssl-volume + hostPath: + path: /ssl_data + type: Directory + +--- + +apiVersion: v1 +kind: Service +metadata: + name: proxy +spec: + selector: + app: nginx + ports: + - name: proxy-entry + protocol: TCP + port: 443 + targetPort: 443 + - name: proxy-grpc-entry + protocol: TCP + port: 9000 + targetPort: 9000 \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/offcpu/c++/e2e.yaml b/test/e2e/cases/profiling/task/offcpu/c++/e2e.yaml index 1a462f55..31f9e2c0 100644 --- a/test/e2e/cases/profiling/task/offcpu/c++/e2e.yaml +++ b/test/e2e/cases/profiling/task/offcpu/c++/e2e.yaml @@ -14,10 +14,18 @@ # limitations under the License. setup: - env: compose - file: docker-compose.yml + env: kind + file: ../../../../../base/kind.yaml timeout: 20m init-system-environment: ../../../../../base/env + kind: + import-images: + - apache/skywalking-rover:latest + - test/offcpu-c_plus_plus:test + expose-ports: + - namespace: istio-system + resource: service/skywalking-ui + port: 80 steps: - name: set PATH command: export PATH=/tmp/skywalking-infra-e2e/bin:$PATH @@ -25,6 +33,35 @@ setup: command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh yq - name: install swctl command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh swctl + - name: Install SkyWalking + command: | + kubectl create namespace istio-system + helm -n istio-system install skywalking \ + oci://ghcr.io/apache/skywalking-helm/skywalking-helm \ + --version "0.0.0-${SW_KUBERNETES_COMMIT_SHA}" \ + --set fullnameOverride=skywalking \ + --set elasticsearch.replicas=1 \ + --set elasticsearch.minimumMasterNodes=1 \ + --set oap.replicas=1 \ + --set ui.image.repository=ghcr.io/apache/skywalking/ui \ + --set ui.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.repository=ghcr.io/apache/skywalking/oap \ + --set oap.storageType=elasticsearch \ + -f test/e2e/base/kubernetes-values.yaml + wait: + - namespace: istio-system + resource: deployments/skywalking-oap + for: condition=available + - name: Deploy services + command: | + export IMAGE_NAME=test/offcpu-c_plus_plus:test + envsubst < test/e2e/cases/profiling/task/offcpu/service.yaml | kubectl apply -f - + envsubst < test/e2e/cases/profiling/task/offcpu/rover.yaml | kubectl apply -f - + wait: + - namespace: default + resource: pod + for: condition=Ready verify: # verify with retry strategy @@ -37,9 +74,9 @@ verify: - includes: - ../profiling-cases.yaml - query: | - taskid=$(swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf list --service-name file |yq e '.[0].taskid' -) - scheduleid=$(swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf schedules --task-id=$taskid |yq e '.[0].scheduleid' -); - start=$(swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf schedules --task-id=$taskid | yq e '.[0].starttime' -) - end=$(swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf schedules --task-id=$taskid | yq e '.[0].endtime' -) - swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf analysis --schedule-id=$scheduleid --time-ranges=$start-$end + taskid=$(swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf list --service-name file |yq e '.[0].taskid' -) + scheduleid=$(swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf schedules --task-id=$taskid |yq e '.[0].scheduleid' -); + start=$(swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf schedules --task-id=$taskid | yq e '.[0].starttime' -) + end=$(swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf schedules --task-id=$taskid | yq e '.[0].endtime' -) + swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf analysis --schedule-id=$scheduleid --time-ranges=$start-$end expected: profiling-analysis.yml \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/offcpu/c/docker-compose.yml b/test/e2e/cases/profiling/task/offcpu/c/docker-compose.yml deleted file mode 100644 index 3013ce53..00000000 --- a/test/e2e/cases/profiling/task/offcpu/c/docker-compose.yml +++ /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. - -version: '2.1' - -services: - oap: - extends: - file: ../../../../../base/base-compose.yml - service: oap - ports: - - 12800:12800 - - rover: - extends: - file: ../../../../../base/base-compose.yml - service: rover - environment: - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_MATCH_CMD: /file - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_SERVICE_NAME: file - depends_on: - oap: - condition: service_healthy - - file_c: - build: - context: . - dockerfile: Dockerfile.file - networks: - - e2e - -networks: - e2e: \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/offcpu/c/e2e.yaml b/test/e2e/cases/profiling/task/offcpu/c/e2e.yaml index 1a462f55..26052d31 100644 --- a/test/e2e/cases/profiling/task/offcpu/c/e2e.yaml +++ b/test/e2e/cases/profiling/task/offcpu/c/e2e.yaml @@ -14,10 +14,18 @@ # limitations under the License. setup: - env: compose - file: docker-compose.yml + env: kind + file: ../../../../../base/kind.yaml timeout: 20m init-system-environment: ../../../../../base/env + kind: + import-images: + - apache/skywalking-rover:latest + - test/offcpu-c:test + expose-ports: + - namespace: istio-system + resource: service/skywalking-ui + port: 80 steps: - name: set PATH command: export PATH=/tmp/skywalking-infra-e2e/bin:$PATH @@ -25,6 +33,35 @@ setup: command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh yq - name: install swctl command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh swctl + - name: Install SkyWalking + command: | + kubectl create namespace istio-system + helm -n istio-system install skywalking \ + oci://ghcr.io/apache/skywalking-helm/skywalking-helm \ + --version "0.0.0-${SW_KUBERNETES_COMMIT_SHA}" \ + --set fullnameOverride=skywalking \ + --set elasticsearch.replicas=1 \ + --set elasticsearch.minimumMasterNodes=1 \ + --set oap.replicas=1 \ + --set ui.image.repository=ghcr.io/apache/skywalking/ui \ + --set ui.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.repository=ghcr.io/apache/skywalking/oap \ + --set oap.storageType=elasticsearch \ + -f test/e2e/base/kubernetes-values.yaml + wait: + - namespace: istio-system + resource: deployments/skywalking-oap + for: condition=available + - name: Deploy services + command: | + export IMAGE_NAME=test/offcpu-c:test + envsubst < test/e2e/cases/profiling/task/offcpu/service.yaml | kubectl apply -f - + envsubst < test/e2e/cases/profiling/task/offcpu/rover.yaml | kubectl apply -f - + wait: + - namespace: default + resource: pod + for: condition=Ready verify: # verify with retry strategy @@ -37,9 +74,9 @@ verify: - includes: - ../profiling-cases.yaml - query: | - taskid=$(swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf list --service-name file |yq e '.[0].taskid' -) - scheduleid=$(swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf schedules --task-id=$taskid |yq e '.[0].scheduleid' -); - start=$(swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf schedules --task-id=$taskid | yq e '.[0].starttime' -) - end=$(swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf schedules --task-id=$taskid | yq e '.[0].endtime' -) - swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf analysis --schedule-id=$scheduleid --time-ranges=$start-$end + taskid=$(swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf list --service-name file |yq e '.[0].taskid' -) + scheduleid=$(swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf schedules --task-id=$taskid |yq e '.[0].scheduleid' -); + start=$(swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf schedules --task-id=$taskid | yq e '.[0].starttime' -) + end=$(swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf schedules --task-id=$taskid | yq e '.[0].endtime' -) + swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf analysis --schedule-id=$scheduleid --time-ranges=$start-$end expected: profiling-analysis.yml \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/offcpu/expected/process.yml b/test/e2e/cases/profiling/task/offcpu/expected/process.yml index 69c1ae98..3a6d2fa4 100644 --- a/test/e2e/cases/profiling/task/offcpu/expected/process.yml +++ b/test/e2e/cases/profiling/task/offcpu/expected/process.yml @@ -21,7 +21,7 @@ instanceid: {{ b64enc "file" }}.1_{{ b64enc "test-instance" }} instancename: test-instance agentid: {{ notEmpty .agentid }} - detecttype: VM + detecttype: KUBERNETES attributes: {{- contains .attributes }} - name: host_ip @@ -32,8 +32,5 @@ value: /file {{- end }} labels: - {{- contains .labels }} - - e2e-label1 - - e2e-label2 - {{- end }} + - k8s-service {{- end }} \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/offcpu/expected/profiling-schedule-list.yml b/test/e2e/cases/profiling/task/offcpu/expected/profiling-schedule-list.yml index 1e3eff60..10ec9447 100644 --- a/test/e2e/cases/profiling/task/offcpu/expected/profiling-schedule-list.yml +++ b/test/e2e/cases/profiling/task/offcpu/expected/profiling-schedule-list.yml @@ -24,7 +24,7 @@ instanceid: {{ b64enc "file" }}.1_{{ b64enc "test-instance" }} instancename: test-instance agentid: {{ notEmpty .process.agentid }} - detecttype: VM + detecttype: KUBERNETES attributes: {{- contains .process.attributes }} - name: host_ip @@ -35,10 +35,7 @@ value: /file {{- end }} labels: - {{- contains .process.labels }} - - e2e-label1 - - e2e-label2 - {{- end }} + - k8s-service starttime: {{ gt .starttime 0 }} endtime: {{ gt .endtime 0 }} {{- end }} \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/offcpu/expected/profiling-task-list.yml b/test/e2e/cases/profiling/task/offcpu/expected/profiling-task-list.yml index 69864ead..976533b9 100644 --- a/test/e2e/cases/profiling/task/offcpu/expected/profiling-task-list.yml +++ b/test/e2e/cases/profiling/task/offcpu/expected/profiling-task-list.yml @@ -20,10 +20,7 @@ serviceinstanceid: null serviceinstancename: null processlabels: - {{- contains .processlabels }} - - e2e-label1 - - e2e-label2 - {{- end }} + - k8s-service processid: null processname: null taskstarttime: {{ gt .taskstarttime 0 }} diff --git a/test/e2e/cases/profiling/task/offcpu/expected/service.yml b/test/e2e/cases/profiling/task/offcpu/expected/service.yml index 814563c1..0470635b 100644 --- a/test/e2e/cases/profiling/task/offcpu/expected/service.yml +++ b/test/e2e/cases/profiling/task/offcpu/expected/service.yml @@ -19,6 +19,6 @@ group: "" shortname: file layers: - - OS_LINUX + - K8S_SERVICE normal: true {{- end }} \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/offcpu/golang/docker-compose.yml b/test/e2e/cases/profiling/task/offcpu/golang/docker-compose.yml deleted file mode 100644 index 41025d2c..00000000 --- a/test/e2e/cases/profiling/task/offcpu/golang/docker-compose.yml +++ /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. - -version: '2.1' - -services: - oap: - extends: - file: ../../../../../base/base-compose.yml - service: oap - ports: - - 12800:12800 - - rover: - extends: - file: ../../../../../base/base-compose.yml - service: rover - environment: - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_MATCH_CMD: /file - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_SERVICE_NAME: file - depends_on: - oap: - condition: service_healthy - - file_go: - build: - context: . - dockerfile: Dockerfile.file - networks: - - e2e - -networks: - e2e: \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/offcpu/golang/e2e.yaml b/test/e2e/cases/profiling/task/offcpu/golang/e2e.yaml index 1a462f55..e2b79532 100644 --- a/test/e2e/cases/profiling/task/offcpu/golang/e2e.yaml +++ b/test/e2e/cases/profiling/task/offcpu/golang/e2e.yaml @@ -14,10 +14,18 @@ # limitations under the License. setup: - env: compose - file: docker-compose.yml + env: kind + file: ../../../../../base/kind.yaml timeout: 20m init-system-environment: ../../../../../base/env + kind: + import-images: + - apache/skywalking-rover:latest + - test/offcpu-golang:test + expose-ports: + - namespace: istio-system + resource: service/skywalking-ui + port: 80 steps: - name: set PATH command: export PATH=/tmp/skywalking-infra-e2e/bin:$PATH @@ -25,6 +33,35 @@ setup: command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh yq - name: install swctl command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh swctl + - name: Install SkyWalking + command: | + kubectl create namespace istio-system + helm -n istio-system install skywalking \ + oci://ghcr.io/apache/skywalking-helm/skywalking-helm \ + --version "0.0.0-${SW_KUBERNETES_COMMIT_SHA}" \ + --set fullnameOverride=skywalking \ + --set elasticsearch.replicas=1 \ + --set elasticsearch.minimumMasterNodes=1 \ + --set oap.replicas=1 \ + --set ui.image.repository=ghcr.io/apache/skywalking/ui \ + --set ui.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.repository=ghcr.io/apache/skywalking/oap \ + --set oap.storageType=elasticsearch \ + -f test/e2e/base/kubernetes-values.yaml + wait: + - namespace: istio-system + resource: deployments/skywalking-oap + for: condition=available + - name: Deploy services + command: | + export IMAGE_NAME=test/offcpu-golang:test + envsubst < test/e2e/cases/profiling/task/offcpu/service.yaml | kubectl apply -f - + envsubst < test/e2e/cases/profiling/task/offcpu/rover.yaml | kubectl apply -f - + wait: + - namespace: default + resource: pod + for: condition=Ready verify: # verify with retry strategy @@ -37,9 +74,9 @@ verify: - includes: - ../profiling-cases.yaml - query: | - taskid=$(swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf list --service-name file |yq e '.[0].taskid' -) - scheduleid=$(swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf schedules --task-id=$taskid |yq e '.[0].scheduleid' -); - start=$(swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf schedules --task-id=$taskid | yq e '.[0].starttime' -) - end=$(swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf schedules --task-id=$taskid | yq e '.[0].endtime' -) - swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf analysis --schedule-id=$scheduleid --time-ranges=$start-$end + taskid=$(swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf list --service-name file |yq e '.[0].taskid' -) + scheduleid=$(swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf schedules --task-id=$taskid |yq e '.[0].scheduleid' -); + start=$(swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf schedules --task-id=$taskid | yq e '.[0].starttime' -) + end=$(swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf schedules --task-id=$taskid | yq e '.[0].endtime' -) + swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf analysis --schedule-id=$scheduleid --time-ranges=$start-$end expected: profiling-analysis.yml \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/offcpu/profiling-cases.yaml b/test/e2e/cases/profiling/task/offcpu/profiling-cases.yaml index b2c72859..3f1e92ab 100644 --- a/test/e2e/cases/profiling/task/offcpu/profiling-cases.yaml +++ b/test/e2e/cases/profiling/task/offcpu/profiling-cases.yaml @@ -16,19 +16,19 @@ # This file is used to show how to write configuration files and can be used to test. cases: - - query: swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml service ls + - query: swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml service ls expected: expected/service.yml - - query: swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml instance ls --service-name file + - query: swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml instance ls --service-name file expected: expected/instance.yml - - query: swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml process ls --service-name file --instance-name test-instance + - query: swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml process ls --service-name file --instance-name test-instance expected: expected/process.yml - query: | - swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf create fixed --service-name file --labels e2e-label1,e2e-label2 --duration 1m --target-type OFF_CPU + swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf create fixed --service-name file --labels k8s-service --duration 1m --target-type OFF_CPU expected: expected/profiling-create.yml - - query: swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf list --service-name file + - query: swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf list --service-name file expected: expected/profiling-task-list.yml - query: | - swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf schedules --task-id=$( \ - swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf list --service-name file |yq e '.[0].taskid' - + swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf schedules --task-id=$( \ + swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf list --service-name file |yq e '.[0].taskid' - ) expected: expected/profiling-schedule-list.yml \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/offcpu/rover.yaml b/test/e2e/cases/profiling/task/offcpu/rover.yaml new file mode 100644 index 00000000..556bfe22 --- /dev/null +++ b/test/e2e/cases/profiling/task/offcpu/rover.yaml @@ -0,0 +1,105 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: v1 +kind: ServiceAccount +metadata: + name: skywalking-rover +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: skywalking-rover +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: skywalking-rover +subjects: + - kind: ServiceAccount + name: skywalking-rover + namespace: default +--- +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: skywalking-rover +rules: + - apiGroups: [""] + resources: ["pods", "nodes", "services"] + verbs: ["get", "watch", "list"] +--- + +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: skywalking-rover +spec: + selector: + matchLabels: + name: skywalking-rover + template: + metadata: + labels: + name: skywalking-rover + spec: + serviceAccountName: skywalking-rover + serviceAccount: skywalking-rover + containers: + - name: skywalking-rover + # SkyWalking Rover image path + image: apache/skywalking-rover:latest + imagePullPolicy: IfNotPresent + securityContext: + capabilities: + add: + - SYS_PTRACE + - SYS_ADMIN + privileged: true + volumeMounts: + - name: host + mountPath: /host + readOnly: true + env: + - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_ACTIVE + value: "true" + - name: ROVER_LOGGER_LEVEL + value: "DEBUG" + - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: ROVER_BACKEND_ADDR + # backend OAP address + value: skywalking-oap.istio-system:11800 + - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_ISTIO_ENVOY_ACTIVE + value: "false" + - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_ISTIO_APPLICATION_ACTIVE + value: "false" + - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_K8S_SERVICE_HAS_SERVICE + value: '.Pod.HasContainer "file"' + - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_K8S_SERVICE_NAME + value: "file" + - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_K8S_SERVICE_INSTANCE_NAME + value: "test-instance" + - name: ROVER_HOST_MAPPING + value: /host + hostPID: true + hostNetwork: true + dnsPolicy: ClusterFirstWithHostNet + volumes: + - name: host + hostPath: + path: /host + type: Directory \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/offcpu/rust/docker-compose.yml b/test/e2e/cases/profiling/task/offcpu/rust/docker-compose.yml deleted file mode 100644 index 02633df7..00000000 --- a/test/e2e/cases/profiling/task/offcpu/rust/docker-compose.yml +++ /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. - -version: '2.1' - -services: - oap: - extends: - file: ../../../../../base/base-compose.yml - service: oap - ports: - - 12800:12800 - - rover: - extends: - file: ../../../../../base/base-compose.yml - service: rover - environment: - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_MATCH_CMD: /file - ROVER_PROCESS_DISCOVERY_REGEX_SCANNER_SERVICE_NAME: file - depends_on: - oap: - condition: service_healthy - - file_rust: - build: - context: . - dockerfile: Dockerfile.file - networks: - - e2e - -networks: - e2e: \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/offcpu/rust/e2e.yaml b/test/e2e/cases/profiling/task/offcpu/rust/e2e.yaml index 1a462f55..0cb4e310 100644 --- a/test/e2e/cases/profiling/task/offcpu/rust/e2e.yaml +++ b/test/e2e/cases/profiling/task/offcpu/rust/e2e.yaml @@ -14,10 +14,18 @@ # limitations under the License. setup: - env: compose - file: docker-compose.yml + env: kind + file: ../../../../../base/kind.yaml timeout: 20m init-system-environment: ../../../../../base/env + kind: + import-images: + - apache/skywalking-rover:latest + - test/offcpu-rust:test + expose-ports: + - namespace: istio-system + resource: service/skywalking-ui + port: 80 steps: - name: set PATH command: export PATH=/tmp/skywalking-infra-e2e/bin:$PATH @@ -25,6 +33,35 @@ setup: command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh yq - name: install swctl command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh swctl + - name: Install SkyWalking + command: | + kubectl create namespace istio-system + helm -n istio-system install skywalking \ + oci://ghcr.io/apache/skywalking-helm/skywalking-helm \ + --version "0.0.0-${SW_KUBERNETES_COMMIT_SHA}" \ + --set fullnameOverride=skywalking \ + --set elasticsearch.replicas=1 \ + --set elasticsearch.minimumMasterNodes=1 \ + --set oap.replicas=1 \ + --set ui.image.repository=ghcr.io/apache/skywalking/ui \ + --set ui.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.repository=ghcr.io/apache/skywalking/oap \ + --set oap.storageType=elasticsearch \ + -f test/e2e/base/kubernetes-values.yaml + wait: + - namespace: istio-system + resource: deployments/skywalking-oap + for: condition=available + - name: Deploy services + command: | + export IMAGE_NAME=test/offcpu-rust:test + envsubst < test/e2e/cases/profiling/task/offcpu/service.yaml | kubectl apply -f - + envsubst < test/e2e/cases/profiling/task/offcpu/rover.yaml | kubectl apply -f - + wait: + - namespace: default + resource: pod + for: condition=Ready verify: # verify with retry strategy @@ -37,9 +74,9 @@ verify: - includes: - ../profiling-cases.yaml - query: | - taskid=$(swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf list --service-name file |yq e '.[0].taskid' -) - scheduleid=$(swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf schedules --task-id=$taskid |yq e '.[0].scheduleid' -); - start=$(swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf schedules --task-id=$taskid | yq e '.[0].starttime' -) - end=$(swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf schedules --task-id=$taskid | yq e '.[0].endtime' -) - swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf analysis --schedule-id=$scheduleid --time-ranges=$start-$end + taskid=$(swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf list --service-name file |yq e '.[0].taskid' -) + scheduleid=$(swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf schedules --task-id=$taskid |yq e '.[0].scheduleid' -); + start=$(swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf schedules --task-id=$taskid | yq e '.[0].starttime' -) + end=$(swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf schedules --task-id=$taskid | yq e '.[0].endtime' -) + swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf analysis --schedule-id=$scheduleid --time-ranges=$start-$end expected: profiling-analysis.yml \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/offcpu/service.yaml b/test/e2e/cases/profiling/task/offcpu/service.yaml new file mode 100644 index 00000000..0286629f --- /dev/null +++ b/test/e2e/cases/profiling/task/offcpu/service.yaml @@ -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. + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: file-deployment +spec: + replicas: 1 + selector: + matchLabels: + app: file + template: + metadata: + labels: + app: file + spec: + containers: + - name: file + image: ${IMAGE_NAME} \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/oncpu/c++/docker-compose.yml b/test/e2e/cases/profiling/task/oncpu/c++/docker-compose.yml deleted file mode 100644 index 05d7d6ee..00000000 --- a/test/e2e/cases/profiling/task/oncpu/c++/docker-compose.yml +++ /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. - -version: '2.1' - -services: - oap: - extends: - file: ../../../../../base/base-compose.yml - service: oap - ports: - - 12800:12800 - - rover: - extends: - file: ../../../../../base/base-compose.yml - service: rover - depends_on: - oap: - condition: service_healthy - - sqrt_c_plus_plus: - build: - context: . - dockerfile: Dockerfile.sqrt - networks: - - e2e - -networks: - e2e: \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/oncpu/c++/e2e.yaml b/test/e2e/cases/profiling/task/oncpu/c++/e2e.yaml index 483ae8e7..bb55d9c6 100644 --- a/test/e2e/cases/profiling/task/oncpu/c++/e2e.yaml +++ b/test/e2e/cases/profiling/task/oncpu/c++/e2e.yaml @@ -14,10 +14,18 @@ # limitations under the License. setup: - env: compose - file: docker-compose.yml + env: kind + file: ../../../../../base/kind.yaml timeout: 20m init-system-environment: ../../../../../base/env + kind: + import-images: + - apache/skywalking-rover:latest + - test/oncpu-c_plus_plus:test + expose-ports: + - namespace: istio-system + resource: service/skywalking-ui + port: 80 steps: - name: set PATH command: export PATH=/tmp/skywalking-infra-e2e/bin:$PATH @@ -25,6 +33,35 @@ setup: command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh yq - name: install swctl command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh swctl + - name: Install SkyWalking + command: | + kubectl create namespace istio-system + helm -n istio-system install skywalking \ + oci://ghcr.io/apache/skywalking-helm/skywalking-helm \ + --version "0.0.0-${SW_KUBERNETES_COMMIT_SHA}" \ + --set fullnameOverride=skywalking \ + --set elasticsearch.replicas=1 \ + --set elasticsearch.minimumMasterNodes=1 \ + --set oap.replicas=1 \ + --set ui.image.repository=ghcr.io/apache/skywalking/ui \ + --set ui.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.repository=ghcr.io/apache/skywalking/oap \ + --set oap.storageType=elasticsearch \ + -f test/e2e/base/kubernetes-values.yaml + wait: + - namespace: istio-system + resource: deployments/skywalking-oap + for: condition=available + - name: Deploy services + command: | + export IMAGE_NAME=test/oncpu-c_plus_plus:test + envsubst < test/e2e/cases/profiling/task/oncpu/service.yaml | kubectl apply -f - + envsubst < test/e2e/cases/profiling/task/oncpu/rover.yaml | kubectl apply -f - + wait: + - namespace: default + resource: pod + for: condition=Ready verify: # verify with retry strategy @@ -37,9 +74,9 @@ verify: - includes: - ../profiling-cases.yaml - query: | - taskid=$(swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf list --service-name sqrt |yq e '.[0].taskid' -) - scheduleid=$(swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf schedules --task-id=$taskid |yq e '.[0].scheduleid' -); - start=$(swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf schedules --task-id=$taskid | yq e '.[0].starttime' -) - end=$(swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf schedules --task-id=$taskid | yq e '.[0].endtime' -) - swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf analysis --schedule-id=$scheduleid --time-ranges=$start-$end + taskid=$(swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf list --service-name sqrt |yq e '.[0].taskid' -) + scheduleid=$(swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf schedules --task-id=$taskid |yq e '.[0].scheduleid' -); + start=$(swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf schedules --task-id=$taskid | yq e '.[0].starttime' -) + end=$(swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf schedules --task-id=$taskid | yq e '.[0].endtime' -) + swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf analysis --schedule-id=$scheduleid --time-ranges=$start-$end expected: profiling-analysis.yml \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/oncpu/c/e2e.yaml b/test/e2e/cases/profiling/task/oncpu/c/e2e.yaml index 483ae8e7..95bb1b20 100644 --- a/test/e2e/cases/profiling/task/oncpu/c/e2e.yaml +++ b/test/e2e/cases/profiling/task/oncpu/c/e2e.yaml @@ -14,10 +14,18 @@ # limitations under the License. setup: - env: compose - file: docker-compose.yml + env: kind + file: ../../../../../base/kind.yaml timeout: 20m init-system-environment: ../../../../../base/env + kind: + import-images: + - apache/skywalking-rover:latest + - test/oncpu-c:test + expose-ports: + - namespace: istio-system + resource: service/skywalking-ui + port: 80 steps: - name: set PATH command: export PATH=/tmp/skywalking-infra-e2e/bin:$PATH @@ -25,6 +33,35 @@ setup: command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh yq - name: install swctl command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh swctl + - name: Install SkyWalking + command: | + kubectl create namespace istio-system + helm -n istio-system install skywalking \ + oci://ghcr.io/apache/skywalking-helm/skywalking-helm \ + --version "0.0.0-${SW_KUBERNETES_COMMIT_SHA}" \ + --set fullnameOverride=skywalking \ + --set elasticsearch.replicas=1 \ + --set elasticsearch.minimumMasterNodes=1 \ + --set oap.replicas=1 \ + --set ui.image.repository=ghcr.io/apache/skywalking/ui \ + --set ui.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.repository=ghcr.io/apache/skywalking/oap \ + --set oap.storageType=elasticsearch \ + -f test/e2e/base/kubernetes-values.yaml + wait: + - namespace: istio-system + resource: deployments/skywalking-oap + for: condition=available + - name: Deploy services + command: | + export IMAGE_NAME=test/oncpu-c:test + envsubst < test/e2e/cases/profiling/task/oncpu/service.yaml | kubectl apply -f - + envsubst < test/e2e/cases/profiling/task/oncpu/rover.yaml | kubectl apply -f - + wait: + - namespace: default + resource: pod + for: condition=Ready verify: # verify with retry strategy @@ -37,9 +74,9 @@ verify: - includes: - ../profiling-cases.yaml - query: | - taskid=$(swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf list --service-name sqrt |yq e '.[0].taskid' -) - scheduleid=$(swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf schedules --task-id=$taskid |yq e '.[0].scheduleid' -); - start=$(swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf schedules --task-id=$taskid | yq e '.[0].starttime' -) - end=$(swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf schedules --task-id=$taskid | yq e '.[0].endtime' -) - swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf analysis --schedule-id=$scheduleid --time-ranges=$start-$end + taskid=$(swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf list --service-name sqrt |yq e '.[0].taskid' -) + scheduleid=$(swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf schedules --task-id=$taskid |yq e '.[0].scheduleid' -); + start=$(swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf schedules --task-id=$taskid | yq e '.[0].starttime' -) + end=$(swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf schedules --task-id=$taskid | yq e '.[0].endtime' -) + swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf analysis --schedule-id=$scheduleid --time-ranges=$start-$end expected: profiling-analysis.yml \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/oncpu/expected/process.yml b/test/e2e/cases/profiling/task/oncpu/expected/process.yml index 02e62c08..556e7074 100644 --- a/test/e2e/cases/profiling/task/oncpu/expected/process.yml +++ b/test/e2e/cases/profiling/task/oncpu/expected/process.yml @@ -21,7 +21,7 @@ instanceid: {{ b64enc "sqrt" }}.1_{{ b64enc "test-instance" }} instancename: test-instance agentid: {{ notEmpty .agentid }} - detecttype: VM + detecttype: KUBERNETES attributes: {{- contains .attributes }} - name: host_ip @@ -32,8 +32,5 @@ value: /sqrt {{- end }} labels: - {{- contains .labels }} - - e2e-label1 - - e2e-label2 - {{- end }} + - k8s-service {{- end }} \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/oncpu/expected/profiling-create-prepare.yml b/test/e2e/cases/profiling/task/oncpu/expected/profiling-create-prepare.yml index b1226a33..61218779 100644 --- a/test/e2e/cases/profiling/task/oncpu/expected/profiling-create-prepare.yml +++ b/test/e2e/cases/profiling/task/oncpu/expected/profiling-create-prepare.yml @@ -15,7 +15,4 @@ couldprofiling: true processlabels: - {{- contains .processlabels }} - - e2e-label1 - - e2e-label2 - {{- end }} \ No newline at end of file + - k8s-service \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/oncpu/expected/profiling-schedule-list.yml b/test/e2e/cases/profiling/task/oncpu/expected/profiling-schedule-list.yml index 0127ebf2..ade296ee 100644 --- a/test/e2e/cases/profiling/task/oncpu/expected/profiling-schedule-list.yml +++ b/test/e2e/cases/profiling/task/oncpu/expected/profiling-schedule-list.yml @@ -24,7 +24,7 @@ instanceid: {{ b64enc "sqrt" }}.1_{{ b64enc "test-instance" }} instancename: test-instance agentid: {{ notEmpty .process.agentid }} - detecttype: VM + detecttype: KUBERNETES attributes: {{- contains .process.attributes }} - name: host_ip @@ -35,10 +35,7 @@ value: /sqrt {{- end }} labels: - {{- contains .process.labels }} - - e2e-label1 - - e2e-label2 - {{- end }} + - k8s-service starttime: {{ gt .starttime 0 }} endtime: {{ gt .endtime 0 }} {{- end }} \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/oncpu/expected/profiling-task-list.yml b/test/e2e/cases/profiling/task/oncpu/expected/profiling-task-list.yml index 0147501b..f673666e 100644 --- a/test/e2e/cases/profiling/task/oncpu/expected/profiling-task-list.yml +++ b/test/e2e/cases/profiling/task/oncpu/expected/profiling-task-list.yml @@ -20,10 +20,7 @@ serviceinstanceid: null serviceinstancename: null processlabels: - {{- contains .processlabels }} - - e2e-label1 - - e2e-label2 - {{- end }} + - k8s-service processid: null processname: null taskstarttime: {{ gt .taskstarttime 0 }} diff --git a/test/e2e/cases/profiling/task/oncpu/expected/service.yml b/test/e2e/cases/profiling/task/oncpu/expected/service.yml index 4c0ee2b0..6929c68a 100644 --- a/test/e2e/cases/profiling/task/oncpu/expected/service.yml +++ b/test/e2e/cases/profiling/task/oncpu/expected/service.yml @@ -19,6 +19,6 @@ group: "" shortname: sqrt layers: - - OS_LINUX + - K8S_SERVICE normal: true {{- end }} \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/oncpu/golang/e2e.yaml b/test/e2e/cases/profiling/task/oncpu/golang/e2e.yaml index 483ae8e7..3c103824 100644 --- a/test/e2e/cases/profiling/task/oncpu/golang/e2e.yaml +++ b/test/e2e/cases/profiling/task/oncpu/golang/e2e.yaml @@ -14,10 +14,18 @@ # limitations under the License. setup: - env: compose - file: docker-compose.yml + env: kind + file: ../../../../../base/kind.yaml timeout: 20m init-system-environment: ../../../../../base/env + kind: + import-images: + - apache/skywalking-rover:latest + - test/oncpu-golang:test + expose-ports: + - namespace: istio-system + resource: service/skywalking-ui + port: 80 steps: - name: set PATH command: export PATH=/tmp/skywalking-infra-e2e/bin:$PATH @@ -25,6 +33,35 @@ setup: command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh yq - name: install swctl command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh swctl + - name: Install SkyWalking + command: | + kubectl create namespace istio-system + helm -n istio-system install skywalking \ + oci://ghcr.io/apache/skywalking-helm/skywalking-helm \ + --version "0.0.0-${SW_KUBERNETES_COMMIT_SHA}" \ + --set fullnameOverride=skywalking \ + --set elasticsearch.replicas=1 \ + --set elasticsearch.minimumMasterNodes=1 \ + --set oap.replicas=1 \ + --set ui.image.repository=ghcr.io/apache/skywalking/ui \ + --set ui.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.repository=ghcr.io/apache/skywalking/oap \ + --set oap.storageType=elasticsearch \ + -f test/e2e/base/kubernetes-values.yaml + wait: + - namespace: istio-system + resource: deployments/skywalking-oap + for: condition=available + - name: Deploy services + command: | + export IMAGE_NAME=test/oncpu-golang:test + envsubst < test/e2e/cases/profiling/task/oncpu/service.yaml | kubectl apply -f - + envsubst < test/e2e/cases/profiling/task/oncpu/rover.yaml | kubectl apply -f - + wait: + - namespace: default + resource: pod + for: condition=Ready verify: # verify with retry strategy @@ -37,9 +74,9 @@ verify: - includes: - ../profiling-cases.yaml - query: | - taskid=$(swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf list --service-name sqrt |yq e '.[0].taskid' -) - scheduleid=$(swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf schedules --task-id=$taskid |yq e '.[0].scheduleid' -); - start=$(swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf schedules --task-id=$taskid | yq e '.[0].starttime' -) - end=$(swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf schedules --task-id=$taskid | yq e '.[0].endtime' -) - swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf analysis --schedule-id=$scheduleid --time-ranges=$start-$end + taskid=$(swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf list --service-name sqrt |yq e '.[0].taskid' -) + scheduleid=$(swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf schedules --task-id=$taskid |yq e '.[0].scheduleid' -); + start=$(swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf schedules --task-id=$taskid | yq e '.[0].starttime' -) + end=$(swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf schedules --task-id=$taskid | yq e '.[0].endtime' -) + swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf analysis --schedule-id=$scheduleid --time-ranges=$start-$end expected: profiling-analysis.yml \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/oncpu/profiling-cases.yaml b/test/e2e/cases/profiling/task/oncpu/profiling-cases.yaml index eb6956f6..782cbfd8 100644 --- a/test/e2e/cases/profiling/task/oncpu/profiling-cases.yaml +++ b/test/e2e/cases/profiling/task/oncpu/profiling-cases.yaml @@ -16,23 +16,23 @@ # This file is used to show how to write configuration files and can be used to test. cases: - - query: swctl --display yaml service ls + - query: swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml service ls expected: expected/service.yml - - query: swctl --display yaml instance ls --service-name sqrt + - query: swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml instance ls --service-name sqrt expected: expected/instance.yml - - query: swctl --display yaml process ls --service-name sqrt --instance-name test-instance + - query: swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml process ls --service-name sqrt --instance-name test-instance expected: expected/process.yml - - query: swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf create prepare --service-name sqrt + - query: swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf create prepare --service-name sqrt expected: expected/profiling-create-prepare.yml - - query: swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml process estimate scale --service-name sqrt --labels e2e-label1,e2e-label2 + - query: swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml process estimate scale --service-name sqrt --labels k8s-service expected: expected/process-estimate-scale.yml - query: | - swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf create fixed --service-name sqrt --labels e2e-label1,e2e-label2 --duration 1m + swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf create fixed --service-name sqrt --labels k8s-service --duration 1m expected: expected/profiling-create.yml - - query: swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf list --service-name sqrt + - query: swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf list --service-name sqrt expected: expected/profiling-task-list.yml - query: | - swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf schedules --task-id=$( \ - swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf list --service-name sqrt |yq e '.[0].taskid' - + swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf schedules --task-id=$( \ + swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf list --service-name sqrt |yq e '.[0].taskid' - ) expected: expected/profiling-schedule-list.yml \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/oncpu/rover.yaml b/test/e2e/cases/profiling/task/oncpu/rover.yaml new file mode 100644 index 00000000..5e88bdf7 --- /dev/null +++ b/test/e2e/cases/profiling/task/oncpu/rover.yaml @@ -0,0 +1,105 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: v1 +kind: ServiceAccount +metadata: + name: skywalking-rover +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: skywalking-rover +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: skywalking-rover +subjects: + - kind: ServiceAccount + name: skywalking-rover + namespace: default +--- +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: skywalking-rover +rules: + - apiGroups: [""] + resources: ["pods", "nodes", "services"] + verbs: ["get", "watch", "list"] +--- + +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: skywalking-rover +spec: + selector: + matchLabels: + name: skywalking-rover + template: + metadata: + labels: + name: skywalking-rover + spec: + serviceAccountName: skywalking-rover + serviceAccount: skywalking-rover + containers: + - name: skywalking-rover + # SkyWalking Rover image path + image: apache/skywalking-rover:latest + imagePullPolicy: IfNotPresent + securityContext: + capabilities: + add: + - SYS_PTRACE + - SYS_ADMIN + privileged: true + volumeMounts: + - name: host + mountPath: /host + readOnly: true + env: + - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_ACTIVE + value: "true" + - name: ROVER_LOGGER_LEVEL + value: "DEBUG" + - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: ROVER_BACKEND_ADDR + # backend OAP address + value: skywalking-oap.istio-system:11800 + - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_ISTIO_ENVOY_ACTIVE + value: "false" + - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_ISTIO_APPLICATION_ACTIVE + value: "false" + - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_K8S_SERVICE_HAS_SERVICE + value: '.Pod.HasContainer "sqrt"' + - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_K8S_SERVICE_NAME + value: "sqrt" + - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_K8S_SERVICE_INSTANCE_NAME + value: "test-instance" + - name: ROVER_HOST_MAPPING + value: /host + hostPID: true + hostNetwork: true + dnsPolicy: ClusterFirstWithHostNet + volumes: + - name: host + hostPath: + path: /host + type: Directory \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/oncpu/rust/e2e.yaml b/test/e2e/cases/profiling/task/oncpu/rust/e2e.yaml index 483ae8e7..213e80b2 100644 --- a/test/e2e/cases/profiling/task/oncpu/rust/e2e.yaml +++ b/test/e2e/cases/profiling/task/oncpu/rust/e2e.yaml @@ -14,10 +14,18 @@ # limitations under the License. setup: - env: compose - file: docker-compose.yml + env: kind + file: ../../../../../base/kind.yaml timeout: 20m init-system-environment: ../../../../../base/env + kind: + import-images: + - apache/skywalking-rover:latest + - test/oncpu-rust:test + expose-ports: + - namespace: istio-system + resource: service/skywalking-ui + port: 80 steps: - name: set PATH command: export PATH=/tmp/skywalking-infra-e2e/bin:$PATH @@ -25,6 +33,35 @@ setup: command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh yq - name: install swctl command: bash test/e2e/base/scripts/prepare/setup-e2e-shell/install.sh swctl + - name: Install SkyWalking + command: | + kubectl create namespace istio-system + helm -n istio-system install skywalking \ + oci://ghcr.io/apache/skywalking-helm/skywalking-helm \ + --version "0.0.0-${SW_KUBERNETES_COMMIT_SHA}" \ + --set fullnameOverride=skywalking \ + --set elasticsearch.replicas=1 \ + --set elasticsearch.minimumMasterNodes=1 \ + --set oap.replicas=1 \ + --set ui.image.repository=ghcr.io/apache/skywalking/ui \ + --set ui.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.tag=${SW_OAP_COMMIT} \ + --set oap.image.repository=ghcr.io/apache/skywalking/oap \ + --set oap.storageType=elasticsearch \ + -f test/e2e/base/kubernetes-values.yaml + wait: + - namespace: istio-system + resource: deployments/skywalking-oap + for: condition=available + - name: Deploy services + command: | + export IMAGE_NAME=test/oncpu-rust:test + envsubst < test/e2e/cases/profiling/task/oncpu/service.yaml | kubectl apply -f - + envsubst < test/e2e/cases/profiling/task/oncpu/rover.yaml | kubectl apply -f - + wait: + - namespace: default + resource: pod + for: condition=Ready verify: # verify with retry strategy @@ -37,9 +74,9 @@ verify: - includes: - ../profiling-cases.yaml - query: | - taskid=$(swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf list --service-name sqrt |yq e '.[0].taskid' -) - scheduleid=$(swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf schedules --task-id=$taskid |yq e '.[0].scheduleid' -); - start=$(swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf schedules --task-id=$taskid | yq e '.[0].starttime' -) - end=$(swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf schedules --task-id=$taskid | yq e '.[0].endtime' -) - swctl --base-url=http://${oap_host}:${oap_12800}/graphql --display yaml profiling ebpf analysis --schedule-id=$scheduleid --time-ranges=$start-$end + taskid=$(swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf list --service-name sqrt |yq e '.[0].taskid' -) + scheduleid=$(swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf schedules --task-id=$taskid |yq e '.[0].scheduleid' -); + start=$(swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf schedules --task-id=$taskid | yq e '.[0].starttime' -) + end=$(swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf schedules --task-id=$taskid | yq e '.[0].endtime' -) + swctl --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql --display yaml profiling ebpf analysis --schedule-id=$scheduleid --time-ranges=$start-$end expected: profiling-analysis.yml \ No newline at end of file diff --git a/test/e2e/cases/profiling/task/oncpu/service.yaml b/test/e2e/cases/profiling/task/oncpu/service.yaml new file mode 100644 index 00000000..d51c352a --- /dev/null +++ b/test/e2e/cases/profiling/task/oncpu/service.yaml @@ -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. + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: sqrt-deployment +spec: + replicas: 1 + selector: + matchLabels: + app: sqrt + template: + metadata: + labels: + app: sqrt + spec: + containers: + - name: sqrt + image: ${IMAGE_NAME} \ No newline at end of file