11import os
22import glob
33import shutil
4+ from pathlib import Path
45import sys
56from subprocess import check_output , check_call , CalledProcessError , STDOUT
67import time
@@ -193,13 +194,23 @@ def vagrant_setup():
193194 vagrant_down ()
194195
195196
196- def git_del_dir (folder ):
197- '''Del git dir'''
198- if os .path .isdir (folder ):
197+ def git_rm_old_files (namespace ):
198+ '''Del old files from namespace'''
199+ nsdirs = Path ('tests/data/parquet/' ).glob (f'**/namespace={ namespace } ' )
200+ for folder in nsdirs :
199201 try :
200- check_call (['git' , 'rm' , '-rf' , folder ])
202+ check_call (['git' , 'rm' , '-rf' , str ( folder ) ])
201203 except CalledProcessError :
202- shutil .rmtree (folder )
204+ shutil .rmtree (str (folder ))
205+
206+
207+ def git_rm_input_dir (dstdir ):
208+ '''Delete the input dir provided'''
209+ if os .path .isdir (dstdir ):
210+ try :
211+ check_call (['git' , 'rm' , '-rf' , dstdir ])
212+ except CalledProcessError :
213+ shutil .rmtree (dstdir )
203214
204215
205216def update_sqcmds (files , data_dir = None , namespace = None ):
@@ -219,7 +230,7 @@ def update_sqcmds(files, data_dir=None, namespace=None):
219230def update_input_data (root_dir , nos , scenario , input_path ):
220231 '''Update collected raw data used for tests'''
221232 dst_dir = f'{ root_dir } /tests/integration/sqcmds/{ nos } -input/{ scenario } /'
222- git_del_dir (dst_dir )
233+ git_rm_input_dir (dst_dir )
223234 copytree (f'{ input_path } /suzieq-input' , dst_dir )
224235
225236
@@ -275,20 +286,22 @@ def test_update_cumulus_multidc_data(self, tmp_path):
275286 orig_dir , tmp_path )
276287
277288 dst_dir = f'{ orig_dir } /tests/data/parquet'
278- git_del_dir (dst_dir )
279- copytree (f'{ tmp_path } /parquet-out' , dst_dir )
280- shutil .rmtree (f'{ tmp_path } /parquet-out' )
289+ git_rm_old_files ('ospf-ibgp' )
290+ git_rm_old_files ('dual-evpn' )
291+ git_rm_old_files ('ospf-single' )
292+ copytree (f'{ tmp_path } /parquet' , dst_dir )
293+ shutil .rmtree (f'{ tmp_path } /parquet' )
281294
282295 update_data (
283296 'dual-bgp' ,
284297 f'{ orig_dir } /tests/integration/sqcmds/cumulus-input/dual-bgp' ,
285298 orig_dir , tmp_path )
286299
287300 dst_dir = f'{ orig_dir } /tests/data/parquet'
288- git_del_dir ( dst_dir )
301+ git_rm_old_files ( 'dual-bgp' )
289302
290- copytree (f'{ tmp_path } /parquet-out ' , dst_dir )
291- shutil .rmtree (f'{ tmp_path } /parquet-out ' )
303+ copytree (f'{ tmp_path } /parquet' , dst_dir )
304+ shutil .rmtree (f'{ tmp_path } /parquet' )
292305
293306 # update the samples data with updates from the newly collected data
294307
@@ -303,9 +316,9 @@ def _update_test_data_common_fn(self, nos, tmp_path, device_cnt):
303316 orig_dir , tmp_path , number_of_devices = device_cnt )
304317
305318 dst_dir = f'{ orig_dir } /tests/data/parquet'
306- git_del_dir ( dst_dir )
307- copytree (f'{ tmp_path } /parquet-out ' , dst_dir )
308- shutil .rmtree (f'{ tmp_path } /parquet-out ' )
319+ git_rm_old_files ( nos )
320+ copytree (f'{ tmp_path } /parquet' , dst_dir )
321+ shutil .rmtree (f'{ tmp_path } /parquet' )
309322
310323 # update the samples data with updates from the newly collected data
311324
@@ -357,6 +370,15 @@ def test_update_vmx_data(self, tmp_path):
357370 '''Update test data for VMX'''
358371 self ._update_test_data_common_fn ('vmx' , tmp_path , '5' )
359372
373+ @pytest .mark .test_update
374+ @pytest .mark .update_data
375+ @pytest .mark .broken
376+ @pytest .mark .skipif (not os .environ .get ('SUZIEQ_POLLER' , None ),
377+ reason = 'Not updating data' )
378+ def test_update_broken_data (self , tmp_path ):
379+ '''Update test data for mixed sim, from Rick'''
380+ self ._update_test_data_common_fn ('broken' , tmp_path , '14' )
381+
360382
361383tests = [
362384 ['bgp' , 'numbered' ],
@@ -421,7 +443,7 @@ def _gather_cndcn_data(topology, proto, scenario, input_path):
421443 os .chdir (path + '/topologies' )
422444 dst_dir = f'{ orig_dir } /tests/integration/all_cndcn/{ name } -input'
423445 gather_data (topology , proto , scenario , name , orig_dir , input_path )
424- git_del_dir (dst_dir )
446+ git_rm_input_dir (dst_dir )
425447 copytree (f'{ input_path } /suzieq-input' , dst_dir )
426448 os .chdir (orig_dir )
427449
@@ -440,19 +462,19 @@ def _update_cndcn_data(topology, proto, scenario, tmp_path):
440462 if not os .path .isdir (f'{ parquet_dir } /{ name } ' ):
441463 os .mkdir (f'{ parquet_dir } /{ name } ' )
442464
443- copytree (f"{ tmp_path } /parquet-out " ,
444- f"{ parquet_dir } /{ name } /parquet-out /" )
465+ copytree (f"{ tmp_path } /parquet" ,
466+ f"{ parquet_dir } /{ name } /parquet/" )
445467
446468 if os .environ .get ('UPDATE_SQCMDS' , None ):
447469 update_sqcmds (glob .glob (f'{ cndcn_samples_dir } /{ name } -samples/*.yml' ),
448- data_dir = f"{ parquet_dir } /{ name } /parquet-out " ,
470+ data_dir = f"{ parquet_dir } /{ name } /parquet" ,
449471 namespace = name )
450472
451473
452474def _test_data (topology , proto , scenario , testvar ):
453475 # pylint: disable=redefined-outer-name
454476 name = f'{ topology } _{ proto } _{ scenario } '
455- testvar ['data-directory' ] = f"{ parquet_dir } /{ name } /parquet-out "
477+ testvar ['data-directory' ] = f"{ parquet_dir } /{ name } /parquet"
456478 dummy_config = load_sq_config (
457479 config_file = conftest .create_dummy_config_file ())
458480 _test_sqcmds (dummy_config , testvar )
0 commit comments