Uploaded image for project: 'Mender'
  1. Mender
  2. MEN-1522

State scripts tests sometimes fail

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Done
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 1.3.0
    • Fix Version/s: 1.3.0
    • Labels:

      Description

      It often fails in the tests that deal with errors in non-Artifact scripts. This is an example of a failure:

      [gw0] linux2 -- Python 2.7.13 /usr/bin/python
      
      self = <tests.test_state_scripts.TestStateScripts object at 0x7fd83f4d6d50>
      test_set = {'ExpectedStatus': None, 'FailureScript': ['Download_Enter_12'], 'ScriptOrder': ['Idle_Enter_08_testing', 'Idle_Enter_09', 'Idle_Leave_09', 'Idle_Leave_10', 'Sync_Enter_02', 'Sync_Enter_03', ...]}
      
      @MenderTesting.slow
      @pytest.mark.usefixtures("standard_setup_one_client_bootstrapped")
      @pytest.mark.parametrize("test_set", TEST_SETS)
      def test_state_scripts(self, test_set):
      """Test that state scripts are executed in right order, and that errors
      are treated like they should."""
      
      if not env.host_string:
      execute(self.test_state_scripts, test_set,
      > hosts=get_mender_clients())
      
      tests/test_state_scripts.py:644:
      _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
      /usr/local/lib/python2.7/dist-packages/fabric/tasks.py:386: in execute
      multiprocessing
      /usr/local/lib/python2.7/dist-packages/fabric/tasks.py:276: in _execute
      return task.run(*args, **kwargs)
      /usr/local/lib/python2.7/dist-packages/fabric/tasks.py:173: in run
      return self.wrapped(*args, **kwargs)
      tests/test_state_scripts.py:751: in test_state_scripts
      run("grep Error /data/test_state_scripts.log")
      /usr/local/lib/python2.7/dist-packages/fabric/network.py:687: in host_prompting_wrapper
      return func(*args, **kwargs)
      /usr/local/lib/python2.7/dist-packages/fabric/operations.py:1090: in run
      shell_escape=shell_escape, capture_buffer_size=capture_buffer_size,
      /usr/local/lib/python2.7/dist-packages/fabric/operations.py:954: in _run_command
      error(message=msg, stdout=out, stderr=err)
      /usr/local/lib/python2.7/dist-packages/fabric/utils.py:358: in error
      return func(message)
      _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
      
      msg = 'run() received nonzero return code 1 while executing!\n\nRequested: grep Error /data/test_state_scripts.log\nExecuted: /bin/sh -c "grep Error /data/test_state_scripts.log"'
      
      def abort(msg):
      """
      Abort execution, print ``msg`` to stderr and exit with error status (1.)
      
      This function currently makes use of `SystemExit`_ in a manner that is
      similar to `sys.exit`_ (but which skips the automatic printing to stderr,
      allowing us to more tightly control it via settings).
      
      Therefore, it's possible to detect and recover from inner calls to `abort`
      by using ``except SystemExit`` or similar.
      
      .. _sys.exit: http://docs.python.org/library/sys.html#sys.exit
      .. _SystemExit: http://docs.python.org/library/exceptions.html#exceptions.SystemExit
      """
      from fabric.state import output, env
      if not env.colorize_errors:
      red = lambda x: x
      else:
      from colors import red
      
      if output.aborts:
      sys.stderr.write(red("\nFatal error: %s\n" % _encode(msg, sys.stderr)))
      sys.stderr.write(red("\nAborting.\n"))
      
      if env.abort_exception:
      raise env.abort_exception(msg)
      else:
      # See issue #1318 for details on the below; it lets us construct a
      # valid, useful SystemExit while sidestepping the automatic stderr
      # print (which would otherwise duplicate with the above in a
      # non-controllable fashion).
      e = SystemExit(1)
      e.message = msg
      > raise e
      E           SystemExit: 1
      
      /usr/local/lib/python2.7/dist-packages/fabric/utils.py:62: SystemExit
      

      System load plays a role; it is much more likely in parallel builds with bad droplets.

        Attachments

          Activity

            People

            • Assignee:
              a10040 Kristian Amlie
              Reporter:
              a10040 Kristian Amlie
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Summary Panel