|
| 1 | +import time |
| 2 | + |
1 | 3 | class TestSflow:
|
2 | 4 | speed_rate_table = {
|
3 | 5 | "400000": "400000",
|
@@ -131,6 +133,48 @@ def test_ConfigDel(self, dvs, testlog):
|
131 | 133 |
|
132 | 134 | expected_fields = {"SAI_SAMPLEPACKET_ATTR_SAMPLE_RATE": rate}
|
133 | 135 | self.adb.wait_for_field_match("ASIC_STATE:SAI_OBJECT_TYPE_SAMPLEPACKET", sample_session, expected_fields)
|
| 136 | + |
| 137 | + def test_SamplingRatePortCfgUpdate(self, dvs, testlog): |
| 138 | + ''' |
| 139 | + This test checks if the SflowMgr updates the sampling rate |
| 140 | + 1) When the Speed is Updated on the port and no local configuration has been given on the port |
| 141 | + Eg: |
| 142 | + config sflow enable |
| 143 | + config interface speed Ethernet0 25000 (Let's suppose Original Speed for Ethernet0 is 100G) |
| 144 | + show sflow interface | grep Ethernet0 (Should see a sampling rate of 25000 not 100000) |
| 145 | + ''' |
| 146 | + self.setup_sflow(dvs) |
| 147 | + appldb = dvs.get_app_db() |
| 148 | + #dvs.runcmd("portconfig -p {} -s {}".format("Ethernet0", "25000")) |
| 149 | + self.cdb.update_entry("PORT", "Ethernet0", {'speed' : "25000"}) |
| 150 | + expected_fields = {"sample_rate": self.speed_rate_table["25000"]} |
| 151 | + appldb.wait_for_field_match("SFLOW_SESSION_TABLE", "Ethernet0", expected_fields) |
| 152 | + |
| 153 | + |
| 154 | + def test_SamplingRateManualUpdate(self, dvs, testlog): |
| 155 | + ''' |
| 156 | + This test checks if the SflowMgr updates the sampling rate |
| 157 | + 1) When the Cfg Sflow Table is updated with sampling rate by the user, this rate should not be impacted by Port Speed Changes |
| 158 | + Eg: |
| 159 | + config sflow enable |
| 160 | + config sflow interface sample-rate Ethernet4 256 |
| 161 | + config interface Ethernet0 speed 25000 (Original Speed for Ethernet0 is 100G) |
| 162 | + show sflow interface | grep Ethernet0 (Should see a sampling rate of 256 not 100000 or 25000 |
| 163 | + ''' |
| 164 | + self.setup_sflow(dvs) |
| 165 | + appldb = dvs.get_app_db() |
| 166 | + |
| 167 | + session_params = {"admin_state": "up", "sample_rate": "256"} |
| 168 | + self.cdb.create_entry("SFLOW_SESSION", "Ethernet4", session_params) |
| 169 | + self.cdb.wait_for_field_match("SFLOW_SESSION", "Ethernet4", session_params) |
| 170 | + appldb.wait_for_field_match("SFLOW_SESSION_TABLE", "Ethernet4", {"sample_rate": "256"}) |
| 171 | + |
| 172 | + self.cdb.update_entry("PORT", "Ethernet4", {'speed' : "25000"}) |
| 173 | + # The Check here is about the original value not getting changed. |
| 174 | + # If some bug was to appear, let's give it some time to get noticed |
| 175 | + time.sleep(1) |
| 176 | + appldb.wait_for_field_match("SFLOW_SESSION_TABLE", "Ethernet4", {"sample_rate": "256"}) |
| 177 | + |
134 | 178 |
|
135 | 179 | def test_Teardown(self, dvs, testlog):
|
136 | 180 | self.setup_sflow(dvs)
|
|
0 commit comments