Please enable Javascript to view the contents

Envoy 的 Integration Test(组件整合测试)

 ·  ☕ 1 分钟

Envoy 成功原因之一是有严格的项目质量流程控制。如要实现一个新特性或扩展,必须编写组件整合测试用例。本文以 transport_sockets.tcp_stats 扩展的测试实现为例,说明 Envoy 的 integration test 架构。

Integration test 设计

envoy-integration-test-threads.drawio.svg
用 Draw.io 打开

Debugging integration test

build

1
bazel build --compilation_mode=dbg --fission=no //test/extensions/transport_sockets/tcp_stats:tcp_stats_integration_test && bazel build --compilation_mode=dbg --fission=no //test/extensions/transport_sockets/tcp_stats:tcp_stats_integration_test.dwp

lldb

check local var in stack

expr &server
(Envoy::Server::InstanceImpl *) $9 = 0x00007ffff73e10b8
memory region 0x00007ffff73e10b8
[0x00007ffff6be6000-0x00007ffff73e6000) rw-


         Address Perm   Offset Device    Inode    Size KernelPageSize MMUPageSize   Rss   Pss Shared_Clean Shared_Dirty Private_Clean Private_Dirty Referenced Anonymous LazyFree AnonHugePages ShmemPmdMapped FilePmdMapped Shared_Hugetlb Private_Hugetlb Swap SwapPss Locked THPeligible                 VmFlags Mapping
    7ffff6be6000 rw-p 00000000  00:00        0    8192              4           4    80    80            0            0             0            80         80        80        0             0              0             0              0               0    0       0      0           0    rd wr mr mw me ac sd 
x $sp
0x7ffff73e0f70: b0 32 3e f7 ff 7f 00 00 20 37 3e f7 ff 7f 00 00  .2>..... 7>.....
0x7ffff73e0f80: 18 37 3e f7 ff 7f 00 00 a8 34 3e f7 ff 7f 00 00  .7>......4>.....


0x00007ffff73e0f70

expr example

expr listener->filter_chains()[0].filters()[0].typed_config().type_url()

test listener timeout

test/integration/base_integration_test.h

1
2
3
4
5
6
  // Timeout to wait for listeners to be created before invoking
  // registerTestServerPorts(), as that needs to know about the bound listener ports.
  // Using 2x default timeout to cover for slow TLS implementations (no inline asm) on slow
  // computers (e.g., Raspberry Pi) that sometimes time out on TLS listeners, or when
  // the number of listeners in a test is large.
  std::chrono::milliseconds listeners_bound_timeout_ms_{2000 * TestUtility::DefaultTimeout};
分享

Mark Zhu
作者
Mark Zhu
An old developer