Skip to content

Commit c9d3550

Browse files
authored
[tests]: fix drops_group_test failure on second run (sonic-net#1023)
a few tests in drops_group_test fails on second run. The reason is that /tmp/dropstat is not cleaned, the first run leave some state in the folder which cause the subsequent run to fail. The fix is the always clean up the folder. Signed-off-by: Guohan Lu <[email protected]>
1 parent dfaae69 commit c9d3550

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

tests/drops_group_test.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import sys
21
import os
2+
import sys
3+
4+
import shutil
35
from click.testing import CliRunner
46

57
test_path = os.path.dirname(os.path.abspath(__file__))
@@ -8,7 +10,6 @@
810
sys.path.insert(0, test_path)
911
sys.path.insert(0, modules_path)
1012

11-
import mock_tables.dbconnector
1213
import show.main as show
1314
import clear.main as clear
1415

@@ -75,10 +76,14 @@
7576
sonic_drops_test 0
7677
"""
7778

79+
dropstat_path = "/tmp/dropstat"
80+
7881
class TestDropCounters(object):
7982
@classmethod
8083
def setup_class(cls):
8184
print("SETUP")
85+
if os.path.exists(dropstat_path):
86+
shutil.rmtree(dropstat_path)
8287
os.environ["PATH"] += os.pathsep + scripts_path
8388
os.environ["UTILITIES_UNIT_TESTING"] = "1"
8489

0 commit comments

Comments
 (0)