- Notifications
You must be signed in to change notification settings - Fork37
A dedicated service for storing and managing recorded and replayed data in AREX.
arextest/arex-storage
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This HTTP web API manages and accesses recording and replaying resources from a remote repository. Resources are organized as MockItem instances, each corresponding to a MockCategoryType enum.
- Agent Recording
- Assigns version numbers to configuration files.
- Saves entry points and dependent instances implementing MockItem.
- Agent Replaying
- Reads configuration files by version number prior to replaying.
- Handles requests, performs diffs, and retrieves mock results as responses.
- Scheduled Replaying
- Uses MainEntry (extending MockItem) as replay trigger sources.
- Provides diff response sources saved from agent’s replay.
- Recording Storage (MongoDB): Default persistence for AREX’s agent recording. Collections are time-managed with TTL index expiration.
- Replaying Cache (Redis): Default cache for AREX’s replaying.
The base interface MockItem, defined in arex.storage.model.mocker, is structured as follows:
publicinterfaceMockItem {StringgetReplayId();voidsetReplayId(StringreplayId);StringgetRecordId();voidsetRecordId(StringrecordId);/** * millis from utc format without timezone */voidsetCreateTime(longcreateTime); }
Identifiers:
replayId
andrecordId
are generated byAREX's Agent.MainEntry
Interface: Defined inarex.storage.model.mocker
,MainEntry
extendsMockItem
and includes methods for accessing request details, category type, format, and more.publicinterfaceMainEntryextendsMockItem {/** * @return utc format without timezone */longgetCreateTime();/** * The request's content encoded by base64 * */StringgetRequest();/** * @return the mock category type value from MockCategoryType * @see MockCategoryType */@JsonIgnoreintgetCategoryType();/** * How to serialize the request's body to target ,default using application/json * * @return application/json or others */defaultStringgetFormat() {returnnull; }/** * @return default http post */defaultStringgetMethod() {return"POST"; }defaultMap<String,String>getRequestHeaders() {returnnull; }defaultStringgetPath() {returnnull; } }
Configuring Remote Storage:Modify the
localhost
default value inresources/META-INF/application.properties
for Redis and MongoDB connections. Example:arex.storage.cache.redis.host=redis://10.3.2.42:6379/arex.mongo.uri=mongodb://arex:iLoveArex@10.3.2.42:27017/arex_storage_db
Extending Providers:Implement your own providers using Java's
SPI
mechanism. TheCacheProvider
interface is defined as:publicinterfaceCacheProvider {/** * put the value with expired seconds * @param key the key for value * @param expiredSeconds the expired seconds * @param value bytes of the object * @return true if success,others false */booleanput(byte[]key,longexpiredSeconds,byte[]value);/** * Get the value of a key * * @param key the bytes of key * @return null when key does not exist. */byte[]get(byte[]key);/** * Increment integer value of the key by on * * @param key the key * @return The value of the key after increment */longincrValue(byte[]key);/** * Decrement the integer value of a key by one. * * @param key the key * @return the value of key after decrement */longdecrValue(byte[]key);/** * Delete value specified by the key * * @param key the bytes of key * @return True if key is removed. */booleanremove(byte[]key); }
- Code:Apache-2.0
About
A dedicated service for storing and managing recorded and replayed data in AREX.