|
10 | 10 | def discovery(npu):
|
11 | 11 | npu.objects_discovery()
|
12 | 12 |
|
| 13 | +@pytest.fixture(scope='module', autouse=True) |
| 14 | +def skip_all(testbed_instance): |
| 15 | + testbed = testbed_instance |
| 16 | + if testbed is not None and len(testbed.npu) != 1: |
| 17 | + pytest.skip('invalid for {} testbed'.format(testbed.name)) |
13 | 18 |
|
14 | 19 | def test_l2_untagged_vlan_traffic(npu, dataplane):
|
15 | 20 | """
|
@@ -74,65 +79,66 @@ def test_l2_untagged_vlan_traffic(npu, dataplane):
|
74 | 79 | result = npu.command_processor.process_command(command)
|
75 | 80 | print(result)
|
76 | 81 | try:
|
77 |
| - macs = ["00:11:11:11:11:11", "00:22:22:22:22:22"] |
78 |
| - config = dataplane.configuration |
79 |
| - config.options.port_options.location_preemption = True |
80 |
| - layer1 = config.layer1.layer1()[-1] |
81 |
| - layer1.name = "port settings" |
82 |
| - layer1.port_names = [port.name for port in config.ports] |
83 |
| - layer1.ieee_media_defaults = False |
84 |
| - layer1.auto_negotiation.rs_fec = False |
85 |
| - layer1.auto_negotiation.link_training = False |
86 |
| - layer1.speed = "speed_100_gbps" |
87 |
| - layer1.auto_negotiate = False |
88 |
| - flow1 = config.flows.flow(name="Vlan Traffic")[-1] |
| 82 | + if npu.run_traffic: |
| 83 | + macs = ["00:11:11:11:11:11", "00:22:22:22:22:22"] |
| 84 | + config = dataplane.configuration |
| 85 | + config.options.port_options.location_preemption = True |
| 86 | + layer1 = config.layer1.layer1()[-1] |
| 87 | + layer1.name = "port settings" |
| 88 | + layer1.port_names = [port.name for port in config.ports] |
| 89 | + layer1.ieee_media_defaults = False |
| 90 | + layer1.auto_negotiation.rs_fec = False |
| 91 | + layer1.auto_negotiation.link_training = False |
| 92 | + layer1.speed = "speed_100_gbps" |
| 93 | + layer1.auto_negotiate = False |
| 94 | + flow1 = config.flows.flow(name="Vlan Traffic")[-1] |
89 | 95 |
|
90 |
| - flow1.tx_rx.port.tx_name = config.ports[0].name |
91 |
| - flow1.tx_rx.port.rx_name = config.ports[1].name |
92 |
| - flow1.size.fixed = 1024 |
93 |
| - flow1.rate.percentage = 100 |
94 |
| - flow1.metrics.enable = True |
95 |
| - flow1.metrics.loss = True |
96 |
| - source = macs[1] |
97 |
| - destination = macs[0] |
98 |
| - eth, vlan = flow1.packet.ethernet().vlan() |
99 |
| - eth.src.value = source |
100 |
| - eth.dst.value = destination |
101 |
| - vlan.id.value = int(vlan_id) |
| 96 | + flow1.tx_rx.port.tx_name = config.ports[0].name |
| 97 | + flow1.tx_rx.port.rx_name = config.ports[1].name |
| 98 | + flow1.size.fixed = 1024 |
| 99 | + flow1.rate.percentage = 100 |
| 100 | + flow1.metrics.enable = True |
| 101 | + flow1.metrics.loss = True |
| 102 | + source = macs[1] |
| 103 | + destination = macs[0] |
| 104 | + eth, vlan = flow1.packet.ethernet().vlan() |
| 105 | + eth.src.value = source |
| 106 | + eth.dst.value = destination |
| 107 | + vlan.id.value = int(vlan_id) |
102 | 108 |
|
103 |
| - dataplane.set_config() |
104 |
| - restpy_session = dataplane.api.assistant.Session |
105 |
| - ixnet = restpy_session.Ixnetwork |
106 |
| - for port in ixnet.Vport.find(): |
107 |
| - port.L1Config.NovusHundredGigLan.AutoInstrumentation = "endOfFrame" |
| 109 | + dataplane.set_config() |
| 110 | + restpy_session = dataplane.api.assistant.Session |
| 111 | + ixnet = restpy_session.Ixnetwork |
| 112 | + for port in ixnet.Vport.find(): |
| 113 | + port.L1Config.NovusHundredGigLan.AutoInstrumentation = "endOfFrame" |
108 | 114 |
|
109 |
| - ts = dataplane.api.transmit_state() |
110 |
| - ts.flow_names = [flow1.name] |
111 |
| - ts.state = ts.START |
112 |
| - dataplane.api.set_transmit_state(ts) |
113 |
| - time.sleep(10) |
114 |
| - ts = dataplane.api.transmit_state() |
115 |
| - ts.flow_names = [flow1.name] |
116 |
| - ts.state = ts.STOP |
117 |
| - dataplane.api.set_transmit_state(ts) |
118 |
| - time.sleep(10) |
119 |
| - request = dataplane.api.metrics_request() |
120 |
| - request.flow.flow_names = [flow1.name] |
121 |
| - rows = dataplane.api.get_metrics(request).flow_metrics |
122 |
| - print("Loss {}".format(rows[0].loss)) |
| 115 | + ts = dataplane.api.transmit_state() |
| 116 | + ts.flow_names = [flow1.name] |
| 117 | + ts.state = ts.START |
| 118 | + dataplane.api.set_transmit_state(ts) |
| 119 | + time.sleep(10) |
| 120 | + ts = dataplane.api.transmit_state() |
| 121 | + ts.flow_names = [flow1.name] |
| 122 | + ts.state = ts.STOP |
| 123 | + dataplane.api.set_transmit_state(ts) |
| 124 | + time.sleep(10) |
| 125 | + request = dataplane.api.metrics_request() |
| 126 | + request.flow.flow_names = [flow1.name] |
| 127 | + rows = dataplane.api.get_metrics(request).flow_metrics |
| 128 | + print("Loss {}".format(rows[0].loss)) |
123 | 129 |
|
124 |
| - req = dataplane.api.metrics_request() |
125 |
| - req.port.port_names = [p.name for p in config.ports] |
126 |
| - req.port.column_names = [req.port.FRAMES_TX, req.port.FRAMES_RX] |
127 |
| - # fetch port metrics |
128 |
| - res = dataplane.api.get_metrics(req) |
129 |
| - total_tx = sum([m.frames_tx for m in res.port_metrics]) |
130 |
| - total_rx = sum([m.frames_rx for m in res.port_metrics]) |
131 |
| - print("Tx_Frame : {}".format(total_tx)) |
132 |
| - print("Rx_Frame : {}".format(total_rx)) |
133 |
| - assert total_tx == total_rx, "Tx Frame not equal to Rx Frame" |
134 |
| - assert int(rows[0].loss) == 0, "Loss observed" |
135 |
| - assert total_tx > 0, "Tx Frame rate is Zero" |
| 130 | + req = dataplane.api.metrics_request() |
| 131 | + req.port.port_names = [p.name for p in config.ports] |
| 132 | + req.port.column_names = [req.port.FRAMES_TX, req.port.FRAMES_RX] |
| 133 | + # fetch port metrics |
| 134 | + res = dataplane.api.get_metrics(req) |
| 135 | + total_tx = sum([m.frames_tx for m in res.port_metrics]) |
| 136 | + total_rx = sum([m.frames_rx for m in res.port_metrics]) |
| 137 | + print("Tx_Frame : {}".format(total_tx)) |
| 138 | + print("Rx_Frame : {}".format(total_rx)) |
| 139 | + assert total_tx == total_rx, "Tx Frame not equal to Rx Frame" |
| 140 | + assert int(rows[0].loss) == 0, "Loss observed" |
| 141 | + assert total_tx > 0, "Tx Frame rate is Zero" |
136 | 142 |
|
137 | 143 | finally:
|
138 | 144 | results = [*npu.process_commands(commands, cleanup=True)]
|
|
0 commit comments