Skip to content

Support for the remote debugging of local E2E testing framework #5196

Closed
codeglzhang wants to merge 5 commits intoapache:masterfrom
codeglzhang:master
Closed

Support for the remote debugging of local E2E testing framework #5196
codeglzhang wants to merge 5 commits intoapache:masterfrom
codeglzhang:master

Conversation

@codeglzhang
Copy link
Contributor

@codeglzhang codeglzhang commented Jul 29, 2020

Please answer these questions before submitting pull request

  • Why submit this pull request?

  • Bug fix

  • New feature provided

  • Improve performance

  • Related issues


Bug fix

  • Bug description.

  • How to fix?


New feature or improvement

  • Describe the details and related test reports.

Motivation

If a developer fails to execute the E2E test locally, he needs to judge the bug through the log output, correct the code, and executing the E2E test again to check whether the bug is fixed. This process is time-consuming, especially in finding bugs and re-deploying the E2E test environment. If the test framework allows developers to debug remotely during local E2E testing, a lot of time will be saved.

Goals

  1. Open the container debugging port in the local E2E test environment to bind with the host port to support remote debugging.
  2. The remote debugging is simple and easy to use.
  3. The remote debugging should be off in the ci environment.

Method

Judging the environment

In the original code, the variable IS_CI is used to judge the environment whether is a ci environment. Thus, we also use it to judge the environment.

Remote debugging port

We designated 5005 as the remote debugging port of a container. If a container requires the remote debugging, it needs to expose the port 5005. The program judges a container whether exposes the port 5005 by using the command docker-compose config. The command docker-compose config can get the all config information even if the docker-compose.yml inherits other configuration files, like skywalking/test/e2e/e2e-test/docker/simple/jdk/docker-compose.yml.

Getting Remote debugging containers

If the container exposes the port 5005, the program will add it to a list. Containers in this list need the remote debugging.

Binding the remote debugging port

After getting the remote debugging containers, the program uses the testcontainers framework to map the port 5005 of containers to the ports not used by the host and write the mapping information to a file remote_real_port.

Compatibility

Because no previous container configuration exposed the port 5005, the change is no effect on previous versions.

Using remote debugging

For the developers, if they want to use remote debugging, they only need to add the remote debugging parameters to the configuration file docker-compose.yml and expose the port 5005. For example, this is the configuration of a container in the skywalking/test/e2e/e2e-test/docker/base-compose.yml.

oap:
    image: skywalking/oap:latest
    expose:
      - 11800
      - 12800
    networks:
      - e2e
    restart: on-failure
    volumes:
      - ../../../jacoco:/jacoco
      - ./download-mysql.sh:/download-mysql.sh
    environment:
      SW_CLUSTER_ZK_HOST_PORT: zk:2181
      SW_STORAGE_ES_CLUSTER_NODES: es:9200
      SW_JDBC_URL: jdbc:mysql://mysql:3306/swtest
      SW_STORAGE_INFLUXDB_URL: http://influxdb:8086
      JAVA_OPTS: >-
        -javaagent:/jacoco/jacocoagent.jar=classdumpdir=/jacoco/classes/oap,destfile=/jacoco/oap.exec,includes=org.apache.skywalking.*,excludes=org.apache.skywalking.oap.query.*:org.apache.skywalking.oap.server.core.query.*
    healthcheck:
      test: ["CMD", "sh", "-c", "nc -zn 127.0.0.1 11800"]
      interval: 5s
      timeout: 60s
      retries: 120

To using remote debugging, the configuration adds the debugging parameters agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 of JAVA and exposes the port 5005.

oap:
    image: skywalking/oap:latest
    expose:
      - 11800
      - 12800
      - 5005
    networks:
      - e2e
    restart: on-failure
    volumes:
      - ../../../jacoco:/jacoco
      - ./download-mysql.sh:/download-mysql.sh
    environment:
      SW_CLUSTER_ZK_HOST_PORT: zk:2181
      SW_STORAGE_ES_CLUSTER_NODES: es:9200
      SW_JDBC_URL: jdbc:mysql://mysql:3306/swtest
      SW_STORAGE_INFLUXDB_URL: http://influxdb:8086
      JAVA_OPTS: >-
        -javaagent:/jacoco/jacocoagent.jar=classdumpdir=/jacoco/classes/oap,destfile=/jacoco/oap.exec,includes=org.apache.skywalking.*,excludes=org.apache.skywalking.oap.query.*:org.apache.skywalking.oap.server.core.query.*
        -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
    healthcheck:
      test: ["CMD", "sh", "-c", "nc -zn 127.0.0.1 11800"]
      interval: 5s
      timeout: 60s
      retries: 120

Then, if the E2E test failed and is retrying, the developer can get the ports mapping in the file skywalking/test/e2e/e2e-test/remote_real_port and selects the host port of the corresponding service for remote debugging.

… exposed ports of containers. 2. Check a port whether is exposed by the container.
…ontainer:

1.Add exposed 5005 port.
2.Add "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005", which is remote debugging parameter of JVM.
@codecov
Copy link

codecov bot commented Jul 29, 2020

Codecov Report

Merging #5196 into master will decrease coverage by 21.86%.
The diff coverage is n/a.

Impacted file tree graph

@@              Coverage Diff              @@
##             master    #5196       +/-   ##
=============================================
- Coverage     53.50%   31.64%   -21.87%     
=============================================
  Files          1458     1392       -66     
  Lines         31359    29743     -1616     
  Branches       3460     3715      +255     
=============================================
- Hits          16778     9411     -7367     
- Misses        13776    19506     +5730     
- Partials        805      826       +21     
Impacted Files Coverage Δ Complexity Δ
...he/skywalking/oal/rt/output/DispatcherContext.java 0.00% <0.00%> (-100.00%) 0.00% <0.00%> (-1.00%)
...skywalking/oal/rt/output/AllDispatcherContext.java 0.00% <0.00%> (-100.00%) 0.00% <0.00%> (-1.00%)
...ache/skywalking/oap/server/core/source/Source.java 0.00% <0.00%> (-100.00%) 0.00% <0.00%> (-2.00%)
...che/skywalking/oap/server/core/source/Service.java 0.00% <0.00%> (-100.00%) 0.00% <0.00%> (-3.00%)
...he/skywalking/oap/server/core/source/Endpoint.java 0.00% <0.00%> (-100.00%) 0.00% <0.00%> (-6.00%)
...he/skywalking/oap/server/core/source/GCPhrase.java 0.00% <0.00%> (-100.00%) 0.00% <0.00%> (-1.00%)
...e/skywalking/oap/server/core/CoreModuleConfig.java 0.00% <0.00%> (-100.00%) 0.00% <0.00%> (-1.00%)
.../skywalking/oap/server/core/alarm/AlarmModule.java 0.00% <0.00%> (-100.00%) 0.00% <0.00%> (-2.00%)
...skywalking/oap/server/core/source/RequestType.java 0.00% <0.00%> (-100.00%) 0.00% <0.00%> (-1.00%)
...ywalking/oap/server/core/config/ConfigService.java 0.00% <0.00%> (-100.00%) 0.00% <0.00%> (-1.00%)
... and 636 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5d7da1a...ddce7ae. Read the comment docs.

@kezhenxu94 kezhenxu94 added enhancement Enhancement on performance or codes test Test requirements about performance, feature or before release. labels Jul 29, 2020
@kezhenxu94 kezhenxu94 added this to the 8.2.0 milestone Jul 29, 2020
@kezhenxu94 kezhenxu94 self-requested a review July 29, 2020 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Enhancement on performance or codes test Test requirements about performance, feature or before release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments