doubu8643 2017-05-05 22:46 采纳率: 100%
浏览 84
已采纳

测试微服务?

I know this question is a little subjective but I am lost on what to do here. At the moment I am using Go + Go-kit to write some microservices. I'd like to test the endpoints of these microservices in an integration test type fashion but I am unsure how to go about it. The only thing I can think of is to have shell scripts that hit the endpoints and check for responses. But this seems like kludge and not a real smart practice. I feel like there should be a better way to do this. Does anyone have any suggestions?

  • 写回答

3条回答 默认 最新

  • dongpan1365 2017-05-06 04:38
    关注

    An alternative approach to end-to-end testing is Consumer-Driven Contract (CDC).

    Although is useful to have some end-to-end tests, they have some disadvantages like:

    • the consumer service must know how to start the provider service. This sounds like unnecessary information, likely difficult to maintain when the number of services start ramping up;

    • starting up a service can be slow. Even if we’re only talking a few seconds, this is adding overhead to build times. If a consumer depends on multiple services, this all starts adding up;

    • the provider service might depend on a data store or other services to work as expected. It means that now not only the Provider needs to be started but also a few other services, maybe a database.

    The idea of CDC is described shortly as:

    1. The consumer defines what it expects from a specific request to a service
    2. The provider and the consumer agree on this contract
    3. The provider continuously verifies that the contract is fulfilled

    This information is taken from here. Read more on this article, it can be useful even if it is specific to Java.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办