You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@dubbo.apache.org by Zonghai Shang <yi...@apache.org> on 2018/09/11 08:31:09 UTC
Local forced trigger mock does not take effect
Hi,
MockClusterInvoker provides local forced mock,I tested it locally, but it
doesn't work.
@Override
public Result invoke(Invocation invocation) throws RpcException {
// ….
else if (value.startsWith("force")) {
if (logger.isWarnEnabled()) {
logger.info("force-mock: " + invocation.getMethodName() + "
force-mock enabled , url : " + directory.getUrl());
}
//force:direct mock
result = doMockInvoke(invocation, null);
}
// ….
}
<dubbo:reference id="demoService" check="false"
interface="com.alibaba.dubbo.samples.mock.api.DemoService" mock="force”/>
Here is demo:
https://github.com/dubbo/dubbo-samples/tree/master/dubbo-samples-mock
`com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should support
force? Can someone help me?
yiji
Re: Local forced trigger mock does not take effect
Posted by Zonghai Shang <yi...@apache.org>.
Hi lan luo,
Yeah, I have recorded and tracked, refer :
https://github.com/apache/incubator-dubbo/issues/2489
Thanks for your reply,
yiji
Ian Luo <ia...@gmail.com> 于2018年9月11日周二 下午11:00写道:
> ZhongHai,
>
> Would you mind to fire an issue on GitHub?
>
> Thanks,
> -Ian.
>
>
> On Tue, Sep 11, 2018 at 4:32 PM Zonghai Shang <yi...@apache.org> wrote:
>
> > Sorry, invoke refer
> > here:
> > com.alibaba.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker#invoke
> >
> > Zonghai Shang <yi...@apache.org> 于2018年9月11日周二 下午4:31写道:
> >
> > > Hi,
> > >
> > > MockClusterInvoker provides local forced mock,I tested it locally, but
> it
> > > doesn't work.
> > >
> > > @Override
> > > public Result invoke(Invocation invocation) throws RpcException {
> > > // ….
> > > else if (value.startsWith("force")) {
> > > if (logger.isWarnEnabled()) {
> > > logger.info("force-mock: " + invocation.getMethodName() +
> "
> > > force-mock enabled , url : " + directory.getUrl());
> > > }
> > > //force:direct mock
> > > result = doMockInvoke(invocation, null);
> > > }
> > > // ….
> > > }
> > >
> > > <dubbo:reference id="demoService" check="false"
> > > interface="com.alibaba.dubbo.samples.mock.api.DemoService"
> mock="force”/>
> > >
> > > Here is demo:
> > > https://github.com/dubbo/dubbo-samples/tree/master/dubbo-samples-mock
> > >
> > > `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should support
> > > force? Can someone help me?
> > >
> > > yiji
> > >
> >
>
Re: Local forced trigger mock does not take effect
Posted by Ian Luo <ia...@gmail.com>.
ZhongHai,
Would you mind to fire an issue on GitHub?
Thanks,
-Ian.
On Tue, Sep 11, 2018 at 4:32 PM Zonghai Shang <yi...@apache.org> wrote:
> Sorry, invoke refer
> here:
> com.alibaba.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker#invoke
>
> Zonghai Shang <yi...@apache.org> 于2018年9月11日周二 下午4:31写道:
>
> > Hi,
> >
> > MockClusterInvoker provides local forced mock,I tested it locally, but it
> > doesn't work.
> >
> > @Override
> > public Result invoke(Invocation invocation) throws RpcException {
> > // ….
> > else if (value.startsWith("force")) {
> > if (logger.isWarnEnabled()) {
> > logger.info("force-mock: " + invocation.getMethodName() + "
> > force-mock enabled , url : " + directory.getUrl());
> > }
> > //force:direct mock
> > result = doMockInvoke(invocation, null);
> > }
> > // ….
> > }
> >
> > <dubbo:reference id="demoService" check="false"
> > interface="com.alibaba.dubbo.samples.mock.api.DemoService" mock="force”/>
> >
> > Here is demo:
> > https://github.com/dubbo/dubbo-samples/tree/master/dubbo-samples-mock
> >
> > `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should support
> > force? Can someone help me?
> >
> > yiji
> >
>
Re: Local forced trigger mock does not take effect
Posted by Zonghai Shang <yi...@apache.org>.
Sorry, invoke refer
here: com.alibaba.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker#invoke
Zonghai Shang <yi...@apache.org> 于2018年9月11日周二 下午4:31写道:
> Hi,
>
> MockClusterInvoker provides local forced mock,I tested it locally, but it
> doesn't work.
>
> @Override
> public Result invoke(Invocation invocation) throws RpcException {
> // ….
> else if (value.startsWith("force")) {
> if (logger.isWarnEnabled()) {
> logger.info("force-mock: " + invocation.getMethodName() + "
> force-mock enabled , url : " + directory.getUrl());
> }
> //force:direct mock
> result = doMockInvoke(invocation, null);
> }
> // ….
> }
>
> <dubbo:reference id="demoService" check="false"
> interface="com.alibaba.dubbo.samples.mock.api.DemoService" mock="force”/>
>
> Here is demo:
> https://github.com/dubbo/dubbo-samples/tree/master/dubbo-samples-mock
>
> `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should support
> force? Can someone help me?
>
> yiji
>
Re: Local forced trigger mock does not take effect
Posted by Ian Luo <ia...@gmail.com>.
I did a quick check in samples project, and it did have samples to
demonstrate mock functionality. Pls. ignore my last email.
On Wed, Sep 12, 2018 at 10:19 AM Ian Luo <ia...@gmail.com> wrote:
> Jun,
>
> Are you suggesting the mock behavior works as expected? If so, we may
> consider to add the corresponding samples if we have done it yet.
>
> Thanks,
> -Ian.
>
>
> On Wed, Sep 12, 2018 at 8:56 AM jun liu <ke...@gmail.com> wrote:
>
>> > <dubbo:reference id="demoService" check="false"
>> > interface="com.alibaba.dubbo.samples.mock.api.DemoService"
>> mock="force”/>
>>
>> As far as I can describe now, I think you can use:
>> 1. mock=“true”, this will direct the to the default mock implementation
>> with a name convention like DemoServiceMock.
>> 2. mock=“force:return xxx”, directly specify the return value you want.
>> This may be the case you want to use, but I think you just forget the mock
>> value you want.
>> 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where your mock
>> logic is located.
>>
>> > `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should support
>> > force? Can someone help me?
>>
>> Given the above usage supported I think there’s no need to add an extra
>> mock=“force” support. What do u think?
>>
>> Best regards,
>> Jun
>>
>> > On 11 Sep 2018, at 16:31, Zonghai Shang <yi...@apache.org> wrote:
>> >
>> > Hi,
>> >
>> > MockClusterInvoker provides local forced mock,I tested it locally, but
>> it
>> > doesn't work.
>> >
>> > @Override
>> > public Result invoke(Invocation invocation) throws RpcException {
>> > // ….
>> > else if (value.startsWith("force")) {
>> > if (logger.isWarnEnabled()) {
>> > logger.info("force-mock: " + invocation.getMethodName() + "
>> > force-mock enabled , url : " + directory.getUrl());
>> > }
>> > //force:direct mock
>> > result = doMockInvoke(invocation, null);
>> > }
>> > // ….
>> > }
>> >
>> > <dubbo:reference id="demoService" check="false"
>> > interface="com.alibaba.dubbo.samples.mock.api.DemoService"
>> mock="force”/>
>> >
>> > Here is demo:
>> > https://github.com/dubbo/dubbo-samples/tree/master/dubbo-samples-mock
>> >
>> > `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should support
>> > force? Can someone help me?
>> >
>> > yiji
>>
>>
Re: Local forced trigger mock does not take effect
Posted by Ian Luo <ia...@gmail.com>.
Jun,
Are you suggesting the mock behavior works as expected? If so, we may
consider to add the corresponding samples if we have done it yet.
Thanks,
-Ian.
On Wed, Sep 12, 2018 at 8:56 AM jun liu <ke...@gmail.com> wrote:
> > <dubbo:reference id="demoService" check="false"
> > interface="com.alibaba.dubbo.samples.mock.api.DemoService" mock="force”/>
>
> As far as I can describe now, I think you can use:
> 1. mock=“true”, this will direct the to the default mock implementation
> with a name convention like DemoServiceMock.
> 2. mock=“force:return xxx”, directly specify the return value you want.
> This may be the case you want to use, but I think you just forget the mock
> value you want.
> 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where your mock
> logic is located.
>
> > `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should support
> > force? Can someone help me?
>
> Given the above usage supported I think there’s no need to add an extra
> mock=“force” support. What do u think?
>
> Best regards,
> Jun
>
> > On 11 Sep 2018, at 16:31, Zonghai Shang <yi...@apache.org> wrote:
> >
> > Hi,
> >
> > MockClusterInvoker provides local forced mock,I tested it locally, but it
> > doesn't work.
> >
> > @Override
> > public Result invoke(Invocation invocation) throws RpcException {
> > // ….
> > else if (value.startsWith("force")) {
> > if (logger.isWarnEnabled()) {
> > logger.info("force-mock: " + invocation.getMethodName() + "
> > force-mock enabled , url : " + directory.getUrl());
> > }
> > //force:direct mock
> > result = doMockInvoke(invocation, null);
> > }
> > // ….
> > }
> >
> > <dubbo:reference id="demoService" check="false"
> > interface="com.alibaba.dubbo.samples.mock.api.DemoService" mock="force”/>
> >
> > Here is demo:
> > https://github.com/dubbo/dubbo-samples/tree/master/dubbo-samples-mock
> >
> > `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should support
> > force? Can someone help me?
> >
> > yiji
>
>
Re: Local forced trigger mock does not take effect
Posted by Zonghai Shang <yi...@apache.org>.
> 1. Improve the documentation
> 2. Consider the configuration of xml compatible with the configuration of
the override protocol
I agree, maybe a pull request to fix it.
Best regards,
yiji
yuhang xiu <ca...@gmail.com> 于2018年9月12日周三 上午10:36写道:
> Hi guys,
>
> I also encountered this confusion when I configured the mock in xml.
> Now it seems that the form of mock=force:return xxx can only be used when
> dynamically configured using the override protocol, which does not match
> the configuration of the xml.
>
> I think we need to do one of the following two things:
> 1. Improve the documentation
> 2. Consider the configuration of xml compatible with the configuration of
> the override protocol
>
> Zonghai Shang <yi...@apache.org> 于2018年9月12日周三 上午10:24写道:
>
> > > 1. mock=“true”, this will direct the to the default mock implementation
> > with a name convention like DemoServiceMock.
> > > 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where your
> mock
> > logic is located.
> >
> > mock=“org.apache.dubbo.xxx.xxxMock” , only throw RpcException to execute
> > the mock, which does not match the force logic.
> >
> > > 2. mock=“force:return xxx”, directly specify the return value you want.
> > This may be the case you want to use, but I think you just forget the
> mock
> > value you want.
> >
> > It does’t work, cause:
> > PropertyAccessException 1:
> > org.springframework.beans.MethodInvocationException: Property 'mock'
> threw
> > exception; nested exception is java.lang.IllegalStateException: Invalid
> > mock="force:return null" contain illegal charactor, only digit, letter,
> > '-', '_' and '.' is legal.
> >
> > I think maybe the implementation of mock may have bugs.
> >
> >
> > Best regards,
> > yiji
> >
> > jun liu <ke...@gmail.com> 于2018年9月12日周三 上午8:56写道:
> >
> > > > <dubbo:reference id="demoService" check="false"
> > > > interface="com.alibaba.dubbo.samples.mock.api.DemoService"
> > mock="force”/>
> > >
> > > As far as I can describe now, I think you can use:
> > > 1. mock=“true”, this will direct the to the default mock implementation
> > > with a name convention like DemoServiceMock.
> > > 2. mock=“force:return xxx”, directly specify the return value you want.
> > > This may be the case you want to use, but I think you just forget the
> > mock
> > > value you want.
> > > 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where your
> mock
> > > logic is located.
> > >
> > > > `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should support
> > > > force? Can someone help me?
> > >
> > > Given the above usage supported I think there’s no need to add an extra
> > > mock=“force” support. What do u think?
> > >
> > > Best regards,
> > > Jun
> > >
> > > > On 11 Sep 2018, at 16:31, Zonghai Shang <yi...@apache.org> wrote:
> > > >
> > > > Hi,
> > > >
> > > > MockClusterInvoker provides local forced mock,I tested it locally,
> but
> > it
> > > > doesn't work.
> > > >
> > > > @Override
> > > > public Result invoke(Invocation invocation) throws RpcException {
> > > > // ….
> > > > else if (value.startsWith("force")) {
> > > > if (logger.isWarnEnabled()) {
> > > > logger.info("force-mock: " + invocation.getMethodName()
> + "
> > > > force-mock enabled , url : " + directory.getUrl());
> > > > }
> > > > //force:direct mock
> > > > result = doMockInvoke(invocation, null);
> > > > }
> > > > // ….
> > > > }
> > > >
> > > > <dubbo:reference id="demoService" check="false"
> > > > interface="com.alibaba.dubbo.samples.mock.api.DemoService"
> > mock="force”/>
> > > >
> > > > Here is demo:
> > > >
> https://github.com/dubbo/dubbo-samples/tree/master/dubbo-samples-mock
> > > >
> > > > `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should support
> > > > force? Can someone help me?
> > > >
> > > > yiji
> > >
> > >
> >
>
Re: Local forced trigger mock does not take effect
Posted by yuhang xiu <ca...@gmail.com>.
Hi guys,
I also encountered this confusion when I configured the mock in xml.
Now it seems that the form of mock=force:return xxx can only be used when
dynamically configured using the override protocol, which does not match
the configuration of the xml.
I think we need to do one of the following two things:
1. Improve the documentation
2. Consider the configuration of xml compatible with the configuration of
the override protocol
Zonghai Shang <yi...@apache.org> 于2018年9月12日周三 上午10:24写道:
> > 1. mock=“true”, this will direct the to the default mock implementation
> with a name convention like DemoServiceMock.
> > 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where your mock
> logic is located.
>
> mock=“org.apache.dubbo.xxx.xxxMock” , only throw RpcException to execute
> the mock, which does not match the force logic.
>
> > 2. mock=“force:return xxx”, directly specify the return value you want.
> This may be the case you want to use, but I think you just forget the mock
> value you want.
>
> It does’t work, cause:
> PropertyAccessException 1:
> org.springframework.beans.MethodInvocationException: Property 'mock' threw
> exception; nested exception is java.lang.IllegalStateException: Invalid
> mock="force:return null" contain illegal charactor, only digit, letter,
> '-', '_' and '.' is legal.
>
> I think maybe the implementation of mock may have bugs.
>
>
> Best regards,
> yiji
>
> jun liu <ke...@gmail.com> 于2018年9月12日周三 上午8:56写道:
>
> > > <dubbo:reference id="demoService" check="false"
> > > interface="com.alibaba.dubbo.samples.mock.api.DemoService"
> mock="force”/>
> >
> > As far as I can describe now, I think you can use:
> > 1. mock=“true”, this will direct the to the default mock implementation
> > with a name convention like DemoServiceMock.
> > 2. mock=“force:return xxx”, directly specify the return value you want.
> > This may be the case you want to use, but I think you just forget the
> mock
> > value you want.
> > 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where your mock
> > logic is located.
> >
> > > `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should support
> > > force? Can someone help me?
> >
> > Given the above usage supported I think there’s no need to add an extra
> > mock=“force” support. What do u think?
> >
> > Best regards,
> > Jun
> >
> > > On 11 Sep 2018, at 16:31, Zonghai Shang <yi...@apache.org> wrote:
> > >
> > > Hi,
> > >
> > > MockClusterInvoker provides local forced mock,I tested it locally, but
> it
> > > doesn't work.
> > >
> > > @Override
> > > public Result invoke(Invocation invocation) throws RpcException {
> > > // ….
> > > else if (value.startsWith("force")) {
> > > if (logger.isWarnEnabled()) {
> > > logger.info("force-mock: " + invocation.getMethodName() + "
> > > force-mock enabled , url : " + directory.getUrl());
> > > }
> > > //force:direct mock
> > > result = doMockInvoke(invocation, null);
> > > }
> > > // ….
> > > }
> > >
> > > <dubbo:reference id="demoService" check="false"
> > > interface="com.alibaba.dubbo.samples.mock.api.DemoService"
> mock="force”/>
> > >
> > > Here is demo:
> > > https://github.com/dubbo/dubbo-samples/tree/master/dubbo-samples-mock
> > >
> > > `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should support
> > > force? Can someone help me?
> > >
> > > yiji
> >
> >
>
Re: Local forced trigger mock does not take effect
Posted by Ian Luo <ia...@gmail.com>.
I am doubting it, maybe we need to check if there's special character we
use but now allowed by XML spec.
On Thu, Sep 20, 2018 at 1:58 PM Zonghai Shang <yi...@apache.org> wrote:
> > Does someone knows why Spring doesn’t support property value containing
> special character? and how to solve it?[1]
>
> Spring does not care about tag specific values, special characters are also
> supported
>
> Best regards,
> yiji
>
> jun liu <ke...@gmail.com> 于2018年9月19日周三 下午4:11写道:
>
> > Sorry, I just have time to check this problem, it turns out I am wrong in
> > the previous email. I think what Zonghai is suggesting should be
> supported,
> > we should support and distinguish configuration prefixed with ‘force:’
> and
> > ‘fail:’,
> >
> > >>> 4. mock=force
> > >>> 6. mock=force:xxx.XxService
> > >>> 7. mock=fail
> > >>> 8. mock=fail:xxx.XxService
> > >>> 5. mock=force:return null
> > >>> 9. mock=fail:return null
> >
> >
> > Does someone knows why Spring doesn’t support property value containing
> > special character? and how to solve it?[1]
> >
> > 1. https://github.com/apache/incubator-dubbo/issues/2489
> >
> > Best regards,
> > Jun
> >
> > > On 14 Sep 2018, at 10:34, Zonghai Shang <yi...@apache.org> wrote:
> > >
> > >>> 4. mock=force
> > >>> 6. mock=force:xxx.XxService
> > >>> 7. mock=fail
> > >>> 8. mock=fail:xxx.XxService
> > >
> > >> Not support at present. But I think there's no need to support these
> > kind
> > > of usage as they can be supported in other forms.
> > >> For example, mock=true and mock=xxx.XxService is enough to cover.
> > >
> > >> -1 to provide this part.
> > >
> > > I disagree with this point of view. mock=true and mock=xxx.XxService
> > only
> > > take effect when an exception is thrown , we need to provide a scenario
> > > that directly calls the mock and does not need to wait for the
> exception
> > to
> > > execute.
> > >
> > > Best regards,
> > > yiji
> > >
> > > jun liu <ke...@gmail.com> 于2018年9月14日周五 上午10:29写道:
> > >
> > >>> 1. mock=true
> > >>> 2. mock=xxx.XxService
> > >>> 3. mock=return null
> > >>
> > >> Double checked, they’re already supported XML and .properties and
> > >> documentation is good.
> > >>
> > >>> 4. mock=force
> > >>> 6. mock=force:xxx.XxService
> > >>> 7. mock=fail
> > >>> 8. mock=fail:xxx.XxService
> > >>
> > >> Not support at present. But I think there's no need to support these
> > kind
> > >> of usage as they can be supported in other forms. For example,
> mock=true
> > >> and mock=xxx.XxService is enough to cover.
> > >>
> > >> -1 to provide this part.
> > >>
> > >>> 5. mock=force:return null
> > >>> 9. mock=fail:return null
> > >>
> > >> Double checked, only support in Override:// protocol:
> > >> https://dubbo.apache.org/zh-cn/docs/user/demos/config-rule.html, we
> can
> > >> consider support in XML and .properties for usage convenience purpose.
> > >>
> > >> +0 to provide.
> > >>
> > >>> 10. mock=throw XxxException
> > >>
> > >> Not support at present.
> > >> +1 to provide.
> > >>
> > >> Best regards,
> > >> Jun
> > >>
> > >>> On 12 Sep 2018, at 18:01, kirito <ki...@foxmail.com> wrote:
> > >>>
> > >>> Hi,Ian.luo and community
> > >>>
> > >>> I has debugged for a while and probably understand the workflow of
> mock
> > >> in dubbo, what confused me was that
> > >>>
> > >>>> I know dubbo was intended to implement `fail:`,`force:`,`throw`
> these
> > >> functions(from the workflow of dubbo source code), but I can’t find
> the
> > >> description in the doc. Like the format as @yiji said: set force as
> > >> mock=“force:return null”. Perhaps dubbo also wants to support
> > >> mock=“force:org.apache.dubbo.xxx.xxxMock”, and maybe dubbo also wants
> to
> > >> support mock=“force” to force match the to the default mock
> > implementation
> > >>>
> > >>> And the `fail:`,`throw` configuration also has their own feature. So
> I
> > >> suggest that we should confirm the behavior of these configuration,
> > then we
> > >> can implement them.
> > >>>
> > >>> As I know, following are some possible configuration of mock
> > >>>
> > >>>
> > >>> 1. mock=true
> > >>> 2. mock=xxx.XxService
> > >>> 3. mock=return null
> > >>>
> > >>> These work well in latest version of dubbo. We can reference
> > >> https://dubbo.apache.org/zh-cn/docs/user/demos/local-mock.html <
> > >> https://dubbo.apache.org/zh-cn/docs/user/demos/local-mock.html> for
> > their
> > >> details.
> > >>>
> > >>> 4. mock=force
> > >>> 5. mock=force:return null
> > >>> 6. mock=force:xxx.XxService
> > >>>
> > >>> These will throw difference type of exception as @yiji reported.from
> > the
> > >> source code of dubbo we can find that they indeed should be supported.
> > But
> > >> there is no description in the doc.
> > >>>
> > >>> 7. mock=fail
> > >>> 8. mock=fail:xxx.XxService
> > >>> 9. mock=fail:return null
> > >>> 10. mock=throw XxxException
> > >>>
> > >>> Any other format of mock, above 7~10 was guess form the source code.
> I
> > >> have no idea about what the all intentions of dubbo mock function.
> Maybe
> > >> need more discuss.
> > >>>
> > >>>
> > >>>
> > >>> Hey guys, I want to know your idea. And look forward to @yiji’s pull
> > >> request.
> > >>>
> > >>> xu jingfeng
> > >>>
> > >>>
> > >>>> 在 2018年9月12日,下午5:14,Ian Luo <ia...@gmail.com> 写道:
> > >>>>
> > >>>> Jingfeng,
> > >>>>
> > >>>> Further more, is there a need to provide support for
> > >>>>> `fail:`,`force:`,`throw`? What the behavior they should own?
> > >>>>>
> > >>>>
> > >>>> I think 'fail:', 'force:' should work, pls. check the code here [1].
> > >> What
> > >>>> unexpected behavior did you see? I have not tried it out, but it
> looks
> > >> we
> > >>>> have the corresponding support but don't have it described in the
> doc.
> > >>>>
> > >>>> 1.
> > >>>>
> > >>
> >
> https://github.com/apache/incubator-dubbo/blob/master/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/wrapper/MockClusterInvoker.java#L76
> > >> <
> > >>
> >
> https://github.com/apache/incubator-dubbo/blob/master/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/wrapper/MockClusterInvoker.java#L76
> > >>>
> > >>>>
> > >>>> On Wed, Sep 12, 2018 at 2:47 PM kirito <kirito.moe@foxmail.com
> > <mailto:
> > >> kirito.moe@foxmail.com>> wrote:
> > >>>>
> > >>>>> Hi
> > >>>>>
> > >>>>> I have a try right now,it was very strange.
> > >>>>> <dubbo:reference id="demoService" check="false"
> > >>>>> interface="com.alibaba.dubbo.samples.mock.api.DemoService"
> > mock="return
> > >>>>> null"/>
> > >>>>> Works very well, but I think the blank is a illegal character too.
> > >>>>> As exception says :
> > >>>>>
> > >>>>>> invalid mock=“xxxx" contain illegal character, only digit, letter,
> > >> '-',
> > >>>>> '_' and '.' is legal.
> > >>>>>
> > >>>>>
> > >>>>> And I search for the dubbo source code find that in
> > >>>>> `com.alibaba.dubbo.common.Constants` exist below attributes
> > >>>>>
> > >>>>> public static final String MOCK_PROTOCOL = "mock";
> > >>>>> public static final String RETURN_PREFIX = "return ";
> > >>>>> public static final String THROW_PREFIX = "throw";
> > >>>>> public static final String FAIL_PREFIX = "fail:";
> > >>>>> public static final String FORCE_PREFIX = "force:";
> > >>>>> public static final String FORCE_KEY = "force”;
> > >>>>>
> > >>>>> While search for the doc
> > >>>>> https://dubbo.apache.org/zh-cn/docs/user/demos/local-mock.html, <
> > >>>>> https://dubbo.apache.org/zh-cn/docs/user/demos/local-mock.html,it
> <
> > >> https://dubbo.apache.org/zh-cn/docs/user/demos/local-mock.html,it>>
> it
> > >>>>> looks like that dubbo doesn’t support throw,fail,force. Maybe any
> of
> > >> these
> > >>>>> attributes are internal?
> > >>>>>
> > >>>>> I think the subject submitted by @yiji was a limitation of spring
> xml
> > >>>>> parser. The character ‘:’ need treated specially.
> > >>>>> Further more, is there a need to provide support for
> > >>>>> `fail:`,`force:`,`throw`? What the behavior they should own?
> > >>>>> As I know,these way works very well now
> > >>>>>> 1. mock=“true”, this will direct the to the default mock
> > >> implementation
> > >>>>>> 2. mock=“return null”
> > >>>>>> 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where
> your
> > >> mock
> > >>>>>
> > >>>>> What do you think about this? It will help us to review the further
> > >>>>> changes.
> > >>>>>
> > >>>>> xujingfeng
> > >>>>>
> > >>>>>> 在 2018年9月12日,下午1:52,Zonghai Shang <yiji@apache.org <mailto:
> > >> yiji@apache.org>> 写道:
> > >>>>>>
> > >>>>>> I have found it , I will fix it later.
> > >>>>>>
> > >>>>>> yiji
> > >>>>>>
> > >>>>>> jun liu <ken.lj.hz@gmail.com <ma...@gmail.com>>
> > >> 于2018年9月12日周三 下午12:45写道:
> > >>>>>>
> > >>>>>>>
> > >>>>>>>>> 2. mock=“force:return xxx”, directly specify the return value
> you
> > >>>>> want.
> > >>>>>>>> This may be the case you want to use, but I think you just
> forget
> > >> the
> > >>>>>>> mock
> > >>>>>>>> value you want.
> > >>>>>>>>
> > >>>>>>>> It does’t work, cause:
> > >>>>>>>> PropertyAccessException 1:
> > >>>>>>>> org.springframework.beans.MethodInvocationException: Property
> > 'mock'
> > >>>>>>> threw
> > >>>>>>>> exception; nested exception is java.lang.IllegalStateException:
> > >> Invalid
> > >>>>>>>> mock="force:return null" contain illegal charactor, only digit,
> > >> letter,
> > >>>>>>>> '-', '_' and '.' is legal.
> > >>>>>>>>
> > >>>>>>>> I think maybe the implementation of mock may have bugs.
> > >>>>>>>
> > >>>>>>> I haven’t tried this usage in xml yet, seems like we need to find
> > the
> > >>>>>>> problem and fix it so that it can work properly as expected.
> > >>>>>>>
> > >>>>>>> Best regards,
> > >>>>>>> Jun
> > >>>>>>>
> > >>>>>>>> On 12 Sep 2018, at 10:24, Zonghai Shang <yiji@apache.org
> <mailto:
> > >> yiji@apache.org>> wrote:
> > >>>>>>>>
> > >>>>>>>>> 1. mock=“true”, this will direct the to the default mock
> > >>>>> implementation
> > >>>>>>>> with a name convention like DemoServiceMock.
> > >>>>>>>>> 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where
> > >> your
> > >>>>>>> mock
> > >>>>>>>> logic is located.
> > >>>>>>>>
> > >>>>>>>> mock=“org.apache.dubbo.xxx.xxxMock” , only throw RpcException to
> > >>>>> execute
> > >>>>>>>> the mock, which does not match the force logic.
> > >>>>>>>>
> > >>>>>>>>> 2. mock=“force:return xxx”, directly specify the return value
> you
> > >>>>> want.
> > >>>>>>>> This may be the case you want to use, but I think you just
> forget
> > >> the
> > >>>>>>> mock
> > >>>>>>>> value you want.
> > >>>>>>>>
> > >>>>>>>> It does’t work, cause:
> > >>>>>>>> PropertyAccessException 1:
> > >>>>>>>> org.springframework.beans.MethodInvocationException: Property
> > 'mock'
> > >>>>>>> threw
> > >>>>>>>> exception; nested exception is java.lang.IllegalStateException:
> > >> Invalid
> > >>>>>>>> mock="force:return null" contain illegal charactor, only digit,
> > >> letter,
> > >>>>>>>> '-', '_' and '.' is legal.
> > >>>>>>>>
> > >>>>>>>> I think maybe the implementation of mock may have bugs.
> > >>>>>>>>
> > >>>>>>>>
> > >>>>>>>> Best regards,
> > >>>>>>>> yiji
> > >>>>>>>>
> > >>>>>>>> jun liu <ken.lj.hz@gmail.com <ma...@gmail.com>>
> > >> 于2018年9月12日周三 上午8:56写道:
> > >>>>>>>>
> > >>>>>>>>>> <dubbo:reference id="demoService" check="false"
> > >>>>>>>>>> interface="com.alibaba.dubbo.samples.mock.api.DemoService"
> > >>>>>>> mock="force”/>
> > >>>>>>>>>
> > >>>>>>>>> As far as I can describe now, I think you can use:
> > >>>>>>>>> 1. mock=“true”, this will direct the to the default mock
> > >>>>> implementation
> > >>>>>>>>> with a name convention like DemoServiceMock.
> > >>>>>>>>> 2. mock=“force:return xxx”, directly specify the return value
> you
> > >>>>> want.
> > >>>>>>>>> This may be the case you want to use, but I think you just
> forget
> > >> the
> > >>>>>>> mock
> > >>>>>>>>> value you want.
> > >>>>>>>>> 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where
> > >> your
> > >>>>>>> mock
> > >>>>>>>>> logic is located.
> > >>>>>>>>>
> > >>>>>>>>>> `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should
> > >> support
> > >>>>>>>>>> force? Can someone help me?
> > >>>>>>>>>
> > >>>>>>>>> Given the above usage supported I think there’s no need to add
> an
> > >>>>> extra
> > >>>>>>>>> mock=“force” support. What do u think?
> > >>>>>>>>>
> > >>>>>>>>> Best regards,
> > >>>>>>>>> Jun
> > >>>>>>>>>
> > >>>>>>>>>> On 11 Sep 2018, at 16:31, Zonghai Shang <yiji@apache.org
> > <mailto:
> > >> yiji@apache.org>> wrote:
> > >>>>>>>>>>
> > >>>>>>>>>> Hi,
> > >>>>>>>>>>
> > >>>>>>>>>> MockClusterInvoker provides local forced mock,I tested it
> > locally,
> > >>>>> but
> > >>>>>>> it
> > >>>>>>>>>> doesn't work.
> > >>>>>>>>>>
> > >>>>>>>>>> @Override
> > >>>>>>>>>> public Result invoke(Invocation invocation) throws
> RpcException
> > {
> > >>>>>>>>>> // ….
> > >>>>>>>>>> else if (value.startsWith("force")) {
> > >>>>>>>>>> if (logger.isWarnEnabled()) {
> > >>>>>>>>>> logger.info("force-mock: " +
> invocation.getMethodName() +
> > >> "
> > >>>>>>>>>> force-mock enabled , url : " + directory.getUrl());
> > >>>>>>>>>> }
> > >>>>>>>>>> //force:direct mock
> > >>>>>>>>>> result = doMockInvoke(invocation, null);
> > >>>>>>>>>> }
> > >>>>>>>>>> // ….
> > >>>>>>>>>> }
> > >>>>>>>>>>
> > >>>>>>>>>> <dubbo:reference id="demoService" check="false"
> > >>>>>>>>>> interface="com.alibaba.dubbo.samples.mock.api.DemoService"
> > >>>>>>> mock="force”/>
> > >>>>>>>>>>
> > >>>>>>>>>> Here is demo:
> > >>>>>>>>>>
> > >>>>>
> > https://github.com/dubbo/dubbo-samples/tree/master/dubbo-samples-mock
> > >>>>>>>>>>
> > >>>>>>>>>> `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should
> > >> support
> > >>>>>>>>>> force? Can someone help me?
> > >>>>>>>>>>
> > >>>>>>>>>> yiji
> > >>>
> > >>
> > >>
> >
> >
>
Re: Local forced trigger mock does not take effect
Posted by Zonghai Shang <yi...@apache.org>.
> Does someone knows why Spring doesn’t support property value containing
special character? and how to solve it?[1]
Spring does not care about tag specific values, special characters are also
supported
Best regards,
yiji
jun liu <ke...@gmail.com> 于2018年9月19日周三 下午4:11写道:
> Sorry, I just have time to check this problem, it turns out I am wrong in
> the previous email. I think what Zonghai is suggesting should be supported,
> we should support and distinguish configuration prefixed with ‘force:’ and
> ‘fail:’,
>
> >>> 4. mock=force
> >>> 6. mock=force:xxx.XxService
> >>> 7. mock=fail
> >>> 8. mock=fail:xxx.XxService
> >>> 5. mock=force:return null
> >>> 9. mock=fail:return null
>
>
> Does someone knows why Spring doesn’t support property value containing
> special character? and how to solve it?[1]
>
> 1. https://github.com/apache/incubator-dubbo/issues/2489
>
> Best regards,
> Jun
>
> > On 14 Sep 2018, at 10:34, Zonghai Shang <yi...@apache.org> wrote:
> >
> >>> 4. mock=force
> >>> 6. mock=force:xxx.XxService
> >>> 7. mock=fail
> >>> 8. mock=fail:xxx.XxService
> >
> >> Not support at present. But I think there's no need to support these
> kind
> > of usage as they can be supported in other forms.
> >> For example, mock=true and mock=xxx.XxService is enough to cover.
> >
> >> -1 to provide this part.
> >
> > I disagree with this point of view. mock=true and mock=xxx.XxService
> only
> > take effect when an exception is thrown , we need to provide a scenario
> > that directly calls the mock and does not need to wait for the exception
> to
> > execute.
> >
> > Best regards,
> > yiji
> >
> > jun liu <ke...@gmail.com> 于2018年9月14日周五 上午10:29写道:
> >
> >>> 1. mock=true
> >>> 2. mock=xxx.XxService
> >>> 3. mock=return null
> >>
> >> Double checked, they’re already supported XML and .properties and
> >> documentation is good.
> >>
> >>> 4. mock=force
> >>> 6. mock=force:xxx.XxService
> >>> 7. mock=fail
> >>> 8. mock=fail:xxx.XxService
> >>
> >> Not support at present. But I think there's no need to support these
> kind
> >> of usage as they can be supported in other forms. For example, mock=true
> >> and mock=xxx.XxService is enough to cover.
> >>
> >> -1 to provide this part.
> >>
> >>> 5. mock=force:return null
> >>> 9. mock=fail:return null
> >>
> >> Double checked, only support in Override:// protocol:
> >> https://dubbo.apache.org/zh-cn/docs/user/demos/config-rule.html, we can
> >> consider support in XML and .properties for usage convenience purpose.
> >>
> >> +0 to provide.
> >>
> >>> 10. mock=throw XxxException
> >>
> >> Not support at present.
> >> +1 to provide.
> >>
> >> Best regards,
> >> Jun
> >>
> >>> On 12 Sep 2018, at 18:01, kirito <ki...@foxmail.com> wrote:
> >>>
> >>> Hi,Ian.luo and community
> >>>
> >>> I has debugged for a while and probably understand the workflow of mock
> >> in dubbo, what confused me was that
> >>>
> >>>> I know dubbo was intended to implement `fail:`,`force:`,`throw` these
> >> functions(from the workflow of dubbo source code), but I can’t find the
> >> description in the doc. Like the format as @yiji said: set force as
> >> mock=“force:return null”. Perhaps dubbo also wants to support
> >> mock=“force:org.apache.dubbo.xxx.xxxMock”, and maybe dubbo also wants to
> >> support mock=“force” to force match the to the default mock
> implementation
> >>>
> >>> And the `fail:`,`throw` configuration also has their own feature. So I
> >> suggest that we should confirm the behavior of these configuration,
> then we
> >> can implement them.
> >>>
> >>> As I know, following are some possible configuration of mock
> >>>
> >>>
> >>> 1. mock=true
> >>> 2. mock=xxx.XxService
> >>> 3. mock=return null
> >>>
> >>> These work well in latest version of dubbo. We can reference
> >> https://dubbo.apache.org/zh-cn/docs/user/demos/local-mock.html <
> >> https://dubbo.apache.org/zh-cn/docs/user/demos/local-mock.html> for
> their
> >> details.
> >>>
> >>> 4. mock=force
> >>> 5. mock=force:return null
> >>> 6. mock=force:xxx.XxService
> >>>
> >>> These will throw difference type of exception as @yiji reported.from
> the
> >> source code of dubbo we can find that they indeed should be supported.
> But
> >> there is no description in the doc.
> >>>
> >>> 7. mock=fail
> >>> 8. mock=fail:xxx.XxService
> >>> 9. mock=fail:return null
> >>> 10. mock=throw XxxException
> >>>
> >>> Any other format of mock, above 7~10 was guess form the source code. I
> >> have no idea about what the all intentions of dubbo mock function. Maybe
> >> need more discuss.
> >>>
> >>>
> >>>
> >>> Hey guys, I want to know your idea. And look forward to @yiji’s pull
> >> request.
> >>>
> >>> xu jingfeng
> >>>
> >>>
> >>>> 在 2018年9月12日,下午5:14,Ian Luo <ia...@gmail.com> 写道:
> >>>>
> >>>> Jingfeng,
> >>>>
> >>>> Further more, is there a need to provide support for
> >>>>> `fail:`,`force:`,`throw`? What the behavior they should own?
> >>>>>
> >>>>
> >>>> I think 'fail:', 'force:' should work, pls. check the code here [1].
> >> What
> >>>> unexpected behavior did you see? I have not tried it out, but it looks
> >> we
> >>>> have the corresponding support but don't have it described in the doc.
> >>>>
> >>>> 1.
> >>>>
> >>
> https://github.com/apache/incubator-dubbo/blob/master/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/wrapper/MockClusterInvoker.java#L76
> >> <
> >>
> https://github.com/apache/incubator-dubbo/blob/master/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/wrapper/MockClusterInvoker.java#L76
> >>>
> >>>>
> >>>> On Wed, Sep 12, 2018 at 2:47 PM kirito <kirito.moe@foxmail.com
> <mailto:
> >> kirito.moe@foxmail.com>> wrote:
> >>>>
> >>>>> Hi
> >>>>>
> >>>>> I have a try right now,it was very strange.
> >>>>> <dubbo:reference id="demoService" check="false"
> >>>>> interface="com.alibaba.dubbo.samples.mock.api.DemoService"
> mock="return
> >>>>> null"/>
> >>>>> Works very well, but I think the blank is a illegal character too.
> >>>>> As exception says :
> >>>>>
> >>>>>> invalid mock=“xxxx" contain illegal character, only digit, letter,
> >> '-',
> >>>>> '_' and '.' is legal.
> >>>>>
> >>>>>
> >>>>> And I search for the dubbo source code find that in
> >>>>> `com.alibaba.dubbo.common.Constants` exist below attributes
> >>>>>
> >>>>> public static final String MOCK_PROTOCOL = "mock";
> >>>>> public static final String RETURN_PREFIX = "return ";
> >>>>> public static final String THROW_PREFIX = "throw";
> >>>>> public static final String FAIL_PREFIX = "fail:";
> >>>>> public static final String FORCE_PREFIX = "force:";
> >>>>> public static final String FORCE_KEY = "force”;
> >>>>>
> >>>>> While search for the doc
> >>>>> https://dubbo.apache.org/zh-cn/docs/user/demos/local-mock.html, <
> >>>>> https://dubbo.apache.org/zh-cn/docs/user/demos/local-mock.html,it <
> >> https://dubbo.apache.org/zh-cn/docs/user/demos/local-mock.html,it>> it
> >>>>> looks like that dubbo doesn’t support throw,fail,force. Maybe any of
> >> these
> >>>>> attributes are internal?
> >>>>>
> >>>>> I think the subject submitted by @yiji was a limitation of spring xml
> >>>>> parser. The character ‘:’ need treated specially.
> >>>>> Further more, is there a need to provide support for
> >>>>> `fail:`,`force:`,`throw`? What the behavior they should own?
> >>>>> As I know,these way works very well now
> >>>>>> 1. mock=“true”, this will direct the to the default mock
> >> implementation
> >>>>>> 2. mock=“return null”
> >>>>>> 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where your
> >> mock
> >>>>>
> >>>>> What do you think about this? It will help us to review the further
> >>>>> changes.
> >>>>>
> >>>>> xujingfeng
> >>>>>
> >>>>>> 在 2018年9月12日,下午1:52,Zonghai Shang <yiji@apache.org <mailto:
> >> yiji@apache.org>> 写道:
> >>>>>>
> >>>>>> I have found it , I will fix it later.
> >>>>>>
> >>>>>> yiji
> >>>>>>
> >>>>>> jun liu <ken.lj.hz@gmail.com <ma...@gmail.com>>
> >> 于2018年9月12日周三 下午12:45写道:
> >>>>>>
> >>>>>>>
> >>>>>>>>> 2. mock=“force:return xxx”, directly specify the return value you
> >>>>> want.
> >>>>>>>> This may be the case you want to use, but I think you just forget
> >> the
> >>>>>>> mock
> >>>>>>>> value you want.
> >>>>>>>>
> >>>>>>>> It does’t work, cause:
> >>>>>>>> PropertyAccessException 1:
> >>>>>>>> org.springframework.beans.MethodInvocationException: Property
> 'mock'
> >>>>>>> threw
> >>>>>>>> exception; nested exception is java.lang.IllegalStateException:
> >> Invalid
> >>>>>>>> mock="force:return null" contain illegal charactor, only digit,
> >> letter,
> >>>>>>>> '-', '_' and '.' is legal.
> >>>>>>>>
> >>>>>>>> I think maybe the implementation of mock may have bugs.
> >>>>>>>
> >>>>>>> I haven’t tried this usage in xml yet, seems like we need to find
> the
> >>>>>>> problem and fix it so that it can work properly as expected.
> >>>>>>>
> >>>>>>> Best regards,
> >>>>>>> Jun
> >>>>>>>
> >>>>>>>> On 12 Sep 2018, at 10:24, Zonghai Shang <yiji@apache.org <mailto:
> >> yiji@apache.org>> wrote:
> >>>>>>>>
> >>>>>>>>> 1. mock=“true”, this will direct the to the default mock
> >>>>> implementation
> >>>>>>>> with a name convention like DemoServiceMock.
> >>>>>>>>> 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where
> >> your
> >>>>>>> mock
> >>>>>>>> logic is located.
> >>>>>>>>
> >>>>>>>> mock=“org.apache.dubbo.xxx.xxxMock” , only throw RpcException to
> >>>>> execute
> >>>>>>>> the mock, which does not match the force logic.
> >>>>>>>>
> >>>>>>>>> 2. mock=“force:return xxx”, directly specify the return value you
> >>>>> want.
> >>>>>>>> This may be the case you want to use, but I think you just forget
> >> the
> >>>>>>> mock
> >>>>>>>> value you want.
> >>>>>>>>
> >>>>>>>> It does’t work, cause:
> >>>>>>>> PropertyAccessException 1:
> >>>>>>>> org.springframework.beans.MethodInvocationException: Property
> 'mock'
> >>>>>>> threw
> >>>>>>>> exception; nested exception is java.lang.IllegalStateException:
> >> Invalid
> >>>>>>>> mock="force:return null" contain illegal charactor, only digit,
> >> letter,
> >>>>>>>> '-', '_' and '.' is legal.
> >>>>>>>>
> >>>>>>>> I think maybe the implementation of mock may have bugs.
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> Best regards,
> >>>>>>>> yiji
> >>>>>>>>
> >>>>>>>> jun liu <ken.lj.hz@gmail.com <ma...@gmail.com>>
> >> 于2018年9月12日周三 上午8:56写道:
> >>>>>>>>
> >>>>>>>>>> <dubbo:reference id="demoService" check="false"
> >>>>>>>>>> interface="com.alibaba.dubbo.samples.mock.api.DemoService"
> >>>>>>> mock="force”/>
> >>>>>>>>>
> >>>>>>>>> As far as I can describe now, I think you can use:
> >>>>>>>>> 1. mock=“true”, this will direct the to the default mock
> >>>>> implementation
> >>>>>>>>> with a name convention like DemoServiceMock.
> >>>>>>>>> 2. mock=“force:return xxx”, directly specify the return value you
> >>>>> want.
> >>>>>>>>> This may be the case you want to use, but I think you just forget
> >> the
> >>>>>>> mock
> >>>>>>>>> value you want.
> >>>>>>>>> 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where
> >> your
> >>>>>>> mock
> >>>>>>>>> logic is located.
> >>>>>>>>>
> >>>>>>>>>> `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should
> >> support
> >>>>>>>>>> force? Can someone help me?
> >>>>>>>>>
> >>>>>>>>> Given the above usage supported I think there’s no need to add an
> >>>>> extra
> >>>>>>>>> mock=“force” support. What do u think?
> >>>>>>>>>
> >>>>>>>>> Best regards,
> >>>>>>>>> Jun
> >>>>>>>>>
> >>>>>>>>>> On 11 Sep 2018, at 16:31, Zonghai Shang <yiji@apache.org
> <mailto:
> >> yiji@apache.org>> wrote:
> >>>>>>>>>>
> >>>>>>>>>> Hi,
> >>>>>>>>>>
> >>>>>>>>>> MockClusterInvoker provides local forced mock,I tested it
> locally,
> >>>>> but
> >>>>>>> it
> >>>>>>>>>> doesn't work.
> >>>>>>>>>>
> >>>>>>>>>> @Override
> >>>>>>>>>> public Result invoke(Invocation invocation) throws RpcException
> {
> >>>>>>>>>> // ….
> >>>>>>>>>> else if (value.startsWith("force")) {
> >>>>>>>>>> if (logger.isWarnEnabled()) {
> >>>>>>>>>> logger.info("force-mock: " + invocation.getMethodName() +
> >> "
> >>>>>>>>>> force-mock enabled , url : " + directory.getUrl());
> >>>>>>>>>> }
> >>>>>>>>>> //force:direct mock
> >>>>>>>>>> result = doMockInvoke(invocation, null);
> >>>>>>>>>> }
> >>>>>>>>>> // ….
> >>>>>>>>>> }
> >>>>>>>>>>
> >>>>>>>>>> <dubbo:reference id="demoService" check="false"
> >>>>>>>>>> interface="com.alibaba.dubbo.samples.mock.api.DemoService"
> >>>>>>> mock="force”/>
> >>>>>>>>>>
> >>>>>>>>>> Here is demo:
> >>>>>>>>>>
> >>>>>
> https://github.com/dubbo/dubbo-samples/tree/master/dubbo-samples-mock
> >>>>>>>>>>
> >>>>>>>>>> `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should
> >> support
> >>>>>>>>>> force? Can someone help me?
> >>>>>>>>>>
> >>>>>>>>>> yiji
> >>>
> >>
> >>
>
>
Re: Local forced trigger mock does not take effect
Posted by jun liu <ke...@gmail.com>.
Sorry, I just have time to check this problem, it turns out I am wrong in the previous email. I think what Zonghai is suggesting should be supported, we should support and distinguish configuration prefixed with ‘force:’ and ‘fail:’,
>>> 4. mock=force
>>> 6. mock=force:xxx.XxService
>>> 7. mock=fail
>>> 8. mock=fail:xxx.XxService
>>> 5. mock=force:return null
>>> 9. mock=fail:return null
Does someone knows why Spring doesn’t support property value containing special character? and how to solve it?[1]
1. https://github.com/apache/incubator-dubbo/issues/2489
Best regards,
Jun
> On 14 Sep 2018, at 10:34, Zonghai Shang <yi...@apache.org> wrote:
>
>>> 4. mock=force
>>> 6. mock=force:xxx.XxService
>>> 7. mock=fail
>>> 8. mock=fail:xxx.XxService
>
>> Not support at present. But I think there's no need to support these kind
> of usage as they can be supported in other forms.
>> For example, mock=true and mock=xxx.XxService is enough to cover.
>
>> -1 to provide this part.
>
> I disagree with this point of view. mock=true and mock=xxx.XxService only
> take effect when an exception is thrown , we need to provide a scenario
> that directly calls the mock and does not need to wait for the exception to
> execute.
>
> Best regards,
> yiji
>
> jun liu <ke...@gmail.com> 于2018年9月14日周五 上午10:29写道:
>
>>> 1. mock=true
>>> 2. mock=xxx.XxService
>>> 3. mock=return null
>>
>> Double checked, they’re already supported XML and .properties and
>> documentation is good.
>>
>>> 4. mock=force
>>> 6. mock=force:xxx.XxService
>>> 7. mock=fail
>>> 8. mock=fail:xxx.XxService
>>
>> Not support at present. But I think there's no need to support these kind
>> of usage as they can be supported in other forms. For example, mock=true
>> and mock=xxx.XxService is enough to cover.
>>
>> -1 to provide this part.
>>
>>> 5. mock=force:return null
>>> 9. mock=fail:return null
>>
>> Double checked, only support in Override:// protocol:
>> https://dubbo.apache.org/zh-cn/docs/user/demos/config-rule.html, we can
>> consider support in XML and .properties for usage convenience purpose.
>>
>> +0 to provide.
>>
>>> 10. mock=throw XxxException
>>
>> Not support at present.
>> +1 to provide.
>>
>> Best regards,
>> Jun
>>
>>> On 12 Sep 2018, at 18:01, kirito <ki...@foxmail.com> wrote:
>>>
>>> Hi,Ian.luo and community
>>>
>>> I has debugged for a while and probably understand the workflow of mock
>> in dubbo, what confused me was that
>>>
>>>> I know dubbo was intended to implement `fail:`,`force:`,`throw` these
>> functions(from the workflow of dubbo source code), but I can’t find the
>> description in the doc. Like the format as @yiji said: set force as
>> mock=“force:return null”. Perhaps dubbo also wants to support
>> mock=“force:org.apache.dubbo.xxx.xxxMock”, and maybe dubbo also wants to
>> support mock=“force” to force match the to the default mock implementation
>>>
>>> And the `fail:`,`throw` configuration also has their own feature. So I
>> suggest that we should confirm the behavior of these configuration, then we
>> can implement them.
>>>
>>> As I know, following are some possible configuration of mock
>>>
>>>
>>> 1. mock=true
>>> 2. mock=xxx.XxService
>>> 3. mock=return null
>>>
>>> These work well in latest version of dubbo. We can reference
>> https://dubbo.apache.org/zh-cn/docs/user/demos/local-mock.html <
>> https://dubbo.apache.org/zh-cn/docs/user/demos/local-mock.html> for their
>> details.
>>>
>>> 4. mock=force
>>> 5. mock=force:return null
>>> 6. mock=force:xxx.XxService
>>>
>>> These will throw difference type of exception as @yiji reported.from the
>> source code of dubbo we can find that they indeed should be supported. But
>> there is no description in the doc.
>>>
>>> 7. mock=fail
>>> 8. mock=fail:xxx.XxService
>>> 9. mock=fail:return null
>>> 10. mock=throw XxxException
>>>
>>> Any other format of mock, above 7~10 was guess form the source code. I
>> have no idea about what the all intentions of dubbo mock function. Maybe
>> need more discuss.
>>>
>>>
>>>
>>> Hey guys, I want to know your idea. And look forward to @yiji’s pull
>> request.
>>>
>>> xu jingfeng
>>>
>>>
>>>> 在 2018年9月12日,下午5:14,Ian Luo <ia...@gmail.com> 写道:
>>>>
>>>> Jingfeng,
>>>>
>>>> Further more, is there a need to provide support for
>>>>> `fail:`,`force:`,`throw`? What the behavior they should own?
>>>>>
>>>>
>>>> I think 'fail:', 'force:' should work, pls. check the code here [1].
>> What
>>>> unexpected behavior did you see? I have not tried it out, but it looks
>> we
>>>> have the corresponding support but don't have it described in the doc.
>>>>
>>>> 1.
>>>>
>> https://github.com/apache/incubator-dubbo/blob/master/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/wrapper/MockClusterInvoker.java#L76
>> <
>> https://github.com/apache/incubator-dubbo/blob/master/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/wrapper/MockClusterInvoker.java#L76
>>>
>>>>
>>>> On Wed, Sep 12, 2018 at 2:47 PM kirito <kirito.moe@foxmail.com <mailto:
>> kirito.moe@foxmail.com>> wrote:
>>>>
>>>>> Hi
>>>>>
>>>>> I have a try right now,it was very strange.
>>>>> <dubbo:reference id="demoService" check="false"
>>>>> interface="com.alibaba.dubbo.samples.mock.api.DemoService" mock="return
>>>>> null"/>
>>>>> Works very well, but I think the blank is a illegal character too.
>>>>> As exception says :
>>>>>
>>>>>> invalid mock=“xxxx" contain illegal character, only digit, letter,
>> '-',
>>>>> '_' and '.' is legal.
>>>>>
>>>>>
>>>>> And I search for the dubbo source code find that in
>>>>> `com.alibaba.dubbo.common.Constants` exist below attributes
>>>>>
>>>>> public static final String MOCK_PROTOCOL = "mock";
>>>>> public static final String RETURN_PREFIX = "return ";
>>>>> public static final String THROW_PREFIX = "throw";
>>>>> public static final String FAIL_PREFIX = "fail:";
>>>>> public static final String FORCE_PREFIX = "force:";
>>>>> public static final String FORCE_KEY = "force”;
>>>>>
>>>>> While search for the doc
>>>>> https://dubbo.apache.org/zh-cn/docs/user/demos/local-mock.html, <
>>>>> https://dubbo.apache.org/zh-cn/docs/user/demos/local-mock.html,it <
>> https://dubbo.apache.org/zh-cn/docs/user/demos/local-mock.html,it>> it
>>>>> looks like that dubbo doesn’t support throw,fail,force. Maybe any of
>> these
>>>>> attributes are internal?
>>>>>
>>>>> I think the subject submitted by @yiji was a limitation of spring xml
>>>>> parser. The character ‘:’ need treated specially.
>>>>> Further more, is there a need to provide support for
>>>>> `fail:`,`force:`,`throw`? What the behavior they should own?
>>>>> As I know,these way works very well now
>>>>>> 1. mock=“true”, this will direct the to the default mock
>> implementation
>>>>>> 2. mock=“return null”
>>>>>> 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where your
>> mock
>>>>>
>>>>> What do you think about this? It will help us to review the further
>>>>> changes.
>>>>>
>>>>> xujingfeng
>>>>>
>>>>>> 在 2018年9月12日,下午1:52,Zonghai Shang <yiji@apache.org <mailto:
>> yiji@apache.org>> 写道:
>>>>>>
>>>>>> I have found it , I will fix it later.
>>>>>>
>>>>>> yiji
>>>>>>
>>>>>> jun liu <ken.lj.hz@gmail.com <ma...@gmail.com>>
>> 于2018年9月12日周三 下午12:45写道:
>>>>>>
>>>>>>>
>>>>>>>>> 2. mock=“force:return xxx”, directly specify the return value you
>>>>> want.
>>>>>>>> This may be the case you want to use, but I think you just forget
>> the
>>>>>>> mock
>>>>>>>> value you want.
>>>>>>>>
>>>>>>>> It does’t work, cause:
>>>>>>>> PropertyAccessException 1:
>>>>>>>> org.springframework.beans.MethodInvocationException: Property 'mock'
>>>>>>> threw
>>>>>>>> exception; nested exception is java.lang.IllegalStateException:
>> Invalid
>>>>>>>> mock="force:return null" contain illegal charactor, only digit,
>> letter,
>>>>>>>> '-', '_' and '.' is legal.
>>>>>>>>
>>>>>>>> I think maybe the implementation of mock may have bugs.
>>>>>>>
>>>>>>> I haven’t tried this usage in xml yet, seems like we need to find the
>>>>>>> problem and fix it so that it can work properly as expected.
>>>>>>>
>>>>>>> Best regards,
>>>>>>> Jun
>>>>>>>
>>>>>>>> On 12 Sep 2018, at 10:24, Zonghai Shang <yiji@apache.org <mailto:
>> yiji@apache.org>> wrote:
>>>>>>>>
>>>>>>>>> 1. mock=“true”, this will direct the to the default mock
>>>>> implementation
>>>>>>>> with a name convention like DemoServiceMock.
>>>>>>>>> 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where
>> your
>>>>>>> mock
>>>>>>>> logic is located.
>>>>>>>>
>>>>>>>> mock=“org.apache.dubbo.xxx.xxxMock” , only throw RpcException to
>>>>> execute
>>>>>>>> the mock, which does not match the force logic.
>>>>>>>>
>>>>>>>>> 2. mock=“force:return xxx”, directly specify the return value you
>>>>> want.
>>>>>>>> This may be the case you want to use, but I think you just forget
>> the
>>>>>>> mock
>>>>>>>> value you want.
>>>>>>>>
>>>>>>>> It does’t work, cause:
>>>>>>>> PropertyAccessException 1:
>>>>>>>> org.springframework.beans.MethodInvocationException: Property 'mock'
>>>>>>> threw
>>>>>>>> exception; nested exception is java.lang.IllegalStateException:
>> Invalid
>>>>>>>> mock="force:return null" contain illegal charactor, only digit,
>> letter,
>>>>>>>> '-', '_' and '.' is legal.
>>>>>>>>
>>>>>>>> I think maybe the implementation of mock may have bugs.
>>>>>>>>
>>>>>>>>
>>>>>>>> Best regards,
>>>>>>>> yiji
>>>>>>>>
>>>>>>>> jun liu <ken.lj.hz@gmail.com <ma...@gmail.com>>
>> 于2018年9月12日周三 上午8:56写道:
>>>>>>>>
>>>>>>>>>> <dubbo:reference id="demoService" check="false"
>>>>>>>>>> interface="com.alibaba.dubbo.samples.mock.api.DemoService"
>>>>>>> mock="force”/>
>>>>>>>>>
>>>>>>>>> As far as I can describe now, I think you can use:
>>>>>>>>> 1. mock=“true”, this will direct the to the default mock
>>>>> implementation
>>>>>>>>> with a name convention like DemoServiceMock.
>>>>>>>>> 2. mock=“force:return xxx”, directly specify the return value you
>>>>> want.
>>>>>>>>> This may be the case you want to use, but I think you just forget
>> the
>>>>>>> mock
>>>>>>>>> value you want.
>>>>>>>>> 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where
>> your
>>>>>>> mock
>>>>>>>>> logic is located.
>>>>>>>>>
>>>>>>>>>> `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should
>> support
>>>>>>>>>> force? Can someone help me?
>>>>>>>>>
>>>>>>>>> Given the above usage supported I think there’s no need to add an
>>>>> extra
>>>>>>>>> mock=“force” support. What do u think?
>>>>>>>>>
>>>>>>>>> Best regards,
>>>>>>>>> Jun
>>>>>>>>>
>>>>>>>>>> On 11 Sep 2018, at 16:31, Zonghai Shang <yiji@apache.org <mailto:
>> yiji@apache.org>> wrote:
>>>>>>>>>>
>>>>>>>>>> Hi,
>>>>>>>>>>
>>>>>>>>>> MockClusterInvoker provides local forced mock,I tested it locally,
>>>>> but
>>>>>>> it
>>>>>>>>>> doesn't work.
>>>>>>>>>>
>>>>>>>>>> @Override
>>>>>>>>>> public Result invoke(Invocation invocation) throws RpcException {
>>>>>>>>>> // ….
>>>>>>>>>> else if (value.startsWith("force")) {
>>>>>>>>>> if (logger.isWarnEnabled()) {
>>>>>>>>>> logger.info("force-mock: " + invocation.getMethodName() +
>> "
>>>>>>>>>> force-mock enabled , url : " + directory.getUrl());
>>>>>>>>>> }
>>>>>>>>>> //force:direct mock
>>>>>>>>>> result = doMockInvoke(invocation, null);
>>>>>>>>>> }
>>>>>>>>>> // ….
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>> <dubbo:reference id="demoService" check="false"
>>>>>>>>>> interface="com.alibaba.dubbo.samples.mock.api.DemoService"
>>>>>>> mock="force”/>
>>>>>>>>>>
>>>>>>>>>> Here is demo:
>>>>>>>>>>
>>>>> https://github.com/dubbo/dubbo-samples/tree/master/dubbo-samples-mock
>>>>>>>>>>
>>>>>>>>>> `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should
>> support
>>>>>>>>>> force? Can someone help me?
>>>>>>>>>>
>>>>>>>>>> yiji
>>>
>>
>>
Re: Local forced trigger mock does not take effect
Posted by Zonghai Shang <yi...@apache.org>.
>> 4. mock=force
>> 6. mock=force:xxx.XxService
>> 7. mock=fail
>> 8. mock=fail:xxx.XxService
> Not support at present. But I think there's no need to support these kind
of usage as they can be supported in other forms.
> For example, mock=true and mock=xxx.XxService is enough to cover.
> -1 to provide this part.
I disagree with this point of view. mock=true and mock=xxx.XxService only
take effect when an exception is thrown , we need to provide a scenario
that directly calls the mock and does not need to wait for the exception to
execute.
Best regards,
yiji
jun liu <ke...@gmail.com> 于2018年9月14日周五 上午10:29写道:
> > 1. mock=true
> > 2. mock=xxx.XxService
> > 3. mock=return null
>
> Double checked, they’re already supported XML and .properties and
> documentation is good.
>
> > 4. mock=force
> > 6. mock=force:xxx.XxService
> > 7. mock=fail
> > 8. mock=fail:xxx.XxService
>
> Not support at present. But I think there's no need to support these kind
> of usage as they can be supported in other forms. For example, mock=true
> and mock=xxx.XxService is enough to cover.
>
> -1 to provide this part.
>
> > 5. mock=force:return null
> > 9. mock=fail:return null
>
> Double checked, only support in Override:// protocol:
> https://dubbo.apache.org/zh-cn/docs/user/demos/config-rule.html, we can
> consider support in XML and .properties for usage convenience purpose.
>
> +0 to provide.
>
> > 10. mock=throw XxxException
>
> Not support at present.
> +1 to provide.
>
> Best regards,
> Jun
>
> > On 12 Sep 2018, at 18:01, kirito <ki...@foxmail.com> wrote:
> >
> > Hi,Ian.luo and community
> >
> > I has debugged for a while and probably understand the workflow of mock
> in dubbo, what confused me was that
> >
> >> I know dubbo was intended to implement `fail:`,`force:`,`throw` these
> functions(from the workflow of dubbo source code), but I can’t find the
> description in the doc. Like the format as @yiji said: set force as
> mock=“force:return null”. Perhaps dubbo also wants to support
> mock=“force:org.apache.dubbo.xxx.xxxMock”, and maybe dubbo also wants to
> support mock=“force” to force match the to the default mock implementation
> >
> > And the `fail:`,`throw` configuration also has their own feature. So I
> suggest that we should confirm the behavior of these configuration, then we
> can implement them.
> >
> > As I know, following are some possible configuration of mock
> >
> >
> > 1. mock=true
> > 2. mock=xxx.XxService
> > 3. mock=return null
> >
> > These work well in latest version of dubbo. We can reference
> https://dubbo.apache.org/zh-cn/docs/user/demos/local-mock.html <
> https://dubbo.apache.org/zh-cn/docs/user/demos/local-mock.html> for their
> details.
> >
> > 4. mock=force
> > 5. mock=force:return null
> > 6. mock=force:xxx.XxService
> >
> > These will throw difference type of exception as @yiji reported.from the
> source code of dubbo we can find that they indeed should be supported. But
> there is no description in the doc.
> >
> > 7. mock=fail
> > 8. mock=fail:xxx.XxService
> > 9. mock=fail:return null
> > 10. mock=throw XxxException
> >
> > Any other format of mock, above 7~10 was guess form the source code. I
> have no idea about what the all intentions of dubbo mock function. Maybe
> need more discuss.
> >
> >
> >
> > Hey guys, I want to know your idea. And look forward to @yiji’s pull
> request.
> >
> > xu jingfeng
> >
> >
> >> 在 2018年9月12日,下午5:14,Ian Luo <ia...@gmail.com> 写道:
> >>
> >> Jingfeng,
> >>
> >> Further more, is there a need to provide support for
> >>> `fail:`,`force:`,`throw`? What the behavior they should own?
> >>>
> >>
> >> I think 'fail:', 'force:' should work, pls. check the code here [1].
> What
> >> unexpected behavior did you see? I have not tried it out, but it looks
> we
> >> have the corresponding support but don't have it described in the doc.
> >>
> >> 1.
> >>
> https://github.com/apache/incubator-dubbo/blob/master/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/wrapper/MockClusterInvoker.java#L76
> <
> https://github.com/apache/incubator-dubbo/blob/master/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/wrapper/MockClusterInvoker.java#L76
> >
> >>
> >> On Wed, Sep 12, 2018 at 2:47 PM kirito <kirito.moe@foxmail.com <mailto:
> kirito.moe@foxmail.com>> wrote:
> >>
> >>> Hi
> >>>
> >>> I have a try right now,it was very strange.
> >>> <dubbo:reference id="demoService" check="false"
> >>> interface="com.alibaba.dubbo.samples.mock.api.DemoService" mock="return
> >>> null"/>
> >>> Works very well, but I think the blank is a illegal character too.
> >>> As exception says :
> >>>
> >>>> invalid mock=“xxxx" contain illegal character, only digit, letter,
> '-',
> >>> '_' and '.' is legal.
> >>>
> >>>
> >>> And I search for the dubbo source code find that in
> >>> `com.alibaba.dubbo.common.Constants` exist below attributes
> >>>
> >>> public static final String MOCK_PROTOCOL = "mock";
> >>> public static final String RETURN_PREFIX = "return ";
> >>> public static final String THROW_PREFIX = "throw";
> >>> public static final String FAIL_PREFIX = "fail:";
> >>> public static final String FORCE_PREFIX = "force:";
> >>> public static final String FORCE_KEY = "force”;
> >>>
> >>> While search for the doc
> >>> https://dubbo.apache.org/zh-cn/docs/user/demos/local-mock.html, <
> >>> https://dubbo.apache.org/zh-cn/docs/user/demos/local-mock.html,it <
> https://dubbo.apache.org/zh-cn/docs/user/demos/local-mock.html,it>> it
> >>> looks like that dubbo doesn’t support throw,fail,force. Maybe any of
> these
> >>> attributes are internal?
> >>>
> >>> I think the subject submitted by @yiji was a limitation of spring xml
> >>> parser. The character ‘:’ need treated specially.
> >>> Further more, is there a need to provide support for
> >>> `fail:`,`force:`,`throw`? What the behavior they should own?
> >>> As I know,these way works very well now
> >>>> 1. mock=“true”, this will direct the to the default mock
> implementation
> >>>> 2. mock=“return null”
> >>>> 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where your
> mock
> >>>
> >>> What do you think about this? It will help us to review the further
> >>> changes.
> >>>
> >>> xujingfeng
> >>>
> >>>> 在 2018年9月12日,下午1:52,Zonghai Shang <yiji@apache.org <mailto:
> yiji@apache.org>> 写道:
> >>>>
> >>>> I have found it , I will fix it later.
> >>>>
> >>>> yiji
> >>>>
> >>>> jun liu <ken.lj.hz@gmail.com <ma...@gmail.com>>
> 于2018年9月12日周三 下午12:45写道:
> >>>>
> >>>>>
> >>>>>>> 2. mock=“force:return xxx”, directly specify the return value you
> >>> want.
> >>>>>> This may be the case you want to use, but I think you just forget
> the
> >>>>> mock
> >>>>>> value you want.
> >>>>>>
> >>>>>> It does’t work, cause:
> >>>>>> PropertyAccessException 1:
> >>>>>> org.springframework.beans.MethodInvocationException: Property 'mock'
> >>>>> threw
> >>>>>> exception; nested exception is java.lang.IllegalStateException:
> Invalid
> >>>>>> mock="force:return null" contain illegal charactor, only digit,
> letter,
> >>>>>> '-', '_' and '.' is legal.
> >>>>>>
> >>>>>> I think maybe the implementation of mock may have bugs.
> >>>>>
> >>>>> I haven’t tried this usage in xml yet, seems like we need to find the
> >>>>> problem and fix it so that it can work properly as expected.
> >>>>>
> >>>>> Best regards,
> >>>>> Jun
> >>>>>
> >>>>>> On 12 Sep 2018, at 10:24, Zonghai Shang <yiji@apache.org <mailto:
> yiji@apache.org>> wrote:
> >>>>>>
> >>>>>>> 1. mock=“true”, this will direct the to the default mock
> >>> implementation
> >>>>>> with a name convention like DemoServiceMock.
> >>>>>>> 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where
> your
> >>>>> mock
> >>>>>> logic is located.
> >>>>>>
> >>>>>> mock=“org.apache.dubbo.xxx.xxxMock” , only throw RpcException to
> >>> execute
> >>>>>> the mock, which does not match the force logic.
> >>>>>>
> >>>>>>> 2. mock=“force:return xxx”, directly specify the return value you
> >>> want.
> >>>>>> This may be the case you want to use, but I think you just forget
> the
> >>>>> mock
> >>>>>> value you want.
> >>>>>>
> >>>>>> It does’t work, cause:
> >>>>>> PropertyAccessException 1:
> >>>>>> org.springframework.beans.MethodInvocationException: Property 'mock'
> >>>>> threw
> >>>>>> exception; nested exception is java.lang.IllegalStateException:
> Invalid
> >>>>>> mock="force:return null" contain illegal charactor, only digit,
> letter,
> >>>>>> '-', '_' and '.' is legal.
> >>>>>>
> >>>>>> I think maybe the implementation of mock may have bugs.
> >>>>>>
> >>>>>>
> >>>>>> Best regards,
> >>>>>> yiji
> >>>>>>
> >>>>>> jun liu <ken.lj.hz@gmail.com <ma...@gmail.com>>
> 于2018年9月12日周三 上午8:56写道:
> >>>>>>
> >>>>>>>> <dubbo:reference id="demoService" check="false"
> >>>>>>>> interface="com.alibaba.dubbo.samples.mock.api.DemoService"
> >>>>> mock="force”/>
> >>>>>>>
> >>>>>>> As far as I can describe now, I think you can use:
> >>>>>>> 1. mock=“true”, this will direct the to the default mock
> >>> implementation
> >>>>>>> with a name convention like DemoServiceMock.
> >>>>>>> 2. mock=“force:return xxx”, directly specify the return value you
> >>> want.
> >>>>>>> This may be the case you want to use, but I think you just forget
> the
> >>>>> mock
> >>>>>>> value you want.
> >>>>>>> 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where
> your
> >>>>> mock
> >>>>>>> logic is located.
> >>>>>>>
> >>>>>>>> `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should
> support
> >>>>>>>> force? Can someone help me?
> >>>>>>>
> >>>>>>> Given the above usage supported I think there’s no need to add an
> >>> extra
> >>>>>>> mock=“force” support. What do u think?
> >>>>>>>
> >>>>>>> Best regards,
> >>>>>>> Jun
> >>>>>>>
> >>>>>>>> On 11 Sep 2018, at 16:31, Zonghai Shang <yiji@apache.org <mailto:
> yiji@apache.org>> wrote:
> >>>>>>>>
> >>>>>>>> Hi,
> >>>>>>>>
> >>>>>>>> MockClusterInvoker provides local forced mock,I tested it locally,
> >>> but
> >>>>> it
> >>>>>>>> doesn't work.
> >>>>>>>>
> >>>>>>>> @Override
> >>>>>>>> public Result invoke(Invocation invocation) throws RpcException {
> >>>>>>>> // ….
> >>>>>>>> else if (value.startsWith("force")) {
> >>>>>>>> if (logger.isWarnEnabled()) {
> >>>>>>>> logger.info("force-mock: " + invocation.getMethodName() +
> "
> >>>>>>>> force-mock enabled , url : " + directory.getUrl());
> >>>>>>>> }
> >>>>>>>> //force:direct mock
> >>>>>>>> result = doMockInvoke(invocation, null);
> >>>>>>>> }
> >>>>>>>> // ….
> >>>>>>>> }
> >>>>>>>>
> >>>>>>>> <dubbo:reference id="demoService" check="false"
> >>>>>>>> interface="com.alibaba.dubbo.samples.mock.api.DemoService"
> >>>>> mock="force”/>
> >>>>>>>>
> >>>>>>>> Here is demo:
> >>>>>>>>
> >>> https://github.com/dubbo/dubbo-samples/tree/master/dubbo-samples-mock
> >>>>>>>>
> >>>>>>>> `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should
> support
> >>>>>>>> force? Can someone help me?
> >>>>>>>>
> >>>>>>>> yiji
> >
>
>
Re: Local forced trigger mock does not take effect
Posted by jun liu <ke...@gmail.com>.
> 1. mock=true
> 2. mock=xxx.XxService
> 3. mock=return null
Double checked, they’re already supported XML and .properties and documentation is good.
> 4. mock=force
> 6. mock=force:xxx.XxService
> 7. mock=fail
> 8. mock=fail:xxx.XxService
Not support at present. But I think there's no need to support these kind of usage as they can be supported in other forms. For example, mock=true and mock=xxx.XxService is enough to cover.
-1 to provide this part.
> 5. mock=force:return null
> 9. mock=fail:return null
Double checked, only support in Override:// protocol:https://dubbo.apache.org/zh-cn/docs/user/demos/config-rule.html, we can consider support in XML and .properties for usage convenience purpose.
+0 to provide.
> 10. mock=throw XxxException
Not support at present.
+1 to provide.
Best regards,
Jun
> On 12 Sep 2018, at 18:01, kirito <ki...@foxmail.com> wrote:
>
> Hi,Ian.luo and community
>
> I has debugged for a while and probably understand the workflow of mock in dubbo, what confused me was that
>
>> I know dubbo was intended to implement `fail:`,`force:`,`throw` these functions(from the workflow of dubbo source code), but I can’t find the description in the doc. Like the format as @yiji said: set force as mock=“force:return null”. Perhaps dubbo also wants to support mock=“force:org.apache.dubbo.xxx.xxxMock”, and maybe dubbo also wants to support mock=“force” to force match the to the default mock implementation
>
> And the `fail:`,`throw` configuration also has their own feature. So I suggest that we should confirm the behavior of these configuration, then we can implement them.
>
> As I know, following are some possible configuration of mock
>
>
> 1. mock=true
> 2. mock=xxx.XxService
> 3. mock=return null
>
> These work well in latest version of dubbo. We can reference https://dubbo.apache.org/zh-cn/docs/user/demos/local-mock.html <https://dubbo.apache.org/zh-cn/docs/user/demos/local-mock.html> for their details.
>
> 4. mock=force
> 5. mock=force:return null
> 6. mock=force:xxx.XxService
>
> These will throw difference type of exception as @yiji reported.from the source code of dubbo we can find that they indeed should be supported. But there is no description in the doc.
>
> 7. mock=fail
> 8. mock=fail:xxx.XxService
> 9. mock=fail:return null
> 10. mock=throw XxxException
>
> Any other format of mock, above 7~10 was guess form the source code. I have no idea about what the all intentions of dubbo mock function. Maybe need more discuss.
>
>
>
> Hey guys, I want to know your idea. And look forward to @yiji’s pull request.
>
> xu jingfeng
>
>
>> 在 2018年9月12日,下午5:14,Ian Luo <ia...@gmail.com> 写道:
>>
>> Jingfeng,
>>
>> Further more, is there a need to provide support for
>>> `fail:`,`force:`,`throw`? What the behavior they should own?
>>>
>>
>> I think 'fail:', 'force:' should work, pls. check the code here [1]. What
>> unexpected behavior did you see? I have not tried it out, but it looks we
>> have the corresponding support but don't have it described in the doc.
>>
>> 1.
>> https://github.com/apache/incubator-dubbo/blob/master/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/wrapper/MockClusterInvoker.java#L76 <https://github.com/apache/incubator-dubbo/blob/master/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/wrapper/MockClusterInvoker.java#L76>
>>
>> On Wed, Sep 12, 2018 at 2:47 PM kirito <kirito.moe@foxmail.com <ma...@foxmail.com>> wrote:
>>
>>> Hi
>>>
>>> I have a try right now,it was very strange.
>>> <dubbo:reference id="demoService" check="false"
>>> interface="com.alibaba.dubbo.samples.mock.api.DemoService" mock="return
>>> null"/>
>>> Works very well, but I think the blank is a illegal character too.
>>> As exception says :
>>>
>>>> invalid mock=“xxxx" contain illegal character, only digit, letter, '-',
>>> '_' and '.' is legal.
>>>
>>>
>>> And I search for the dubbo source code find that in
>>> `com.alibaba.dubbo.common.Constants` exist below attributes
>>>
>>> public static final String MOCK_PROTOCOL = "mock";
>>> public static final String RETURN_PREFIX = "return ";
>>> public static final String THROW_PREFIX = "throw";
>>> public static final String FAIL_PREFIX = "fail:";
>>> public static final String FORCE_PREFIX = "force:";
>>> public static final String FORCE_KEY = "force”;
>>>
>>> While search for the doc
>>> https://dubbo.apache.org/zh-cn/docs/user/demos/local-mock.html, <
>>> https://dubbo.apache.org/zh-cn/docs/user/demos/local-mock.html,it <https://dubbo.apache.org/zh-cn/docs/user/demos/local-mock.html,it>> it
>>> looks like that dubbo doesn’t support throw,fail,force. Maybe any of these
>>> attributes are internal?
>>>
>>> I think the subject submitted by @yiji was a limitation of spring xml
>>> parser. The character ‘:’ need treated specially.
>>> Further more, is there a need to provide support for
>>> `fail:`,`force:`,`throw`? What the behavior they should own?
>>> As I know,these way works very well now
>>>> 1. mock=“true”, this will direct the to the default mock implementation
>>>> 2. mock=“return null”
>>>> 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where your mock
>>>
>>> What do you think about this? It will help us to review the further
>>> changes.
>>>
>>> xujingfeng
>>>
>>>> 在 2018年9月12日,下午1:52,Zonghai Shang <yiji@apache.org <ma...@apache.org>> 写道:
>>>>
>>>> I have found it , I will fix it later.
>>>>
>>>> yiji
>>>>
>>>> jun liu <ken.lj.hz@gmail.com <ma...@gmail.com>> 于2018年9月12日周三 下午12:45写道:
>>>>
>>>>>
>>>>>>> 2. mock=“force:return xxx”, directly specify the return value you
>>> want.
>>>>>> This may be the case you want to use, but I think you just forget the
>>>>> mock
>>>>>> value you want.
>>>>>>
>>>>>> It does’t work, cause:
>>>>>> PropertyAccessException 1:
>>>>>> org.springframework.beans.MethodInvocationException: Property 'mock'
>>>>> threw
>>>>>> exception; nested exception is java.lang.IllegalStateException: Invalid
>>>>>> mock="force:return null" contain illegal charactor, only digit, letter,
>>>>>> '-', '_' and '.' is legal.
>>>>>>
>>>>>> I think maybe the implementation of mock may have bugs.
>>>>>
>>>>> I haven’t tried this usage in xml yet, seems like we need to find the
>>>>> problem and fix it so that it can work properly as expected.
>>>>>
>>>>> Best regards,
>>>>> Jun
>>>>>
>>>>>> On 12 Sep 2018, at 10:24, Zonghai Shang <yiji@apache.org <ma...@apache.org>> wrote:
>>>>>>
>>>>>>> 1. mock=“true”, this will direct the to the default mock
>>> implementation
>>>>>> with a name convention like DemoServiceMock.
>>>>>>> 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where your
>>>>> mock
>>>>>> logic is located.
>>>>>>
>>>>>> mock=“org.apache.dubbo.xxx.xxxMock” , only throw RpcException to
>>> execute
>>>>>> the mock, which does not match the force logic.
>>>>>>
>>>>>>> 2. mock=“force:return xxx”, directly specify the return value you
>>> want.
>>>>>> This may be the case you want to use, but I think you just forget the
>>>>> mock
>>>>>> value you want.
>>>>>>
>>>>>> It does’t work, cause:
>>>>>> PropertyAccessException 1:
>>>>>> org.springframework.beans.MethodInvocationException: Property 'mock'
>>>>> threw
>>>>>> exception; nested exception is java.lang.IllegalStateException: Invalid
>>>>>> mock="force:return null" contain illegal charactor, only digit, letter,
>>>>>> '-', '_' and '.' is legal.
>>>>>>
>>>>>> I think maybe the implementation of mock may have bugs.
>>>>>>
>>>>>>
>>>>>> Best regards,
>>>>>> yiji
>>>>>>
>>>>>> jun liu <ken.lj.hz@gmail.com <ma...@gmail.com>> 于2018年9月12日周三 上午8:56写道:
>>>>>>
>>>>>>>> <dubbo:reference id="demoService" check="false"
>>>>>>>> interface="com.alibaba.dubbo.samples.mock.api.DemoService"
>>>>> mock="force”/>
>>>>>>>
>>>>>>> As far as I can describe now, I think you can use:
>>>>>>> 1. mock=“true”, this will direct the to the default mock
>>> implementation
>>>>>>> with a name convention like DemoServiceMock.
>>>>>>> 2. mock=“force:return xxx”, directly specify the return value you
>>> want.
>>>>>>> This may be the case you want to use, but I think you just forget the
>>>>> mock
>>>>>>> value you want.
>>>>>>> 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where your
>>>>> mock
>>>>>>> logic is located.
>>>>>>>
>>>>>>>> `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should support
>>>>>>>> force? Can someone help me?
>>>>>>>
>>>>>>> Given the above usage supported I think there’s no need to add an
>>> extra
>>>>>>> mock=“force” support. What do u think?
>>>>>>>
>>>>>>> Best regards,
>>>>>>> Jun
>>>>>>>
>>>>>>>> On 11 Sep 2018, at 16:31, Zonghai Shang <yiji@apache.org <ma...@apache.org>> wrote:
>>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> MockClusterInvoker provides local forced mock,I tested it locally,
>>> but
>>>>> it
>>>>>>>> doesn't work.
>>>>>>>>
>>>>>>>> @Override
>>>>>>>> public Result invoke(Invocation invocation) throws RpcException {
>>>>>>>> // ….
>>>>>>>> else if (value.startsWith("force")) {
>>>>>>>> if (logger.isWarnEnabled()) {
>>>>>>>> logger.info("force-mock: " + invocation.getMethodName() + "
>>>>>>>> force-mock enabled , url : " + directory.getUrl());
>>>>>>>> }
>>>>>>>> //force:direct mock
>>>>>>>> result = doMockInvoke(invocation, null);
>>>>>>>> }
>>>>>>>> // ….
>>>>>>>> }
>>>>>>>>
>>>>>>>> <dubbo:reference id="demoService" check="false"
>>>>>>>> interface="com.alibaba.dubbo.samples.mock.api.DemoService"
>>>>> mock="force”/>
>>>>>>>>
>>>>>>>> Here is demo:
>>>>>>>>
>>> https://github.com/dubbo/dubbo-samples/tree/master/dubbo-samples-mock
>>>>>>>>
>>>>>>>> `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should support
>>>>>>>> force? Can someone help me?
>>>>>>>>
>>>>>>>> yiji
>
Re: Local forced trigger mock does not take effect
Posted by kirito <ki...@foxmail.com>.
Hi,Ian.luo and community
I has debugged for a while and probably understand the workflow of mock in dubbo, what confused me was that
> I know dubbo was intended to implement `fail:`,`force:`,`throw` these functions(from the workflow of dubbo source code), but I can’t find the description in the doc. Like the format as @yiji said: set force as mock=“force:return null”. Perhaps dubbo also wants to support mock=“force:org.apache.dubbo.xxx.xxxMock”, and maybe dubbo also wants to support mock=“force” to force match the to the default mock implementation
And the `fail:`,`throw` configuration also has their own feature. So I suggest that we should confirm the behavior of these configuration, then we can implement them.
As I know, following are some possible configuration of mock
1. mock=true
2. mock=xxx.XxService
3. mock=return null
These work well in latest version of dubbo. We can reference https://dubbo.apache.org/zh-cn/docs/user/demos/local-mock.html <https://dubbo.apache.org/zh-cn/docs/user/demos/local-mock.html> for their details.
4. mock=force
5. mock=force:return null
6. mock=force:xxx.XxService
These will throw difference type of exception as @yiji reported.from the source code of dubbo we can find that they indeed should be supported. But there is no description in the doc.
7. mock=fail
8. mock=fail:xxx.XxService
9. mock=fail:return null
10. mock=throw XxxException
Any other format of mock, above 7~10 was guess form the source code. I have no idea about what the all intentions of dubbo mock function. Maybe need more discuss.
Hey guys, I want to know your idea. And look forward to @yiji’s pull request.
xu jingfeng
> 在 2018年9月12日,下午5:14,Ian Luo <ia...@gmail.com> 写道:
>
> Jingfeng,
>
> Further more, is there a need to provide support for
>> `fail:`,`force:`,`throw`? What the behavior they should own?
>>
>
> I think 'fail:', 'force:' should work, pls. check the code here [1]. What
> unexpected behavior did you see? I have not tried it out, but it looks we
> have the corresponding support but don't have it described in the doc.
>
> 1.
> https://github.com/apache/incubator-dubbo/blob/master/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/wrapper/MockClusterInvoker.java#L76 <https://github.com/apache/incubator-dubbo/blob/master/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/wrapper/MockClusterInvoker.java#L76>
>
> On Wed, Sep 12, 2018 at 2:47 PM kirito <kirito.moe@foxmail.com <ma...@foxmail.com>> wrote:
>
>> Hi
>>
>> I have a try right now,it was very strange.
>> <dubbo:reference id="demoService" check="false"
>> interface="com.alibaba.dubbo.samples.mock.api.DemoService" mock="return
>> null"/>
>> Works very well, but I think the blank is a illegal character too.
>> As exception says :
>>
>>> invalid mock=“xxxx" contain illegal character, only digit, letter, '-',
>> '_' and '.' is legal.
>>
>>
>> And I search for the dubbo source code find that in
>> `com.alibaba.dubbo.common.Constants` exist below attributes
>>
>> public static final String MOCK_PROTOCOL = "mock";
>> public static final String RETURN_PREFIX = "return ";
>> public static final String THROW_PREFIX = "throw";
>> public static final String FAIL_PREFIX = "fail:";
>> public static final String FORCE_PREFIX = "force:";
>> public static final String FORCE_KEY = "force”;
>>
>> While search for the doc
>> https://dubbo.apache.org/zh-cn/docs/user/demos/local-mock.html, <
>> https://dubbo.apache.org/zh-cn/docs/user/demos/local-mock.html,it <https://dubbo.apache.org/zh-cn/docs/user/demos/local-mock.html,it>> it
>> looks like that dubbo doesn’t support throw,fail,force. Maybe any of these
>> attributes are internal?
>>
>> I think the subject submitted by @yiji was a limitation of spring xml
>> parser. The character ‘:’ need treated specially.
>> Further more, is there a need to provide support for
>> `fail:`,`force:`,`throw`? What the behavior they should own?
>> As I know,these way works very well now
>>> 1. mock=“true”, this will direct the to the default mock implementation
>>> 2. mock=“return null”
>>> 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where your mock
>>
>> What do you think about this? It will help us to review the further
>> changes.
>>
>> xujingfeng
>>
>>> 在 2018年9月12日,下午1:52,Zonghai Shang <yiji@apache.org <ma...@apache.org>> 写道:
>>>
>>> I have found it , I will fix it later.
>>>
>>> yiji
>>>
>>> jun liu <ken.lj.hz@gmail.com <ma...@gmail.com>> 于2018年9月12日周三 下午12:45写道:
>>>
>>>>
>>>>>> 2. mock=“force:return xxx”, directly specify the return value you
>> want.
>>>>> This may be the case you want to use, but I think you just forget the
>>>> mock
>>>>> value you want.
>>>>>
>>>>> It does’t work, cause:
>>>>> PropertyAccessException 1:
>>>>> org.springframework.beans.MethodInvocationException: Property 'mock'
>>>> threw
>>>>> exception; nested exception is java.lang.IllegalStateException: Invalid
>>>>> mock="force:return null" contain illegal charactor, only digit, letter,
>>>>> '-', '_' and '.' is legal.
>>>>>
>>>>> I think maybe the implementation of mock may have bugs.
>>>>
>>>> I haven’t tried this usage in xml yet, seems like we need to find the
>>>> problem and fix it so that it can work properly as expected.
>>>>
>>>> Best regards,
>>>> Jun
>>>>
>>>>> On 12 Sep 2018, at 10:24, Zonghai Shang <yiji@apache.org <ma...@apache.org>> wrote:
>>>>>
>>>>>> 1. mock=“true”, this will direct the to the default mock
>> implementation
>>>>> with a name convention like DemoServiceMock.
>>>>>> 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where your
>>>> mock
>>>>> logic is located.
>>>>>
>>>>> mock=“org.apache.dubbo.xxx.xxxMock” , only throw RpcException to
>> execute
>>>>> the mock, which does not match the force logic.
>>>>>
>>>>>> 2. mock=“force:return xxx”, directly specify the return value you
>> want.
>>>>> This may be the case you want to use, but I think you just forget the
>>>> mock
>>>>> value you want.
>>>>>
>>>>> It does’t work, cause:
>>>>> PropertyAccessException 1:
>>>>> org.springframework.beans.MethodInvocationException: Property 'mock'
>>>> threw
>>>>> exception; nested exception is java.lang.IllegalStateException: Invalid
>>>>> mock="force:return null" contain illegal charactor, only digit, letter,
>>>>> '-', '_' and '.' is legal.
>>>>>
>>>>> I think maybe the implementation of mock may have bugs.
>>>>>
>>>>>
>>>>> Best regards,
>>>>> yiji
>>>>>
>>>>> jun liu <ken.lj.hz@gmail.com <ma...@gmail.com>> 于2018年9月12日周三 上午8:56写道:
>>>>>
>>>>>>> <dubbo:reference id="demoService" check="false"
>>>>>>> interface="com.alibaba.dubbo.samples.mock.api.DemoService"
>>>> mock="force”/>
>>>>>>
>>>>>> As far as I can describe now, I think you can use:
>>>>>> 1. mock=“true”, this will direct the to the default mock
>> implementation
>>>>>> with a name convention like DemoServiceMock.
>>>>>> 2. mock=“force:return xxx”, directly specify the return value you
>> want.
>>>>>> This may be the case you want to use, but I think you just forget the
>>>> mock
>>>>>> value you want.
>>>>>> 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where your
>>>> mock
>>>>>> logic is located.
>>>>>>
>>>>>>> `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should support
>>>>>>> force? Can someone help me?
>>>>>>
>>>>>> Given the above usage supported I think there’s no need to add an
>> extra
>>>>>> mock=“force” support. What do u think?
>>>>>>
>>>>>> Best regards,
>>>>>> Jun
>>>>>>
>>>>>>> On 11 Sep 2018, at 16:31, Zonghai Shang <yiji@apache.org <ma...@apache.org>> wrote:
>>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> MockClusterInvoker provides local forced mock,I tested it locally,
>> but
>>>> it
>>>>>>> doesn't work.
>>>>>>>
>>>>>>> @Override
>>>>>>> public Result invoke(Invocation invocation) throws RpcException {
>>>>>>> // ….
>>>>>>> else if (value.startsWith("force")) {
>>>>>>> if (logger.isWarnEnabled()) {
>>>>>>> logger.info("force-mock: " + invocation.getMethodName() + "
>>>>>>> force-mock enabled , url : " + directory.getUrl());
>>>>>>> }
>>>>>>> //force:direct mock
>>>>>>> result = doMockInvoke(invocation, null);
>>>>>>> }
>>>>>>> // ….
>>>>>>> }
>>>>>>>
>>>>>>> <dubbo:reference id="demoService" check="false"
>>>>>>> interface="com.alibaba.dubbo.samples.mock.api.DemoService"
>>>> mock="force”/>
>>>>>>>
>>>>>>> Here is demo:
>>>>>>>
>> https://github.com/dubbo/dubbo-samples/tree/master/dubbo-samples-mock
>>>>>>>
>>>>>>> `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should support
>>>>>>> force? Can someone help me?
>>>>>>>
>>>>>>> yiji
Re: Local forced trigger mock does not take effect
Posted by Ian Luo <ia...@gmail.com>.
Jingfeng,
Further more, is there a need to provide support for
> `fail:`,`force:`,`throw`? What the behavior they should own?
>
I think 'fail:', 'force:' should work, pls. check the code here [1]. What
unexpected behavior did you see? I have not tried it out, but it looks we
have the corresponding support but don't have it described in the doc.
1.
https://github.com/apache/incubator-dubbo/blob/master/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/wrapper/MockClusterInvoker.java#L76
On Wed, Sep 12, 2018 at 2:47 PM kirito <ki...@foxmail.com> wrote:
> Hi
>
> I have a try right now,it was very strange.
> <dubbo:reference id="demoService" check="false"
> interface="com.alibaba.dubbo.samples.mock.api.DemoService" mock="return
> null"/>
> Works very well, but I think the blank is a illegal character too.
> As exception says :
>
> > invalid mock=“xxxx" contain illegal character, only digit, letter, '-',
> '_' and '.' is legal.
>
>
> And I search for the dubbo source code find that in
> `com.alibaba.dubbo.common.Constants` exist below attributes
>
> public static final String MOCK_PROTOCOL = "mock";
> public static final String RETURN_PREFIX = "return ";
> public static final String THROW_PREFIX = "throw";
> public static final String FAIL_PREFIX = "fail:";
> public static final String FORCE_PREFIX = "force:";
> public static final String FORCE_KEY = "force”;
>
> While search for the doc
> https://dubbo.apache.org/zh-cn/docs/user/demos/local-mock.html, <
> https://dubbo.apache.org/zh-cn/docs/user/demos/local-mock.html,it> it
> looks like that dubbo doesn’t support throw,fail,force. Maybe any of these
> attributes are internal?
>
> I think the subject submitted by @yiji was a limitation of spring xml
> parser. The character ‘:’ need treated specially.
> Further more, is there a need to provide support for
> `fail:`,`force:`,`throw`? What the behavior they should own?
> As I know,these way works very well now
> > 1. mock=“true”, this will direct the to the default mock implementation
> > 2. mock=“return null”
> > 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where your mock
>
> What do you think about this? It will help us to review the further
> changes.
>
> xujingfeng
>
> > 在 2018年9月12日,下午1:52,Zonghai Shang <yi...@apache.org> 写道:
> >
> > I have found it , I will fix it later.
> >
> > yiji
> >
> > jun liu <ke...@gmail.com> 于2018年9月12日周三 下午12:45写道:
> >
> >>
> >>>> 2. mock=“force:return xxx”, directly specify the return value you
> want.
> >>> This may be the case you want to use, but I think you just forget the
> >> mock
> >>> value you want.
> >>>
> >>> It does’t work, cause:
> >>> PropertyAccessException 1:
> >>> org.springframework.beans.MethodInvocationException: Property 'mock'
> >> threw
> >>> exception; nested exception is java.lang.IllegalStateException: Invalid
> >>> mock="force:return null" contain illegal charactor, only digit, letter,
> >>> '-', '_' and '.' is legal.
> >>>
> >>> I think maybe the implementation of mock may have bugs.
> >>
> >> I haven’t tried this usage in xml yet, seems like we need to find the
> >> problem and fix it so that it can work properly as expected.
> >>
> >> Best regards,
> >> Jun
> >>
> >>> On 12 Sep 2018, at 10:24, Zonghai Shang <yi...@apache.org> wrote:
> >>>
> >>>> 1. mock=“true”, this will direct the to the default mock
> implementation
> >>> with a name convention like DemoServiceMock.
> >>>> 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where your
> >> mock
> >>> logic is located.
> >>>
> >>> mock=“org.apache.dubbo.xxx.xxxMock” , only throw RpcException to
> execute
> >>> the mock, which does not match the force logic.
> >>>
> >>>> 2. mock=“force:return xxx”, directly specify the return value you
> want.
> >>> This may be the case you want to use, but I think you just forget the
> >> mock
> >>> value you want.
> >>>
> >>> It does’t work, cause:
> >>> PropertyAccessException 1:
> >>> org.springframework.beans.MethodInvocationException: Property 'mock'
> >> threw
> >>> exception; nested exception is java.lang.IllegalStateException: Invalid
> >>> mock="force:return null" contain illegal charactor, only digit, letter,
> >>> '-', '_' and '.' is legal.
> >>>
> >>> I think maybe the implementation of mock may have bugs.
> >>>
> >>>
> >>> Best regards,
> >>> yiji
> >>>
> >>> jun liu <ke...@gmail.com> 于2018年9月12日周三 上午8:56写道:
> >>>
> >>>>> <dubbo:reference id="demoService" check="false"
> >>>>> interface="com.alibaba.dubbo.samples.mock.api.DemoService"
> >> mock="force”/>
> >>>>
> >>>> As far as I can describe now, I think you can use:
> >>>> 1. mock=“true”, this will direct the to the default mock
> implementation
> >>>> with a name convention like DemoServiceMock.
> >>>> 2. mock=“force:return xxx”, directly specify the return value you
> want.
> >>>> This may be the case you want to use, but I think you just forget the
> >> mock
> >>>> value you want.
> >>>> 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where your
> >> mock
> >>>> logic is located.
> >>>>
> >>>>> `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should support
> >>>>> force? Can someone help me?
> >>>>
> >>>> Given the above usage supported I think there’s no need to add an
> extra
> >>>> mock=“force” support. What do u think?
> >>>>
> >>>> Best regards,
> >>>> Jun
> >>>>
> >>>>> On 11 Sep 2018, at 16:31, Zonghai Shang <yi...@apache.org> wrote:
> >>>>>
> >>>>> Hi,
> >>>>>
> >>>>> MockClusterInvoker provides local forced mock,I tested it locally,
> but
> >> it
> >>>>> doesn't work.
> >>>>>
> >>>>> @Override
> >>>>> public Result invoke(Invocation invocation) throws RpcException {
> >>>>> // ….
> >>>>> else if (value.startsWith("force")) {
> >>>>> if (logger.isWarnEnabled()) {
> >>>>> logger.info("force-mock: " + invocation.getMethodName() + "
> >>>>> force-mock enabled , url : " + directory.getUrl());
> >>>>> }
> >>>>> //force:direct mock
> >>>>> result = doMockInvoke(invocation, null);
> >>>>> }
> >>>>> // ….
> >>>>> }
> >>>>>
> >>>>> <dubbo:reference id="demoService" check="false"
> >>>>> interface="com.alibaba.dubbo.samples.mock.api.DemoService"
> >> mock="force”/>
> >>>>>
> >>>>> Here is demo:
> >>>>>
> https://github.com/dubbo/dubbo-samples/tree/master/dubbo-samples-mock
> >>>>>
> >>>>> `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should support
> >>>>> force? Can someone help me?
> >>>>>
> >>>>> yiji
> >>>>
> >>>>
> >>
> >>
>
>
Re: Local forced trigger mock does not take effect
Posted by kirito <ki...@foxmail.com>.
Hi
I have a try right now,it was very strange.
<dubbo:reference id="demoService" check="false" interface="com.alibaba.dubbo.samples.mock.api.DemoService" mock="return null"/>
Works very well, but I think the blank is a illegal character too.
As exception says :
> invalid mock=“xxxx" contain illegal character, only digit, letter, '-', '_' and '.' is legal.
And I search for the dubbo source code find that in `com.alibaba.dubbo.common.Constants` exist below attributes
public static final String MOCK_PROTOCOL = "mock";
public static final String RETURN_PREFIX = "return ";
public static final String THROW_PREFIX = "throw";
public static final String FAIL_PREFIX = "fail:";
public static final String FORCE_PREFIX = "force:";
public static final String FORCE_KEY = "force”;
While search for the doc https://dubbo.apache.org/zh-cn/docs/user/demos/local-mock.html, <https://dubbo.apache.org/zh-cn/docs/user/demos/local-mock.html,it> it looks like that dubbo doesn’t support throw,fail,force. Maybe any of these attributes are internal?
I think the subject submitted by @yiji was a limitation of spring xml parser. The character ‘:’ need treated specially.
Further more, is there a need to provide support for `fail:`,`force:`,`throw`? What the behavior they should own?
As I know,these way works very well now
> 1. mock=“true”, this will direct the to the default mock implementation
> 2. mock=“return null”
> 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where your mock
What do you think about this? It will help us to review the further changes.
xujingfeng
> 在 2018年9月12日,下午1:52,Zonghai Shang <yi...@apache.org> 写道:
>
> I have found it , I will fix it later.
>
> yiji
>
> jun liu <ke...@gmail.com> 于2018年9月12日周三 下午12:45写道:
>
>>
>>>> 2. mock=“force:return xxx”, directly specify the return value you want.
>>> This may be the case you want to use, but I think you just forget the
>> mock
>>> value you want.
>>>
>>> It does’t work, cause:
>>> PropertyAccessException 1:
>>> org.springframework.beans.MethodInvocationException: Property 'mock'
>> threw
>>> exception; nested exception is java.lang.IllegalStateException: Invalid
>>> mock="force:return null" contain illegal charactor, only digit, letter,
>>> '-', '_' and '.' is legal.
>>>
>>> I think maybe the implementation of mock may have bugs.
>>
>> I haven’t tried this usage in xml yet, seems like we need to find the
>> problem and fix it so that it can work properly as expected.
>>
>> Best regards,
>> Jun
>>
>>> On 12 Sep 2018, at 10:24, Zonghai Shang <yi...@apache.org> wrote:
>>>
>>>> 1. mock=“true”, this will direct the to the default mock implementation
>>> with a name convention like DemoServiceMock.
>>>> 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where your
>> mock
>>> logic is located.
>>>
>>> mock=“org.apache.dubbo.xxx.xxxMock” , only throw RpcException to execute
>>> the mock, which does not match the force logic.
>>>
>>>> 2. mock=“force:return xxx”, directly specify the return value you want.
>>> This may be the case you want to use, but I think you just forget the
>> mock
>>> value you want.
>>>
>>> It does’t work, cause:
>>> PropertyAccessException 1:
>>> org.springframework.beans.MethodInvocationException: Property 'mock'
>> threw
>>> exception; nested exception is java.lang.IllegalStateException: Invalid
>>> mock="force:return null" contain illegal charactor, only digit, letter,
>>> '-', '_' and '.' is legal.
>>>
>>> I think maybe the implementation of mock may have bugs.
>>>
>>>
>>> Best regards,
>>> yiji
>>>
>>> jun liu <ke...@gmail.com> 于2018年9月12日周三 上午8:56写道:
>>>
>>>>> <dubbo:reference id="demoService" check="false"
>>>>> interface="com.alibaba.dubbo.samples.mock.api.DemoService"
>> mock="force”/>
>>>>
>>>> As far as I can describe now, I think you can use:
>>>> 1. mock=“true”, this will direct the to the default mock implementation
>>>> with a name convention like DemoServiceMock.
>>>> 2. mock=“force:return xxx”, directly specify the return value you want.
>>>> This may be the case you want to use, but I think you just forget the
>> mock
>>>> value you want.
>>>> 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where your
>> mock
>>>> logic is located.
>>>>
>>>>> `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should support
>>>>> force? Can someone help me?
>>>>
>>>> Given the above usage supported I think there’s no need to add an extra
>>>> mock=“force” support. What do u think?
>>>>
>>>> Best regards,
>>>> Jun
>>>>
>>>>> On 11 Sep 2018, at 16:31, Zonghai Shang <yi...@apache.org> wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> MockClusterInvoker provides local forced mock,I tested it locally, but
>> it
>>>>> doesn't work.
>>>>>
>>>>> @Override
>>>>> public Result invoke(Invocation invocation) throws RpcException {
>>>>> // ….
>>>>> else if (value.startsWith("force")) {
>>>>> if (logger.isWarnEnabled()) {
>>>>> logger.info("force-mock: " + invocation.getMethodName() + "
>>>>> force-mock enabled , url : " + directory.getUrl());
>>>>> }
>>>>> //force:direct mock
>>>>> result = doMockInvoke(invocation, null);
>>>>> }
>>>>> // ….
>>>>> }
>>>>>
>>>>> <dubbo:reference id="demoService" check="false"
>>>>> interface="com.alibaba.dubbo.samples.mock.api.DemoService"
>> mock="force”/>
>>>>>
>>>>> Here is demo:
>>>>> https://github.com/dubbo/dubbo-samples/tree/master/dubbo-samples-mock
>>>>>
>>>>> `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should support
>>>>> force? Can someone help me?
>>>>>
>>>>> yiji
>>>>
>>>>
>>
>>
Re: Local forced trigger mock does not take effect
Posted by Zonghai Shang <yi...@apache.org>.
I have found it , I will fix it later.
yiji
jun liu <ke...@gmail.com> 于2018年9月12日周三 下午12:45写道:
>
> >> 2. mock=“force:return xxx”, directly specify the return value you want.
> > This may be the case you want to use, but I think you just forget the
> mock
> > value you want.
> >
> > It does’t work, cause:
> > PropertyAccessException 1:
> > org.springframework.beans.MethodInvocationException: Property 'mock'
> threw
> > exception; nested exception is java.lang.IllegalStateException: Invalid
> > mock="force:return null" contain illegal charactor, only digit, letter,
> > '-', '_' and '.' is legal.
> >
> > I think maybe the implementation of mock may have bugs.
>
> I haven’t tried this usage in xml yet, seems like we need to find the
> problem and fix it so that it can work properly as expected.
>
> Best regards,
> Jun
>
> > On 12 Sep 2018, at 10:24, Zonghai Shang <yi...@apache.org> wrote:
> >
> >> 1. mock=“true”, this will direct the to the default mock implementation
> > with a name convention like DemoServiceMock.
> >> 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where your
> mock
> > logic is located.
> >
> > mock=“org.apache.dubbo.xxx.xxxMock” , only throw RpcException to execute
> > the mock, which does not match the force logic.
> >
> >> 2. mock=“force:return xxx”, directly specify the return value you want.
> > This may be the case you want to use, but I think you just forget the
> mock
> > value you want.
> >
> > It does’t work, cause:
> > PropertyAccessException 1:
> > org.springframework.beans.MethodInvocationException: Property 'mock'
> threw
> > exception; nested exception is java.lang.IllegalStateException: Invalid
> > mock="force:return null" contain illegal charactor, only digit, letter,
> > '-', '_' and '.' is legal.
> >
> > I think maybe the implementation of mock may have bugs.
> >
> >
> > Best regards,
> > yiji
> >
> > jun liu <ke...@gmail.com> 于2018年9月12日周三 上午8:56写道:
> >
> >>> <dubbo:reference id="demoService" check="false"
> >>> interface="com.alibaba.dubbo.samples.mock.api.DemoService"
> mock="force”/>
> >>
> >> As far as I can describe now, I think you can use:
> >> 1. mock=“true”, this will direct the to the default mock implementation
> >> with a name convention like DemoServiceMock.
> >> 2. mock=“force:return xxx”, directly specify the return value you want.
> >> This may be the case you want to use, but I think you just forget the
> mock
> >> value you want.
> >> 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where your
> mock
> >> logic is located.
> >>
> >>> `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should support
> >>> force? Can someone help me?
> >>
> >> Given the above usage supported I think there’s no need to add an extra
> >> mock=“force” support. What do u think?
> >>
> >> Best regards,
> >> Jun
> >>
> >>> On 11 Sep 2018, at 16:31, Zonghai Shang <yi...@apache.org> wrote:
> >>>
> >>> Hi,
> >>>
> >>> MockClusterInvoker provides local forced mock,I tested it locally, but
> it
> >>> doesn't work.
> >>>
> >>> @Override
> >>> public Result invoke(Invocation invocation) throws RpcException {
> >>> // ….
> >>> else if (value.startsWith("force")) {
> >>> if (logger.isWarnEnabled()) {
> >>> logger.info("force-mock: " + invocation.getMethodName() + "
> >>> force-mock enabled , url : " + directory.getUrl());
> >>> }
> >>> //force:direct mock
> >>> result = doMockInvoke(invocation, null);
> >>> }
> >>> // ….
> >>> }
> >>>
> >>> <dubbo:reference id="demoService" check="false"
> >>> interface="com.alibaba.dubbo.samples.mock.api.DemoService"
> mock="force”/>
> >>>
> >>> Here is demo:
> >>> https://github.com/dubbo/dubbo-samples/tree/master/dubbo-samples-mock
> >>>
> >>> `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should support
> >>> force? Can someone help me?
> >>>
> >>> yiji
> >>
> >>
>
>
Re: Local forced trigger mock does not take effect
Posted by jun liu <ke...@gmail.com>.
>> 2. mock=“force:return xxx”, directly specify the return value you want.
> This may be the case you want to use, but I think you just forget the mock
> value you want.
>
> It does’t work, cause:
> PropertyAccessException 1:
> org.springframework.beans.MethodInvocationException: Property 'mock' threw
> exception; nested exception is java.lang.IllegalStateException: Invalid
> mock="force:return null" contain illegal charactor, only digit, letter,
> '-', '_' and '.' is legal.
>
> I think maybe the implementation of mock may have bugs.
I haven’t tried this usage in xml yet, seems like we need to find the problem and fix it so that it can work properly as expected.
Best regards,
Jun
> On 12 Sep 2018, at 10:24, Zonghai Shang <yi...@apache.org> wrote:
>
>> 1. mock=“true”, this will direct the to the default mock implementation
> with a name convention like DemoServiceMock.
>> 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where your mock
> logic is located.
>
> mock=“org.apache.dubbo.xxx.xxxMock” , only throw RpcException to execute
> the mock, which does not match the force logic.
>
>> 2. mock=“force:return xxx”, directly specify the return value you want.
> This may be the case you want to use, but I think you just forget the mock
> value you want.
>
> It does’t work, cause:
> PropertyAccessException 1:
> org.springframework.beans.MethodInvocationException: Property 'mock' threw
> exception; nested exception is java.lang.IllegalStateException: Invalid
> mock="force:return null" contain illegal charactor, only digit, letter,
> '-', '_' and '.' is legal.
>
> I think maybe the implementation of mock may have bugs.
>
>
> Best regards,
> yiji
>
> jun liu <ke...@gmail.com> 于2018年9月12日周三 上午8:56写道:
>
>>> <dubbo:reference id="demoService" check="false"
>>> interface="com.alibaba.dubbo.samples.mock.api.DemoService" mock="force”/>
>>
>> As far as I can describe now, I think you can use:
>> 1. mock=“true”, this will direct the to the default mock implementation
>> with a name convention like DemoServiceMock.
>> 2. mock=“force:return xxx”, directly specify the return value you want.
>> This may be the case you want to use, but I think you just forget the mock
>> value you want.
>> 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where your mock
>> logic is located.
>>
>>> `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should support
>>> force? Can someone help me?
>>
>> Given the above usage supported I think there’s no need to add an extra
>> mock=“force” support. What do u think?
>>
>> Best regards,
>> Jun
>>
>>> On 11 Sep 2018, at 16:31, Zonghai Shang <yi...@apache.org> wrote:
>>>
>>> Hi,
>>>
>>> MockClusterInvoker provides local forced mock,I tested it locally, but it
>>> doesn't work.
>>>
>>> @Override
>>> public Result invoke(Invocation invocation) throws RpcException {
>>> // ….
>>> else if (value.startsWith("force")) {
>>> if (logger.isWarnEnabled()) {
>>> logger.info("force-mock: " + invocation.getMethodName() + "
>>> force-mock enabled , url : " + directory.getUrl());
>>> }
>>> //force:direct mock
>>> result = doMockInvoke(invocation, null);
>>> }
>>> // ….
>>> }
>>>
>>> <dubbo:reference id="demoService" check="false"
>>> interface="com.alibaba.dubbo.samples.mock.api.DemoService" mock="force”/>
>>>
>>> Here is demo:
>>> https://github.com/dubbo/dubbo-samples/tree/master/dubbo-samples-mock
>>>
>>> `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should support
>>> force? Can someone help me?
>>>
>>> yiji
>>
>>
Re: Local forced trigger mock does not take effect
Posted by Zonghai Shang <yi...@apache.org>.
> 1. mock=“true”, this will direct the to the default mock implementation
with a name convention like DemoServiceMock.
> 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where your mock
logic is located.
mock=“org.apache.dubbo.xxx.xxxMock” , only throw RpcException to execute
the mock, which does not match the force logic.
> 2. mock=“force:return xxx”, directly specify the return value you want.
This may be the case you want to use, but I think you just forget the mock
value you want.
It does’t work, cause:
PropertyAccessException 1:
org.springframework.beans.MethodInvocationException: Property 'mock' threw
exception; nested exception is java.lang.IllegalStateException: Invalid
mock="force:return null" contain illegal charactor, only digit, letter,
'-', '_' and '.' is legal.
I think maybe the implementation of mock may have bugs.
Best regards,
yiji
jun liu <ke...@gmail.com> 于2018年9月12日周三 上午8:56写道:
> > <dubbo:reference id="demoService" check="false"
> > interface="com.alibaba.dubbo.samples.mock.api.DemoService" mock="force”/>
>
> As far as I can describe now, I think you can use:
> 1. mock=“true”, this will direct the to the default mock implementation
> with a name convention like DemoServiceMock.
> 2. mock=“force:return xxx”, directly specify the return value you want.
> This may be the case you want to use, but I think you just forget the mock
> value you want.
> 3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where your mock
> logic is located.
>
> > `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should support
> > force? Can someone help me?
>
> Given the above usage supported I think there’s no need to add an extra
> mock=“force” support. What do u think?
>
> Best regards,
> Jun
>
> > On 11 Sep 2018, at 16:31, Zonghai Shang <yi...@apache.org> wrote:
> >
> > Hi,
> >
> > MockClusterInvoker provides local forced mock,I tested it locally, but it
> > doesn't work.
> >
> > @Override
> > public Result invoke(Invocation invocation) throws RpcException {
> > // ….
> > else if (value.startsWith("force")) {
> > if (logger.isWarnEnabled()) {
> > logger.info("force-mock: " + invocation.getMethodName() + "
> > force-mock enabled , url : " + directory.getUrl());
> > }
> > //force:direct mock
> > result = doMockInvoke(invocation, null);
> > }
> > // ….
> > }
> >
> > <dubbo:reference id="demoService" check="false"
> > interface="com.alibaba.dubbo.samples.mock.api.DemoService" mock="force”/>
> >
> > Here is demo:
> > https://github.com/dubbo/dubbo-samples/tree/master/dubbo-samples-mock
> >
> > `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should support
> > force? Can someone help me?
> >
> > yiji
>
>
Re: Local forced trigger mock does not take effect
Posted by jun liu <ke...@gmail.com>.
> <dubbo:reference id="demoService" check="false"
> interface="com.alibaba.dubbo.samples.mock.api.DemoService" mock="force”/>
As far as I can describe now, I think you can use:
1. mock=“true”, this will direct the to the default mock implementation with a name convention like DemoServiceMock.
2. mock=“force:return xxx”, directly specify the return value you want. This may be the case you want to use, but I think you just forget the mock value you want.
3. mock=“org.apache.dubbo.xxx.xxxMock”, specify the class where your mock logic is located.
> `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should support
> force? Can someone help me?
Given the above usage supported I think there’s no need to add an extra mock=“force” support. What do u think?
Best regards,
Jun
> On 11 Sep 2018, at 16:31, Zonghai Shang <yi...@apache.org> wrote:
>
> Hi,
>
> MockClusterInvoker provides local forced mock,I tested it locally, but it
> doesn't work.
>
> @Override
> public Result invoke(Invocation invocation) throws RpcException {
> // ….
> else if (value.startsWith("force")) {
> if (logger.isWarnEnabled()) {
> logger.info("force-mock: " + invocation.getMethodName() + "
> force-mock enabled , url : " + directory.getUrl());
> }
> //force:direct mock
> result = doMockInvoke(invocation, null);
> }
> // ….
> }
>
> <dubbo:reference id="demoService" check="false"
> interface="com.alibaba.dubbo.samples.mock.api.DemoService" mock="force”/>
>
> Here is demo:
> https://github.com/dubbo/dubbo-samples/tree/master/dubbo-samples-mock
>
> `com.alibaba.dubbo.common.utils.ConfigUtils#isDefault` should support
> force? Can someone help me?
>
> yiji