tempesta-tech / tempesta-test

Test suite for Tempesta FW
10 stars 4 forks source link

Supplement websocket tests #351

Closed const-t closed 1 year ago

const-t commented 1 year ago

Need to develop few websocket tests, that must include:

  1. Test of pipelining ws upgrade requests.
  2. Test of rescheduling upgrade requests.
  3. Test to verify correctness of closing all ws connections during tempesta restart or shutdown.

Tests may be based on https://github.com/tempesta-tech/tempesta-test/blob/kt-1647-poc/ws/test_ws_ping.py#L364

krizhanovsky commented 1 year ago

@pale-emperor could you also please check the test ws.test_ws_ping.CacheTest.test_ping_websockets - apparently it does not what expected. Since the test raises https://github.com/tempesta-tech/tempesta/issues/1647 it should do the task in a loop to reproduce the issue on the current master.

The things, which doesn't look correct/confusing:

  1. CacheTest is inherited from WssPing (i.e. Secure Websocket) and there is certificates cleanup code remove_certs(["/tmp/cert.pem", "/tmp/key.pem"]), but the test works over 81 port, i.e. does not use TLS at all.

  2. please check the attacked tcpdump logs (a means output for -A tcpdump option and x stands for -X, so you can analyze readable -A version and see the binary data for the -X): the websockets server sends 4 bytes after upgrading the protocol - is this exected? What are the bytes for? The confusing thing is that I do not see which code of the test sends the 4 bytes.

18:24:43.639807 IP 127.0.0.1.8099 > 127.0.0.1.34132: Flags [P.], seq 1:304, ack 622, win 512, options [nop,nop,TS val 239522521 ecr 239522520], length 303
        0x0000:  0000 0000 0000 0000 0000 0000 0800 4500  ..............E.
        0x0010:  0163 c8c0 4000 4006 72d2 7f00 0001 7f00  .c..@.@.r.......
        0x0020:  0001 1fa3 8554 090d ce98 94ec 621a 8018  .....T......b...
        0x0030:  0200 ff57 0000 0101 080a 0e46 d2d9 0e46  ...W.......F...F
        0x0040:  d2d8 4854 5450 2f31 2e31 2031 3031 2053  ..HTTP/1.1.101.S
        0x0050:  7769 7463 6869 6e67 2050 726f 746f 636f  witching.Protoco
        0x0060:  6c73 0d0a 5570 6772 6164 653a 2077 6562  ls..Upgrade:.web
        0x0070:  736f 636b 6574 0d0a 436f 6e6e 6563 7469  socket..Connecti
        0x0080:  6f6e 3a20 5570 6772 6164 650d 0a53 6563  on:.Upgrade..Sec
        0x0090:  2d57 6562 536f 636b 6574 2d41 6363 6570  -WebSocket-Accep
        0x00a0:  743a 202b 4a6d 3977 796b 762f 4f70 5252  t:.+Jm9wykv/OpRR
        0x00b0:  6e78 5479 3135 3779 6963 5257 7a34 3d0d  nxTy157yicRWz4=.
        0x00c0:  0a53 6563 2d57 6562 536f 636b 6574 2d45  .Sec-WebSocket-E
        0x00d0:  7874 656e 7369 6f6e 733a 2070 6572 6d65  xtensions:.perme
        0x00e0:  7373 6167 652d 6465 666c 6174 653b 2073  ssage-deflate;.s
        0x00f0:  6572 7665 725f 6d61 785f 7769 6e64 6f77  erver_max_window
        0x0100:  5f62 6974 733d 3132 3b20 636c 6965 6e74  _bits=12;.client
        0x0110:  5f6d 6178 5f77 696e 646f 775f 6269 7473  _max_window_bits
        0x0120:  3d31 320d 0a44 6174 653a 2057 6564 2c20  =12..Date:.Wed,.
        0x0130:  3031 2046 6562 2032 3032 3320 3138 3a32  01.Feb.2023.18:2
        0x0140:  343a 3433 2047 4d54 0d0a 5365 7276 6572  4:43.GMT..Server
        0x0150:  3a20 5079 7468 6f6e 2f33 2e31 3020 7765  :.Python/3.10.we
        0x0160:  6273 6f63 6b65 7473 2f31 302e 330d 0a0d  bsockets/10.3...
        0x0170:  0a                                       .
18:24:43.842004 IP 127.0.0.1.34132 > 127.0.0.1.8099: Flags [.], ack 304, win 512, options [nop,nop,TS val 239522723 ecr 239522521], length 0
        0x0000:  0000 0000 0000 0000 0000 0000 0800 4500  ..............E.
        0x0010:  0034 8aa0 4000 4006 b221 7f00 0001 7f00  .4..@.@..!......
        0x0020:  0001 8554 1fa3 94ec 621a 090d cfc7 8010  ...T....b.......
        0x0030:  0200 fe28 0000 0101 080a 0e46 d3a3 0e46  ...(.......F...F
        0x0040:  d2d9                                     ..
18:24:43.842470 IP 127.0.0.1.8099 > 127.0.0.1.34132: Flags [P.], seq 304:308, ack 622, win 512, options [nop,nop,TS val 239522724 ecr 239522723], length 4
        0x0000:  0000 0000 0000 0000 0000 0000 0800 4500  ..............E.
        0x0010:  0038 c8c1 4000 4006 73fc 7f00 0001 7f00  .8..@.@.s.......
        0x0020:  0001 1fa3 8554 090d cfc7 94ec 621a 8018  .....T......b...
        0x0030:  0200 fe2c 0000 0101 080a 0e46 d3a4 0e46  ...,.......F...F
        0x0040:  d3a3 8802 03e8                           ......

1797-x.txt 1797-a.txt

krizhanovsky commented 1 year ago

https://github.com/tempesta-tech/tempesta/pull/1797 fixes/changes the server connections handling. Please make a test, which verifies, that server connections are correctly stolen and recovered: start tempesta with conns_n = 10, make at least 20 client connection upgrades and verify that all of them correctly proxy messages.