1. 24 2月, 2016 1 次提交
    • L
      avocado: Change logging initialization · 83a50b5f
      Lukáš Doktor 提交于
      This patch changes the way logging is initialized in avocado app:
      
      1. stdout/stderr/logging is replaced with in-memory handlers
      2. when arg parsing is done, logging is reconfigured accordingly to
         setting and re-logs stored messages (when streams are enabled)
      3. when job starts and "test" stream is enabled, "" and "avocado.test"
         streams are enabled
      4. when job finishes and "test" stream enabled the additional outputs,
         the additional outputs are disabled again.
      
      The 3 and 4 is necessarily as the "" logger contains all logs including
      avocado initialization (stevedore, PIL, ...). This way the "test" stream
      still outputs everything, but only during the job-execution and not
      during avocado initialization and cleanup. (one can use "early" log to
      see those).
      
      Last but not least it keeps "avocado.app" output in stdout (and stderr),
      but it moves all other outputs to stderr instead. This is IMO better
      handling as one can distinguish between debug and "additional" output.
      Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
      83a50b5f
  2. 23 2月, 2016 2 次提交
    • L
      avocado.core.output: Rename add_console_handler to add_log_handler · 7b3c553d
      Lukáš Doktor 提交于
      The function "add_console_handler" is quite useful. This patch extends
      it's capabilities and renames it to fit the new purpose.
      
      Because the new default logging level for "add_log_handler" is INFO,
      we add the "avocado.test" and root logger to level DEBUG.
      
      Then finally a few adjustments to the tests that rely on specific
      log format and level:
      
      1) selftests/functional/test_multiplex.py: adapt to changes in
      test logger That means that extra prefixes ('avocado.test') are
      printed out on each line when avocado is run with '--show-job-log'.
      While at it, be more precise and check for the specific params at the
      specific run with the given variant, instead of looking for a given
      param in the output of the three tests variants.
      
      2) selftests/functional/test_standalone.py: adapt to the change of
      log prefix ('avocado.test') and extra line because of DEBUG level.
      Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
      Signed-off-by: NCleber Rosa <crosa@redhat.com>
      7b3c553d
    • L
      avocado: Rename start_file_logging to start_job_logging · 38ad6b82
      Lukáš Doktor 提交于
      The "start_file_logging" is used when job results are created to add
      job file-handlers to logging.
      Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
      38ad6b82
  3. 18 2月, 2016 1 次提交
  4. 16 2月, 2016 1 次提交
    • C
      Remote/VM: move functionality from result to runners · 50cc98e9
      Cleber Rosa 提交于
      The functionality to run tests on remote machines and on VMs are
      implemented using a mixture of TestRunner and TestResult classes.
      
      In all fairness, it looks like the TestResult classes were abused
      because non-standard attributes were used as a foundation for that
      functionality. Now that `setup` and `tear_down` have been added
      to the TestRunner interface, let's move those custom features from
      the TestResult classes to the TestRunner ones.
      Signed-off-by: NCleber Rosa <crosa@redhat.com>
      Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
      50cc98e9
  5. 15 2月, 2016 1 次提交
  6. 12 2月, 2016 2 次提交
  7. 05 2月, 2016 1 次提交
    • C
      Test Result: define a formal method to register test result classes · 6ee69b27
      Cleber Rosa 提交于
      Avocado defines avocado.core.result.TestResult, so that alternative
      test result classes can inherit from it. When a user writes a new
      test result class, he's left wondering how to activate that.
      
      First, for consistency, Avocado should define proper interfaces
      for "test result plugins". This is on sight, and will ultimately
      allow users to register new test result implementations simply by
      registering the setuptools entry points, just as it's currently
      done (on versions >= 0.31.0) for command line related plugins.
      
      Until then, let's at least improve the current state of things.
      These changes believe that the following improvements are given here:
      
      * avocado.core.job.Job._set_output_plugins now won't look at every
        possible key in the application arguments, and won't silence
        possible errors while trying to instantiate test result classes.
      * test result writers can now use a documented method for registering
        their test result classes.
      
      The same approach was not chosen to be done with the test runner
      classes because there can only by one test runner per Avocado job.
      Signed-off-by: NCleber Rosa <crosa@redhat.com>
      6ee69b27
  8. 04 2月, 2016 1 次提交
  9. 03 2月, 2016 2 次提交
  10. 29 1月, 2016 1 次提交
    • C
      avocado.main(): avoid an infinite fork loop bomb · 08103fb4
      Cleber Rosa 提交于
      Because the current implementation of avocado.main() creates a job
      and runs "sys.argv[0]" to implement standalone mode, it ends up
      running itself over and over.
      
      This simple proposed fix, prevents avocado.main() from running
      itself again if called from itself. Since they are on different
      processes, the mechanism chosen to do this is to set an environment
      variable, that will be seen by the next process.
      
      Also, by exiting from main() with an error code, the test first
      level test will fail. This will let the user know that the chosen
      approach (SIMPLE tests written in Python and calling main()) are
      not worthy of a PASS.
      
      The functional tests make use of Python's standard library utilities
      (subprocess module) directly for running Avocado because of current
      issues with Avocado's own process utility module.
      
      This adresses issue #961.
      Signed-off-by: NCleber Rosa <crosa@redhat.com>
      08103fb4
  11. 27 1月, 2016 3 次提交
    • L
      avocado.utils.service: Use sudo if a command requires root · 3654551e
      Lucas Meneghel Rodrigues 提交于
      Instead of assuming we have administrative privileges to
      run service manager related commands, use sudo in commands
      that do require root. We now assume you're running the
      test as a user that has sudo configuration such that no
      password will be prompted to execute that command [1].
      
      A place where we need such a provision is when running on
      Amazon AWS instances (we can't run as root, but the base
      user of the image has the appropriate sudo configuration).
      
      [1] Running as root means that sudo won't be necessary,
      but figuring that out is responsibility of the process
      APIs, that were modified to take a sudo parameter and
      figure things out based on that.
      Signed-off-by: NLucas Meneghel Rodrigues <lookkas@gmail.com>
      3654551e
    • L
      avocado.utils.process: Add 'sudo' parameter to run and system APIs · 7dad50e7
      Lucas Meneghel Rodrigues 提交于
      Some commands do require admin privileges to run, but we
      can't use the 'root' user in some testing scenarios [1].
      
      So let's add a 'sudo' parameter to process.run(), process.system()
      and process.system_output() interfaces, that will append
      a sudo command to the original command string, causing it
      to be executed under sudo. The basic assumption here is
      that the user executing the tests was added to the sudoers
      file in such a way that it can run administrative commands
      without a password.
      
      [1] One specific environment where we can't use the root
      user is when avocado runs on an AWS (Amazon Web Services)
      instance.
      Signed-off-by: NLucas Meneghel Rodrigues <lookkas@gmail.com>
      7dad50e7
    • A
      avocado.core: show the subcommand help on unknown argparse option · 6cd03d6f
      Amador Pahim 提交于
      Using an unknown option in a given subcommand leads argparse to
      show the main avocado usage instructions.
      
      This patch makes the argparse show the subcommand help instead.
      
      Also, argparse error exit code now matches error_codes.AVOCADO_FAIL,
      which makes more sense than error_codes.AVOCADO_JOB_FAIL.
      
      Reference:https://trello.com/c/o0TpH9aeSigned-off-by: NAmador Pahim <apahim@redhat.com>
      6cd03d6f
  12. 26 1月, 2016 1 次提交
  13. 21 1月, 2016 1 次提交
  14. 20 1月, 2016 1 次提交
  15. 19 1月, 2016 1 次提交
  16. 16 1月, 2016 1 次提交
  17. 13 1月, 2016 1 次提交
    • C
      loader: make test methods unique when discovering tests · f86e7dad
      Cleber Rosa 提交于
      As per report on issue #952, Avocado currently finds multiple tests
      when multiple test names exist in a given Python class. When the
      test code itself is loaded and the test class instantiated, only
      one test method will remain (others will have been overloaded by
      that one).
      
      So, to mimic this in the static, AST based, test discovery, let's
      make the test methods unique and try to keep the order in which the
      AST parser found them.
      Signed-off-by: NCleber Rosa <crosa@redhat.com>
      f86e7dad
  18. 07 1月, 2016 2 次提交
    • C
      selftests/functional/test_basic.py: remove references to old Plugin · c4180e95
      Cleber Rosa 提交于
      There are a few leftover references to the old Plugin classes in
      the functional tests. Let's remove them.
      Signed-off-by: NCleber Rosa <crosa@redhat.com>
      c4180e95
    • L
      avocado.core.loader: Append test directory to sys.path · 62ae0d60
      Lucas Meneghel Rodrigues 提交于
      If a test has local imports (a fairly common use case),
      we have to append the base test dir to sys.path. Otherwise,
      we end up having a horrible traceback as a result:
      
      Exception loading test
      Traceback (most recent call last):
        File "/home/lmr/Code/avocado.lmr/avocado/core/runner.py", line 200, in _run_test
          instance = loader.load_test(test_factory)
        File "/home/lmr/Code/avocado.lmr/avocado/core/loader.py", line 262, in load_test
          test_module = imp.load_module(module_name, f, p, d)
        File "scylla_longevity.py", line 5, in <module>
          from sdcm.tester import ScyllaClusterTester
      ImportError: No module named sdcm.tester
      
      Which is clearly not wanted. We had this problem before
      and now we have a regression. It's time for a functional
      test to make sure we don't regress again.
      Signed-off-by: NLucas Meneghel Rodrigues <lookkas@gmail.com>
      Signed-off-by: NCleber Rosa <crosa@redhat.com>
      62ae0d60
  19. 04 1月, 2016 1 次提交
  20. 28 12月, 2015 1 次提交
    • C
      Pseudo terminals: add utility module · 003bfaed
      Cleber Rosa 提交于
      Based on previous experiences (GDB terminal redirection attempts),
      it's common for applications that need to allocate a pseudo to have
      the name of the allocated file. This is, unfortunately, something that
      the Python standard library doesn't give for free.
      
      This simple utility module wraps and extends the Python standard
      library `pty` module, providing a `openpty` function that, besides
      allocating the pseudo terminal, also returns its name.
      Signed-off-by: NCleber Rosa <crosa@redhat.com>
      003bfaed
  21. 18 12月, 2015 14 次提交