]> git.ipfire.org Git - thirdparty/git.git/blame - t/t0052-simple-ipc.sh
help: make sure local html page exists before calling external processes
[thirdparty/git.git] / t / t0052-simple-ipc.sh
CommitLineData
36a7eb68
JH
1#!/bin/sh
2
3test_description='simple command server'
4
5. ./test-lib.sh
6
7test-tool simple-ipc SUPPORTS_SIMPLE_IPC || {
8 skip_all='simple IPC not supported on this platform'
9 test_done
10}
11
12stop_simple_IPC_server () {
13 test-tool simple-ipc stop-daemon
14}
15
16test_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
20'
21
22test_expect_success 'simple command server' '
23 test-tool simple-ipc send --token=ping >actual &&
24 echo pong >expect &&
25 test_cmp expect actual
26'
27
28test_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
31'
32
33test_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
37'
38
39test_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
43'
44
45test_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
49'
50
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.
54#
55test_expect_success 'sendbytes' '
56 test-tool simple-ipc sendbytes --bytecount=100000 --byte=A >actual &&
57 grep "sent:A00100000 rcvd:A00100000" actual
58'
59
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.)
67#
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.)
73#
74# On Windows it also lets us adjust the connection timeout in the
75# `ipc_client_send_command()`.
76#
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.
82#
83# We expect output of the form "sent:<letter><length> ..."
84# With terms (7, 19, 13) we expect:
85# <letter> in [A-G]
86# <length> in [19+0 .. 19+(13-1)]
87# and (7 * 13) successful responses.
88#
89test_expect_success 'stress test threads' '
90 test-tool simple-ipc multiple \
91 --threads=7 \
92 --bytecount=19 \
93 --batchsize=13 \
94 >actual &&
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
112 EOF
113 test_cmp expect_a actual_a
114'
115
116test_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
120'
121
122test_done