<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p><font face="Ubuntu">This will not have any negative affect on the
        way SRU testing operates.  I agree that it is annoying setup()
        will only get run once, unless you iterate the version +=1. It's
        also not apparent to someone unless they rummage through the
        autotest docs.<br>
      </font></p>
    <p><font face="Ubuntu">Unfortunately, not every test in our
        collection operate in the same manner, there are some that do
        not use a setup() but that is neither here nor there. I have
        also just modified the version if running through any sort of
        triage in the past. This is because the intended use case always
        runs once on a freshly deployed system.<br>
      </font></p>
    <p><font face="Ubuntu">This is good Krzysztof!   Will def help for
        those working on test improvements.<br>
      </font></p>
    <p><font face="Ubuntu">+1 from me. <br>
      </font></p>
    <p><font face="Ubuntu">-Sean<br>
      </font></p>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 6/3/21 9:21 AM, Krzysztof Kozlowski
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:20210603132118.40298-1-krzysztof.kozlowski@canonical.com">
      <pre class="moz-quote-pre" wrap="">The autotest had nice idea that test setup can be executed only once on
a machine, till test version does not change.  If version stays the
same, autotest will not run test setup on next executions.

However this requirement/feature was not defined clear enough and some
tests:
1. Perform cleanup() which reverts the setup() (e.g. ubuntu_boot).
2. Set runtime configuration (e.g. initialize object's field in Python
   __init__()) during setup() and read it on each test (e.g.
   ubuntu_sysdig_smoke_test).

All of these cases fail.  Fix this by calling the test setup() every
time.

Signed-off-by: Krzysztof Kozlowski <a class="moz-txt-link-rfc2396E" href="mailto:krzysztof.kozlowski@canonical.com"><krzysztof.kozlowski@canonical.com></a>
---
 client/shared/utils.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/client/shared/utils.py b/client/shared/utils.py
index 3e8c9448d23e..367edcd04a03 100644
--- a/client/shared/utils.py
+++ b/client/shared/utils.py
@@ -862,7 +862,11 @@ def update_version(srcdir, preserve_srcdir, new_version, install,
                                      os.path.basename(patch_src))
             shutil.copyfile(patch_src, patch_dst)
 
-        install(*args, **dargs)
+    # The test-specific setup is always needed because:
+    #  - it could have been reverted with cleanup()
+    #  - few broken tests might depend on setup() run always
+    install(*args, **dargs)
+    if install_needed:
         pickle.dump(new_version, open(versionfile, 'w'))
 
 
</pre>
    </blockquote>
  </body>
</html>