商业版2.9.0.RELEASE,blade-user模块,controller层搭建junit测试环境,运行失败

Blade 未结 2 1116
aaaaa
aaaaa 剑童 2022-02-11 14:36


我想提问的两个问题:

  1. 未授权部分如何取消。(未通过auth模块执行,仅user单模块运行该junit)

  2. 报错部分的信息是什么原因导致的。(Send request fail,nacosexception两部分错误)


关键代码部分


@RunWith(BladeSpringRunner.class)
@BladeBootTest(appName = AppConstant.APPLICATION_USER_NAME, profile = "test", enableLoader = true)
@SpringBootTest(classes= UserApplication.class)
public class UserControllerTest extends BladeBaseTest {
   UserController userController;
   @Before
   public void setUp(){
      userController = applicationContext.getBean(UserController.class);
   }


   @Test
   public void importUser() {
      MultipartFile multipartFile = getMultipartFile();

      //R res = userController.importUser(multipartFile, 1);
      R res = userController.grant("12","22");
      Assert.assertTrue(res.getCode()==200);
   }



执行结果如下:

2022-02-11 14:24:39.341 ERROR 22764 --- [s.client.Worker] com.alibaba.nacos.common.remote.client   : Send request fail, request=ConfigBatchListenRequest{headers={}, requestId='null'}, retryTimes=0,errorMessage=java.util.concurrent.TimeoutException: Waited 3000 milliseconds (plus 2307 milliseconds, 753900 nanoseconds delay) for com.alibaba.nacos.shaded.io.grpc.stub.ClientCalls$GrpcFuture@76633fa1[status=PENDING, info=[GrpcFuture{clientCall={delegate={delegate=ClientCallImpl{method=MethodDescriptor{fullMethodName=Request/request, type=UNARY, idempotent=false, safe=false, sampledToLocalTracing=true, requestMarshaller=com.alibaba.nacos.shaded.io.grpc.protobuf.lite.ProtoLiteUtils$MessageMarshaller@6e8fdd19, responseMarshaller=com.alibaba.nacos.shaded.io.grpc.protobuf.lite.ProtoLiteUtils$MessageMarshaller@35787726, schemaDescriptor=com.alibaba.nacos.api.grpc.auto.RequestGrpc$RequestMethodDescriptorSupplier@2199e845}}}}}]]

2022-02-11 14:24:39.343 ERROR 22764 --- [s.client.Worker] c.a.n.client.config.impl.ClientWorker    : Async listen config change error 


com.alibaba.nacos.api.exception.NacosException: java.util.concurrent.TimeoutException: Waited 3000 milliseconds (plus 2307 milliseconds, 753900 nanoseconds delay) for com.alibaba.nacos.shaded.io.grpc.stub.ClientCalls$GrpcFuture@76633fa1[status=PENDING, info=[GrpcFuture{clientCall={delegate={delegate=ClientCallImpl{method=MethodDescriptor{fullMethodName=Request/request, type=UNARY, idempotent=false, safe=false, sampledToLocalTracing=true, requestMarshaller=com.alibaba.nacos.shaded.io.grpc.protobuf.lite.ProtoLiteUtils$MessageMarshaller@6e8fdd19, responseMarshaller=com.alibaba.nacos.shaded.io.grpc.protobuf.lite.ProtoLiteUtils$MessageMarshaller@35787726, schemaDescriptor=com.alibaba.nacos.api.grpc.auto.RequestGrpc$RequestMethodDescriptorSupplier@2199e845}}}}}]]

at com.alibaba.nacos.common.remote.client.grpc.GrpcConnection.request(GrpcConnection.java:78)

at com.alibaba.nacos.common.remote.client.RpcClient.request(RpcClient.java:657)

at com.alibaba.nacos.client.config.impl.ClientWorker$ConfigRpcTransportClient.requestProxy(ClientWorker.java:1067)

at com.alibaba.nacos.client.config.impl.ClientWorker$ConfigRpcTransportClient.requestProxy(ClientWorker.java:1042)

at com.alibaba.nacos.client.config.impl.ClientWorker$ConfigRpcTransportClient.executeConfigListen(ClientWorker.java:831)

at com.alibaba.nacos.client.config.impl.ClientWorker$ConfigRpcTransportClient$4.run(ClientWorker.java:748)

at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)

at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266)

at java.util.concurrent.FutureTask.run(FutureTask.java)

at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)

at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

at java.lang.Thread.run(Thread.java:745)

Caused by: java.util.concurrent.TimeoutException: Waited 3000 milliseconds (plus 2307 milliseconds, 753900 nanoseconds delay) for com.alibaba.nacos.shaded.io.grpc.stub.ClientCalls$GrpcFuture@76633fa1[status=PENDING, info=[GrpcFuture{clientCall={delegate={delegate=ClientCallImpl{method=MethodDescriptor{fullMethodName=Request/request, type=UNARY, idempotent=false, safe=false, sampledToLocalTracing=true, requestMarshaller=com.alibaba.nacos.shaded.io.grpc.protobuf.lite.ProtoLiteUtils$MessageMarshaller@6e8fdd19, responseMarshaller=com.alibaba.nacos.shaded.io.grpc.protobuf.lite.ProtoLiteUtils$MessageMarshaller@35787726, schemaDescriptor=com.alibaba.nacos.api.grpc.auto.RequestGrpc$RequestMethodDescriptorSupplier@2199e845}}}}}]]

at com.alibaba.nacos.shaded.com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:508)

at com.alibaba.nacos.common.remote.client.grpc.GrpcConnection.request(GrpcConnection.java:76)

... 13 common frames omitted


2022-02-11 14:24:41.777  INFO 22764 --- [           main] o.s.core.log.aspect.RequestLogAspect     : 


================  Request Start  ================

===> :  Parameters: {"roleIds":"22","userIds":"12"}

================   Request End   ================


2022-02-11 14:24:41.825  INFO 22764 --- [           main] o.s.core.log.aspect.RequestLogAspect     : 


===============  Response Start  ================

<=== :  (48 ms)

===============   Response End   ================



org.springblade.core.secure.exception.SecureException: 请求未授权



2条回答
  • 2022-02-15 01:28

    你需要在test包创建launcherServiceImpl来指定nacos,否则会链接错误

    你调用controller内方法涉及到request调用,权限框架会进行token校验,你没有指定自然会提示未授权。想要解决这个问题,你可以对api放行也可以给request统一加上token。


    另外商业版答疑规则见:https://sns.bladex.cn/article-14990.html

    请将账号邮箱修改为下单购买授权的qq邮箱便可咨询商业版疑问

    修改完邮箱后请将此贴删除并重新发一贴


    0 讨论(0)
  • 2022-02-15 16:16

    感谢回答。我理解的是,我的这个问题跟是否为商业版应该没有关系,免费版也同样存在这个问题。我注明版本号是为了让解答更快捷。而且购买账号是同事的,我这里没有,我想知道后期是否意味着我将无法进行任何问题的提问?

    0 讨论(0)
提交回复