diff mbox series

[ACT,1/4] UBUNTU: SAUCE: fix git clone failures and setups not being idempotent

Message ID 20210607111117.43251-1-krzysztof.kozlowski@canonical.com
State New
Headers show
Series [ACT,1/4] UBUNTU: SAUCE: fix git clone failures and setups not being idempotent | expand

Commit Message

Krzysztof Kozlowski June 7, 2021, 11:11 a.m. UTC
The tests and their setup should be idempotent.  They should not fail
(neither pass) because it is second run on a target.  The setup() should
prepare everything needed for the test assuming that some steps could be
already executed from previous runs.

Recent change in autotest caused setup() to be executed every time which
lead to 'git clone' failures in few tests executing setup multiple
times, for example ubuntu_performance_thermal:

    11:03:11 DEBUG| Running 'git clone git://kernel.ubuntu.com/cking/stress-ng'
    11:03:11 ERROR| [stderr] fatal: destination path 'stress-ng' already exists and is not an empty directory.
    11:03:11 ERROR| Exception escaping from test:
    Traceback (most recent call last):
      File "/home/ubuntu/autotest/client/shared/test.py", line 387, in _exec
        *p_args, **p_dargs)
      File "/home/ubuntu/autotest/client/shared/utils.py", line 868, in update_version
        install(*args, **dargs)
      File "/home/ubuntu/autotest/client/tests/ubuntu_performance_thermal/ubuntu_performance_thermal.py", line 96, in setup
        self.results = utils.system_output('git clone git://kernel.ubuntu.com/cking/stress-ng', retain_output=True)
      File "/home/ubuntu/autotest/client/shared/utils.py", line 1271, in system_output
        verbose=verbose, args=args).stdout
      File "/home/ubuntu/autotest/client/shared/utils.py", line 922, in run
        "Command returned non-zero exit status")
    CmdError: Command <git clone git://kernel.ubuntu.com/cking/stress-ng> failed, rc=128, Command returned non-zero exit status
    * Command:
        git clone git://kernel.ubuntu.com/cking/stress-ng

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 libhugetlbfs/libhugetlbfs.py                                    | 2 ++
 ubuntu_futex/ubuntu_futex.py                                    | 2 ++
 ubuntu_kvm_unit_tests/ubuntu_kvm_unit_tests.py                  | 2 ++
 ubuntu_ltp/ubuntu_ltp.py                                        | 2 ++
 ubuntu_ltp_stable/ubuntu_ltp_stable.py                          | 2 ++
 ubuntu_ltp_syscalls/ubuntu_ltp_syscalls.py                      | 2 ++
 ubuntu_performance_latency/ubuntu_performance_latency.py        | 2 ++
 ubuntu_performance_power/ubuntu_performance_power.py            | 2 ++
 ubuntu_performance_stress_ng/ubuntu_performance_stress_ng.py    | 2 ++
 ubuntu_performance_thermal/ubuntu_performance_thermal.py        | 2 ++
 ubuntu_qrt_apparmor/ubuntu_qrt_apparmor.py                      | 2 ++
 .../ubuntu_qrt_kernel_aslr_collisions.py                        | 2 ++
 ubuntu_qrt_kernel_hardening/ubuntu_qrt_kernel_hardening.py      | 2 ++
 ubuntu_qrt_kernel_panic/ubuntu_qrt_kernel_panic.py              | 2 ++
 ubuntu_qrt_kernel_security/ubuntu_qrt_kernel_security.py        | 2 ++
 ubuntu_ramfs_stress/ubuntu_ramfs_stress.py                      | 2 ++
 ubuntu_seccomp/ubuntu_seccomp.py                                | 2 ++
 ubuntu_stress_btrfs/ubuntu_stress_btrfs.py                      | 2 ++
 ubuntu_stress_btrfs_cmd/ubuntu_stress_btrfs_cmd.py              | 2 ++
 ubuntu_stress_smoke_test/ubuntu_stress_smoke_test.py            | 2 ++
 ubuntu_unionmount_ovlfs/ubuntu_unionmount_ovlfs.py              | 2 ++
 ubuntu_vfat_stress/ubuntu_vfat_stress.py                        | 2 ++
 ubuntu_xfstests_btrfs/ubuntu_xfstests_btrfs.py                  | 2 ++
 ubuntu_xfstests_ext4/ubuntu_xfstests_ext4.py                    | 2 ++
 ubuntu_xfstests_xfs/ubuntu_xfstests_xfs.py                      | 2 ++
 ubuntu_zfs_stress/ubuntu_zfs_stress.py                          | 2 ++
 ubuntu_zfs_xfs_generic/ubuntu_zfs_xfs_generic.py                | 2 ++
 xfstests/xfstests.py                                            | 2 ++
 28 files changed, 56 insertions(+)

Comments

Po-Hsu Lin June 7, 2021, 2:02 p.m. UTC | #1
I agree that the second run on the same SUT should not alter the test
result.

We don't have this failed-with-second-run issue before because we will
clean up the autotest directory by rsync'ing a clean tree from our
jenkins server no matter it's a freshly deployed system or a manually
provisioned one. The old autotest/client/tmp/<test-suite> directory
will be gone, the test will start fresh.

