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.
17 from resources.libraries.python.PapiExecutor import PapiSocketExecutor
18 from resources.libraries.python.Constants import Constants
21 class TCPUtils(object):
22 """Implementation of the TCP utilities.
24 www_root_dir = '{rmt_fw_dir}/{wrk_www}'\
25 .format(rmt_fw_dir=Constants.REMOTE_FW_DIR,
26 wrk_www=Constants.RESOURCES_TP_WRK_WWW)
32 def start_vpp_http_server_params(cls, node, http_static_plugin,
33 prealloc_fifos, fifo_size,
34 private_segment_size):
35 """Start the test HTTP server internal application or
36 the HTTP static server plugin internal applicatoin on the given node.
38 http static server www-root <www-root-dir> prealloc-fifos <N>
39 fifo-size <size in kB>
40 private-segment-size <seg_size expressed as number + unit, e.g. 100m>
42 test http server static prealloc-fifos <N> fifo-size <size in kB>
43 private-segment-size <seg_size expressed as number + unit, e.g. 100m>
46 Where N is the max number of connections you expect to handle at one
47 time and <size> should be small if you test for CPS and exchange few
48 bytes, say 4, if each connection just exchanges few packets. Or it
49 should be much larger, up to 1024/4096 (i.e. 1-4MB) if you have only
50 one connection and exchange a lot of packets, i.e., when you test for
51 RPS. If you need to allocate lots of FIFOs, so you test for CPS, make
52 private-segment-size something like 4g.
57 http static server www-root <www-root-dir> prealloc-fifos 10000
58 fifo-size 64 private-segment-size 4000m
61 test http server static prealloc-fifos 500000 fifo-size 4
62 private-segment-size 4000m
64 :param node: Node to start HTTP server on.
65 :param http_static_plugin: Run HTTP static server plugin
66 :param prealloc_fifos: Max number of connections you expect to handle at
68 :param fifo_size: FIFO size in kB.
69 :param private_segment_size: Private segment size. Number + unit.
71 :type http_static_plugin: boolean
72 :type prealloc_fifos: str
74 :type private_segment_size: str
76 if http_static_plugin:
77 cmd = 'http static server www-root {www_root} '\
78 'prealloc-fifos {prealloc_fifos} fifo-size {fifo_size}'\
79 ' private-segment-size {pvt_seg_size}'\
80 .format(www_root=cls.www_root_dir,
81 prealloc_fifos=prealloc_fifos, fifo_size=fifo_size,
82 pvt_seg_size=private_segment_size)
84 cmd = 'test http server static prealloc-fifos {prealloc_fifos} '\
85 'fifo-size {fifo_size} private-segment-size {pvt_seg_size}'\
86 .format(prealloc_fifos=prealloc_fifos, fifo_size=fifo_size,
87 pvt_seg_size=private_segment_size)
88 PapiSocketExecutor.run_cli_cmd(node, cmd)