Skip to content

Commit

Permalink
增加测试
Browse files Browse the repository at this point in the history
  • Loading branch information
chengyouling committed Mar 3, 2025
1 parent 49dbfff commit 0de51a2
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.sermant.flowcontrol;

import io.sermant.core.plugin.agent.declarer.AbstractPluginDeclarer;
import io.sermant.core.plugin.agent.declarer.InterceptDeclarer;
import io.sermant.core.plugin.agent.matcher.ClassMatcher;
import io.sermant.core.plugin.agent.matcher.MethodMatcher;

public class FilterExtendDeclare extends AbstractPluginDeclarer {
private static final String ENHANCE_CLASS = "org.apache.dubbo.rpc.BaseFilter";

private static final String INTERCEPT_CLASS = FilterExtendTestInterceptor.class.getCanonicalName();

@Override
public ClassMatcher getClassMatcher() {
return ClassMatcher.isExtendedFrom(ENHANCE_CLASS);
}

@Override
public InterceptDeclarer[] getInterceptDeclarers(ClassLoader classLoader) {
return new InterceptDeclarer[]{
InterceptDeclarer.build(MethodMatcher.nameEquals("invoke"), INTERCEPT_CLASS)
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package io.sermant.flowcontrol;

Check failure on line 1 in sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java

View workflow job for this annotation

GitHub Actions / Checkstyle

[Checkstyle Check] reported by reviewdog 🐶 编程规范-规则2.4:顶层public类javadoc缺少@SInCE或格式不正确(正确格式示例:@SInCE 2019-01-22) Raw Output: /home/runner/work/Sermant/Sermant/./sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java:1:0: error: 编程规范-规则2.4:顶层public类javadoc缺少@SInCE或格式不正确(正确格式示例:@SInCE 2019-01-22) (com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineCheck)

Check failure on line 1 in sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java

View workflow job for this annotation

GitHub Actions / Checkstyle

[Checkstyle Check] reported by reviewdog 🐶 请检查版权声明中其实年份与@SInCE中年份是否一致 Raw Output: /home/runner/work/Sermant/Sermant/./sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java:1:0: error: 请检查版权声明中其实年份与@SInCE中年份是否一致 (com.puppycrawl.tools.checkstyle.checks.regexp.RegexpMultilineCheck)

import java.util.logging.Logger;

import org.apache.dubbo.common.Version;

Check failure on line 5 in sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java

View workflow job for this annotation

GitHub Actions / Checkstyle

[Checkstyle Check] reported by reviewdog 🐶 Wrong order for 'org.apache.dubbo.common.Version' import. Raw Output: /home/runner/work/Sermant/Sermant/./sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java:5:1: error: Wrong order for 'org.apache.dubbo.common.Version' import. (com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderCheck)

import io.sermant.core.common.LoggerFactory;

Check failure on line 7 in sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java

View workflow job for this annotation

GitHub Actions / Checkstyle

[Checkstyle Check] reported by reviewdog 🐶 Wrong order for 'io.sermant.core.common.LoggerFactory' import. Raw Output: /home/runner/work/Sermant/Sermant/./sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java:7:1: error: Wrong order for 'io.sermant.core.common.LoggerFactory' import. (com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderCheck)
import io.sermant.core.plugin.agent.entity.ExecuteContext;
import io.sermant.core.plugin.agent.interceptor.Interceptor;

public class FilterExtendTestInterceptor implements Interceptor {

Check failure on line 11 in sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java

View workflow job for this annotation

GitHub Actions / Checkstyle

[Checkstyle Check] reported by reviewdog 🐶 Type Javadoc comment is missing @SInCE tag. Raw Output: /home/runner/work/Sermant/Sermant/./sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java:11:0: error: Type Javadoc comment is missing @SInCE tag. (com.puppycrawl.tools.checkstyle.checks.javadoc.WriteTagCheck)
private static final Logger LOGGER = LoggerFactory.getLogger();

Check failure on line 12 in sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java

View workflow job for this annotation

GitHub Actions / Checkstyle

[Checkstyle Check] reported by reviewdog 🐶 'member def modifier' has incorrect indentation level 2, expected level should be 4. Raw Output: /home/runner/work/Sermant/Sermant/./sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java:12:3: error: 'member def modifier' has incorrect indentation level 2, expected level should be 4. (com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck)

@Override

Check failure on line 14 in sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java

View workflow job for this annotation

GitHub Actions / Checkstyle

[Checkstyle Check] reported by reviewdog 🐶 'method def modifier' has incorrect indentation level 2, expected level should be 4. Raw Output: /home/runner/work/Sermant/Sermant/./sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java:14:3: error: 'method def modifier' has incorrect indentation level 2, expected level should be 4. (com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck)
public ExecuteContext before(ExecuteContext context) throws Exception {
Object invoke = context.getArguments()[0];

Check failure on line 16 in sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java

View workflow job for this annotation

GitHub Actions / Checkstyle

[Checkstyle Check] reported by reviewdog 🐶 'method def' child has incorrect indentation level 4, expected level should be 8. Raw Output: /home/runner/work/Sermant/Sermant/./sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java:16:5: error: 'method def' child has incorrect indentation level 4, expected level should be 8. (com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck)
String currentVersion = invoke.getClass().getPackage().getImplementationVersion();

Check failure on line 17 in sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java

View workflow job for this annotation

GitHub Actions / Checkstyle

[Checkstyle Check] reported by reviewdog 🐶 'method def' child has incorrect indentation level 4, expected level should be 8. Raw Output: /home/runner/work/Sermant/Sermant/./sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java:17:5: error: 'method def' child has incorrect indentation level 4, expected level should be 8. (com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck)
if (currentVersion == null) {
currentVersion = Version.getVersion();
}
LOGGER.info("===========================>find version:" + currentVersion);
String className = context.getObject().getClass().getCanonicalName();
LOGGER.info("===========================>current filter name:" + className);
return context;
}

@Override
public ExecuteContext after(ExecuteContext context) throws Exception {
return context;
}

@Override
public ExecuteContext onThrow(ExecuteContext context) throws Exception {
return context;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
* @author chengyouling
* @since 2025-02-27
*/
public class FutureFilterDeclarer extends DubboDeclarer {
private static final String ENHANCE_CLASS = "org.apache.dubbo.rpc.protocol.dubbo.filter.FutureFilter";
public class RouterSnapshotFilterDeclarer extends DubboDeclarer {
private static final String ENHANCE_CLASS = "org.apache.dubbo.rpc.cluster.router.RouterSnapshotFilter";

private static final String INTERCEPT_CLASS = ApacheDubboInterceptor.class.getCanonicalName();

/**
* apache dubbo Declarer
*/
public FutureFilterDeclarer() {
public RouterSnapshotFilterDeclarer() {
super(ENHANCE_CLASS, INTERCEPT_CLASS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
# limitations under the License.
#
#

io.sermant.flowcontrol.FilterExtendDeclare
io.sermant.flowcontrol.DispatcherServletDeclarer
io.sermant.flowcontrol.AlibabaDubboDeclarer
io.sermant.flowcontrol.ApacheDubboDeclarer
io.sermant.flowcontrol.ConsumerRpcExceptionFilterDeclarer
io.sermant.flowcontrol.FutureFilterDeclarer
io.sermant.flowcontrol.RouterSnapshotFilterDeclarer
io.sermant.flowcontrol.ConsumerContextFilterDeclarer
io.sermant.flowcontrol.config.DubboServiceNameDeclarer
io.sermant.flowcontrol.config.ApacheDubboConfigDeclarer
Expand Down

0 comments on commit 0de51a2

Please sign in to comment.