6
6
from collections import defaultdict
7
7
from unittest .mock import patch
8
8
9
- from generic_config_updater .services_validator import vlan_validator , rsyslog_validator , caclmgrd_validator
9
+ from generic_config_updater .services_validator import vlan_validator , rsyslog_validator , caclmgrd_validator , vlanintf_validator
10
10
import generic_config_updater .gu_common
11
11
12
12
@@ -152,6 +152,46 @@ def mock_time_sleep_call(sleep_time):
152
152
{ "cmd" : "systemctl restart rsyslog" , "rc" : 1 }, # restart again; fails
153
153
]
154
154
155
+ test_vlanintf_data = [
156
+ { "old" : {}, "upd" : {}, "cmd" : "" },
157
+ {
158
+ "old" : { "VLAN_INTERFACE" : {
159
+ "Vlan1000" : {},
160
+ "Vlan1000|192.168.0.1/21" : {} } },
161
+ "upd" : { "VLAN_INTERFACE" : {
162
+ "Vlan1000" : {},
163
+ "Vlan1000|192.168.0.1/21" : {} } },
164
+ "cmd" : ""
165
+ },
166
+ {
167
+ "old" : { "VLAN_INTERFACE" : {
168
+ "Vlan1000" : {},
169
+ "Vlan1000|192.168.0.1/21" : {} } },
170
+ "upd" : { "VLAN_INTERFACE" : {
171
+ "Vlan1000" : {},
172
+ "Vlan1000|192.168.0.2/21" : {} } },
173
+ "cmd" : "ip neigh flush dev Vlan1000 192.168.0.1/21"
174
+ },
175
+ {
176
+ "old" : { "VLAN_INTERFACE" : {
177
+ "Vlan1000" : {},
178
+ "Vlan1000|192.168.0.1/21" : {} } },
179
+ "upd" : { "VLAN_INTERFACE" : {
180
+ "Vlan1000" : {},
181
+ "Vlan1000|192.168.0.1/21" : {},
182
+ "Vlan1000|192.168.0.2/21" : {} } },
183
+ "cmd" : ""
184
+ },
185
+ {
186
+ "old" : { "VLAN_INTERFACE" : {
187
+ "Vlan1000" : {},
188
+ "Vlan1000|192.168.0.1/21" : {} } },
189
+ "upd" : {},
190
+ "cmd" : "ip neigh flush dev Vlan1000 192.168.0.1/21"
191
+ }
192
+ ]
193
+
194
+
155
195
class TestServiceValidator (unittest .TestCase ):
156
196
157
197
@patch ("generic_config_updater.change_applier.os.system" )
@@ -177,6 +217,15 @@ def test_change_apply_os_system(self, mock_os_sys):
177
217
rc = rsyslog_validator ("" , "" , "" )
178
218
assert not rc , "rsyslog_validator expected to fail"
179
219
220
+ os_system_calls = []
221
+ os_system_call_index = 0
222
+ for entry in test_vlanintf_data :
223
+ if entry ["cmd" ]:
224
+ os_system_calls .append ({"cmd" : entry ["cmd" ], "rc" : 0 })
225
+ msg = "case failed: {}" .format (str (entry ))
226
+
227
+ vlanintf_validator (entry ["old" ], entry ["upd" ], None )
228
+
180
229
@patch ("generic_config_updater.services_validator.time.sleep" )
181
230
def test_change_apply_time_sleep (self , mock_time_sleep ):
182
231
global time_sleep_calls , time_sleep_call_index
0 commit comments