Debug Point

Debug point is used in code test. When enabling a debug point, it can run related code.

Both FE and BE support debug points.

Code Example

FE example

  1. private Status foo() {
  2. // dbug_fe_foo_do_nothing is the debug point name.
  3. // When it's active,DebugPointUtil.isEnable("dbug_fe_foo_do_nothing") will return true.
  4. if (DebugPointUtil.isEnable("dbug_fe_foo_do_nothing")) {
  5. return Status.Nothing;
  6. }
  7. do_foo_action();
  8. return Status.Ok;
  9. }

BE 桩子示例代码

  1. void Status foo() {
  2. // dbug_be_foo_do_nothing is the debug point name.
  3. // When it's active,DEBUG_EXECUTE_IF will execute the code block.
  4. DEBUG_EXECUTE_IF("dbug_be_foo_do_nothing", { return Status.Nothing; });
  5. do_foo_action();
  6. return Status.Ok;
  7. }

Global config

To activate debug points, need set enable_debug_points to true.

enable_debug_points was located in FE’s fe.conf and BE’s be.conf。

Enable Debug Point

API

  1. POST /api/debug_point/add/{debug_point_name}[?timeout=<int>&execute=<int>]

Query Parameters

  • debug_point_name Debug point name. Require.

  • timeout Timeout in seconds. When timeout, the debug point will be disable. Default is -1, not timeout. Optional.

  • execute Max active times。Default is -1, unlimit active times. Optional.

Request body

None

Response

  1. ```
  2. {
  3. msg: "OK",
  4. code: 0
  5. }
  6. ```

Examples

Enable debug point foo, activate no more than five times.

  1. ```
  2. curl -X POST "http://127.0.0.1:8030/api/debug_point/add/foo?execute=5"
  3. ```

Disable Debug Point

API

  1. POST /api/debug_point/remove/{debug_point_name}

Query Parameters

  • debug_point_name Debug point name. Require.

Request body

None

Response

  1. {
  2. msg: "OK",
  3. code: 0
  4. }

Examples

Disable debug point foo

  1. ```
  2. curl -X POST "http://127.0.0.1:8030/api/debug_point/remove/foo"
  3. ```

Clear Debug Points

API

  1. POST /api/debug_point/clear

Request body

None

Response

  1. ```
  2. {
  3. msg: "OK",
  4. code: 0
  5. }
  6. ```

Examples

  1. ```
  2. curl -X POST "http://127.0.0.1:8030/api/debug_point/clear"
  3. ```