Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/t0052-simple-ipc.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / t0052-simple-ipc.sh` 122 lines ยท 3894 bytes Raw Blame History 1 #!/bin/sh 2 3 test_description='simple command server' 4 5 . ./test-lib.sh 6 7 test-tool simple-ipc SUPPORTS_SIMPLE_IPC || { 8 skip_all='simple IPC not supported on this platform' 9 test_done 10 } 11 12 stop_simple_IPC_server () { 13 test-tool simple-ipc stop-daemon 14 } 15 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 20 ' 21 22 test_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 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 31 ' 32 33 test_expect_success 'big response' ' 34 test-tool simple-ipc send --token=big >actual && 35 test_line_count -ge 10000 actual && 36 test_grep -q "big: [0]*9999\$" actual 37 ' 38 39 test_expect_success 'chunk response' ' 40 test-tool simple-ipc send --token=chunk >actual && 41 test_line_count -ge 10000 actual && 42 test_grep -q "big: [0]*9999\$" actual 43 ' 44 45 test_expect_success 'slow response' ' 46 test-tool simple-ipc send --token=slow >actual && 47 test_line_count -ge 100 actual && 48 test_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 # 55 test_expect_success 'sendbytes' ' 56 test-tool simple-ipc sendbytes --bytecount=100000 --byte=A >actual && 57 test_grep "sent:A00100000 rcvd:A00100000" actual 58 ' 59 60 # Start a series of client threads that each make 61 # IPC requests to the server. Each ( * ) 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 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: ..." 84 # With terms (7, 19, 13) we expect: 85 # in [A-G] 86 # in [19+0 .. 19+(13-1)] 87 # and (7 * 13) successful responses. 88 # 89 test_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 test_grep "good 91" actual && 97 grep "sent:A" 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 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 120 ' 121 122 test_done