|
| 1 | +import pytest |
1 | 2 | import time
|
2 | 3 | import re
|
3 | 4 | import json
|
|
6 | 7 | from swsscommon import swsscommon
|
7 | 8 |
|
8 | 9 |
|
| 10 | +@pytest.mark.usefixtures('dvs_lag_manager') |
9 | 11 | class TestPortchannel(object):
|
10 | 12 | def test_Portchannel(self, dvs, testlog):
|
11 | 13 |
|
@@ -90,51 +92,28 @@ def test_Portchannel(self, dvs, testlog):
|
90 | 92 | assert len(lagms) == 0
|
91 | 93 |
|
92 | 94 | def test_Portchannel_fast_rate(self, dvs, testlog):
|
93 |
| - portchannel_slow = ("PortChannel0003", "Ethernet16", 0) |
94 |
| - portchannel_fast = ("PortChannel0004", "Ethernet20", 0) |
95 |
| - |
96 |
| - self.cdb = swsscommon.DBConnector(4, dvs.redis_sock, 0) |
| 95 | + portchannels = [("0003", "Ethernet16", False), |
| 96 | + ("0004", "Ethernet20", True)] |
97 | 97 |
|
98 | 98 | # Create PortChannels
|
99 |
| - tbl = swsscommon.Table(self.cdb, "PORTCHANNEL") |
100 |
| - fvs_base = [("admin_status", "up"), ("mtu", "9100"), ("oper_status", "up"), ("lacp_key", "auto")] |
101 |
| - |
102 |
| - fvs_slow = swsscommon.FieldValuePairs(fvs_base + [("fast_rate", "false")]) |
103 |
| - tbl.set(portchannel_slow[0], fvs_slow) |
104 |
| - |
105 |
| - fvs_fast = swsscommon.FieldValuePairs(fvs_base + [("fast_rate", "true")]) |
106 |
| - tbl.set(portchannel_fast[0], fvs_fast) |
107 |
| - time.sleep(1) |
| 99 | + for portchannel in portchannels: |
| 100 | + self.dvs_lag.create_port_channel(portchannel[0], fast_rate=portchannel[2]) |
| 101 | + self.dvs_lag.get_and_verify_port_channel(len(portchannels)) |
108 | 102 |
|
109 | 103 | # Add members to PortChannels
|
110 |
| - tbl = swsscommon.Table(self.cdb, "PORTCHANNEL_MEMBER") |
111 |
| - fvs = swsscommon.FieldValuePairs([("NULL", "NULL")]) |
112 |
| - |
113 |
| - for portchannel in portchannel_slow, portchannel_fast: |
114 |
| - tbl.set(portchannel[0] + "|" + portchannel[1], fvs) |
115 |
| - time.sleep(1) |
| 104 | + for portchannel in portchannels: |
| 105 | + self.dvs_lag.create_port_channel_member(portchannel[0], portchannel[1]) |
| 106 | + self.dvs_lag.get_and_verify_port_channel_members(len(portchannels)) |
116 | 107 |
|
117 | 108 | # test fast rate was not set on portchannel_slow
|
118 |
| - output = dvs.runcmd("teamdctl {} state dump".format(portchannel_slow[0]))[1] |
119 |
| - port_state_dump = json.loads(output) |
120 |
| - assert not port_state_dump["runner"]["fast_rate"] |
121 |
| - |
122 |
| - # test fast rate was set on portchannel_fast |
123 |
| - output = dvs.runcmd("teamdctl {} state dump".format(portchannel_fast[0]))[1] |
124 |
| - port_state_dump = json.loads(output) |
125 |
| - assert port_state_dump["runner"]["fast_rate"] |
| 109 | + for portchannel in portchannels: |
| 110 | + self.dvs_lag.get_and_verify_port_channel_fast_rate(portchannel[0], portchannel[2]) |
126 | 111 |
|
127 | 112 | # remove PortChannel members
|
128 |
| - tbl = swsscommon.Table(self.cdb, "PORTCHANNEL_MEMBER") |
129 |
| - for portchannel in portchannel_slow, portchannel_fast: |
130 |
| - tbl._del(portchannel[0] + "|" + portchannel[1]) |
131 |
| - time.sleep(1) |
| 113 | + for portchannel in portchannels: |
| 114 | + self.dvs_lag.remove_port_channel(portchannel[0]) |
| 115 | + self.dvs_lag.get_and_verify_port_channel(0) |
132 | 116 |
|
133 |
| - # remove PortChannel |
134 |
| - tbl = swsscommon.Table(self.cdb, "PORTCHANNEL") |
135 |
| - for portchannel in portchannel_slow, portchannel_fast: |
136 |
| - tbl._del(portchannel[0]) |
137 |
| - time.sleep(1) |
138 | 117 |
|
139 | 118 | def test_Portchannel_lacpkey(self, dvs, testlog):
|
140 | 119 | portchannelNamesAuto = [("PortChannel001", "Ethernet0", 1001),
|
|
0 commit comments