FAQ
Please note
- You don't need to configure
void
methods for dynamic class configurations, because there's no point in mocking them if they don't return a result. - Dynamic classes will only be recorded once if the request parameters are the same. This practice is mainly for de-emphasis, to be able to reduce the amount of recorded data and improve recording efficiency.
- If the Apollo configuration is mocked during replay, then the machine's memory at the current time is the mocked configuration. Note that no other external requests are allowed during replay, otherwise the mocked configuration will still be returned.
- It is not recommended to replay in production environments. Generally, production environments only record traffic and replay in test environments or local operations.
Login Failure Issues
Can't receive verification code in email when logging in
Please make sure that the server where the AREX service is deployed can send requests properly, for sending emails requires going to an external mail server.
If you cannot access external networks and cannot receive the verification code, you can get the verification code by yourself in the verificationCode
field of the user
table in the arex_storage_db
database after sending verification code.
Nomal API Testing Issues
Unable to send request and the response keeps showing in process
Since AREX sends requests through the browser, you need to install the Chrome plugin to unblock browser cross-domain restrictions before sending the request.
Please check if the plugin is installed first.
If the plug-in is installed, it may be because the plug-in version is too old, you need to go to Release to download the latest version.
Recording Issues
Error at startup: [AREX] Agent would not install due to ip (not recording)
This situation usually indicates that the Agent has failed to start. A possible reason is that the Agent has been started before and has already been registered with AREX. The default setting for AREX is that only one application's Agent is allowed to start under the same service name. Normally, when an application stops, the Agent can detect this state and notify AREX of a shutdown event through the shutdown hook mechanism. However, if a forced shutdown method is used, such as executing the kill -9
command, the Agent cannot detect the shutdown event.
To cancel the restriction that only one application's Agent is allowed to start under the same service name, this can be achieved by modifying the "Record" -> "Record Machine Count" on the AREX configuration page. This allows multiple application Agents to be started under the same service name. When modifying the configuration, it is important to understand the potential implications, such as the complexity of resource usage and data management.
What are the impacts of AREX Agent recording on the application?
During recording, the primary impact of the AREX Agent on the application is on the metaspace, consuming approximately 5-15MB of space, depending on the size of the recording results. Additionally, when the Agent starts, it needs to retransform the bytecode, triggering a JVM recompilation, which may increase the startup time by about 1 to 2 seconds.
Agent failed to start
If you get the error: Unsupported major.minor version 52.0
, please make sure that the JDK version is greater than 1.8.0_25 by the following command. If not, please upgrade the JDK version > 1.8.0_25.
java -version
Modify the storage time of recorded test cases
The database only stores recorded cases within the last 4 days by default, and expired cases will be automatically deleted. If you need to keep them for a longer time, just add a configuration item in the arex-storage-service
of the docker-compose.yml
.
arex-storage-service:
...
environment:
- TZ=Asia/Shanghai
- JAVA_OPTS=-Darex.storage.mongo.host=mongodb://arex:iLoveArex@mongodb:27017/arex_storage_db
-Darex.storage.cache.url=redis://redis:6379/
-Darex.api.service.api=http://arex-api-service:8080
-Darex.storage.defaultExpirationDuration=1000000000
...
Only takes effect after modifying the configuration and restarting AREX.
The Replay list does not show the application started with AREX Agent
- Check if the Agent startup parameters are correct.
Check the application startup parameters to confirm whether the address is configured correctly, as follows:
environment:
- JAVA_TOOL_OPTIONS='-javaagent:/usr/local/tomcat/arex-agent.jar' -Darex.service.name=community-test-0905 -Darex.storage.service.host=10.5.153.151
-Darex.enable.debug=true -Dspring.datasource.url=jdbc:mysql://cmysql:3306/community?useUnicode=true&characterEncoding=utf-8 -Dspring.datasource.username=arex_admin
-Dspring.datasource.password=arex_admin_password -Dspring.redis.host=credis -Dspring.redis.port=6379
- Check the AREX jar package location.
- Check the service name.
- Check the address and port of the Storage service.
- Check if the console output information during the Agent startup is correct.
As shown below (arex-commnity-test
is the application name):
arex-commnity-test | [main] INFO io.arex.foundation.services.ConfigService - [AREX] Load agent config
arex-commnity-test | request: "recordVersion":"0.3.8","host":"172.29.0.4","agentStatus":"START","systemProperties":{"awt.toolkit":"sun.awt.X11.XToolkit","file.encoding.pkg":"sun.io","java.specification.version":"1.8","spring.redis.host":"credis","sun.cpu.isalist":"","sun.jnu.encoding":"UTF-8","java.class.path":"/usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar:/usr/local/tomcat/arex-agent.jar","arex.service.name":"community-test-0905","java.vm.vendor":"Oracle Corporation","sun.arch.data.model":"64","java.vendor.url":"http://java.oracle.com/","user.timezone":"Etc/UTC","os.name":"Linux","java.vm.specification.version":"1.8","sun.java.launcher":"SUN_STANDARD","sun.boot.library.path":"/usr/local/openjdk-8/jre/lib/amd64","sun.java.command":"org.apache.catalina.startup.Bootstrap start","arex.agent.version":"0.3.8","sun.cpu.endian":"little","user.home":"/root","user.language":"en","spring.redis.port":"6379","java.specification.vendor":"Oracle Corporation","java.home":"/usr/local/openjdk-8/jre","ignore.endorsed.dirs":"","arex.rate.limit":"1","spring.datasource.password":"arex_admin_password","file.separator":"/","arex.agent.jar.file.path":"/usr/local/tomcat/arex-agent.jar","line.separator":"\n","java.vm.specification.vendor":"Oracle Corporation","java.specification.name":"Java Platform API Specification","spring.datasource.url":"jdbc:mysql://cmysql:3306/community?useUnicode=true&characterEncoding=utf-8","java.awt.graphicsenv":"sun.awt.X11GraphicsEnvironment","arex.storage.service.host":"10.5.153.151","sun.boot.class.path":"/usr/local/openjdk-8/jre/lib/resources.jar:/usr/local/openjdk-8/jre/lib/rt.jar:/usr/local/openjdk-8/jre/lib/sunrsasign.jar:/usr/local/openjdk-8/jre/lib/jsse.jar:/usr/local/openjdk-8/jre/lib/jce.jar:/usr/local/openjdk-8/jre/lib/charsets.jar:/usr/local/openjdk-8/jre/lib/jfr.jar:/usr/local/openjdk-8/jre/classes","jdk.tls.ephemeralDHKeySize":"2048","java.util.logging.config.file":"/usr/local/tomcat/conf/logging.properties","java.protocol.handler.pkgs":"org.apache.catalina.webresources","sun.management.compiler":"HotSpot 64-Bit Tiered Compilers","arex.allow.time.to":"23:59","java.runtime.version":"1.8.0_342-b07","user.name":"root","path.separator":":","arex.dynamic.result.size.limit":"1000","os.version":"3.10.0-693.21.1.el7.x86_64","java.endorsed.dirs":"/usr/local/openjdk-8/jre/lib/endorsed","java.runtime.name":"OpenJDK Runtime Environment","file.encoding":"UTF-8","java.vm.name":"OpenJDK 64-Bit Server VM","arex.enable.report.status":"true","org.apache.catalina.security.SecurityListener.UMASK":"0027","java.vendor.url.bug":"http://bugreport.sun.com/bugreport/","java.io.tmpdir":"/usr/local/tomcat/temp","catalina.home":"/usr/local/tomcat","java.version":"1.8.0_342","user.dir":"/usr/local/tomcat","os.arch":"amd64","java.vm.specification.name":"Java Virtual Machine Specification","java.awt.printerjob":"sun.print.PSPrinterJob","sun.os.patch.level":"unknown","catalina.base":"/usr/local/tomcat","java.util.logging.manager":"org.apache.juli.ClassLoaderLogManager","spring.datasource.username":"arex_admin","arex.allow.time.from":"00:01","java.library.path":"/usr/local/tomcat/native-jni-lib:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib","java.vendor":"Oracle Corporation","java.vm.info":"mixed mode","java.vm.version":"25.342-b07","sun.io.unicode.encoding":"UnicodeLittle","java.ext.dirs":"/usr/local/openjdk-8/jre/lib/ext:/usr/java/packages/lib/ext","arex.enable.debug":"true","java.class.version":"52.0"},"systemEnv":{"PATH":"/usr/local/tomcat/bin:/usr/local/openjdk-8/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","JAVA_HOME":"/usr/local/openjdk-8","CATALINA_HOME":"/usr/local/tomcat","JDK_JAVA_OPTIONS":" --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED","LANG":"C.UTF-8","TOMCAT_MAJOR":"9","TOMCAT_VERSION":"9.0.65","HOSTNAME":"403f7af2398e","LD_LIBRARY_PATH":"/usr/local/tomcat/native-jni-lib","JAVA_TOOL_OPTIONS":"'-javaagent:/usr/local/tomcat/arex-agent.jar' -Darex.service.name=community-test-0905 -Darex.storage.service.host=10.5.153.151 -Darex.enable.debug=true -Dspring.datasource.url=jdbc:mysql://cmysql:3306/community?useUnicode=true&characterEncoding=utf-8 -Dspring.datasource.username=arex_admin -Dspring.datasource.password=arex_admin_password -Dspring.redis.host=credis -Dspring.redis.port=6379","TOMCAT_SHA512":"2ae846848b8436856be11cfa18d9c62caa06ca7d3134012b2e10cbf6078753c4af20cc5d37f7dc75f1779f5c59d7c033850b8626534c3ce7e389641a67963cf6","TOMCAT_NATIVE_LIBDIR":"/usr/local/tomcat/native-jni-lib","JAVA_VERSION":"8u342","PWD":"/usr/local/tomcat","SHLVL":"0","HOME":"/root","GPG_KEYS":"48F8E69F6390C9F25CFEDCD268248959359E722B A9C5DF4D22E99998D9875A5110C01C5A2F6059E7 DCFD35E0BF8CA7344752DE8B6FB21E8933C60243"}}
arex-commnity-test | response: {"responseStatusType":{"responseCode":0,"responseDesc":"success","timestamp":1693902650048},"body":{"serviceCollectConfiguration":{"status":null,"modifiedTime":1693901294108,"appId":"community-test-0905","sampleRate":1,"allowDayOfWeeks":127,"timeMock":true,"allowTimeOfDayFrom":"00:01","allowTimeOfDayTo":"23:59","excludeServiceOperationSet":null,"recordMachineCountLimit":1,"extendField":null},"dynamicClassConfigurationList":null,"status":3,"targetAddress":"172.29.0.4"}}
[main] INFO io.arex.foundation.services.ConfigService - [AREX] Load agent config
is the log printed by the AREX Agent, indicating that it is loading the configuration.- request: This is the request information sent by AREX to Storage, which includes version information, registration status, and other details.
- response: This is the information returned by Storage, which includes configuration information, Agent log information, and more.
Check the configuration output of the Agent:
arex-commnity-test | 05-Sep-2023 08:44:14.019 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name: Apache Tomcat/9.0.65
arex-commnity-test | 05-Sep-2023 08:44:14.023 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Jul 14 2022 12:28:53 UTC
arex-commnity-test | 05-Sep-2023 08:44:14.024 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 9.0.65.0
arex-commnity-test | 05-Sep-2023 08:44:14.024 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Linux
arex-commnity-test | 05-Sep-2023 08:44:14.024 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 3.10.0-693.21.1.el7.x86_64
arex-commnity-test | 05-Sep-2023 08:44:14.024 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
arex-commnity-test | 05-Sep-2023 08:44:14.024 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: /usr/local/openjdk-8/jre
arex-commnity-test | 05-Sep-2023 08:44:14.024 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_342-b07
arex-commnity-test | 05-Sep-2023 08:44:14.024 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
arex-commnity-test | 05-Sep-2023 08:44:14.025 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: /usr/local/tomcat
arex-commnity-test | 05-Sep-2023 08:44:14.025 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: /usr/local/tomcat
arex-commnity-test | 05-Sep-2023 08:44:14.033 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -javaagent:/usr/local/tomcat/arex-agent.jar
arex-commnity-test | 05-Sep-2023 08:44:14.033 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Darex.service.name=community-test-0905
arex-commnity-test | 05-Sep-2023 08:44:14.033 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Darex.storage.service.host=10.5.153.151
arex-commnity-test | 05-Sep-2023 08:44:14.033 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Darex.enable.debug=true
arex-commnity-test | 05-Sep-2023 08:44:14.033 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dspring.datasource.url=jdbc:mysql://cmysql:3306/community?useUnicode=true&characterEncoding=utf-8
arex-commnity-test | 05-Sep-2023 08:44:14.033 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dspring.datasource.username=arex_admin
arex-commnity-test | 05-Sep-2023 08:44:14.033 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dspring.datasource.password=arex_admin_password
arex-commnity-test | 05-Sep-2023 08:44:14.033 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dspring.redis.host=credis
arex-commnity-test | 05-Sep-2023 08:44:14.034 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dspring.redis.port=6379
arex-commnity-test | 05-Sep-2023 08:44:14.034 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties
arex-commnity-test | 05-Sep-2023 08:44:14.034 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
arex-commnity-test | 05-Sep-2023 08:44:14.034 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
arex-commnity-test | 05-Sep-2023 08:44:14.034 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
arex-commnity-test | 05-Sep-2023 08:44:14.034 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dorg.apache.catalina.security.SecurityListener.UMASK=0027
arex-commnity-test | 05-Sep-2023 08:44:14.034 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
arex-commnity-test | 05-Sep-2023 08:44:14.034 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/usr/local/tomcat
arex-commnity-test | 05-Sep-2023 08:44:14.035 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/usr/local/tomcat
arex-commnity-test | 05-Sep-2023 08:44:14.035 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/usr/local/tomcat/temp
After this, you should see the log indicating that the Agent is starting to perform injection. At this point, the instrumentation should be successful. If this log does not appear, it usually means that the injection failed (although this is not a common issue).
...
arex-commnity-test | [main] INFO io.arex.agent.instrumentation.InstrumentationInstaller - [arex] installed instrumentation module: internal-executors
arex-commnity-test | [main] INFO io.arex.agent.instrumentation.InstrumentationInstaller - [arex] installed instrumentation module: class-loader
arex-commnity-test | [main] INFO io.arex.agent.instrumentation.InstrumentationInstaller - [arex] installed instrumentation module: filter-v3
arex-commnity-test | [main] INFO io.arex.agent.instrumentation.InstrumentationInstaller - [arex] installed instrumentation module: filter-v5
arex-commnity-test | [main] INFO io.arex.agent.instrumentation.InstrumentationInstaller - [arex] installed instrumentation module: httpservlet-v3
arex-commnity-test | [main] INFO io.arex.agent.instrumentation.InstrumentationInstaller - [arex] installed instrumentation module: httpservlet-v5
arex-commnity-test | [main] INFO io.arex.agent.instrumentation.InstrumentationInstaller - [arex] installed instrumentation module: apache-httpclient-v4
arex-commnity-test | [main] INFO io.arex.agent.instrumentation.InstrumentationInstaller - [arex] installed instrumentation module: hibernate-v5
arex-commnity-test | [main] INFO io.arex.agent.instrumentation.InstrumentationInstaller - [arex] installed instrumentation module: mybatis-v3
arex-commnity-test | [main] INFO io.arex.agent.instrumentation.InstrumentationInstaller - [arex] installed instrumentation module: mongo
arex-commnity-test | [main] INFO io.arex.agent.instrumentation.InstrumentationInstaller - [arex] installed instrumentation module: jedis-v4
arex-commnity-test | [main] INFO io.arex.agent.instrumentation.InstrumentationInstaller - [arex] installed instrumentation module: lettuce-v5
...
arex-commnity-test | [main] INFO io.arex.agent.instrumentation.TransformListener - [arex] onTransformation: java.util.concurrent.CompletableFuture$Signaller loaded: true from classLoader null
arex-commnity-test | [main] INFO io.arex.agent.instrumentation.TransformListener - [arex] onTransformation: java.util.concurrent.FutureTask loaded: true from classLoader null
arex-commnity-test | [main] INFO io.arex.agent.instrumentation.TransformListener - [arex] onTransformation: java.util.concurrent.Executors$FinalizableDelegatedExecutorService loaded: true from classLoader null
arex-commnity-test | [main] INFO io.arex.agent.instrumentation.TransformListener - [arex] onTransformation: java.util.concurrent.Executors$DelegatedExecutorService loaded: true from classLoader null
arex-commnity-test | [main] INFO io.arex.agent.instrumentation.TransformListener - [arex] onTransformation: java.util.concurrent.ThreadPoolExecutor loaded: true from classLoader null
arex-commnity-test | [main] INFO io.arex.agent.instrumentation.TransformListener - [arex] onTransformation: java.util.concurrent.CompletableFuture$Completion loaded: true from classLoader null
arex-commnity-test | [main] INFO io.arex.agent.instrumentation.TransformListener - [arex] onTransformation: java.util.concurrent.ForkJoinTask loaded: true from classLoader null
arex-commnity-test | [main] INFO io.arex.agent.instrumentation.TransformListener - [arex] onTransformation: java.util.concurrent.AbstractExecutorService loaded: true from classLoader null
...
arex-commnity-test | [main] INFO io.arex.agent.instrumentation.TransformListener - [arex] onTransformation: org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter loaded: false from classLoader ParallelWebappClassLoader
arex-commnity-test | context: ROOT
arex-commnity-test | delegate: false
arex-commnity-test | ----------> Parent Classloader:
arex-commnity-test | java.net.URLClassLoader@629b780f
Finally, you should see the log indicating Report agent status
, which indicates that the Agent has successfully started and is reporting its status to Storage:
arex-commnity-test | [arex-timer-service-3-thread-1] INFO io.arex.foundation.services.ConfigService - [AREX] Report agent status, previous lastModified: Tue, 05 Sep 2023 08:08:14 GMT, lastModified: Tue, 05 Sep 2023 08:08:14 GMT. request: {"appId":"community-test-0905","host":"172.29.0.4","agentStatus":"WORKING","currentRate":"1","decelerateCode":0}
Agent deployed successfully, but application is still not in the Replay list
Access the database to check if there is data in the database.
- View the Docker image of MongoDB:
- Log in to the MongoDB image and access the database:
# log into the image
docker exec -it 1e84d2ee1f08 bash
# linking database
mongo mongodb://arex:iLoveArex@mongodb:27017/arex_storage_db
# view commands for Mongo
help
# view instance
db.Instances.find()
# this means the application has registered
{ "_id" : ObjectId("64f6e73a8af8432a9b10e369"), "appId" : "community-test-0905", "host" : "172.29.0.4", "agentStatus" : "WORKING", "dataChangeCreateTime" : NumberLong("1693902650044"), "dataChangeUpdateTime" : NumberLong("1693904387816"), "dataUpdateTime" : ISODate("2023-09-05T08:59:47.816Z"), "recordVersion" : "0.3.8", "systemEnv"
# check if Servlet has recorded test cases
db.RollingServletMocker.find()
# this means the test case has been recorded
{ "_id" : "AREX-172-28-0-4-1014277717960", "appId" : "community-test-0905", "creationTime" : ISODate("2023-09-05T08:10:16.724Z"), "expirationTime" : ISODate("2023-09-09T08:10:17.325Z"), "operationName" : "/redisTest/jedis/copy", "recordEnvironment" : 1, "recordVersion" : "0.3.8", "targetRequest" : "KLUv/QBYpQ0ApmBkJvBynQMoTUS67OXqvb58b+tYIkOYQOB9LFTc5/f/JJYJDovD4hQPWABWAF0AzkQSSaTHU7bUfnQ1OqvX3aPqwxEw0GCjACLhVR+O8uO5spcKXev1xVIuxtMyw909riqbbE6c0XTGFdmcGGseX/VKdMaXDZ44SHzGfZEm1r13f7zHVKWDBI+3Kta0yseVXHl3WrOMhtbZK6d1Xft4vjz6NeVmjmntu5gtj6d1tmRKq7w7jGDkRAdymAdyGIiBzuM7q9XdI0nEkZzJ81BQegQDUPQk0kbeQzDwPMkTC40t02rugVLB4ADQJA8zeaCmp4PEFmxd10ELmGBADgZ02kWjiGhyKc3ipg2toMpq0ymXAtAgAzVrWfOjUh7flCv7MM4udxdoBB7fa1E8NXfNj8rjK3ROVVJ2f5UGIZZ1oXIiPZGVGHqiR1HRvgfCyINk5HlyIqkIJPfxFaKSvQiVSVUoLDx+qlUz5epmuAs5X7B+/IRVydhjiVXqdTC2d5/YUkvRIAMZyEgcp2GNilUJLaBaJAcKAFU7AJy48CVrFIJVGS26RdZQE5t3uz0njuXeoK0yAw==", "targetResponse" : "KLUv/QBYzQsABhtSJRCtVgcOfg1BwoTsJcel1KrVeuNigsRwzCD+16m/hwEERAAAAIBGAEkARwCLoc3epIghlhlp16amBgRBT+NxHgAP6GFvkXRdV8Z+U2+17nuY+sbeXl0D5bC3hQxhbxtJk4pp15Ktk6O69K3i7BLkyisCDnJ1B3o4HofDwWg8zrMay1kBjMVwPIsScSA4O4wLUn5LV2apu/rDQsTg7HVy7IhhrXT0YFHoQrcJr2Cv25hKpN3u6tO0LVXeVEwblkRCcc5el8YoE7m6kxZHG64OARFn5RlJk9VzKVffdjBeHMXS1RUjF8oZWItbGScXail3XTwXaiOee4vn2S9MezJkbcQL0yXIBVLEkK47qRGuQlMjXIlG6thzm55rcQ4v0p2L0DSXhSybyVLya7puZ5a6RvI7+0ZSX03TJx5fKgMLWS4EnrNPjv22AxAACkGjCBdoveXYtdmbj/BcMpG4ChjGqhgbBhCazEUMagxqOCtkfLfNLbPGJAM=", "updateTime" : ISODate("1970-01-01T00:00:00Z") }
How to deploy AREX Agent for a service deployed on multiple machines
If the service to be tested is deployed on multiple machines, when configuring the AREX Agent for the service, you need to mount the Agent on all these machines at the same time and ensure that the same service has the same service name. In this case, you need to record on multiple machines, go to Setting > Record > Running Status and adjust the Record Machine Count to control the number of recorded machines to the corresponding number of machines.
The application is not recording traffic.
You can troubleshoot from the following aspects:
- Click the Settings button to view the Agent's working status and ensure that the Agent is in proper working condition.
If there was a manual deletion of MongoDB data before, it is possible that the Redis cache was not completely cleared during the deletion. This is because the deletion operation resulted in the deletion of both data and configuration in the database, but the cached data in Redis was not removed. When AREX is working, it directly reads the database through a query operation. Therefore, it cannot find the corresponding configuration and the recording fails. You can solve this problem by clearing the Redis cache. To do this, download a Redis connection tool and connect to the Redis server by filling in its IP address and port number. After a successful connection, clear all cache keys (keys) starting with “service_mapping”.
Some components may not yet be supported for recording and playback by the AREX Java Agent. Please refer to the list of supported frameworks and components in Framework Supported.
Replay Failure
Installed AREX locally and recorded a local application for testing, and replay task interrupted.
In this scenario, the Target Host cannot use localhost
or 127.0.0.1
to access.
The network modes in Docker Compose are as follows:
- bridge: the default mode, each container will have a unique IP address, and can access each other through the container name or IP address.
- host: the container shares the host's network namespace and can access all network interfaces of the host, including the local
127.0.0.1
. - none: the container will not join any network and can only be accessed through the container ID.
- container: the container shares another container's network namespace and can access each other through the container name or IP address.
This is because the default network mode used by Docker is the Bridge mode. In this mode, the Schedule service is unable to access 127.0.0.1
, which causes the replay to fail.
If you encounter this situation, you need to change the IP address in the Target Host from 127.0.0.1
to the local IP address.
Start Replay after the application has successfully configured the Agent, and the report status shows `interrupted`.
In case of this, please first confirm whether the Target Host is correct, the complete Target Host should be protocol + domain name + port number, as shown below:
If correct, hover on interrupted to look for specific reasons of termination and solve the problems.
Or select the invalid case to view details of the error message.
If you still can't trace the faults, go to the /logs
path (e.g. http://0.0.0.0:8088/logs
) to see the error logs:
Replay always fails when the recorded interface has time-sensitive status information such as token, session, etc.
When recording an interface, if it contains some time-sensitive state information, such as token, session, etc., these state information will expire after a certain period of time. The recorded status information will expire at the time of playback and cannot be used anymore, so it will cause playback failure.
Faced with this situation, there are two ways to solve it:
Add the token check function as a dynamic class in Recording Settings, so that when recording, the AREX will record the return value of the token check function, which should normally be
true
, indicating that the token check passed. During playback, the token check function is mocked to returntrue
, thus simulating the situation during recording. This will ensure the consistency of playback, and in theory the playback will pass.Select Time Mock in Recording Settings.
In the following token verification logic, the recorded token has a time in it, and when playing back, the verification logic will take a
Date.now
to determine it, and AREX Time Mock will mock theDate.now
return value to make it the same as the time information in the recorded case. If the time used in the replay logic is the same as the time information in the token, the token will not be expired and the replay will pass.function verifyToken(token) {
try {
const decoded = jwt.verify(token, secret);
const currentTime = Math.floor(Date.now() / 1000);
if (decoded.exp < currentTime) {
return false;
}
return true;
} catch (error) {
return false;
}
}
There is a `new call` in replay report even if there is no changes in the code, resulting in failure of replay.
In AREX, a test case typically consists of multiple steps, each containing a request and a response. The request can be a main entry or an external call (including DB, Redis, etc.). In each step, information such as the parameters of the request and the response result is recorded for subsequent comparison. If there is no difference between the recorded and replayed responses of the main entry, as well as the requests of the external dependencies, the replay of the test case is passed.
The differences between main entries and external calls fall into the following three main categories:
- new call: This type indicates that the main entry or externally called mock did not exist at the time of recording, but existed at the time of replay, i.e., a new call was added, usually due to an iteration of a new feature.
- call missing: indicates that the call existed during recording but is missing during replay, usually because the project has been optimized to remove some unnecessary call relationships.
- value diff: indicates the value exists in both recording and replay, but some nodes are different.
Generally speaking, if there are no differences in the code, there should be no new calls. If there is, please check if there is a local cache in the code. For example, when recording, there are values in the cache, but when replaying, the cache has been invalidated or emptied, so you need to re-access dependent interfaces such as databases to load the data, which leads to some new calls.
What is AREX's replay matching logic?
AREX's replay matching logic varies depending on the type of dependent components, mainly divided into two algorithms:
- For dynamic classes (Dynamic class) and Redis, a precise matching plus fuzzy matching algorithm is used.
- For other types of dependencies, such as databases, HTTP, and Dubbo Consumer, a precise matching plus characteristic value matching algorithm is used.
How to handle differences in API responses, caused by code changes in the developed new version?
For example: Changes in table structure, addition, or reduction of database operations may lead to difference.
During replay testing, AREX defaults to blocking all external dependencies, including databases. If the new version used for replay modifies the database structure or operations, some expected differences may arise during the replay process. These differences do not indicate errors in the code itself but are due to changes in the database. Especially for new database operations that were not recorded in previous sessions, if there is no corresponding recording data during replay, these operations cannot be successfully mocked, leading to replay failure.
AREX allows users to configure certain operation types (such as query, update) to ignore mock, directly invoking operations in the real environment. However, this may result in the creation of dirty data. Users must ensure that real calls will not have side effects to safely use this feature.
Others
Why does the same test case send four requests during replay in AREX?
This is due to AREX's Warm-up + Noise Reduction mechanism during replay:
First Request: Warm-up Operation. At the start of the test, AREX performs a warm-up operation. Especially in scenarios involving configuration centers like Apollo, the first request retrieves the same configuration information as during recording by accessing the cache, ensuring consistency between the test and recording environments.
Second and Third Requests: Noise Reduction. After the warm-up, AREX conducts two pre-replays of the same test case. The purpose of these replays is to identify and eliminate "noise" points (such as random numbers, timestamps, etc.) by comparing the traffic differences between them.
Fourth Request: Official Request. This is compared against the recorded traffic to verify that the test results meet expectations.
For the forced recorded test cases and saved from replay reports, send a request after modifying one of the Mock values, it was found that the response was returned with the same value as before the modification.
This is because AREX does not mock the return value of the main interface, it only mocks the third-party dependencies that are called during the intermediate process, and the modifications are only valid.