sync_factory_server

Source code: sync_factory_server.py

Connect to factory server to find software updates and upload logs.

Description

This test will create connections from DUT to Chrome OS factory server and invoke remote procedure calls for syncing data and programs.

This test will sync following items:

  1. If sync_time is enabled (default True), sync system time from server.

  2. If sync_event_logs is enabled (default True), sync the event_log YAML event logs to factory server.

  3. If flush_testlog is enabled (default False), flush TestLog to factory server (which should have Instalog node running).

  4. If upload_report is enabled (default False), upload a Gooftool style report collecting system information and manufacturing logs to server.

  5. If update_toolkit is enabled (default True), compare the factory software (toolkit) installed on DUT with the active version on server, and update if needed.

  6. If upload_reg_codes is enabled (default False), upload the registration codes to server using UploadCSVEntry API, and have the data stored in registration_code_log.csv file on server. If the reg codes must be sent back to partner’s shopfloor backend, please use shopfloor_service pytest and ActivateRegCode API instead.

  7. If upload_zero_touch_ids is enabled (default False), upload the attested device ID and serial number pair using the UploadCSVEntry API. The CSV can be downloaded from Dome server in the Logs -> CSV page.

Additionally, if argument server_url is specified, this test will update the stored ‘default factory server URL’ so all following tests connecting to factory server via server_proxy.GetServerProxy() will use the new URL.

server_url supports few different input:

  • If a string is given, that is interpreted as simple URL. For example, "http://10.3.0.11:8080/".

  • If a mapping (dict) is given, take key as network IP/CIDR and value as URL. For example, {"10.3.0.0/24": "http://10.3.0.11:8080"}

Test Procedure

Basically no user interaction required unless a toolkit update is found.

  • Make sure network is connected.

  • Start the test and it will try to reach factory server and sync time and logs.

  • If update_toolkit is True, compare installed toolkit with server’s active version.

  • If a new version is found, a message like ‘A software update is available.’ will be displayed on screen. Operator can follow the instruction (usually just press space) to start downloading and installing new software.

Dependency

Nothing special. This test uses only server components in Chrome OS Factory Software.

Examples

To connect to default server and sync time, event logs, and update software, add this in test list:

{
  "pytest_name": "sync_factory_server"
}

To only sync time and logs, and never update software (useful for stations):

{
  "pytest_name": "sync_factory_server",
  "args": {
    "update_toolkit": false
  }
}

To sync time and logs, and then upload a report:

{
  "pytest_name": "sync_factory_server",
  "args": {
    "upload_report": true
  }
}

To override default factory server URL for all tests, change the default_factory_server_url in test list constants:

{
  "constants": {
    "default_factory_server_url": "http://192.168.3.11:8080"
  }
}

It is also possible to override and create one test item using different factory server URL, and all tests after that:

{
  "pytest_name": "sync_factory_server",
  "args": {
    "server_url": "http://192.168.3.11:8080"
  }
}

To implement “station specific factory server” in JSON test lists, extend SyncFactoryServer from generic_common.test_list.json as:

{ "inherit": "SyncFactoryServer",
  "args": {
    "server_url": "eval! locals.factory_server_url"
  }
}

And then in each station (or stage), override URL in locals:

{"SMT": {"locals": {"factory_server_url": "http://192.168.3.11:8080" }}},
{"FAT": {"locals": {"factory_server_url": "http://10.3.0.11:8080" }}},
{"RunIn": {"locals": {"factory_server_url": "http://10.1.2.10:7000" }}},
{"FFT": {"locals": {"factory_server_url": "http://10.3.0.11:8080" }}},
{"GRT": {"locals": {"factory_server_url": "http://172.30.1.2:8081" }}},

To implement “auto-detect factory server by received DHCP IP address”, specify a mapping object with key set to “IP/CIDR” and value set to server URL:

{
  "constants": {
    "default_factory_server_url": {
      "192.168.3.0/24": "http://192.168.3.11:8080",
      "10.3.0.0/24": "http://10.3.0.11:8080",
      "10.1.0.0/16": "http://10.1.2.10:8080"
    }
  }
}

Test Arguments

Name

Type

Description

first_retry_secs

int

(optional; default: 1) Time to wait after the first attempt; this will increase exponentially up to retry_secs. This is useful because sometimes the network may not be available by the time the tests starts, but a full 10-second wait is unnecessary.

retry_secs

int

(optional; default: 10) Maximum time to wait between retries.

timeout_secs

int

(optional; default: 10) Timeout for XML/RPC operations.

update_toolkit

bool

(optional; default: True) Whether to check factory update.

update_without_prompt

bool

(optional; default: False) Update without prompting when an update is available.

sync_time

bool

(optional; default: True) Sync system time from factory server.

sync_event_logs

bool

(optional; default: True) Sync event logs to factory server.

flush_testlog

bool

(optional; default: False) Flush test logs to factory server.

upload_reg_codes

bool

(optional; default: False) Upload registration codes to server.

upload_sn

bool

(optional; default: False) Upload serial number for auditing.

upload_report

bool

(optional; default: False) Upload a factory report to factory server.

report_stage

str, None

(optional; default: None) Stage of report to upload.

report_serial_number_name

str, None

(optional; default: None) Name of serial number to use for report file name to use.

server_url

str, dict, None

(optional; default: None) Set and keep new factory server URL.

upload_zero_touch_ids

bool

(optional; default: False) Upload attested_device_id and serial_number pair to server.

upload_csv_entries

bool

(optional; default: True) Upload CSV entries recorded by csv_utils.CSVManager