diff --git a/.github/workflows/skywalking.yaml b/.github/workflows/skywalking.yaml index d83a708c11..599d547c4a 100644 --- a/.github/workflows/skywalking.yaml +++ b/.github/workflows/skywalking.yaml @@ -716,6 +716,10 @@ jobs: with: submodules: true persist-credentials: false + - run: grep -v '^#' test/e2e-v2/script/env >> "$GITHUB_ENV" + - uses: apache/skywalking-cli/actions/setup@master + with: + version: ${{ env.SW_CTL_COMMIT }} - uses: actions/download-artifact@v4 name: Download docker images with: @@ -796,6 +800,10 @@ jobs: with: submodules: true persist-credentials: false + - run: grep -v '^#' test/e2e-v2/script/env >> "$GITHUB_ENV" + - uses: apache/skywalking-cli/actions/setup@master + with: + version: ${{ env.SW_CTL_COMMIT }} - uses: actions/download-artifact@v4 name: Download docker images with: @@ -848,6 +856,10 @@ jobs: with: submodules: true persist-credentials: false + - run: grep -v '^#' test/e2e-v2/script/env >> "$GITHUB_ENV" + - uses: apache/skywalking-cli/actions/setup@master + with: + version: ${{ env.SW_CTL_COMMIT }} - uses: actions/download-artifact@v4 name: Download docker images with: @@ -877,6 +889,111 @@ jobs: with: e2e-file: $GITHUB_WORKSPACE/test/e2e-v2/cases/simple/jdk/e2e.yaml + e2e-test-banyandb-stages: + if: | + ( always() && ! cancelled() ) && + ((github.event_name == 'schedule' && github.repository == 'apache/skywalking') || needs.changes.outputs.oap == 'true') + name: E2E test + needs: [docker, dist-tar] + runs-on: ${{ matrix.test.runs-on || 'ubuntu-latest' }} + timeout-minutes: 60 + env: + BANYANDB_DATA_GENERATE_ROOT: test/e2e-v2/cases/storage/banyandb/data-generate + strategy: + fail-fast: false + matrix: + test: + - name: BanyanDB Stages + config: test/e2e-v2/cases/storage/banyandb/stages/e2e.yaml + steps: + - uses: actions/checkout@v4 + with: + submodules: true + persist-credentials: false + - run: grep -v '^#' test/e2e-v2/script/env >> "$GITHUB_ENV" + - uses: apache/skywalking-cli/actions/setup@master + with: + version: ${{ env.SW_CTL_COMMIT }} + - uses: actions/download-artifact@v4 + name: Download docker images + with: + name: docker-images-11 + path: docker-images + - name: Load docker images + run: | + find docker-images -name "*.tar" -exec docker load -i {} \; + find docker-images -name "*.tar" -exec rm {} \; + - uses: actions/download-artifact@v4 + name: Download distribution tar + with: + name: dist + path: dist + - name: Login to ghcr + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Cache maven repository + uses: actions/cache@v4 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('test/e2e-v2/java-test-service/**/pom.xml') }} + restore-keys: ${{ runner.os }}-maven- + - name: Prepare test services + shell: bash + run: ./mvnw -B -q -f test/e2e-v2/java-test-service/pom.xml clean flatten:flatten package + - 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.docker.base }}/${{ matrix.test.docker.file }} ${{ matrix.test.docker.base }} + - name: Generate BanyanDB cold data + run: | + export $(grep -v '^#' test/e2e-v2/script/env | xargs) + docker compose -f ${BANYANDB_DATA_GENERATE_ROOT}/docker-compose.yml up -d + CONTAINER_ID=$(docker compose -f ${BANYANDB_DATA_GENERATE_ROOT}/docker-compose.yml ps -q banyandb) + echo "⌛ monitoring segment files..." + found=false + for i in {1..60}; do + # check if segment files exist + if docker exec $CONTAINER_ID sh -c '[ -n "$(ls /tmp/measure-data/measure/data/day/seg* 2>/dev/null)" ]'; then + echo "✅ found segment files" + sleep 30 + # create and copy files + docker cp $CONTAINER_ID:/tmp ${BANYANDB_DATA_GENERATE_ROOT} + docker cp $CONTAINER_ID:/tmp/measure-data/measure/data/index ${BANYANDB_DATA_GENERATE_ROOT} + found=true + break + else + echo "⏳ didn't find segment files (retry $i/60)" + sleep 10 + fi + done + if $found; then + echo "✅ segment files copied to ${BANYANDB_DATA_GENERATE_ROOT}" + else + echo "❌ segment files not found" + exit 1 + fi + docker compose -f ${BANYANDB_DATA_GENERATE_ROOT}/docker-compose.yml down -v + - name: ${{ matrix.test.name }} + uses: apache/skywalking-infra-e2e@cf589b4a0b9f8e6f436f78e9cfd94a1ee5494180 + with: + e2e-file: $GITHUB_WORKSPACE/${{ matrix.test.config }} + - if: ${{ failure() }} + run: | + df -h + du -sh . + docker images + - uses: actions/upload-artifact@v4 + if: ${{ failure() }} + name: Upload Logs + with: + name: test-logs-${{ matrix.test.name }} + path: "${{ env.SW_INFRA_E2E_LOG_DIR }}" + required: if: always() name: Required diff --git a/test/e2e-v2/cases/apisix/otel-collector/e2e.yaml b/test/e2e-v2/cases/apisix/otel-collector/e2e.yaml index bd1dd45e79..283c4d3e11 100644 --- a/test/e2e-v2/cases/apisix/otel-collector/e2e.yaml +++ b/test/e2e-v2/cases/apisix/otel-collector/e2e.yaml @@ -37,8 +37,8 @@ trigger: verify: retry: - count: 10 - interval: 3s + count: 20 + interval: 10s cases: - includes: - - ../apisix-cases.yaml \ No newline at end of file + - ../apisix-cases.yaml diff --git a/test/e2e-v2/cases/aws/api-gateway/e2e.yaml b/test/e2e-v2/cases/aws/api-gateway/e2e.yaml index 358fab7090..2b221d493b 100644 --- a/test/e2e-v2/cases/aws/api-gateway/e2e.yaml +++ b/test/e2e-v2/cases/aws/api-gateway/e2e.yaml @@ -37,8 +37,8 @@ trigger: verify: retry: - count: 10 - interval: 3s + count: 20 + interval: 10s cases: - includes: - ./gateway-cases.yaml diff --git a/test/e2e-v2/cases/aws/dynamodb/e2e.yaml b/test/e2e-v2/cases/aws/dynamodb/e2e.yaml index e99cba86dd..ef3a9b1480 100644 --- a/test/e2e-v2/cases/aws/dynamodb/e2e.yaml +++ b/test/e2e-v2/cases/aws/dynamodb/e2e.yaml @@ -37,8 +37,8 @@ trigger: verify: retry: - count: 10 - interval: 3s + count: 20 + interval: 10s cases: - includes: - - ./dynamodb-cases.yaml \ No newline at end of file + - ./dynamodb-cases.yaml diff --git a/test/e2e-v2/cases/aws/eks/e2e.yaml b/test/e2e-v2/cases/aws/eks/e2e.yaml index 7eb0bdabb5..938e46a1a3 100644 --- a/test/e2e-v2/cases/aws/eks/e2e.yaml +++ b/test/e2e-v2/cases/aws/eks/e2e.yaml @@ -37,8 +37,8 @@ trigger: verify: retry: - count: 10 - interval: 3s + count: 20 + interval: 10s cases: - includes: - ./eks-cases.yaml diff --git a/test/e2e-v2/cases/aws/s3/e2e.yaml b/test/e2e-v2/cases/aws/s3/e2e.yaml index 5cde5b61d1..7ae7e0d4e2 100644 --- a/test/e2e-v2/cases/aws/s3/e2e.yaml +++ b/test/e2e-v2/cases/aws/s3/e2e.yaml @@ -37,8 +37,8 @@ trigger: verify: retry: - count: 10 - interval: 3s + count: 20 + interval: 10s cases: - includes: - ./s3-cases.yaml diff --git a/test/e2e-v2/cases/php/e2e.yaml b/test/e2e-v2/cases/php/e2e.yaml index 124f9ac206..bed6bfeddf 100644 --- a/test/e2e-v2/cases/php/e2e.yaml +++ b/test/e2e-v2/cases/php/e2e.yaml @@ -38,10 +38,8 @@ trigger: verify: # verify with retry strategy retry: - # max retry count count: 20 - # the interval between two retries, in millisecond. - interval: 3s + interval: 10s cases: # layer list - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql layer ls diff --git a/test/e2e-v2/cases/storage/banyandb/data-generate/docker-compose.yml b/test/e2e-v2/cases/storage/banyandb/data-generate/docker-compose.yml new file mode 100644 index 0000000000..9bcf98e8c6 --- /dev/null +++ b/test/e2e-v2/cases/storage/banyandb/data-generate/docker-compose.yml @@ -0,0 +1,62 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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: + banyandb: + image: "ghcr.io/apache/skywalking-banyandb:${SW_BANYANDB_COMMIT}" + ports: + - 17912:17912 + - 17913:17913 + command: standalone --stream-root-path /tmp/stream-data --measure-root-path /tmp/measure-data + networks: + - e2e + healthcheck: + test: [ "CMD", "sh", "-c", "nc -nz 127.0.0.1 17912" ] + interval: 5s + timeout: 60s + retries: 120 + + oap: + extends: + file: ../../../../script/docker-compose/base-compose.yml + service: oap + environment: + SW_STORAGE: banyandb + SW_STORAGE_BANYANDB_GR_NORMAL_TTL_DAYS: 5 + SW_STORAGE_BANYANDB_GR_SUPER_TTL_DAYS: 5 + ports: + - 12800 + depends_on: + banyandb: + condition: service_healthy + + trace-mocker: + image: "eclipse-temurin:17-jre" + volumes: + - ../../../../java-test-service/trace-mocker/target/trace-mocker-2.0.0.jar:/trace-mocker-2.0.0.jar + command: [ "java", "-jar", "/trace-mocker-2.0.0.jar" ] + environment: + OAP_HOST: oap + MINUS_DAYS: 3 + networks: + - e2e + depends_on: + oap: + condition: service_healthy + +networks: + e2e: diff --git a/test/e2e-v2/cases/storage/banyandb/stages/docker-compose.yml b/test/e2e-v2/cases/storage/banyandb/stages/docker-compose.yml new file mode 100644 index 0000000000..2f08e694c2 --- /dev/null +++ b/test/e2e-v2/cases/storage/banyandb/stages/docker-compose.yml @@ -0,0 +1,117 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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: + etcd: + extends: + file: ../../../../script/docker-compose/base-compose.yml + service: etcd + networks: + - e2e + + data-hot1: + extends: + file: ../../../../script/docker-compose/base-compose.yml + service: banyandb-data + hostname: data-hot1 + command: data --etcd-endpoints=http://etcd:2379 --node-labels type=hot + volumes: + - ../data-generate/index:/tmp/measure/data/index + networks: + - e2e + + data-warm1: + extends: + file: ../../../../script/docker-compose/base-compose.yml + service: banyandb-data + hostname: data-warm1 + command: data --etcd-endpoints=http://etcd:2379 --node-labels type=warm + networks: + - e2e + + data-cold1: + extends: + file: ../../../../script/docker-compose/base-compose.yml + service: banyandb-data + hostname: data-cold1 + command: data --etcd-endpoints=http://etcd:2379 --node-labels type=cold + volumes: + - ../data-generate/tmp/measure-data/measure:/tmp/measure + - ../data-generate/tmp/stream-data/stream:/tmp/stream + - ../data-generate/tmp/property/data:/tmp/property + networks: + - e2e + + liaison: + extends: + file: ../../../../script/docker-compose/base-compose.yml + service: liaison + command: liaison --etcd-endpoints=http://etcd:2379 --data-node-selector type=hot + networks: + - e2e + + oap: + extends: + file: ../../../../script/docker-compose/base-compose.yml + service: oap + environment: + SW_STORAGE: banyandb + SW_STORAGE_BANYANDB_TARGETS: "liaison:17912" + SW_STORAGE_BANYANDB_GM_MINUTE_ENABLE_WARM_STAGE: "true" + SW_STORAGE_BANYANDB_GM_MINUTE_ENABLE_COLD_STAGE: "true" + SW_STORAGE_BANYANDB_GM_HOUR_ENABLE_WARM_STAGE: "true" + SW_STORAGE_BANYANDB_GM_HOUR_ENABLE_COLD_STAGE: "true" + SW_STORAGE_BANYANDB_GM_DAY_ENABLE_WARM_STAGE: "true" + SW_STORAGE_BANYANDB_GM_DAY_ENABLE_COLD_STAGE: "true" + SW_STORAGE_BANYANDB_GR_NORMAL_ENABLE_WARM_STAGE: "true" + SW_STORAGE_BANYANDB_GR_NORMAL_ENABLE_COLD_STAGE: "true" + SW_STORAGE_BANYANDB_GR_SUPER_ENABLE_WARM_STAGE: "true" + SW_STORAGE_BANYANDB_GR_SUPER_ENABLE_COLD_STAGE: "true" + ports: + - 12800:12800 + - 11800:11800 + depends_on: + liaison: + condition: service_healthy + + provider: + extends: + file: ../../../../script/docker-compose/base-compose.yml + service: provider + ports: + - 9090 + networks: + - e2e + depends_on: + oap: + condition: service_healthy + + consumer: + extends: + file: ../../../../script/docker-compose/base-compose.yml + service: consumer + ports: + - 9092 + depends_on: + oap: + condition: service_healthy + provider: + condition: service_healthy + +networks: + e2e: + diff --git a/test/e2e-v2/cases/storage/banyandb/stages/e2e.yaml b/test/e2e-v2/cases/storage/banyandb/stages/e2e.yaml new file mode 100644 index 0000000000..70d9466e44 --- /dev/null +++ b/test/e2e-v2/cases/storage/banyandb/stages/e2e.yaml @@ -0,0 +1,71 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This file is used to show how to write configuration files and can be used to test. + +setup: + env: compose + file: docker-compose.yml + timeout: 20m + init-system-environment: ../../../../script/env + steps: + - name: set PATH + command: export PATH=/tmp/skywalking-infra-e2e/bin:$PATH + - name: install yq + command: bash test/e2e-v2/script/prepare/setup-e2e-shell/install.sh yq + - name: install swctl + command: bash test/e2e-v2/script/prepare/setup-e2e-shell/install.sh swctl + +trigger: + action: http + interval: 5s + times: 40 + url: http://${consumer_host}:${consumer_9092}/users + method: POST + body: '{"id":"123","name":"skywalking"}' + headers: + "Content-Type": "application/json" + +verify: + # verify with retry strategy + retry: + # max retry count + count: 20 + # the interval between two retries, in millisecond. + interval: 10s + cases: + - includes: + - ../../storage-cases.yaml + - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression="top_n(service_resp_time,3,des,attr0='GENERAL',attr1!='Not_exist')/100" + expected: ../../expected/topN-OP-service.yml + + # cold data test + - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression=service_resp_time --service-name=mock_a_service --start="-96h" --end="-48h" --cold=true --step=DAY + expected: ../../expected/metrics-has-value.yml + - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql dependency service --service-name=mock_a_service --start="-96h" --end="-48h" --cold=true --step=DAY + expected: ../../expected/cold/dependency-services.yml + - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql dependency instance --service-name=mock_a_service --dest-service-name=mock_b_service --start="-96h" --end="-48h" --cold=true --step=DAY + expected: ../../expected/cold/dependency-instance.yml + - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql dependency endpoint --service-name=mock_a_service --endpoint-name=/dubbox-case/case/dubbox-rest/404-test --start="-96h" --end="-48h" --cold=true --step=DAY + expected: ../../expected/cold/dependency-endpoint.yml + # trace segment list + - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql trace ls --tags http.method=get --start="-96h" --end="-48h" --cold=true + expected: ../../expected/cold/traces-list.yml + - query: | + swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql trace ls --trace-id=$( \ + swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql trace ls --tags http.method=get --start="-96h" --end="-48h" --cold=true \ + | yq e '.traces | select(.[].endpointnames[0]=="/dubbox-case/case/dubbox-rest/404-test") | .[0].traceids[0]' - + ) --start="-96h" --end="-48h" --cold=true + expected: ../../expected/cold/trace-detail.yml diff --git a/test/e2e-v2/cases/storage/expected/cold/dependency-endpoint.yml b/test/e2e-v2/cases/storage/expected/cold/dependency-endpoint.yml new file mode 100644 index 0000000000..d381b07335 --- /dev/null +++ b/test/e2e-v2/cases/storage/expected/cold/dependency-endpoint.yml @@ -0,0 +1,54 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +debuggingtrace: null +nodes: +{{- contains .nodes }} +- id: {{ b64enc "mock_a_service" }}.1_{{ b64enc "/dubbox-case/case/dubbox-rest/404-test" }} + name: /dubbox-case/case/dubbox-rest/404-test + serviceid: {{ b64enc "mock_a_service" }}.1 + servicename: mock_a_service + type: "" + isreal: true +- id: {{ b64enc "mock_b_service" }}.1_{{ b64enc "org.skywaking.apm.testcase.dubbo.services.GreetServiceImpl.doBusiness()" }} + name: org.skywaking.apm.testcase.dubbo.services.GreetServiceImpl.doBusiness() + serviceid: {{ b64enc "mock_b_service" }}.1 + servicename: mock_b_service + type: "" + isreal: true +- id: {{ b64enc "User" }}.0_{{ b64enc "User" }} + name: User + serviceid: {{ b64enc "User" }}.0 + servicename: User + type: "" + isreal: false +{{- end }} +calls: +{{- contains .calls }} +- source: {{ b64enc "mock_a_service" }}.1_{{ b64enc "/dubbox-case/case/dubbox-rest/404-test" }} + sourcecomponents: [] + target: {{ b64enc "mock_b_service" }}.1_{{ b64enc "org.skywaking.apm.testcase.dubbo.services.GreetServiceImpl.doBusiness()" }} + targetcomponents: [] + id: {{ b64enc "mock_a_service" }}.1-{{ b64enc "/dubbox-case/case/dubbox-rest/404-test" }}-{{ b64enc "mock_b_service" }}.1-{{ b64enc "org.skywaking.apm.testcase.dubbo.services.GreetServiceImpl.doBusiness()" }} + detectpoints: + - SERVER +- source: {{ b64enc "User" }}.0_{{ b64enc "User" }} + sourcecomponents: [] + target: {{ b64enc "mock_a_service" }}.1_{{ b64enc "/dubbox-case/case/dubbox-rest/404-test" }} + targetcomponents: [] + id: {{ b64enc "User" }}.0-{{ b64enc "User" }}-{{ b64enc "mock_a_service" }}.1-{{ b64enc "/dubbox-case/case/dubbox-rest/404-test" }} + detectpoints: + - SERVER +{{- end }} diff --git a/test/e2e-v2/cases/storage/expected/cold/dependency-instance.yml b/test/e2e-v2/cases/storage/expected/cold/dependency-instance.yml new file mode 100644 index 0000000000..90d583f3a2 --- /dev/null +++ b/test/e2e-v2/cases/storage/expected/cold/dependency-instance.yml @@ -0,0 +1,41 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +debuggingtrace: null +nodes: +{{- contains .nodes }} +- id: {{ b64enc "mock_a_service" }}.1_{{ b64enc "mock_a_service_instance" }} + name: mock_a_service_instance + serviceid: {{ b64enc "mock_a_service" }}.1 + servicename: mock_a_service + type: "" + isreal: true +- id: {{ b64enc "mock_b_service" }}.1_{{ b64enc "mock_b_service_instance" }} + name: mock_b_service_instance + serviceid: {{ b64enc "mock_b_service" }}.1 + servicename: mock_b_service + type: "" + isreal: true +{{- end }} +calls: +{{- contains .calls }} +- source: {{ b64enc "mock_a_service" }}.1_{{ b64enc "mock_a_service_instance" }} + sourcecomponents: [] + target: {{ b64enc "mock_b_service" }}.1_{{ b64enc "mock_b_service_instance" }} + targetcomponents: [] + id: {{ b64enc "mock_a_service" }}.1_{{ b64enc "mock_a_service_instance" }}-{{ b64enc "mock_b_service" }}.1_{{ b64enc "mock_b_service_instance" }} + detectpoints: + - SERVER +{{- end }} diff --git a/test/e2e-v2/cases/storage/expected/cold/dependency-services.yml b/test/e2e-v2/cases/storage/expected/cold/dependency-services.yml new file mode 100644 index 0000000000..d2d62e1777 --- /dev/null +++ b/test/e2e-v2/cases/storage/expected/cold/dependency-services.yml @@ -0,0 +1,58 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +debuggingtrace: null +nodes: +{{- contains .nodes }} +- id: {{ b64enc "User"}}.0 + name: User + type: USER + isreal: false + layers: + - UNDEFINED +- id: {{ b64enc "mock_a_service"}}.1 + name: mock_a_service + type: Tomcat + isreal: true + layers: + - GENERAL +- id: {{ b64enc "mock_b_service"}}.1 + name: mock_b_service + type: Dubbo + isreal: true + layers: + - GENERAL +{{- end }} +calls: +{{- contains .calls }} +- source: {{ b64enc "mock_a_service"}}.1 + sourcecomponents: + - Dubbo + target: {{ b64enc "mock_b_service"}}.1 + targetcomponents: + - Dubbo + id: {{ b64enc "mock_a_service"}}.1-{{ b64enc "mock_b_service"}}.1 + detectpoints: + - CLIENT + - SERVER +- source: {{ b64enc "User" }}.0 + sourcecomponents: [] + target: {{ b64enc "mock_a_service"}}.1 + targetcomponents: + - Tomcat + id: {{ b64enc "User" }}.0-{{ b64enc "mock_a_service"}}.1 + detectpoints: + - SERVER +{{- end }} diff --git a/test/e2e-v2/cases/storage/expected/cold/trace-detail.yml b/test/e2e-v2/cases/storage/expected/cold/trace-detail.yml new file mode 100644 index 0000000000..2b8d683777 --- /dev/null +++ b/test/e2e-v2/cases/storage/expected/cold/trace-detail.yml @@ -0,0 +1,45 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +debuggingtrace: null +spans: + {{- contains .spans }} + - traceid: {{ .traceid }} + segmentid: {{ .segmentid }} + spanid: {{ .spanid }} + parentspanid: {{ .parentspanid }} + refs: [] + servicecode: mock_a_service + serviceinstancename: mock_a_service_instance + starttime: {{ gt .starttime 0 }} + endtime: {{ gt .endtime 0 }} + endpointname: /dubbox-case/case/dubbox-rest/404-test + type: Entry + peer: "" + component: Tomcat + iserror: false + layer: Http + tags: + {{- contains .tags }} + - key: http.method + value: get + - key: http.status_code + value: "404" + - key: http.status_code + value: "200" + {{- end }} + logs: [] + attachedevents: [] + {{- end }} diff --git a/test/e2e-v2/cases/storage/expected/cold/traces-list.yml b/test/e2e-v2/cases/storage/expected/cold/traces-list.yml new file mode 100644 index 0000000000..9c5e4f15f9 --- /dev/null +++ b/test/e2e-v2/cases/storage/expected/cold/traces-list.yml @@ -0,0 +1,27 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +debuggingtrace: null +traces: +{{- contains .traces }} +- segmentid: {{ notEmpty .segmentid }} + endpointnames: + - /dubbox-case/case/dubbox-rest/404-test + duration: {{ ge .duration 0 }} + start: "{{ notEmpty .start}}" + iserror: false + traceids: + - {{ index .traceids 0 }} +{{- end }} diff --git a/test/e2e-v2/cases/win/e2e.yaml b/test/e2e-v2/cases/win/e2e.yaml index 49fd45b9a8..275eb17eb0 100644 --- a/test/e2e-v2/cases/win/e2e.yaml +++ b/test/e2e-v2/cases/win/e2e.yaml @@ -37,8 +37,8 @@ trigger: verify: retry: - count: 10 - interval: 3s + count: 20 + interval: 10s cases: - includes: - ./win-cases.yaml diff --git a/test/e2e-v2/java-test-service/pom.xml b/test/e2e-v2/java-test-service/pom.xml index 68ef442632..1c909770be 100644 --- a/test/e2e-v2/java-test-service/pom.xml +++ b/test/e2e-v2/java-test-service/pom.xml @@ -34,6 +34,7 @@ e2e-protocol opentelemetry-proto e2e-mock-baseline-server + trace-mocker diff --git a/test/e2e-v2/java-test-service/trace-mocker/pom.xml b/test/e2e-v2/java-test-service/trace-mocker/pom.xml new file mode 100644 index 0000000000..fa8d6716bc --- /dev/null +++ b/test/e2e-v2/java-test-service/trace-mocker/pom.xml @@ -0,0 +1,74 @@ + + + + 4.0.0 + + apache-skywalking-e2e + org.apache.skywalking + 2.0.0 + + + trace-mocker + + + + + + + org.apache.skywalking + e2e-protocol + ${project.version} + + + joda-time + joda-time + 2.10.5 + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.6.0 + + + jar-with-dependencies + + + + org.apache.skywalking.mock.AgentDataMock + + + false + + + + package + + single + + + + + + + diff --git a/test/e2e-v2/java-test-service/trace-mocker/src/main/java/org/apache/skywalking/mock/AgentDataMock.java b/test/e2e-v2/java-test-service/trace-mocker/src/main/java/org/apache/skywalking/mock/AgentDataMock.java new file mode 100644 index 0000000000..645ee6e1c4 --- /dev/null +++ b/test/e2e-v2/java-test-service/trace-mocker/src/main/java/org/apache/skywalking/mock/AgentDataMock.java @@ -0,0 +1,132 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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 org.apache.skywalking.mock; + +import io.grpc.ManagedChannel; +import io.grpc.ManagedChannelBuilder; +import io.grpc.stub.StreamObserver; +import java.util.UUID; +import java.util.concurrent.TimeUnit; +import org.apache.skywalking.apm.network.common.v3.Commands; +import org.apache.skywalking.apm.network.common.v3.KeyStringValuePair; +import org.apache.skywalking.apm.network.language.agent.v3.SegmentObject; +import org.apache.skywalking.apm.network.language.agent.v3.TraceSegmentReportServiceGrpc; +import org.apache.skywalking.apm.network.management.v3.InstancePingPkg; +import org.apache.skywalking.apm.network.management.v3.InstanceProperties; +import org.apache.skywalking.apm.network.management.v3.ManagementServiceGrpc; +import org.joda.time.DateTime; + +public class AgentDataMock { + private static boolean IS_COMPLETED = false; + + public static void main(String[] args) throws InterruptedException { + String oapHost = System.getenv("OAP_HOST"); + String minusDays = System.getenv("MINUS_DAYS"); + ManagedChannel channel = ManagedChannelBuilder.forAddress(oapHost, 11800).usePlaintext().build(); + + StreamObserver streamObserver = createStreamObserver(channel); + + long startTimestamp = new DateTime().minusDays(Integer.parseInt(minusDays)).getMillis(); + + ManagementServiceGrpc.ManagementServiceBlockingStub managementServiceBlockingStub = ManagementServiceGrpc.newBlockingStub( + channel); + + // ServiceAMock + ServiceAMock serviceAMock = new ServiceAMock(); + managementServiceBlockingStub.keepAlive(InstancePingPkg.newBuilder() + .setService(ServiceAMock.SERVICE_NAME) + .setServiceInstance(ServiceAMock.SERVICE_INSTANCE_NAME) + .build()); + + // ServiceBMock + ServiceBMock serviceBMock = new ServiceBMock(); + + // ServiceCMock + ServiceCMock serviceCMock = new ServiceCMock(); + + TimeUnit.SECONDS.sleep(10); + + for (int i = 0; i < 5; i++) { + String traceId = UUID.randomUUID().toString(); + String serviceASegmentId = UUID.randomUUID().toString(); + String serviceBSegmentId = UUID.randomUUID().toString(); + String serviceCSegmentId = UUID.randomUUID().toString(); + serviceAMock.mock( + streamObserver, traceId, serviceASegmentId, startTimestamp); + serviceBMock.mock( + streamObserver, traceId, serviceBSegmentId, serviceASegmentId, startTimestamp); + serviceCMock.mock( + streamObserver, traceId, serviceCSegmentId, serviceBSegmentId, startTimestamp); + } + + streamObserver.onCompleted(); + + managementServiceBlockingStub.reportInstanceProperties( + InstanceProperties.newBuilder() + .setService(ServiceAMock.SERVICE_NAME) + .setServiceInstance(ServiceAMock.SERVICE_INSTANCE_NAME) + .addProperties( + KeyStringValuePair.newBuilder() + .setKey("os_name").setValue("MacOS") + .build()) + .addProperties( + KeyStringValuePair.newBuilder() + .setKey("language").setValue("java") + .build() + ) + .build()); + managementServiceBlockingStub.reportInstanceProperties( + InstanceProperties.newBuilder() + .setService(ServiceBMock.SERVICE_NAME) + .setServiceInstance(ServiceBMock.SERVICE_INSTANCE_NAME) + .addProperties( + KeyStringValuePair.newBuilder() + .setKey("os_name").setValue("MacOS") + .build()) + .addProperties( + KeyStringValuePair.newBuilder() + .setKey("language").setValue("java") + .build() + ) + .build()); + + while (!IS_COMPLETED) { + TimeUnit.MILLISECONDS.sleep(500); + } + } + + private static StreamObserver createStreamObserver(ManagedChannel channel) { + TraceSegmentReportServiceGrpc.TraceSegmentReportServiceStub stub = TraceSegmentReportServiceGrpc.newStub( + channel); + return stub.collect(new StreamObserver() { + @Override + public void onNext(Commands downstream) { + } + + @Override + public void onError(Throwable throwable) { + } + + @Override + public void onCompleted() { + IS_COMPLETED = true; + } + }); + } +} diff --git a/test/e2e-v2/java-test-service/trace-mocker/src/main/java/org/apache/skywalking/mock/Component.java b/test/e2e-v2/java-test-service/trace-mocker/src/main/java/org/apache/skywalking/mock/Component.java new file mode 100644 index 0000000000..8ccaa7024e --- /dev/null +++ b/test/e2e-v2/java-test-service/trace-mocker/src/main/java/org/apache/skywalking/mock/Component.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.mock; + +/** + * The Component represents component library, which has been supported by skywalking sniffer. + *