This is defintely an issue we need to deal with if we want to run tests
for multiple times manually on the same SUT (I just clean out the
aformentioned tmp directory manually).


As discussed on Mattermost, I think this fix is base on the assumption
that the change to autotest f6e444df45f45 ("UBUNTU: SAUCE: fix missing
setup on second run") is correct.

With a quick test on the ubuntu_ltp_syscalls test, this will make the
test clone the source and build it twice before running the actual
syscall tests from LTP. From this fact it looks like the setup() was
called twice with one execution.

On the other hand, this issue does not exist in libhugetlbfs test,
which will do a git clone for an external source as well, therefore
it doesn't look like a real fix to me.
Krzysztof Kozlowski June 8, 2021, 6:11 a.m. UTC | #2
On 07/06/2021 16:02, Po-Hsu Lin wrote:
> I agree that the second run on the same SUT should not alter the test
> result.
> 
> We don't have this failed-with-second-run issue before because we will
> clean up the autotest directory by rsync'ing a clean tree from our
> jenkins server no matter it's a freshly deployed system or a manually
> provisioned one. The old autotest/client/tmp/<test-suite> directory
> will be gone, the test will start fresh.
> 
> This is defintely an issue we need to deal with if we want to run tests
> for multiple times manually on the same SUT (I just clean out the
> aformentioned tmp directory manually).

I would expect that's regular process for autotest since they
implemented this setup() caching (being called only once).


> As discussed on Mattermost, I think this fix is base on the assumption
> that the change to autotest f6e444df45f45 ("UBUNTU: SAUCE: fix missing
> setup on second run") is correct.

Mentioned autotest change indeed looks wrong. However this does not make
this change here wrong, either.

Consider case when test version is bumped, while being executed for
second time. The setup() will be called and all git clones will fail.

Making setup() idempotent or resistent to existing stuff is good idea IMHO.

> 
> With a quick test on the ubuntu_ltp_syscalls test, this will make the
> test clone the source and build it twice before running the actual
> syscall tests from LTP. From this fact it looks like the setup() was
> called twice with one execution.
> 
> On the other hand, this issue does not exist in libhugetlbfs test,
> which will do a git clone for an external source as well, therefore
> it doesn't look like a real fix to me.



Best regards,
Krzysztof
Po-Hsu Lin June 8, 2021, 1:09 p.m. UTC | #3
On Tue, Jun 8, 2021 at 2:11 PM Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> wrote:
>
> On 07/06/2021 16:02, Po-Hsu Lin wrote:
> > I agree that the second run on the same SUT should not alter the test
> > result.
> >
> > We don't have this failed-with-second-run issue before because we will
> > clean up the autotest directory by rsync'ing a clean tree from our
> > jenkins server no matter it's a freshly deployed system or a manually
> > provisioned one. The old autotest/client/tmp/<test-suite> directory
> > will be gone, the test will start fresh.
> >
> > This is defintely an issue we need to deal with if we want to run tests
> > for multiple times manually on the same SUT (I just clean out the
> > aformentioned tmp directory manually).
>
> I would expect that's regular process for autotest since they
> implemented this setup() caching (being called only once).
>
>
> > As discussed on Mattermost, I think this fix is base on the assumption
> > that the change to autotest f6e444df45f45 ("UBUNTU: SAUCE: fix missing
> > setup on second run") is correct.
>
> Mentioned autotest change indeed looks wrong. However this does not make
> this change here wrong, either.
>
> Consider case when test version is bumped, while being executed for
> second time. The setup() will be called and all git clones will fail.
>
> Making setup() idempotent or resistent to existing stuff is good idea IMHO.

Indeed.
This is more likely a case that people run it manually on a long-running
instance with a long existing autotest directory (which we don't have in our
current setup for SRU, that's probably the reason why the version number for
tests in autotest-client-tests was untouched for a while), it's unusual but
not impossible.

I just found that we can use autotest/client/shared/git.py for git related
commands in our tests:
    from autotest.client.shared import git
    git.get_repo(REPO_LINK)

It will try to fetch the repo in /tmp or any other specified places, if the
repo exists it will do a hard reset and fetch again.

But since this has become rather trivial now, I think we can just give it a
go and iterate from this patch.

Acked-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
Applied and pushed.

Thanks
Sam
Sean Feole June 8, 2021, 2:54 p.m. UTC | #4
See inline below,

On Tue, Jun 8, 2021 at 2:12 AM Krzysztof Kozlowski <
krzysztof.kozlowski@canonical.com> wrote:

> On 07/06/2021 16:02, Po-Hsu Lin wrote:
> > I agree that the second run on the same SUT should not alter the test
> > result.
> >
> > We don't have this failed-with-second-run issue before because we will
> > clean up the autotest directory by rsync'ing a clean tree from our
> > jenkins server no matter it's a freshly deployed system or a manually
> > provisioned one. The old autotest/client/tmp/<test-suite> directory
> > will be gone, the test will start fresh.
> >
> > This is defintely an issue we need to deal with if we want to run tests
> > for multiple times manually on the same SUT (I just clean out the
> > aformentioned tmp directory manually).
>
> I would expect that's regular process for autotest since they
> implemented this setup() caching (being called only once).
>

+1 , Running the test setup() should always be step one. Even if the test
has already been run on the SUT. I feel that is the correct workflow, i
never like the autotest versioning scheme that required
the version to increment `foo+=1`

Autotest is old and EOL. it's no longer maintained, so for the time being
we gotta fix the pieces that do not work correctly.


>
>
> > As discussed on Mattermost, I think this fix is base on the assumption
> > that the change to autotest f6e444df45f45 ("UBUNTU: SAUCE: fix missing
> > setup on second run") is correct.
>
> Mentioned autotest change indeed looks wrong. However this does not make
> this change here wrong, either.
>
> Consider case when test version is bumped, while being executed for
> second time. The setup() will be called and all git clones will fail.
>
> Making setup() idempotent or resistent to existing stuff is good idea IMHO.
>

Moving forward imo, all tests should be written/updated with the intention
that we are not using autotest.

I know that sounds sort of confusing, I'm trying to convey that each of the
tests should be able to effectively and quickly accomplish their goal
without
any added helpers from the autotest client program. I know and well aware
that many of them are tightly intertwined with decorators and functions
that call on the autotest client.
But if the test is actually under review and going through some sort of
triage like Krzsztof has done, then we can take that time to fix this.

I believe each of the tests should indeed have a setup() that is
responsible for ensuring the SUT is correctly staged prior to running the
desired test. regardless of how many executions occur on the SUT

Sean



>
> >
> > With a quick test on the ubuntu_ltp_syscalls test, this will make the
> > test clone the source and build it twice before running the actual
> > syscall tests from LTP. From this fact it looks like the setup() was
> > called twice with one execution.
> >
> > On the other hand, this issue does not exist in libhugetlbfs test,
> > which will do a git clone for an external source as well, therefore
> > it doesn't look like a real fix to me.
>
>
>
> Best regards,
> Krzysztof
>
> --
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
>
diff mbox series

Patch

diff --git a/libhugetlbfs/libhugetlbfs.py b/libhugetlbfs/libhugetlbfs.py
index ced343e10268..6645042f21c3 100644
--- a/libhugetlbfs/libhugetlbfs.py
+++ b/libhugetlbfs/libhugetlbfs.py
@@ -1,6 +1,7 @@ 
 import re
 import os
 import platform
+import shutil
 from autotest.client import utils, test, os_dep
 from autotest.client.shared import error
 
@@ -60,6 +61,7 @@  class libhugetlbfs(test.test):
         self.job.require_gcc()
         # get the sources
         os.chdir(self.srcdir)
+        shutil.rmtree('libhugetlbfs', ignore_errors=True)
         cmd = 'git clone --depth=1 -b next https://github.com/libhugetlbfs/libhugetlbfs.git'
         self.results = utils.system_output(cmd, retain_output=True)
 
diff --git a/ubuntu_futex/ubuntu_futex.py b/ubuntu_futex/ubuntu_futex.py
index b83eabbe8857..00474c6c4e74 100644
--- a/ubuntu_futex/ubuntu_futex.py
+++ b/ubuntu_futex/ubuntu_futex.py
@@ -2,6 +2,7 @@ 
 #
 import os
 import platform
+import shutil
 from autotest.client                        import test, utils
 from autotest.client                        import canonical
 
@@ -39,6 +40,7 @@  class ubuntu_futex(test.test):
         canonical.setup_proxy()
 
         os.chdir(self.srcdir)
+        shutil.rmtree('futextest', ignore_errors=True)
         cmd = 'git clone --depth=1 https://git.kernel.org/pub/scm/linux/kernel/git/dvhart/futextest.git'
         self.results = utils.system_output(cmd, retain_output=True)
 
diff --git a/ubuntu_kvm_unit_tests/ubuntu_kvm_unit_tests.py b/ubuntu_kvm_unit_tests/ubuntu_kvm_unit_tests.py
index e28174ec276f..c6ddf63d0b5d 100644
--- a/ubuntu_kvm_unit_tests/ubuntu_kvm_unit_tests.py
+++ b/ubuntu_kvm_unit_tests/ubuntu_kvm_unit_tests.py
@@ -3,6 +3,7 @@  import os
 import sys
 import re
 import platform
+import shutil
 from autotest.client            import test, utils, os_dep
 from autotest.client.shared     import error
 from autotest.client            import canonical
@@ -38,6 +39,7 @@  class ubuntu_kvm_unit_tests(test.test):
         arch = platform.processor()
         opt = []
         os.chdir(self.srcdir)
+        shutil.rmtree('kvm-unit-tests', ignore_errors=True)
         cmd = 'git clone --depth=1 git://kernel.ubuntu.com/ubuntu/kvm-unit-tests/ -b disco'
         self.results = utils.system_output(cmd, retain_output=True)
         # Print test suite HEAD SHA1 commit id for future reference
diff --git a/ubuntu_ltp/ubuntu_ltp.py b/ubuntu_ltp/ubuntu_ltp.py
index e84a463e5288..91ac9649223b 100644
--- a/ubuntu_ltp/ubuntu_ltp.py
+++ b/ubuntu_ltp/ubuntu_ltp.py
@@ -4,6 +4,7 @@  import multiprocessing
 import os
 import platform
 import re
+import shutil
 import time
 from autotest.client                        import test, utils
 from autotest.client.shared     import error
@@ -63,6 +64,7 @@  class ubuntu_ltp(test.test):
         self.install_required_pkgs()
         self.job.require_gcc()
         os.chdir(self.srcdir)
+        shutil.rmtree('ltp', ignore_errors=True)
         cmd = 'git clone --depth=1 https://github.com/linux-test-project/ltp.git'
         self.results = utils.system_output(cmd, retain_output=True)
 
diff --git a/ubuntu_ltp_stable/ubuntu_ltp_stable.py b/ubuntu_ltp_stable/ubuntu_ltp_stable.py
index c2ce24e846fd..591cc70d2320 100644
--- a/ubuntu_ltp_stable/ubuntu_ltp_stable.py
+++ b/ubuntu_ltp_stable/ubuntu_ltp_stable.py
@@ -4,6 +4,7 @@  import multiprocessing
 import os
 import platform
 import re
+import shutil
 import time
 from autotest.client                        import test, utils
 from autotest.client.shared     import error
@@ -63,6 +64,7 @@  class ubuntu_ltp_stable(test.test):
         self.install_required_pkgs()
         self.job.require_gcc()
         os.chdir(self.srcdir)
+        shutil.rmtree('ltp', ignore_errors=True)
         cmd = 'git clone --depth=1 https://github.com/linux-test-project/ltp.git'
         self.results = utils.system_output(cmd, retain_output=True)
 
diff --git a/ubuntu_ltp_syscalls/ubuntu_ltp_syscalls.py b/ubuntu_ltp_syscalls/ubuntu_ltp_syscalls.py
index 176e1df7c8c5..c4c4450ec78f 100644
--- a/ubuntu_ltp_syscalls/ubuntu_ltp_syscalls.py
+++ b/ubuntu_ltp_syscalls/ubuntu_ltp_syscalls.py
@@ -6,6 +6,7 @@  import platform
 import re
 import sys
 import time
+import shutil
 import signal
 from autotest.client                        import test, utils
 from autotest.client.shared     import error
@@ -81,6 +82,7 @@  class ubuntu_ltp_syscalls(test.test):
         self.install_required_pkgs()
         self.job.require_gcc()
         os.chdir(self.srcdir)
+        shutil.rmtree('ltp', ignore_errors=True)
         cmd = 'git clone https://github.com/linux-test-project/ltp.git'
         self.results = utils.system_output(cmd, retain_output=True)
 
diff --git a/ubuntu_performance_latency/ubuntu_performance_latency.py b/ubuntu_performance_latency/ubuntu_performance_latency.py
index 4114eee6ae25..df8261a01ba3 100644
--- a/ubuntu_performance_latency/ubuntu_performance_latency.py
+++ b/ubuntu_performance_latency/ubuntu_performance_latency.py
@@ -5,6 +5,7 @@  from autotest.client                        import test, utils
 from math import sqrt
 import platform
 import time
+import shutil
 import subprocess
 import resource
 
@@ -108,6 +109,7 @@  class ubuntu_performance_latency(test.test):
         self.install_required_pkgs()
         self.job.require_gcc()
         os.chdir(self.srcdir)
+        shutil.rmtree('stress-ng', ignore_errors=True)
         self.results = utils.system_output('git clone git://kernel.ubuntu.com/cking/stress-ng', retain_output=True)
         os.chdir(os.path.join(self.srcdir, 'stress-ng'))
         self.results = utils.system_output('git checkout -b V0.09.56 V0.09.56', retain_output=True)
diff --git a/ubuntu_performance_power/ubuntu_performance_power.py b/ubuntu_performance_power/ubuntu_performance_power.py
index e8b91c50d6a7..5fda4eb3d056 100644
--- a/ubuntu_performance_power/ubuntu_performance_power.py
+++ b/ubuntu_performance_power/ubuntu_performance_power.py
@@ -5,6 +5,7 @@  from autotest.client                        import test, utils
 from math import sqrt
 import platform
 import time
+import shutil
 import subprocess
 import resource
 
@@ -95,6 +96,7 @@  class ubuntu_performance_power(test.test):
         self.install_required_pkgs()
         self.job.require_gcc()
         os.chdir(self.srcdir)
+        shutil.rmtree('stress-ng', ignore_errors=True)
         self.results = utils.system_output('git clone git://kernel.ubuntu.com/cking/stress-ng', retain_output=True)
         os.chdir(os.path.join(self.srcdir, 'stress-ng'))
         self.results = utils.system_output('git checkout -b V0.09.56 V0.09.56', retain_output=True)
diff --git a/ubuntu_performance_stress_ng/ubuntu_performance_stress_ng.py b/ubuntu_performance_stress_ng/ubuntu_performance_stress_ng.py
index 9b08a2d13dec..1026278c91ca 100644
--- a/ubuntu_performance_stress_ng/ubuntu_performance_stress_ng.py
+++ b/ubuntu_performance_stress_ng/ubuntu_performance_stress_ng.py
@@ -5,6 +5,7 @@  from autotest.client                        import test, utils
 from math import sqrt
 import platform
 import time
+import shutil
 import subprocess
 import resource
 
@@ -108,6 +109,7 @@  class ubuntu_performance_stress_ng(test.test):
         self.install_required_pkgs()
         self.job.require_gcc()
         os.chdir(self.srcdir)
+        shutil.rmtree('stress-ng', ignore_errors=True)
         self.results = utils.system_output('git clone git://kernel.ubuntu.com/cking/stress-ng', retain_output=True)
         os.chdir(os.path.join(self.srcdir, 'stress-ng'))
         self.results = utils.system_output('git checkout -b V0.09.56 V0.09.56', retain_output=True)
diff --git a/ubuntu_performance_thermal/ubuntu_performance_thermal.py b/ubuntu_performance_thermal/ubuntu_performance_thermal.py
index 15f470fc5232..ec051d8ba96f 100644
--- a/ubuntu_performance_thermal/ubuntu_performance_thermal.py
+++ b/ubuntu_performance_thermal/ubuntu_performance_thermal.py
@@ -4,6 +4,7 @@  import os
 from autotest.client                        import test, utils
 from math import sqrt
 import platform
+import shutil
 import subprocess
 import resource
 
@@ -93,6 +94,7 @@  class ubuntu_performance_thermal(test.test):
         self.install_required_pkgs()
         self.job.require_gcc()
         os.chdir(self.srcdir)
+        shutil.rmtree('stress-ng', ignore_errors=True)
         self.results = utils.system_output('git clone git://kernel.ubuntu.com/cking/stress-ng', retain_output=True)
         os.chdir(os.path.join(self.srcdir, 'stress-ng'))
         self.results = utils.system_output('git checkout -b V0.09.56 V0.09.56', retain_output=True)
diff --git a/ubuntu_qrt_apparmor/ubuntu_qrt_apparmor.py b/ubuntu_qrt_apparmor/ubuntu_qrt_apparmor.py
index 45aae648109b..cd331832c2b9 100644
--- a/ubuntu_qrt_apparmor/ubuntu_qrt_apparmor.py
+++ b/ubuntu_qrt_apparmor/ubuntu_qrt_apparmor.py
@@ -1,5 +1,6 @@ 
 import os
 import platform
+import shutil
 import time
 from autotest.client import test, utils
 
@@ -75,6 +76,7 @@  class ubuntu_qrt_apparmor(test.test):
         self.install_required_pkgs()
 
         os.chdir(self.srcdir)
+        shutil.rmtree('qa-regression-testing', ignore_errors=True)
         cmd = 'git clone --depth 1 https://git.launchpad.net/qa-regression-testing'
         self.results = utils.system_output(cmd, retain_output=True)
         # Print test suite HEAD SHA1 commit id for future reference
diff --git a/ubuntu_qrt_kernel_aslr_collisions/ubuntu_qrt_kernel_aslr_collisions.py b/ubuntu_qrt_kernel_aslr_collisions/ubuntu_qrt_kernel_aslr_collisions.py
index 3651afe769cc..8cf6fbc56257 100644
--- a/ubuntu_qrt_kernel_aslr_collisions/ubuntu_qrt_kernel_aslr_collisions.py
+++ b/ubuntu_qrt_kernel_aslr_collisions/ubuntu_qrt_kernel_aslr_collisions.py
@@ -1,5 +1,6 @@ 
 import os
 import platform
+import shutil
 from autotest.client import test, utils
 from autotest.client.shared import software_manager
 import platform
@@ -31,6 +32,7 @@  class ubuntu_qrt_kernel_aslr_collisions(test.test):
         self.install_required_pkgs()
         self.job.require_gcc()
         os.chdir(self.srcdir)
+        shutil.rmtree('qa-regression-testing', ignore_errors=True)
         cmd = 'git clone --depth 1 https://git.launchpad.net/qa-regression-testing'
         self.results = utils.system_output(cmd, retain_output=True)
         # Print test suite HEAD SHA1 commit id for future reference
diff --git a/ubuntu_qrt_kernel_hardening/ubuntu_qrt_kernel_hardening.py b/ubuntu_qrt_kernel_hardening/ubuntu_qrt_kernel_hardening.py
index 0ece9802865a..26e837b9d0bf 100644
--- a/ubuntu_qrt_kernel_hardening/ubuntu_qrt_kernel_hardening.py
+++ b/ubuntu_qrt_kernel_hardening/ubuntu_qrt_kernel_hardening.py
@@ -1,5 +1,6 @@ 
 import os
 import platform
+import shutil
 from autotest.client import test, utils
 
 class ubuntu_qrt_kernel_hardening(test.test):
@@ -26,6 +27,7 @@  class ubuntu_qrt_kernel_hardening(test.test):
     def setup(self):
         self.install_required_pkgs()
         os.chdir(self.srcdir)
+        shutil.rmtree('qa-regression-testing', ignore_errors=True)
         cmd = 'git clone --depth 1 https://git.launchpad.net/qa-regression-testing'
         self.results = utils.system_output(cmd, retain_output=True)
         # Print test suite HEAD SHA1 commit id for future reference
diff --git a/ubuntu_qrt_kernel_panic/ubuntu_qrt_kernel_panic.py b/ubuntu_qrt_kernel_panic/ubuntu_qrt_kernel_panic.py
index 115a55e86566..73a31f942710 100644
--- a/ubuntu_qrt_kernel_panic/ubuntu_qrt_kernel_panic.py
+++ b/ubuntu_qrt_kernel_panic/ubuntu_qrt_kernel_panic.py
@@ -1,6 +1,7 @@ 
 import os
 from autotest.client import test, utils
 import platform
+import shutil
 
 class ubuntu_qrt_kernel_panic(test.test):
     version = 1
@@ -37,6 +38,7 @@  class ubuntu_qrt_kernel_panic(test.test):
         self.install_required_pkgs()
         self.job.require_gcc()
         os.chdir(self.srcdir)
+        shutil.rmtree('qa-regression-testing', ignore_errors=True)
         cmd = 'git clone --depth 1 https://git.launchpad.net/qa-regression-testing'
         self.results = utils.system_output(cmd, retain_output=True)
         # Print test suite HEAD SHA1 commit id for future reference
diff --git a/ubuntu_qrt_kernel_security/ubuntu_qrt_kernel_security.py b/ubuntu_qrt_kernel_security/ubuntu_qrt_kernel_security.py
index ebfc4cc34096..76a77952b083 100644
--- a/ubuntu_qrt_kernel_security/ubuntu_qrt_kernel_security.py
+++ b/ubuntu_qrt_kernel_security/ubuntu_qrt_kernel_security.py
@@ -1,5 +1,6 @@ 
 import os
 import platform
+import shutil
 from autotest.client import test, utils
 
 class ubuntu_qrt_kernel_security(test.test):
@@ -29,6 +30,7 @@  class ubuntu_qrt_kernel_security(test.test):
         self.install_required_pkgs()
         self.job.require_gcc()
         os.chdir(self.srcdir)
+        shutil.rmtree('qa-regression-testing', ignore_errors=True)
         cmd = 'GIT_CURL_VERBOSE=1 GIT_TRACE=1 git clone --depth 1 https://git.launchpad.net/qa-regression-testing'
         self.results = utils.system_output(cmd, retain_output=True)
         # Print test suite HEAD SHA1 commit id for future reference
diff --git a/ubuntu_ramfs_stress/ubuntu_ramfs_stress.py b/ubuntu_ramfs_stress/ubuntu_ramfs_stress.py
index 5abb721f888f..42361eb3240d 100644
--- a/ubuntu_ramfs_stress/ubuntu_ramfs_stress.py
+++ b/ubuntu_ramfs_stress/ubuntu_ramfs_stress.py
@@ -3,6 +3,7 @@ 
 import multiprocessing
 import os
 import platform
+import shutil
 from autotest.client                        import test, utils
 
 class ubuntu_ramfs_stress(test.test):
@@ -46,6 +47,7 @@  class ubuntu_ramfs_stress(test.test):
 
         utils.system('cp %s/ubuntu_ramfs_stress.sh %s' % (self.bindir, self.srcdir))
         os.chdir(self.srcdir)
+        shutil.rmtree('stress-ng', ignore_errors=True)
         cmd = 'git clone --depth=1 git://kernel.ubuntu.com/cking/stress-ng 2>&1'
         self.results = utils.system_output(cmd, retain_output=True)
 
diff --git a/ubuntu_seccomp/ubuntu_seccomp.py b/ubuntu_seccomp/ubuntu_seccomp.py
index 6b15dbcf2963..5c7b59dc3425 100644
--- a/ubuntu_seccomp/ubuntu_seccomp.py
+++ b/ubuntu_seccomp/ubuntu_seccomp.py
@@ -2,6 +2,7 @@ 
 #
 import os
 import platform
+import shutil
 from autotest.client                        import test, utils
 
 class ubuntu_seccomp(test.test):
@@ -35,6 +36,7 @@  class ubuntu_seccomp(test.test):
         self.install_required_pkgs()
         self.job.require_gcc()
         os.chdir(self.srcdir)
+        shutil.rmtree('libseccomp', ignore_errors=True)
         cmd = 'git clone --depth=1 https://github.com/seccomp/libseccomp.git'
         self.results = utils.system_output(cmd, retain_output=True)
 
diff --git a/ubuntu_stress_btrfs/ubuntu_stress_btrfs.py b/ubuntu_stress_btrfs/ubuntu_stress_btrfs.py
index 4f98964ed0d9..c5bd8bdf9550 100644
--- a/ubuntu_stress_btrfs/ubuntu_stress_btrfs.py
+++ b/ubuntu_stress_btrfs/ubuntu_stress_btrfs.py
@@ -3,6 +3,7 @@ 
 import multiprocessing
 import os
 import platform
+import shutil
 from autotest.client                        import test, utils
 
 class ubuntu_stress_btrfs(test.test):
@@ -45,6 +46,7 @@  class ubuntu_stress_btrfs(test.test):
         self.job.require_gcc()
         utils.system('cp %s/ubuntu_stress_btrfs.sh %s' % (self.bindir, self.srcdir))
         os.chdir(self.srcdir)
+        shutil.rmtree('stress-ng', ignore_errors=True)
         cmd = 'git clone --depth=1 git://kernel.ubuntu.com/cking/stress-ng 2>&1'
         self.results = utils.system_output(cmd, retain_output=True)
 
diff --git a/ubuntu_stress_btrfs_cmd/ubuntu_stress_btrfs_cmd.py b/ubuntu_stress_btrfs_cmd/ubuntu_stress_btrfs_cmd.py
index cdcc71036722..61eabb270ec3 100644
--- a/ubuntu_stress_btrfs_cmd/ubuntu_stress_btrfs_cmd.py
+++ b/ubuntu_stress_btrfs_cmd/ubuntu_stress_btrfs_cmd.py
@@ -3,6 +3,7 @@ 
 import multiprocessing
 import os
 import platform
+import shutil
 from autotest.client                        import test, utils
 
 class ubuntu_stress_btrfs_cmd(test.test):
@@ -46,6 +47,7 @@  class ubuntu_stress_btrfs_cmd(test.test):
 
         utils.system('cp %s/ubuntu_stress_btrfs_cmd.sh %s' % (self.bindir, self.srcdir))
         os.chdir(self.srcdir)
+        shutil.rmtree('stress-ng', ignore_errors=True)
         cmd = 'git clone --depth=1 git://kernel.ubuntu.com/cking/stress-ng 2>&1'
         self.results = utils.system_output(cmd, retain_output=True)
 
diff --git a/ubuntu_stress_smoke_test/ubuntu_stress_smoke_test.py b/ubuntu_stress_smoke_test/ubuntu_stress_smoke_test.py
index 67fd52720aac..a250b50a3a45 100644
--- a/ubuntu_stress_smoke_test/ubuntu_stress_smoke_test.py
+++ b/ubuntu_stress_smoke_test/ubuntu_stress_smoke_test.py
@@ -4,6 +4,7 @@  import multiprocessing
 import os
 from autotest.client                        import test, utils
 import platform
+import shutil
 
 class ubuntu_stress_smoke_test(test.test):
     version = 1
@@ -49,6 +50,7 @@  class ubuntu_stress_smoke_test(test.test):
         self.install_required_pkgs()
         self.job.require_gcc()
         os.chdir(self.srcdir)
+        shutil.rmtree('stress-ng', ignore_errors=True)
         cmd = 'git clone --depth=1 git://kernel.ubuntu.com/cking/stress-ng'
         self.results = utils.system_output(cmd, retain_output=True)
 
diff --git a/ubuntu_unionmount_ovlfs/ubuntu_unionmount_ovlfs.py b/ubuntu_unionmount_ovlfs/ubuntu_unionmount_ovlfs.py
index f38059e97481..6432c543b9c0 100644
--- a/ubuntu_unionmount_ovlfs/ubuntu_unionmount_ovlfs.py
+++ b/ubuntu_unionmount_ovlfs/ubuntu_unionmount_ovlfs.py
@@ -1,6 +1,7 @@ 
 #
 #
 import os
+import shutil
 from autotest.client                        import test, utils
 
 class ubuntu_unionmount_ovlfs(test.test):
@@ -27,6 +28,7 @@  class ubuntu_unionmount_ovlfs(test.test):
     def setup(self):
         self.install_required_pkgs()
         os.chdir(self.srcdir)
+        shutil.rmtree('unionmount-testsuite', ignore_errors=True)
         cmd = 'git clone --depth=1 https://github.com/amir73il/unionmount-testsuite.git'
         self.results = utils.system_output(cmd, retain_output=True)
         # Print test suite HEAD SHA1 commit id for future reference
diff --git a/ubuntu_vfat_stress/ubuntu_vfat_stress.py b/ubuntu_vfat_stress/ubuntu_vfat_stress.py
index 495cf516abdd..2ee7250523d5 100644
--- a/ubuntu_vfat_stress/ubuntu_vfat_stress.py
+++ b/ubuntu_vfat_stress/ubuntu_vfat_stress.py
@@ -3,6 +3,7 @@ 
 import multiprocessing
 import os
 import platform
+import shutil
 from autotest.client                        import test, utils
 
 class ubuntu_vfat_stress(test.test):
@@ -46,6 +47,7 @@  class ubuntu_vfat_stress(test.test):
 
         utils.system('cp %s/ubuntu_vfat_stress.sh %s' % (self.bindir, self.srcdir))
         os.chdir(self.srcdir)
+        shutil.rmtree('stress-ng', ignore_errors=True)
         cmd = 'git clone --depth=1 git://kernel.ubuntu.com/cking/stress-ng 2>&1'
         self.results = utils.system_output(cmd, retain_output=True)
 
diff --git a/ubuntu_xfstests_btrfs/ubuntu_xfstests_btrfs.py b/ubuntu_xfstests_btrfs/ubuntu_xfstests_btrfs.py
index a01457139230..ee5937ff07fc 100644
--- a/ubuntu_xfstests_btrfs/ubuntu_xfstests_btrfs.py
+++ b/ubuntu_xfstests_btrfs/ubuntu_xfstests_btrfs.py
@@ -1,6 +1,7 @@ 
 import multiprocessing
 import os, re, glob, logging
 import platform
+import shutil
 from autotest.client.shared import error
 from autotest.client import test, utils, os_dep
 from autotest.client import canonical
@@ -173,6 +174,7 @@  class ubuntu_xfstests_btrfs(test.test):
 
         print("Fetching xfstests..")
         os.chdir(self.srcdir)
+        shutil.rmtree('xfstests-bld', ignore_errors=True)
         utils.system('git clone https://github.com/tytso/xfstests-bld')
         os.chdir(os.path.join(self.srcdir, 'xfstests-bld'))
         commit_bld = 'a4df7d7b31125901cb1fe9b092f495b6aa950448'
diff --git a/ubuntu_xfstests_ext4/ubuntu_xfstests_ext4.py b/ubuntu_xfstests_ext4/ubuntu_xfstests_ext4.py
index fd2a052999c7..2df880bb685d 100644
--- a/ubuntu_xfstests_ext4/ubuntu_xfstests_ext4.py
+++ b/ubuntu_xfstests_ext4/ubuntu_xfstests_ext4.py
@@ -1,6 +1,7 @@ 
 import multiprocessing
 import os, re, glob, logging
 import platform
+import shutil
 from autotest.client.shared import error
 from autotest.client import test, utils, os_dep
 from autotest.client import canonical
@@ -175,6 +176,7 @@  class ubuntu_xfstests_ext4(test.test):
 
         print("Fetching xfstests..")
         os.chdir(self.srcdir)
+        shutil.rmtree('xfstests-bld', ignore_errors=True)
         utils.system('git clone https://github.com/tytso/xfstests-bld')
         os.chdir(os.path.join(self.srcdir, 'xfstests-bld'))
         commit_bld = 'a4df7d7b31125901cb1fe9b092f495b6aa950448'
diff --git a/ubuntu_xfstests_xfs/ubuntu_xfstests_xfs.py b/ubuntu_xfstests_xfs/ubuntu_xfstests_xfs.py
index c68ffeee5050..7e0d9a035e71 100644
--- a/ubuntu_xfstests_xfs/ubuntu_xfstests_xfs.py
+++ b/ubuntu_xfstests_xfs/ubuntu_xfstests_xfs.py
@@ -1,6 +1,7 @@ 
 import multiprocessing
 import os, re, glob, logging
 import platform
+import shutil
 from autotest.client.shared import error
 from autotest.client import test, utils, os_dep
 from autotest.client import canonical
@@ -173,6 +174,7 @@  class ubuntu_xfstests_xfs(test.test):
 
         print("Fetching xfstests..")
         os.chdir(self.srcdir)
+        shutil.rmtree('xfstests-bld', ignore_errors=True)
         utils.system('git clone https://github.com/tytso/xfstests-bld')
         os.chdir(os.path.join(self.srcdir, 'xfstests-bld'))
         commit_bld = 'a4df7d7b31125901cb1fe9b092f495b6aa950448'
diff --git a/ubuntu_zfs_stress/ubuntu_zfs_stress.py b/ubuntu_zfs_stress/ubuntu_zfs_stress.py
index 070bab19250f..ceb81c04759c 100644
--- a/ubuntu_zfs_stress/ubuntu_zfs_stress.py
+++ b/ubuntu_zfs_stress/ubuntu_zfs_stress.py
@@ -3,6 +3,7 @@ 
 import multiprocessing
 import os
 import platform
+import shutil
 from autotest.client                        import test, utils
 
 class ubuntu_zfs_stress(test.test):
@@ -43,6 +44,7 @@  class ubuntu_zfs_stress(test.test):
 
         utils.system('cp %s/ubuntu_zfs_stress.sh %s' % (self.bindir, self.srcdir))
         os.chdir(self.srcdir)
+        shutil.rmtree('stress-ng', ignore_errors=True)
         cmd = 'git clone --depth=1 git://kernel.ubuntu.com/cking/stress-ng 2>&1'
         self.results = utils.system_output(cmd, retain_output=True)
 
diff --git a/ubuntu_zfs_xfs_generic/ubuntu_zfs_xfs_generic.py b/ubuntu_zfs_xfs_generic/ubuntu_zfs_xfs_generic.py
index be14294c4a51..0ad76e6802fc 100644
--- a/ubuntu_zfs_xfs_generic/ubuntu_zfs_xfs_generic.py
+++ b/ubuntu_zfs_xfs_generic/ubuntu_zfs_xfs_generic.py
@@ -2,6 +2,7 @@ 
 #
 import os
 import platform
+import shutil
 from autotest.client                        import test, utils
 import platform
 from autotest.client                        import canonical
@@ -78,6 +79,7 @@  class ubuntu_zfs_xfs_generic(test.test):
 
         print("Fetching xfstests..")
         os.chdir(self.srcdir)
+        shutil.rmtree('xfstests-bld', ignore_errors=True)
         utils.system('git clone https://github.com/tytso/xfstests-bld')
 
         os.chdir(os.path.join(self.srcdir, 'xfstests-bld'))
diff --git a/xfstests/xfstests.py b/xfstests/xfstests.py
index 740edc2656ab..5b39f40b66f0 100644
--- a/xfstests/xfstests.py
+++ b/xfstests/xfstests.py
@@ -1,6 +1,7 @@ 
 import multiprocessing
 import os, re, glob, logging
 import platform
+import shutil
 from autotest.client.shared import error
 from autotest.client import test, utils, os_dep
 from autotest.client import canonical
@@ -168,6 +169,7 @@  class xfstests(test.test):
 
         print("Fetching xfstests..")
         os.chdir(self.srcdir)
+        shutil.rmtree('xfstests-bld', ignore_errors=True)
         utils.system('git clone https://github.com/tytso/xfstests-bld')
         os.chdir(os.path.join(self.srcdir, 'xfstests-bld'))
         print("Using head commit d6e3c3559cf05b5ef078f91a97e9639c3688ead0")