New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 759501 link

Starred by 2 users

Issue metadata

Status: Archived
Owner:
Last visit > 30 days ago
Closed: Aug 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 1
Type: Bug



Sign in to add a comment

test_that fails with "NameError: name 'utils' is not defined"

Project Member Reported by dtosic@chromium.org, Aug 28 2017

Issue description

After repo sync this morning I am not able to use test_that anymore.

Seeing the following exception:

test_that --autotest_dir ~/trunk/src/third_party/autotest/files/ --args "servo_host=" --board=guado 100.104.43.235 enterprise_CFM_MeetAppSanity
INFO:root:Identity added: /tmp/test_that_results_ykKjpc/testing_rsa (/tmp/test_that_results_ykKjpc/testing_rsa)
11:55:42 INFO | Began logging to /tmp/test_that_results_ykKjpc
Adding labels [u'cros-version:ad_hoc_build', u'board:guado'] to host 100.104.43.235
04:55:42 INFO | Fetching suite for job named enterprise_CFM_MeetAppSanity...
04:55:46 INFO | Scheduling suite for job named enterprise_CFM_MeetAppSanity...
04:55:46 INFO | ... scheduled 1 job(s).
04:55:47 INFO | autoserv| Traceback (most recent call last):
04:55:47 INFO | autoserv| File "/home/dtosic/trunk/src/third_party/autotest/files/server/autoserv", line 35, in <module>
04:55:47 INFO | autoserv| metrics = utils.metrics_mock
04:55:47 INFO | autoserv| NameError: name 'utils' is not defined

Doing a sync to an earlier build with
repo forall -c 'git checkout `git rev-list --all -n1 --before="2017-08-26 3:00"`' (assuming this is right as I am no expert)

I managed to get rid of the error and the test started running again.
 

Comment 1 by dtosic@chromium.org, Aug 28 2017

Tried with test_that --autotest_dir ~/trunk/src/third_party/autotest/files/ --board=guado 100.104.43.235 enterprise_KioskEnrollment, same result
Cc: jrbarnette@chromium.org pprabhu@chromium.org pho...@chromium.org
Components: -Tests>Telemetry Infra>Client>ChromeOS
Owner: ayatane@chromium.org
Owner: pprabhu@chromium.org
Status: Started (was: Untriaged)

Comment 5 by pho...@chromium.org, Aug 28 2017

It looks like at the time that import guard was introduced, we were importing utils: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/438754/5/server/autoserv

..but it was removed at some point. The reason you're hitting this now is that I added the line "from chromite.lib import cloud_trace", which isn't succeeding on your machine - your chromite checkout must be out of date. If you repo sync chromite, it should work fine.

I've uploaded https://chromium-review.googlesource.com/639050 to fix the utils import bug.

Comment 6 by pho...@chromium.org, Aug 28 2017

Oops, pprabhu@ already uploaded a fix. I'll change my review to only fix the non-autoserv files.
Probably my utils refactor then.  Git isn't smart enough to report that new code was added that referenced deleted code.

At the time I wrote my commit, utils wasn't used and in fact was getting redefined by another import below.  Your commit must have landed before mine.
Cc: achuith@chromium.org
Cc: ayatane@chromium.org dshi@chromium.org modia@chromium.org venkatar...@chromium.org kmshelton@chromium.org tgillella@chromium.org haddowk@chromium.org
 Issue 759842  has been merged into this issue.
Project Member

Comment 10 by bugdroid1@chromium.org, Aug 29 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/third_party/autotest/+/d16c801824d28089b722895ebfdae3e49889c8ac

commit d16c801824d28089b722895ebfdae3e49889c8ac
Author: Prathmesh Prabhu <pprabhu@chromium.org>
Date: Tue Aug 29 01:21:33 2017

autotest: Fix metrics_mock import in autoserv

BUG= chromium:759501 
TEST=None

Change-Id: I1742b4c080b2a22ea8a03bcd4bd05a5dcec7eec6
Reviewed-on: https://chromium-review.googlesource.com/638917
Commit-Ready: Prathmesh Prabhu <pprabhu@chromium.org>
Tested-by: Prathmesh Prabhu <pprabhu@chromium.org>
Reviewed-by: Paul Hobbs <phobbs@google.com>
Reviewed-by: Harpreet Grewal <harpreet@chromium.org>
Reviewed-by: Dan Shi <dshi@google.com>

[modify] https://crrev.com/d16c801824d28089b722895ebfdae3e49889c8ac/server/autoserv

Project Member

Comment 11 by bugdroid1@chromium.org, Aug 29 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/third_party/autotest/+/cd10e48320198aaf476fbb344709f317bf728d04

commit cd10e48320198aaf476fbb344709f317bf728d04
Author: Paul Hobbs <phobbs@google.com>
Date: Tue Aug 29 01:21:36 2017

[autotest] Fix 'utils' imports for metrics_mock

Some usages of utils.metrics_mock had been broken accidentally by deleting or
rearranging the autotest.client.common_lib.utils import.

BUG= chromium:759501 
TEST=None

Change-Id: Iad5d62dd76d6b5215116401afb1de11303db9cc1
Reviewed-on: https://chromium-review.googlesource.com/639050
Commit-Ready: Paul Hobbs <phobbs@google.com>
Tested-by: Paul Hobbs <phobbs@google.com>
Reviewed-by: Prathmesh Prabhu <pprabhu@chromium.org>

[modify] https://crrev.com/cd10e48320198aaf476fbb344709f317bf728d04/site_utils/gs_offloader.py
[modify] https://crrev.com/cd10e48320198aaf476fbb344709f317bf728d04/scheduler/host_scheduler.py

After syncing I am hitting the following error in mock.py:

02:39:30 INFO | autoserv| Traceback (most recent call last):
02:39:30 INFO | autoserv| File "/home/dtosic/trunk/src/third_party/autotest/files/server/autoserv", line 37, in <module>
02:39:30 INFO | autoserv| import mock
02:39:30 INFO | autoserv| File "/mnt/host/source/src/third_party/autotest/files/site-packages/mock/__init__.py", line 2, in <module>
02:39:30 INFO | autoserv| import mock.mock as _mock
02:39:30 INFO | autoserv| File "/mnt/host/source/src/third_party/autotest/files/site-packages/mock/mock.py", line 69, in <module>
02:39:30 INFO | autoserv| from pbr.version import VersionInfo
02:39:30 INFO | autoserv| ImportError: No module named pbr.version


Re #5: I am by no means a chrome or git expert, but I did repo sync (chromite looks up to date to me) but when running tests from my local machine I still end up in the expect branch due to, as you mentioned, the failed cloud_trace import :(
Also, is it possible to add a test (or run some existing one) that would have prevented this regression?
Cc: dancarregosa@google.com
Owner: dtosic@chromium.org
dtosic - if you can't import mock, your site-packages is seriously out of date. You should rebuild it with utils/build_externals.py

This might also fix the chromite import error you're seeing.
Thanks Paul, all works now at my local station!
Status: Fixed (was: Started)
Filed issue 760261 as follow up to protect test_that from regressions.

Comment 19 by dchan@chromium.org, Jan 22 2018

Status: Archived (was: Fixed)

Sign in to add a comment