aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_vhost.py
blob: 9ee92a91b2b40385a2ac1634258463a82dce3746 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python

import unittest

from framework import VppTestCase, VppTestRunner

from vpp_vhost_interface import VppVhostInterface


class TesVhostInterface(VppTestCase):
    """Vhost User Test Case

    """

    def test_vhost(self):
        """ Vhost User add/delete interface test """
        self.logger.info("Vhost User add interfaces")

        # create interface 1 (VirtualEthernet0/0/0)
        vhost_if1 = VppVhostInterface(self, sock_filename='/tmp/sock1')
        vhost_if1.add_vpp_config()
        vhost_if1.admin_up()

        # create interface 2 (VirtualEthernet0/0/1)
        vhost_if2 = VppVhostInterface(self, sock_filename='/tmp/sock2')
        vhost_if2.add_vpp_config()
        vhost_if2.admin_up()

        # verify both interfaces in the show
        ifs = self.vapi.cli("show interface")
        self.assertNotEqual(ifs.find('VirtualEthernet0/0/0'), -1)
        self.assertNotEqual(ifs.find('VirtualEthernet0/0/1'), -1)

        # verify they are in the dump also
        if_dump = self.vapi.sw_interface_vhost_user_dump()
        self.assertTrue(vhost_if1.is_interface_config_in_dump(if_dump))
        self.assertTrue(vhost_if2.is_interface_config_in_dump(if_dump))

        # delete VirtualEthernet0/0/1
        self.logger.info("Deleting VirtualEthernet0/0/1")
        vhost_if2.remove_vpp_config()

        self.logger.info("Verifying VirtualEthernet0/0/1 is deleted")

        ifs = self.vapi.cli("show interface")
        # verify VirtualEthernet0/0/0 still in the show
        self.assertNotEqual(ifs.find('VirtualEthernet0/0/0'), -1)

        # verify VirtualEthernet0/0/1 not in the show
        self.assertEqual(ifs.find('VirtualEthernet0/0/1'), -1)

        # verify VirtualEthernet0/0/1 is not in the dump
        if_dump = self.vapi.sw_interface_vhost_user_dump()
        self.assertFalse(vhost_if2.is_interface_config_in_dump(if_dump))

        # verify VirtualEthernet0/0/0 is still in the dump
        self.assertTrue(vhost_if1.is_interface_config_in_dump(if_dump))

        # delete VirtualEthernet0/0/0
        self.logger.info("Deleting VirtualEthernet0/0/0")
        vhost_if1.remove_vpp_config()

        self.logger.info("Verifying VirtualEthernet0/0/0 is deleted")

        # verify VirtualEthernet0/0/0 not in the show
        ifs = self.vapi.cli("show interface")
        self.assertEqual(ifs.find('VirtualEthernet0/0/0'), -1)

        # verify VirtualEthernet0/0/0 is not in the dump
        if_dump = self.vapi.sw_interface_vhost_user_dump()
        self.assertFalse(vhost_if1.is_interface_config_in_dump(if_dump))

if __name__ == '__main__':
    unittest.main(testRunner=VppTestRunner)
#0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
plot-trending-tput:
  # title: ""
  # titlefont:
  #   size: 16
  autosize: True
  showlegend: True
  # width: 1100
  #height: 400
  yaxis:
    showticklabels: True
    tickformat: ".3s"
    title: "Throughput [Mpps]"
    hoverformat: ".5s"
    gridcolor: "rgb(238, 238, 238)"
    linecolor: "rgb(238, 238, 238)"
    showline: True
    zeroline: False
    tickcolor: "rgb(238, 238, 238)"
    linewidth: 1
    showgrid: True
  xaxis:
    title: 'Date [MMDD]'
    type: "date"
    autorange: True
    fixedrange: False
    showgrid: True
    gridcolor: "rgb(238, 238, 238)"
    showline: True
    linecolor: "rgb(238, 238, 238)"
    zeroline: False
    linewidth: 1
    showticklabels: True
    tickcolor: "rgb(238, 238, 238)"
    tickmode: "auto"
    tickformat: "%m%d"
    rangeselector:
      buttons:
      - count: 14
        label: "2w"
        step: "day"
        stepmode: "backward"
      - count: 1
        label: "1m"
        step: "month"
        stepmode: "backward"
      - count: 2
        label: "2m"
        step: "month"
        stepmode: "backward"
      - count: 3
        label: "3m"
        step: "month"
        stepmode: "backward"
      - count: 4
        label: "4m"
        step: "month"
        stepmode: "backward"
      - count: 5
        label: "5m"
        step: "month"
        stepmode: "backward"
      - step: "all"
  margin:
    r: 20
    b: 0
    t: 5
    l: 70
  legend:
    orientation: "h"
    y: -0.18
    xanchor: "auto"
    traceorder: "normal"
    bordercolor: "rgb(238, 238, 238)"
  paper_bgcolor: "#fff"
  plot_bgcolor: "#fff"
  hoverlabel:
    namelength: -1

