1 # Copyright (c) 2019 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
14 """TCP util library."""
16 from resources.libraries.python.Constants import Constants
17 from resources.libraries.python.PapiExecutor import PapiSocketExecutor
21 """Implementation of the TCP utilities."""
23 www_root_dir = f"{Constants.REMOTE_FW_DIR}/{Constants.RESOURCES_TP_WRK_WWW}"
29 def start_vpp_http_server_params(
30 cls, node, http_static_plugin, prealloc_fifos, fifo_size,
31 private_segment_size):
32 """Start the test HTTP server internal application or
33 the HTTP static server plugin internal applicatoin on the given node.
35 http static server www-root <www-root-dir> prealloc-fifos <N>
36 fifo-size <size in kB>
37 private-segment-size <seg_size expressed as number + unit, e.g. 100m>
39 test http server static prealloc-fifos <N> fifo-size <size in kB>
40 private-segment-size <seg_size expressed as number + unit, e.g. 100m>
43 Where N is the max number of connections you expect to handle at one
44 time and <size> should be small if you test for CPS and exchange few
45 bytes, say 4, if each connection just exchanges few packets. Or it
46 should be much larger, up to 1024/4096 (i.e. 1-4MB) if you have only
47 one connection and exchange a lot of packets, i.e., when you test for
48 RPS. If you need to allocate lots of FIFOs, so you test for CPS, make
49 private-segment-size something like 4g.
54 http static server www-root <www-root-dir> prealloc-fifos 10000
55 fifo-size 64 private-segment-size 4000m
58 test http server static prealloc-fifos 500000 fifo-size 4
59 private-segment-size 4000m
61 :param node: Node to start HTTP server on.
62 :param http_static_plugin: Run HTTP static server plugin
63 :param prealloc_fifos: Max number of connections you expect to handle at
65 :param fifo_size: FIFO size in kB.
66 :param private_segment_size: Private segment size. Number + unit.
68 :type http_static_plugin: boolean
69 :type prealloc_fifos: str
71 :type private_segment_size: str
73 cmd = f"http static server www-root {cls.www_root_dir} " \
74 f"prealloc-fifos {prealloc_fifos} fifo-size {fifo_size} " \
75 f"private-segment-size {private_segment_size}" \
76 if http_static_plugin \
77 else f"test http server static prealloc-fifos {prealloc_fifos} " \
78 f"fifo-size {fifo_size} private-segment-size {private_segment_size}"
80 PapiSocketExecutor.run_cli_cmd(node, cmd)