+ * The supported list is in {@link ComponentsDefine}. + */ +public interface Component { + int getId(); + + String getName(); +} diff --git a/test/e2e-v2/java-test-service/trace-mocker/src/main/java/org/apache/skywalking/mock/ComponentsDefine.java b/test/e2e-v2/java-test-service/trace-mocker/src/main/java/org/apache/skywalking/mock/ComponentsDefine.java new file mode 100755 index 0000000000..4f3f69b4d9 --- /dev/null +++ b/test/e2e-v2/java-test-service/trace-mocker/src/main/java/org/apache/skywalking/mock/ComponentsDefine.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.mock; + +/** + * The supported list of skywalking java sniffer. + */ +public class ComponentsDefine { + + public static final OfficialComponent TOMCAT = new OfficialComponent(1, "Tomcat"); + + public static final OfficialComponent DUBBO = new OfficialComponent(3, "Dubbo"); + + public static final OfficialComponent ROCKET_MQ_PRODUCER = new OfficialComponent(38, "rocketMQ-producer"); + + public static final OfficialComponent ROCKET_MQ_CONSUMER = new OfficialComponent(39, "rocketMQ-consumer"); + + public static final OfficialComponent MONGO_DRIVER = new OfficialComponent(42, "mongodb-driver"); +} diff --git a/test/e2e-v2/java-test-service/trace-mocker/src/main/java/org/apache/skywalking/mock/OfficialComponent.java b/test/e2e-v2/java-test-service/trace-mocker/src/main/java/org/apache/skywalking/mock/OfficialComponent.java new file mode 100644 index 0000000000..74f6499289 --- /dev/null +++ b/test/e2e-v2/java-test-service/trace-mocker/src/main/java/org/apache/skywalking/mock/OfficialComponent.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.mock; + +public class OfficialComponent implements Component { + private int id; + private String name; + + public OfficialComponent(int id, String name) { + this.id = id; + this.name = name; + } + + @Override + public int getId() { + return id; + } + + @Override + public String getName() { + return name; + } +} diff --git a/test/e2e-v2/java-test-service/trace-mocker/src/main/java/org/apache/skywalking/mock/ServiceAMock.java b/test/e2e-v2/java-test-service/trace-mocker/src/main/java/org/apache/skywalking/mock/ServiceAMock.java new file mode 100644 index 0000000000..7d1ecfd7f3 --- /dev/null +++ b/test/e2e-v2/java-test-service/trace-mocker/src/main/java/org/apache/skywalking/mock/ServiceAMock.java @@ -0,0 +1,97 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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 org.apache.skywalking.mock; + +import io.grpc.stub.StreamObserver; +import org.apache.skywalking.apm.network.common.v3.KeyStringValuePair; +import org.apache.skywalking.apm.network.language.agent.v3.SegmentObject; +import org.apache.skywalking.apm.network.language.agent.v3.SpanLayer; +import org.apache.skywalking.apm.network.language.agent.v3.SpanObject; +import org.apache.skywalking.apm.network.language.agent.v3.SpanType; + +class ServiceAMock { + public static String SERVICE_NAME = "mock_a_service"; + public static String SERVICE_INSTANCE_NAME = "mock_a_service_instance"; + + static String REST_ENDPOINT = "/dubbox-case/case/dubbox-rest/404-test"; + static String DUBBO_ENDPOINT = "org.skywaking.apm.testcase.dubbo.services.GreetService.doBusiness()"; + static String DUBBO_ADDRESS = "DubboIPAddress:1000"; + + void mock(StreamObserver streamObserver, String traceId, + String segmentId, long startTimestamp) { + streamObserver.onNext(createSegment(startTimestamp, traceId, segmentId).build()); + } + + private SegmentObject.Builder createSegment(long startTimestamp, String traceId, String segmentId) { + SegmentObject.Builder segment = SegmentObject.newBuilder(); + segment.setTraceId(traceId); + segment.setTraceSegmentId(segmentId); + segment.setService(SERVICE_NAME); + segment.setServiceInstance(SERVICE_INSTANCE_NAME); + segment.addSpans(createEntrySpan(startTimestamp)); + segment.addSpans(createLocalSpan(startTimestamp)); + segment.addSpans(createExitSpan(startTimestamp)); + + return segment; + } + + private SpanObject.Builder createEntrySpan(long startTimestamp) { + SpanObject.Builder span = SpanObject.newBuilder(); + span.setSpanId(0); + span.setSpanType(SpanType.Entry); + span.setSpanLayer(SpanLayer.Http); + span.setParentSpanId(-1); + span.setStartTime(startTimestamp); + span.setEndTime(startTimestamp + 6000); + span.setComponentId(ComponentsDefine.TOMCAT.getId()); + span.setOperationName(REST_ENDPOINT); + span.setIsError(false); + span.addTags(KeyStringValuePair.newBuilder().setKey("http.method").setValue("get").build()); + span.addTags(KeyStringValuePair.newBuilder().setKey("http.status_code").setValue("404").build()); + span.addTags(KeyStringValuePair.newBuilder().setKey("http.status_code").setValue("200").build()); + return span; + } + + private SpanObject.Builder createLocalSpan(long startTimestamp) { + SpanObject.Builder span = SpanObject.newBuilder(); + span.setSpanId(1); + span.setSpanType(SpanType.Local); + span.setParentSpanId(0); + span.setStartTime(startTimestamp + 100); + span.setEndTime(startTimestamp + 500); + span.setOperationName("org.apache.skywalking.Local.do"); + span.setIsError(false); + return span; + } + + private SpanObject.Builder createExitSpan(long startTimestamp) { + SpanObject.Builder span = SpanObject.newBuilder(); + span.setSpanId(2); + span.setSpanType(SpanType.Exit); + span.setSpanLayer(SpanLayer.RPCFramework); + span.setParentSpanId(1); + span.setStartTime(startTimestamp + 120); + span.setEndTime(startTimestamp + 5800); + span.setComponentId(ComponentsDefine.DUBBO.getId()); + span.setOperationName(DUBBO_ENDPOINT); + span.setPeer(DUBBO_ADDRESS); + span.setIsError(false); + return span; + } +} diff --git a/test/e2e-v2/java-test-service/trace-mocker/src/main/java/org/apache/skywalking/mock/ServiceBMock.java b/test/e2e-v2/java-test-service/trace-mocker/src/main/java/org/apache/skywalking/mock/ServiceBMock.java new file mode 100644 index 0000000000..6c7d6d6d3a --- /dev/null +++ b/test/e2e-v2/java-test-service/trace-mocker/src/main/java/org/apache/skywalking/mock/ServiceBMock.java @@ -0,0 +1,126 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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 org.apache.skywalking.mock; + +import io.grpc.stub.StreamObserver; +import org.apache.skywalking.apm.network.common.v3.KeyStringValuePair; +import org.apache.skywalking.apm.network.language.agent.v3.RefType; +import org.apache.skywalking.apm.network.language.agent.v3.SegmentObject; +import org.apache.skywalking.apm.network.language.agent.v3.SegmentReference; +import org.apache.skywalking.apm.network.language.agent.v3.SpanLayer; +import org.apache.skywalking.apm.network.language.agent.v3.SpanObject; +import org.apache.skywalking.apm.network.language.agent.v3.SpanType; + +class ServiceBMock { + public static String SERVICE_NAME = "mock_b_service"; + public static String SERVICE_INSTANCE_NAME = "mock_b_service_instance"; + + static String DUBBO_PROVIDER_ENDPOINT = "org.skywaking.apm.testcase.dubbo.services.GreetServiceImpl.doBusiness()"; + static String ROCKET_MQ_ENDPOINT = "org.apache.skywalking.RocketMQ"; + static String ROCKET_MQ_ADDRESS = "RocketMQAddress:2000"; + + void mock(StreamObserver streamObserver, String traceId, + String segmentId, String parentSegmentId, long startTimestamp) { + streamObserver.onNext(createSegment(startTimestamp, traceId, segmentId, parentSegmentId).build()); + } + + private SegmentObject.Builder createSegment(long startTimestamp, + String traceId, + String segmentId, + String parentSegmentId) { + SegmentObject.Builder segment = SegmentObject.newBuilder(); + segment.setTraceId(traceId); + segment.setTraceSegmentId(segmentId); + segment.setService(SERVICE_NAME); + segment.setServiceInstance(SERVICE_INSTANCE_NAME); + segment.addSpans(createEntrySpan(startTimestamp, traceId, parentSegmentId)); + segment.addSpans(createExitSpan(startTimestamp)); + segment.addSpans(createMQExitSpan(startTimestamp)); + + return segment; + } + + private SegmentReference.Builder createReference(String traceId, String parentTraceSegmentId) { + SegmentReference.Builder reference = SegmentReference.newBuilder(); + reference.setTraceId(traceId); + reference.setParentTraceSegmentId(parentTraceSegmentId); + reference.setParentService(ServiceAMock.SERVICE_NAME); + reference.setParentServiceInstance(ServiceAMock.SERVICE_INSTANCE_NAME); + reference.setParentSpanId(2); + reference.setParentEndpoint(ServiceAMock.REST_ENDPOINT); + reference.setRefType(RefType.CrossProcess); + reference.setNetworkAddressUsedAtPeer(ServiceAMock.DUBBO_ADDRESS); + + return reference; + } + + private SpanObject.Builder createEntrySpan(long startTimestamp, String traceId, String parentSegmentId) { + SpanObject.Builder span = SpanObject.newBuilder(); + span.setSpanId(0); + span.setSpanType(SpanType.Entry); + span.setSpanLayer(SpanLayer.RPCFramework); + span.setParentSpanId(-1); + span.setStartTime(startTimestamp + 500); + span.setEndTime(startTimestamp + 5000); + span.setComponentId(ComponentsDefine.DUBBO.getId()); + span.setIsError(false); + span.addRefs(createReference(traceId, parentSegmentId)); + + span.setOperationName(ServiceBMock.DUBBO_PROVIDER_ENDPOINT); + return span; + } + + private SpanObject.Builder createExitSpan(long startTimestamp) { + SpanObject.Builder span = SpanObject.newBuilder(); + span.setSpanId(1); + span.setSpanType(SpanType.Exit); + span.setSpanLayer(SpanLayer.Database); + span.setParentSpanId(0); + span.setStartTime(startTimestamp + 550); + span.setEndTime(startTimestamp + 1500); + span.setComponentId(ComponentsDefine.MONGO_DRIVER.getId()); + span.setIsError(true); + span.addTags(KeyStringValuePair.newBuilder() + .setKey("db.statement") + .setValue("select * from database where complex = 1;") + .build()); + span.addTags(KeyStringValuePair.newBuilder().setKey("db.type").setValue("mongodb").build()); + + span.setOperationName( + "mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]"); + span.setPeer("localhost:27017"); + return span; + } + + private SpanObject.Builder createMQExitSpan(long startTimestamp) { + SpanObject.Builder span = SpanObject.newBuilder(); + span.setSpanId(2); + span.setSpanType(SpanType.Exit); + span.setSpanLayer(SpanLayer.MQ); + span.setParentSpanId(1); + span.setStartTime(startTimestamp + 1100); + span.setEndTime(startTimestamp + 1500); + span.setComponentId(ComponentsDefine.ROCKET_MQ_PRODUCER.getId()); + span.setIsError(false); + + span.setOperationName(ROCKET_MQ_ENDPOINT); + span.setPeer(ROCKET_MQ_ADDRESS); + return span; + } +} diff --git a/test/e2e-v2/java-test-service/trace-mocker/src/main/java/org/apache/skywalking/mock/ServiceCMock.java b/test/e2e-v2/java-test-service/trace-mocker/src/main/java/org/apache/skywalking/mock/ServiceCMock.java new file mode 100644 index 0000000000..885bb2f317 --- /dev/null +++ b/test/e2e-v2/java-test-service/trace-mocker/src/main/java/org/apache/skywalking/mock/ServiceCMock.java @@ -0,0 +1,81 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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 org.apache.skywalking.mock; + +import io.grpc.stub.StreamObserver; +import org.apache.skywalking.apm.network.common.v3.KeyStringValuePair; +import org.apache.skywalking.apm.network.language.agent.v3.RefType; +import org.apache.skywalking.apm.network.language.agent.v3.SegmentObject; +import org.apache.skywalking.apm.network.language.agent.v3.SegmentReference; +import org.apache.skywalking.apm.network.language.agent.v3.SpanLayer; +import org.apache.skywalking.apm.network.language.agent.v3.SpanObject; +import org.apache.skywalking.apm.network.language.agent.v3.SpanType; + +class ServiceCMock { + public static String SERVICE_NAME = "mock_c_service"; + public static String SERVICE_INSTANCE_NAME = "mock_c_service_instance"; + + void mock(StreamObserver streamObserver, String traceId, + String segmentId, String parentSegmentId, long startTimestamp) { + streamObserver.onNext(createSegment(startTimestamp, traceId, segmentId, parentSegmentId).build()); + } + + private SegmentObject.Builder createSegment(long startTimestamp, + String traceId, + String segmentId, + String parentSegmentId) { + SegmentObject.Builder segment = SegmentObject.newBuilder(); + segment.setTraceId(traceId); + segment.setTraceSegmentId(segmentId); + segment.setService(SERVICE_NAME); + segment.setServiceInstance(SERVICE_INSTANCE_NAME); + segment.addSpans(createEntrySpan(startTimestamp, traceId, parentSegmentId)); + + return segment; + } + + private SpanObject.Builder createEntrySpan(long startTimestamp, String traceId, String parentSegmentId) { + SpanObject.Builder span = SpanObject.newBuilder(); + span.setSpanId(0); + span.setSpanType(SpanType.Entry); + span.setSpanLayer(SpanLayer.MQ); + span.setParentSpanId(-1); + span.setStartTime(startTimestamp + 3000); + span.setEndTime(startTimestamp + 5000); + span.setComponentId(ComponentsDefine.ROCKET_MQ_CONSUMER.getId()); + span.setIsError(false); + span.addRefs(createReference(traceId, parentSegmentId)); + span.setOperationName(ServiceBMock.ROCKET_MQ_ENDPOINT); + span.addTags(KeyStringValuePair.newBuilder().setKey("transmission.latency").setValue("100").build()); + return span; + } + + private SegmentReference.Builder createReference(String traceId, String parentTraceSegmentId) { + SegmentReference.Builder reference = SegmentReference.newBuilder(); + reference.setTraceId(traceId); + reference.setParentTraceSegmentId(parentTraceSegmentId); + reference.setParentService(ServiceBMock.SERVICE_NAME); + reference.setParentServiceInstance(ServiceBMock.SERVICE_INSTANCE_NAME); + reference.setParentSpanId(2); + reference.setRefType(RefType.CrossProcess); + reference.setNetworkAddressUsedAtPeer(ServiceBMock.ROCKET_MQ_ADDRESS); + reference.setParentEndpoint(ServiceBMock.DUBBO_PROVIDER_ENDPOINT); + return reference; + } +} diff --git a/test/e2e-v2/script/docker-compose/base-compose.yml b/test/e2e-v2/script/docker-compose/base-compose.yml index 7d045ae9dc..b4a1a1af44 100644 --- a/test/e2e-v2/script/docker-compose/base-compose.yml +++ b/test/e2e-v2/script/docker-compose/base-compose.yml @@ -56,8 +56,9 @@ services: image: "ghcr.io/apache/skywalking-banyandb:${SW_BANYANDB_COMMIT}" networks: - e2e - expose: - - 17912 + ports: + - 17912:17912 + - 17913:17913 command: standalone --stream-root-path /tmp/stream-data --measure-root-path /tmp/measure-data healthcheck: test: [ "CMD", "sh", "-c", "nc -nz 127.0.0.1 17912" ] @@ -65,6 +66,48 @@ services: timeout: 60s retries: 120 + banyandb-data: + image: "ghcr.io/apache/skywalking-banyandb:${SW_BANYANDB_COMMIT}-testing" + hostname: data + expose: + - 17912 + - 2121 + - 6060 + command: data --etcd-endpoints=http://etcd:2379 + healthcheck: + test: [ "CMD", "./bydbctl", "health", "--addr=http://127.0.0.1:17913" ] + interval: 5s + timeout: 120s + retries: 120 + + liaison: + image: "ghcr.io/apache/skywalking-banyandb:${SW_BANYANDB_COMMIT}-testing" + hostname: liaison + ports: + - 17913:17913 + - 17912:17912 + expose: + - 2121 + - 6060 + command: liaison --etcd-endpoints=http://etcd:2379 + healthcheck: + test: [ "CMD", "./bydbctl", "health", "--addr=http://liaison:17913" ] + interval: 5s + timeout: 120s + retries: 120 + + etcd: + image: gcr.io/etcd-development/etcd:v3.5.9 + ports: + - "2379:2379" + command: etcd --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://etcd:2379 --max-request-bytes 10485760 --backend-batch-limit 10000 + healthcheck: + test: [ "CMD", "etcdctl", "endpoint", "health" ] + interval: 1m30s + timeout: 10s + retries: 3 + start_period: 40s + provider: image: "ghcr.io/apache/skywalking-java/skywalking-java:${SW_AGENT_JAVA_COMMIT}-java${SW_AGENT_JDK_VERSION}" volumes: diff --git a/test/e2e-v2/script/env b/test/e2e-v2/script/env index 91fa59b005..ef63dca6e4 100644 --- a/test/e2e-v2/script/env +++ b/test/e2e-v2/script/env @@ -23,8 +23,8 @@ SW_AGENT_CLIENT_JS_COMMIT=af0565a67d382b683c1dbd94c379b7080db61449 SW_AGENT_CLIENT_JS_TEST_COMMIT=4f1eb1dcdbde3ec4a38534bf01dded4ab5d2f016 SW_KUBERNETES_COMMIT_SHA=6fe5e6f0d3b7686c6be0457733e825ee68cb9b35 SW_ROVER_COMMIT=738b1a42fe4941e0b4e6f5816403437cf572708f -SW_BANYANDB_COMMIT=458041a561b0acc1f2ed37690df2ce753b791283 +SW_BANYANDB_COMMIT=c4b4384f3083f44ca6067257f5fa59030427ad6b SW_AGENT_PHP_COMMIT=3192c553002707d344bd6774cfab5bc61f67a1d3 SW_PREDICTOR_COMMIT=54a0197654a3781a6f73ce35146c712af297c994 -SW_CTL_COMMIT=67cbc89dd7b214d5791321a7ca992f940cb586ba +SW_CTL_COMMIT=7bbac156e74e8fdc0c5bd6f377be9f0b30420176 diff --git a/test/e2e-v2/script/prepare/setup-e2e-shell/install-swctl.sh b/test/e2e-v2/script/prepare/setup-e2e-shell/install-swctl.sh index f9bcf34807..d435f5ad92 100644 --- a/test/e2e-v2/script/prepare/setup-e2e-shell/install-swctl.sh +++ b/test/e2e-v2/script/prepare/setup-e2e-shell/install-swctl.sh @@ -32,7 +32,7 @@ install_swctl() { if ! command -v swctl &> /dev/null; then echo "swctl is not installed" install_swctl -elif ! swctl --version | grep -q "${SW_CTL_COMMIT}"; then +elif ! swctl --version | grep -q "${SW_CTL_COMMIT::7}"; then # Check if the installed version is correct echo "swctl is already installed, but version is not ${SW_CTL_COMMIT}, will re-install it" install_swctl