From c9d3550d9372541e3a58688b8e01a7ffe92071e3 Mon Sep 17 00:00:00 2001 From: lguohan Date: Mon, 3 Aug 2020 08:23:23 -0700 Subject: [PATCH] [tests]: fix drops_group_test failure on second run (#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 --- tests/drops_group_test.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/drops_group_test.py b/tests/drops_group_test.py index df3c6c4f9372..0076e7b47723 100644 --- a/tests/drops_group_test.py +++ b/tests/drops_group_test.py @@ -1,5 +1,7 @@ -import sys import os +import sys + +import shutil from click.testing import CliRunner test_path = os.path.dirname(os.path.abspath(__file__)) @@ -8,7 +10,6 @@ sys.path.insert(0, test_path) sys.path.insert(0, modules_path) -import mock_tables.dbconnector import show.main as show import clear.main as clear @@ -75,10 +76,14 @@ sonic_drops_test 0 """ +dropstat_path = "/tmp/dropstat" + class TestDropCounters(object): @classmethod def setup_class(cls): print("SETUP") + if os.path.exists(dropstat_path): + shutil.rmtree(dropstat_path) os.environ["PATH"] += os.pathsep + scripts_path os.environ["UTILITIES_UNIT_TESTING"] = "1"