codeglzhang opened a new pull request #5198:
URL: https://github.com/apache/skywalking/pull/5198


   Please answer these questions before submitting pull request
   
   - Why submit this pull request?
   - [ ] Bug fix
   - [x] 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](https://github.com/apache/skywalking/blob/master/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](https://github.com/apache/skywalking/blob/master/test/e2e/e2e-test/docker/base-compose.yml).
   ```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`.
   ```yml
   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.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to