Developers or testers need to call online services to debug the services or query online data during the development process. The service testing feature of Enterprise Distributed Application Service (EDAS) allows you to set parameters in the console to initiate service calls and view the results.

Background information

  • The service testing feature is in public preview. You can use this feature free of charge.
  • If you want to test a service as a RAM user, you must first grant the permissions to test services to the RAM user in the RAM console. For more information, see Configure permissions for service testing in the RAM console.

Procedure

  1. Log on to the EDAS console. In the left-side navigation pane, choose Traffic Management > Microservices Governance > HSF > Service Testing.
  2. On the Service Testing - Select Service page, select a microservices namespace from the Microservice Namespace drop-down list. In the service list, click the name of the service that you want to test.
  3. In the Select a test method. panel, set the parameters and click Execute. The following table describes the parameters.
    Parameter Description
    Call IP Address The IP address of an instance on which the service is deployed. The instance can be an Elastic Compute Service (ECS) instance or a pod. You can select only one instance IP address even if the service is deployed on multiple instances.
    Test Method The method to be tested.
    Parameter Type The parameter type used by the method. You must specify a package path for the parameter type. For example, you must specify the package path java.lang.String for the String type. EDAS automatically generates package paths for common Java types. If you use a custom type, you must specify the package path for the type before you can test the service.
    Test Parameters The parameter settings for the method. Set the parameters based on the specified parameter type. You can specify the parameter settings by using a file tree or a code editor.

Verify the result

In the Result section, you can check whether the test is successful. The following list describes the types of test results:

  • The test fails. The system displays an error message indicating that the instance for the test is being prepared and you need to try again later. After you start a test, wait 30 to 50 seconds until the instance for the test is initiated.
  • The test fails. The system displays an error message. You can troubleshoot issues in the port, network, and code of the service based on the error message that is returned.
  • The test succeeds. A response is returned.

Examples of parameter settings

You must specify parameter settings for the method to test in the form of a JSON array. The following table provides examples of parameter settings for different parameter types.

Parameter type Sample parameter settings Remarks
(java.lang.String, int) ["test", 100] N/A
(java.util.List, int) [["hello", "world"], 100] N/A
(java.util.Map, java.lang.List) [{"test": true}, ["hello", "world]] N/A
(java.util.Map, com.test.User) [{"test": true}, {"id": 1, "name": "jack"}] com.test.User is a custom parameter type. In this example, the id and name parameters of this type are used.