plot-trending-lat:
  # title: ""
  # titlefont:
  #   size: 16
  autosize: True
  showlegend: True
  # width: 1100
  #height: 400
  yaxis:
    showticklabels: True
    tickformat: ".3s"
    title: "Average Latency at 50% PDR [us]"
    hoverformat: ".5s"
    gridcolor: "rgb(238, 238, 238)"
    linecolor: "rgb(238, 238, 238)"
    showline: True
    zeroline: False
    tickcolor: "rgb(238, 238, 238)"
    linewidth: 1
    showgrid: True
  xaxis:
    title: 'Date [MMDD]'
    type: "date"
    autorange: True
    fixedrange: False
    showgrid: True
    gridcolor: "rgb(238, 238, 238)"
    showline: True
    linecolor: "rgb(238, 238, 238)"
    zeroline: False
    linewidth: 1
    showticklabels: True
    tickcolor: "rgb(238, 238, 238)"
    tickmode: "auto"
    tickformat: "%m%d"
    rangeselector:
      buttons:
      - count: 14
        label: "2w"
        step: "day"
        stepmode: "backward"
      - count: 1
        label: "1m"
        step: "month"
        stepmode: "backward"
      - count: 2
        label: "2m"
        step: "month"
        stepmode: "backward"
      - count: 3
        label: "3m"
        step: "month"
        stepmode: "backward"
      - count: 4
        label: "4m"
        step: "month"
        stepmode: "backward"
      - count: 5
        label: "5m"
        step: "month"
        stepmode: "backward"
      - step: "all"
  margin:
    r: 20
    b: 0
    t: 5
    l: 70
  legend:
    orientation: "h"
    y: -0.18
    xanchor: "auto"
    traceorder: "normal"
    bordercolor: "rgb(238, 238, 238)"
  paper_bgcolor: "#fff"
  plot_bgcolor: "#fff"
  hoverlabel:
    namelength: -1

plot-hdrh-latency:
  # title:
  #   text: "Latency by Percentile Distribution"
  #   xanchor: "center"
  #   x: 0.5
    # font:
    #   size: 10
  showlegend: True
  legend:
    traceorder: "normal"
    orientation: "h"
    # font:
    #   size: 16
    xanchor: "left"
    yanchor: "top"
    x: 0
    y: -0.25
    bgcolor: "rgba(255, 255, 255, 0)"
    bordercolor: "rgba(255, 255, 255, 0)"
  xaxis:
    type: "log"
    title: "Percentile [%]"
    # titlefont:
    #   size: 14
    autorange: False
    fixedrange: True
    gridcolor: "rgb(230, 230, 230)"
    linecolor: "rgb(220, 220, 220)"
    linewidth: 1
    showgrid: True
    showline: True
    showticklabels: True
    tickcolor: "rgb(220, 220, 220)"
    tickvals: [1, 2, 1e1, 20, 1e2, 1e3, 1e4, 1e5, 1e6]
    ticktext: [0, 50, 90, 95, 99, 99.9, 99.99, 99.999, 99.9999]
    # tickfont:
    #   size: 14
  yaxis:
    title: "One-Way Latency per Direction [us]"
    # titlefont:
    #   size: 14
    gridcolor: "rgb(230, 230, 230)"
    linecolor: "rgb(220, 220, 220)"
    linewidth: 1
    showgrid: True
    showline: True
    showticklabels: True
    tickcolor: "rgb(220, 220, 220)"
    # tickfont:
    #   size: 14
  autosize: True
  #height: 400
  paper_bgcolor: "white"
  plot_bgcolor: "white"