Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: reformat code to google style #191

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ut.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

name: Test

on: [pull_request, workflow_dispatch]
on: [ pull_request, workflow_dispatch ]

permissions:
checks: write
Expand Down
183 changes: 99 additions & 84 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,92 +2,107 @@

## Introduction

After your success installed the **AREX's Agent**, and configure it used the [`Remote Storage Service`](https://github.com/arextest/arex-storage).

You should be run a replay from what your operations and how many recorded sources retrieved you wants to
validate the changes of a new version deployed on the target host is expected or unexpected.

To implements the purpose, we accept a target host to create a plan by your requested and a schedule trigger will running for :

1. Loading all records from `Remote Storage Service` by each operations(your APIs) and group it by dependent on version.
1. Prepare the request message and send it to the target host.
1. If send success we retrieve all the response results(include entry service and called dependency service) by `recordId` + `replayId`
1. Use configuration indicate that how to compare the results which grouped by `MockCategoryType` such as : http servlet, redis, db .....
1. send replay compared results to the [`Report Service`](https://github.com/arextest/arex-report), which should be able to analysis and build summary.

**Note:**
* The plan should not create if the target host is unreachable.
* The plan should interrupt if sending request too many exceptions over then 10%
After your success installed the **AREX's Agent**, and configure it used
the [`Remote Storage Service`](https://github.com/arextest/arex-storage).

You should be run a replay from what your operations and how many recorded sources retrieved you
wants to
validate the changes of a new version deployed on the target host is expected or unexpected.

To implements the purpose, we accept a target host to create a plan by your requested and a schedule
trigger will running for :

1. Loading all records from `Remote Storage Service` by each operations(your APIs) and group it by
dependent on version.
1. Prepare the request message and send it to the target host.
1. If send success we retrieve all the response results(include entry service and called dependency
service) by `recordId` + `replayId`
1. Use configuration indicate that how to compare the results which grouped by `MockCategoryType`
such as : http servlet, redis, db .....
1. send replay compared results to the [`Report Service`](https://github.com/arextest/arex-report),
which should be able to analysis and build summary.

**Note:**

* The plan should not create if the target host is unreachable.
* The plan should interrupt if sending request too many exceptions over then 10%

## Getting Started

1. **Modify default `localhost` connection string value**

you should be change the connection string in the file of path 'resources/META-INF/application.properties'.

example for `Redis`,`mysql` and dependent `web services` as following:
```yaml
# web api
arex.storage.service.api=http://10.3.2.42:8093/api/storage/replay/query
arex.api.service.api=http://10.3.2.42:8090/api/report
arex.config.service.api=http://10.3.2.42:8091/api/config
# mysql
spring.datasource.url=jdbc:mysql://10.3.2.42:3306/arexdb?&useUnicode=true&characterEncoding=UTF-8
spring.datasource.username=arex_admin
spring.datasource.password=arex_admin_password
# redis
arex.redis.uri=redis://10.3.2.42:6379/
```
1. **Extends the replay sender if you have a requirement**

There is a `DefaultHttpReplaySender` implemented `ReplaySender` used to handle http request,such as:put,get,post,delete etc.

You should be write another implementation which loaded by spring,the `ReplaySender` defined as following:

```java
public interface ReplaySender {
/**
* Indicate the instance should be working for the message content type,
* return true should be used,others skipped
*/
boolean isSupported(int contentType);

/**
* Try to send the replay case to remote target host
*/
boolean send(ReplayActionCaseItem caseItem);

/**
* Try to send the request message to remote target host
*/
ReplaySendResult send(SenderParameters senderParameters);

/**
* Try to prepare the replay case remote dependency such as resume config files
*/
boolean prepareRemoteDependency(ReplayActionCaseItem caseItem);

/**
* Try to warm up the remote target service before sending
*/
default boolean activeRemoteService(ReplayActionCaseItem caseItem) {
return true;
}
}
```
1. **Extends the deploy environment**

To create a plan for report, we should be required more info such as target image's version and the source code author.

By default,there is a empty instance implemented `DeploymentEnvironmentProvider` which defined as following:

```java
public interface DeploymentEnvironmentProvider {

DeploymentVersion getVersion(String appId, String env);

List<ServiceInstance> getActiveInstanceList(AppServiceDescriptor serviceDescriptor, String env);
}
```
1. **Modify default `localhost` connection string value**

you should be change the connection string in the file of path '
resources/META-INF/application.properties'.

example for `Redis`,`mysql` and dependent `web services` as following:
```yaml
# web api
arex.storage.service.api=http://10.3.2.42:8093/api/storage/replay/query
arex.api.service.api=http://10.3.2.42:8090/api/report
arex.config.service.api=http://10.3.2.42:8091/api/config
# mysql
spring.datasource.url=jdbc:mysql://10.3.2.42:3306/arexdb?&useUnicode=true&characterEncoding=UTF-8
spring.datasource.username=arex_admin
spring.datasource.password=arex_admin_password
# redis
arex.redis.uri=redis://10.3.2.42:6379/
```
1. **Extends the replay sender if you have a requirement**

There is a `DefaultHttpReplaySender` implemented `ReplaySender` used to handle http request,such
as:put,get,post,delete etc.

You should be write another implementation which loaded by spring,the `ReplaySender` defined as
following:

```java
public interface ReplaySender {
/**
* Indicate the instance should be working for the message content type,
* return true should be used,others skipped
*/
boolean isSupported(int contentType);

/**
* Try to send the replay case to remote target host
*/
boolean send(ReplayActionCaseItem caseItem);

/**
* Try to send the request message to remote target host
*/
ReplaySendResult send(SenderParameters senderParameters);

/**
* Try to prepare the replay case remote dependency such as resume config files
*/
boolean prepareRemoteDependency(ReplayActionCaseItem caseItem);

/**
* Try to warm up the remote target service before sending
*/
default boolean activeRemoteService(ReplayActionCaseItem caseItem) {
return true;
}
}
```
1. **Extends the deploy environment**

To create a plan for report, we should be required more info such as target image's version and
the source code author.

By default,there is a empty instance implemented `DeploymentEnvironmentProvider` which defined as
following:

```java
public interface DeploymentEnvironmentProvider {

DeploymentVersion getVersion(String appId, String env);

List<ServiceInstance> getActiveInstanceList(AppServiceDescriptor serviceDescriptor, String env);
}
```

## License

- Code: [Apache-2.0](https://github.com/arextest/arex-agent-java/blob/LICENSE)
82 changes: 41 additions & 41 deletions arex-schedule-extension/pom.xml
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<artifactId>arex-schedule-extension</artifactId>

<parent>
<groupId>com.arextest</groupId>
<artifactId>arex-schedule-parent</artifactId>
<version>1.0.34.4</version>
</parent>
<build>
<finalName>arex-schedule-extension</finalName>
<plugins>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<detectJavaApiLink>false</detectJavaApiLink>
<doclint>none</doclint>
<source>8</source>
</configuration>
<executions>
<execution>
<goals>
<goal>jar</goal>
</goals>
<id>generate-javadocs</id>
</execution>
</executions>
<groupId>org.apache.maven.plugins</groupId>
<version>3.4.0</version>
</plugin>
</plugins>
</build>

<artifactId>arex-schedule-extension</artifactId>
<version>1.0.33.1</version>
<name>${project.groupId}:${project.artifactId}</name>
<dependencies>
<dependency>
<artifactId>lombok</artifactId>
<groupId>org.projectlombok</groupId>
</dependency>
</dependencies>
<modelVersion>4.0.0</modelVersion>
<name>${project.groupId}:${project.artifactId}</name>

<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>
<parent>
<artifactId>arex-schedule-parent</artifactId>
<groupId>com.arextest</groupId>
<version>1.0.34.4</version>
</parent>

<build>
<finalName>arex-schedule-extension</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.4.0</version>
<configuration>
<doclint>none</doclint>
<source>8</source>
<detectJavaApiLink>false</detectJavaApiLink>
</configuration>
<executions>
<execution>
<id>generate-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<version>1.0.33.1</version>

</project>
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package com.arextest.schedule.extension.invoker;

public class InvokerConstants {
public static final String HEADERS = "headers";

// dubbo
public static final String DUBBO_INTERFACE_NAME = "interfaceName";
public static final String DUBBO_METHOD_NAME = "methodName";
public static final String DUBBO_PARAMETER_TYPES = "parameterTypes";
public static final String DUBBO_PARAMETERS = "parameters";
public static final String HEADERS = "headers";

public static final String DUBBO_CASE_TYPE = "DubboProvider";
// dubbo
public static final String DUBBO_INTERFACE_NAME = "interfaceName";
public static final String DUBBO_METHOD_NAME = "methodName";
public static final String DUBBO_PARAMETER_TYPES = "parameterTypes";
public static final String DUBBO_PARAMETERS = "parameters";

public static final String DUBBO_CASE_TYPE = "DubboProvider";


}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
import com.arextest.schedule.extension.model.ReplayInvokeResult;

public interface ReplayExtensionInvoker {
/**
* check caseType by InvokerConstants#XXXCaseType.
*/
boolean isSupported(String caseType);

ReplayInvokeResult invoke(ReplayInvocation invocation);
/**
* check caseType by InvokerConstants#XXXCaseType.
*/
boolean isSupported(String caseType);

default int order() {
return 1;
}
ReplayInvokeResult invoke(ReplayInvocation invocation);

default int order() {
return 1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,25 @@
import java.util.Map;

public interface ReplayInvocation {
/**
* eg: dubbo:127.0.0.1:20880
* protocol + host + port
*/
String getUrl();

Map<String, Object> getAttributes();
/**
* eg: dubbo:127.0.0.1:20880 protocol + host + port
*/
String getUrl();

ReplayExtensionInvoker getInvoker();
Map<String, Object> getAttributes();

void put(String key, Object value);
ReplayExtensionInvoker getInvoker();

/**
* Get specified class item from attributes.
* key: refer to InvokerConstants.
*/
<T> T get(String key, Class<T> clazz);
void put(String key, Object value);

/**
* Get object item from attributes.
* key: refer to InvokerConstants.
*/
Object get(String key);
/**
* Get specified class item from attributes. key: refer to InvokerConstants.
*/
<T> T get(String key, Class<T> clazz);

/**
* Get object item from attributes. key: refer to InvokerConstants.
*/
Object get(String key);
}
Loading