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

test_inventory_os test not passing on zeus

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Done
    • Priority: (None)
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: yocto-3.0-zeus
    • Labels:

      Description

      _______________________ TestInventory.test_inventory_os ________________________
      self = <test_inventory.TestInventory object at 0x7fb48428b4a8>
      bitbake_variables = {'ABIEXTENSION': 'eabi', 'ABIEXTENSION_class-nativesdk': '', 'ALLOW_EMPTY_core-image-minimal-dbg': '1', 'ALLOW_EMPTY_core-image-minimal-dev': '1', ...}
      connection = <Connection host=localhost user=root port=8822>
              @pytest.mark.min_mender_version("2.0.0")
              def test_inventory_os(self, bitbake_variables, connection):
                  """Test that "os" inventory attribute is reported correctly by the
                  inventory script."""
          
                  sources = [
                      {
                          "name": "/etc/os-release",
                          "content": """NAME="Ubuntu"
          VERSION="16.04.4 LTS (Xenial Xerus)"
          ID=ubuntu
          ID_LIKE=debian
          PRETTY_NAME="Ubuntu 16.04.4 LTS"
          VERSION_ID="16.04"
          HOME_URL="http://www.ubuntu.com/"
          SUPPORT_URL="http://help.ubuntu.com/"
          BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
          VERSION_CODENAME=xenial
          UBUNTU_CODENAME=xenial""",
                          "mode": 0o644,
                          "expected": "os=Ubuntu 16.04.4 LTS",
                      },
                      {
                          "name": "/usr/lib/os-release",
                          "content": """ID="poky"
          NAME="Poky (Yocto Project Reference Distro)"
          VERSION="2.5+snapshot-20180731 (master)"
          VERSION_ID="2.5-snapshot-20180731"
          """,
                          "mode": 0o644,
                          "expected": "os=Poky (Yocto Project Reference Distro) 2.5+snapshot-20180731 (master)",
                      },
                      {
                          "name": "/bin/lsb_release",
                          "content": """#!/bin/sh
          echo Base LSB OS""",
                          "mode": 0o755,
                          "expected": "os=Base LSB OS",
                      },
                      {
                          "name": "/usr/bin/lsb_release",
                          "content": """#!/bin/sh
          echo LSB OS""",
                          "mode": 0o755,
                          "expected": "os=LSB OS",
                      },
                      {
                          "name": "/etc/issue",
                          "content": "Issue OS",
                          "mode": 0o644,
                          "expected": "os=Issue OS",
                      },
                      {"name": None, "expected": "os=unknown"},
                  ]
                  for file in [src["name"] for src in sources if src["name"]]:
                      backup = "/data%s.backup" % file
                      bdir = os.path.dirname(backup)
                      connection.run(
                          "mkdir -p %s && if [ -e %s ]; then cp %s %s; fi"
                          % (bdir, file, file, backup)
                      )
          
                  try:
                      for src in sources:
                          if src.get("name") is None:
                              continue
                          with open("tmpfile", "w") as fd:
                              fd.write(src["content"])
                              if src["content"][-1] != "\n":
                                  # Write a final newline if there isn't one.
                                  fd.write("\n")
                          try:
      >                       put_no_sftp("tmpfile", connection, remote=src["name"])
      test_inventory.py:130: 
      _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
      common.py:240: in put_no_sftp
          raise e
      common.py:236: in put_no_sftp
          % (cmd, conn.port, file, conn.user, conn.host, remote)
      /usr/local/lib/python3.6/dist-packages/fabric/connection.py:748: in local
          return super(Connection, self).run(*args, **kwargs)
      /usr/local/lib/python3.6/dist-packages/invoke/context.py:94: in run
          return self._run(runner, command, **kwargs)
      /usr/local/lib/python3.6/dist-packages/invoke/context.py:101: in _run
          return runner.run(command, **kwargs)
      /usr/local/lib/python3.6/dist-packages/invoke/runners.py:363: in run
          return self._run_body(command, **kwargs)
      /usr/local/lib/python3.6/dist-packages/invoke/runners.py:422: in _run_body
          return self.make_promise() if self._asynchronous else self._finish()
      _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
      self = <invoke.runners.Local object at 0x7fb4842c3be0>
          def _finish(self):
              # Wait for subprocess to run, forwarding signals as we get them.
              try:
                  while True:
                      try:
                          self.wait()
                          break  # done waiting!
                      # Don't locally stop on ^C, only forward it:
                      # - if remote end really stops, we'll naturally stop after
                      # - if remote end does not stop (eg REPL, editor) we don't want
                      # to stop prematurely
                      except KeyboardInterrupt as e:
                          self.send_interrupt(e)
                      # TODO: honor other signals sent to our own process and
                      # transmit them to the subprocess before handling 'normally'.
              # Make sure we tie off our worker threads, even if something exploded.
              # Any exceptions that raised during self.wait() above will appear after
              # this block.
              finally:
                  # Inform stdin-mirroring worker to stop its eternal looping
                  self.program_finished.set()
                  # Join threads, storing inner exceptions, & set a timeout if
                  # necessary. (Segregate WatcherErrors as they are "anticipated
                  # errors" that want to show up at the end during creation of
                  # Failure objects.)
                  watcher_errors = []
                  thread_exceptions = []
                  for target, thread in six.iteritems(self.threads):
                      thread.join(self._thread_join_timeout(target))
                      exception = thread.exception()
                      if exception is not None:
                          real = exception.value
                          if isinstance(real, WatcherError):
                              watcher_errors.append(real)
                          else:
                              thread_exceptions.append(exception)
              # If any exceptions appeared inside the threads, raise them now as an
              # aggregate exception object.
              # NOTE: this is kept outside the 'finally' so that main-thread
              # exceptions are raised before worker-thread exceptions; they're more
              # likely to be Big Serious Problems.
              if thread_exceptions:
                  raise ThreadException(thread_exceptions)
              # Collate stdout/err, calculate exited, and get final result obj
              result = self._collate_result(watcher_errors)
              # Any presence of WatcherError from the threads indicates a watcher was
              # upset and aborted execution; make a generic Failure out of it and
              # raise that.
              if watcher_errors:
                  # TODO: ambiguity exists if we somehow get WatcherError in *both*
                  # threads...as unlikely as that would normally be.
                  raise Failure(result, reason=watcher_errors[0])
              # If a timeout was requested and the subprocess did time out, shout.
              timeout = self.opts["timeout"]
              if timeout is not None and self.timed_out:
                  raise CommandTimedOut(result, timeout=timeout)
              if not (result or self.opts["warn"]):
      >           raise UnexpectedExit(result)
      E           invoke.exceptions.UnexpectedExit: Encountered a bad command exit code!
      E           
      E           Command: 'scp -C -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -P 8822 tmpfile root@localhost:/bin/lsb_release'
      E           
      E           Exit code: 1
      E           
      E           Stdout: already printed
      E           
      E           Stderr: already printed
      /usr/local/lib/python3.6/dist-packages/invoke/runners.py:489: UnexpectedExit
      

        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