30
30
sys .path .insert (0 , modules_path )
31
31
sys .path .insert (0 , test_path )
32
32
import mock_tables .dbconnector
33
- socket .gethostname = lambda : 'sonic_drops_test'
33
+ socket .gethostname = lambda : 'sonic_drops_test'
34
+ os .getuid = lambda : 27
34
35
except KeyError :
35
36
pass
36
37
@@ -75,8 +76,10 @@ std_port_headers_map = {
75
76
# Standard Switch-Level Headers
76
77
std_switch_description_header = ['DEVICE' ]
77
78
78
- # Bookkeeping Files
79
- dropstat_dir = '/tmp/dropstat/'
79
+
80
+ def get_dropstat_dir ():
81
+ dropstat_dir_prefix = '/tmp/dropstat'
82
+ return "{}-{}/" .format (dropstat_dir_prefix , os .getuid ())
80
83
81
84
82
85
class DropStat (object ):
@@ -89,8 +92,9 @@ class DropStat(object):
89
92
self .db .connect (self .db .ASIC_DB )
90
93
self .db .connect (self .db .APPL_DB )
91
94
92
- self .port_drop_stats_file = os .path .join (dropstat_dir , 'port-stats-{}' .format (os .getuid ()))
93
- self .switch_drop_stats_file = os .path .join (dropstat_dir + 'switch-stats-{}' .format (os .getuid ()))
95
+ dropstat_dir = get_dropstat_dir ()
96
+ self .port_drop_stats_file = os .path .join (dropstat_dir , 'port-stats' )
97
+ self .switch_drop_stats_file = os .path .join (dropstat_dir + 'switch-stats' )
94
98
95
99
self .stat_lookup = {}
96
100
self .reverse_stat_lookup = {}
@@ -405,6 +409,8 @@ Examples:
405
409
group = args .group
406
410
counter_type = args .type
407
411
412
+ dropstat_dir = get_dropstat_dir ()
413
+
408
414
# Create the directory to hold clear results
409
415
if not os .path .exists (dropstat_dir ):
410
416
try :
@@ -422,5 +428,6 @@ Examples:
422
428
else :
423
429
print ("Command not recognized" )
424
430
431
+
425
432
if __name__ == '__main__' :
426
433
main ()
0 commit comments