skylab: upgrade mysql update commands in server_db_sync

Previously, we used a hostname_id_map dict to map the server hostname to
its id in servers tables, and then update server_attributes and
server_roles tables based on this hostname_id_map dict. This is
unnecessary complex, switch to use the 'select id from servers where
hostname=xx' to dynamically find the server_id for a given attibute or
role to be updated.

BUG=b:64912213
TEST=1.unittest
2. Local db is empty, sync up with staging server_db with
cmd: ./bin/server_db_sync -o localhost -u root -p autotest -e staging
--warn_only
Nothing will be inserted into local db, since --warn_only is specified.
3. Local db is empty,
cmd: ./bin/server_db_sync -o localhost -u root -p autotest -e staging
All the servers, attributes and roles inserted into local server_db.
4. Local db has one fake server entry that doesn't exist in inventory
server_db.
cmd: ./bin/server_db_sync -o localhost -u root -p autotest -e staging
The fake entry has been deleted, and all the valid entries from
inventory server_db have been inserted.

Change-Id: I05e522532a894c2304eb92c8d03895a719f5ab0f
Reviewed-on: https://chromium-review.googlesource.com/969624
Commit-Ready: Shuqian Zhao <shuqianz@chromium.org>
Tested-by: Shuqian Zhao <shuqianz@chromium.org>
Reviewed-by: Xixuan Wu <xixuan@chromium.org>
2 files changed
tree: 09d483609b9bb73e3571c0a37b439cc37a76d474
  1. apache/
  2. bin/
  3. cli/
  4. client/
  5. contrib/
  6. database/
  7. docs/
  8. frontend/
  9. leases/
  10. logs/
  11. results/
  12. scheduler/
  13. server/
  14. site_utils/
  15. skylab_migration/
  16. test_suites/
  17. tko/
  18. utils/
  19. venv/
  20. .gitignore
  21. .quickmerge_sentinel
  22. .style.yapf
  23. __init__.py
  24. COMMIT-QUEUE-moblab-pre-cq-only.ini
  25. COMMIT-QUEUE.ini
  26. common.py
  27. global_config.ini
  28. LGPL_LICENSE
  29. LICENSE
  30. metadata.chromium
  31. moblab_config.ini
  32. PRESUBMIT.cfg
  33. README.md
  34. ssp_deploy_config.json
README.md

Autotest: Automated integration testing for Android and Chrome OS Devices

Autotest is a framework for fully automated testing. It was originally designed to test the Linux kernel, and expanded by the Chrome OS team to validate complete system images of Chrome OS and Android.

Autotest is composed of a number of modules that will help you to do stand alone tests or setup a fully automated test grid, depending on what you are up to. A non extensive list of functionality is:

  • A body of code to run tests on the device under test. In this setup, test logic executes on the machine being tested, and results are written to files for later collection from a development machine or lab infrastructure.

  • A body of code to run tests against a remote device under test. In this setup, test logic executes on a development machine or piece of lab infrastructure, and the device under test is controlled remotely via SSH/adb/some combination of the above.

  • Developer tools to execute one or more tests. test_that for Chrome OS and test_droid for Android allow developers to run tests against a device connected to their development machine on their desk. These tools are written so that the same test logic that runs in the lab will run at their desk, reducing the number of configurations under which tests are run.

  • Lab infrastructure to automate the running of tests. This infrastructure is capable of managing and running tests against thousands of devices in various lab environments. This includes code for both synchronous and asynchronous scheduling of tests. Tests are run against this hardware daily to validate every build of Chrome OS.

  • Infrastructure to set up miniature replicas of a full lab. A full lab does entail a certain amount of administrative work which isn't appropriate for a work group interested in automated tests against a small set of devices. Since this scale is common during device bringup, a special setup, called Moblab, allows a natural progressing from desk -> mini lab -> full lab.

Run some autotests

See the guides to test_that and test_droid:

test_droid Basic Usage

test_that Basic Usage

Write some autotests

See the best practices guide, existing tests, and comments in the code.

Autotest Best Practices

Grabbing the latest source

git clone https://chromium.googlesource.com/chromiumos/third_party/autotest

Hacking and submitting patches

See the coding style guide for guidance on submitting patches.

Coding Style

Pre-upload hook dependencies

You need to run utils/build_externals.py to set up the dependencies for pre-upload hook tests.