3 test_description='simple command server'
7 test-tool simple-ipc SUPPORTS_SIMPLE_IPC || {
8 skip_all='simple IPC not supported on this platform'
12 stop_simple_IPC_server () {
13 test-tool simple-ipc stop-daemon
16 test_expect_success 'start simple command server' '
17 test_atexit stop_simple_IPC_server &&
18 test-tool simple-ipc start-daemon --threads=8 &&
19 test-tool simple-ipc is-active
22 test_expect_success 'simple command server' '
23 test-tool simple-ipc send --token=ping >actual &&
25 test_cmp expect actual
28 test_expect_success 'servers cannot share the same path' '
29 test_must_fail test-tool simple-ipc run-daemon &&
30 test-tool simple-ipc is-active
33 test_expect_success 'big response' '
34 test-tool simple-ipc send --token=big >actual &&
35 test_line_count -ge 10000 actual &&
36 grep -q "big: [0]*9999\$" actual
39 test_expect_success 'chunk response' '
40 test-tool simple-ipc send --token=chunk >actual &&
41 test_line_count -ge 10000 actual &&
42 grep -q "big: [0]*9999\$" actual
45 test_expect_success 'slow response' '
46 test-tool simple-ipc send --token=slow >actual &&
47 test_line_count -ge 100 actual &&
48 grep -q "big: [0]*99\$" actual
51 # Send an IPC with n=100,000 bytes of ballast. This should be large enough
52 # to force both the kernel and the pkt-line layer to chunk the message to the
53 # daemon and for the daemon to receive it in chunks.
55 test_expect_success 'sendbytes' '
56 test-tool simple-ipc sendbytes --bytecount=100000 --byte=A >actual &&
57 grep "sent:A00100000 rcvd:A00100000" actual
60 # Start a series of <threads> client threads that each make <batchsize>
61 # IPC requests to the server. Each (<threads> * <batchsize>) request
62 # will open a new connection to the server and randomly bind to a server
63 # thread. Each client thread exits after completing its batch. So the
64 # total number of live client threads will be smaller than the total.
65 # Each request will send a message containing at least <bytecount> bytes
66 # of ballast. (Responses are small.)
68 # The purpose here is to test threading in the server and responding to
69 # many concurrent client requests (regardless of whether they come from
70 # 1 client process or many). And to test that the server side of the
71 # named pipe/socket is stable. (On Windows this means that the server
72 # pipe is properly recycled.)
74 # On Windows it also lets us adjust the connection timeout in the
75 # `ipc_client_send_command()`.
77 # Note it is easy to drive the system into failure by requesting an
78 # insane number of threads on client or server and/or increasing the
79 # per-thread batchsize or the per-request bytecount (ballast).
80 # On Windows these failures look like "pipe is busy" errors.
81 # So I've chosen fairly conservative values for now.
83 # We expect output of the form "sent:<letter><length> ..."
84 # With terms (7, 19, 13) we expect:
86 # <length> in [19+0 .. 19+(13-1)]
87 # and (7 * 13) successful responses.
89 test_expect_success 'stress test threads' '
90 test-tool simple-ipc multiple \
95 test_line_count = 92 actual &&
96 grep "good 91" actual &&
97 grep "sent:A" <actual >actual_a &&
98 cat >expect_a <<-EOF &&
99 sent:A00000019 rcvd:A00000019
100 sent:A00000020 rcvd:A00000020
101 sent:A00000021 rcvd:A00000021
102 sent:A00000022 rcvd:A00000022
103 sent:A00000023 rcvd:A00000023
104 sent:A00000024 rcvd:A00000024
105 sent:A00000025 rcvd:A00000025
106 sent:A00000026 rcvd:A00000026
107 sent:A00000027 rcvd:A00000027
108 sent:A00000028 rcvd:A00000028
109 sent:A00000029 rcvd:A00000029
110 sent:A00000030 rcvd:A00000030
111 sent:A00000031 rcvd:A00000031
113 test_cmp expect_a actual_a
116 test_expect_success 'stop-daemon works' '
117 test-tool simple-ipc stop-daemon &&
118 test_must_fail test-tool simple-ipc is-active &&
119 test_must_fail test-tool simple-ipc send --token=ping