1// Copyright 2019 The Chromium OS Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5syntax = "proto3"; 6 7package chromiumos.config.api.test.tls; 8 9option go_package = "go.chromium.org/chromiumos/config/go/api/test/tls"; 10 11import "google/protobuf/empty.proto"; 12 13import "dependencies/longrunning/operations.proto"; 14 15// Common lab services implemented on top of the wiring APIs. 16// 17// The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL 18// NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and 19// "OPTIONAL" in this document are to be interpreted as described in 20// RFC 2119. 21// 22// All clients SHOULD pass the gRPC metadata key request_trace_id with one 23// value. The value is a unique string that is associated with the method call 24// in metrics. Clients that do not pass request_trace_id MAY be rejected so that 25// they can be fixed. 26service Common { 27 // ExecDutCommand runs a command on a DUT. 28 // 29 // The working directory is /. 30 // A tty is not spawned for the command. 31 // The user and group is root. 32 // All signals have their default dispositions and are not masked. 33 // The umask is set to 0. 34 // 35 // The environment contains: 36 // 37 // TERM=dumb 38 // PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin 39 // LANG=en_US.UTF-8 40 // USER=root 41 // HOME=/root 42 // 43 // The environment MAY also contain SSH client variables. 44 // The environment SHALL NOT contain variables not mentioned above. 45 // 46 // If the stream is interrupted, the implementation MAY attempt to 47 // stop the command by sending SIGINT, SIGHUP, SIGTERM, or SIGKILL. 48 rpc ExecDutCommand(ExecDutCommandRequest) 49 returns (stream ExecDutCommandResponse); 50 51 // ProvisionDut installs a specified version of ChromeOS on the DUT, along 52 // with any specified DLCs. 53 // 54 // If the DUT is already on the specified version of ChromeOS, the OS will 55 // not be provisioned. 56 // 57 // If the DUT already has the specified list of DLCs, only the missing DLCs 58 // will be provisioned. 59 rpc ProvisionDut(ProvisionDutRequest) returns (google.longrunning.Operation) { 60 option (google.longrunning.operation_info) = { 61 response_type: "ProvisionDutResponse", 62 metadata_type: "ProvisionDutMetadata" 63 }; 64 } 65 66 // ProvisionLacros installs a specified version of Lacros on the DUT. 67 // 68 // If the DUT already has the specified version of Lacros, Lacros will not be 69 // provisioned. 70 rpc ProvisionLacros(ProvisionLacrosRequest) returns (google.longrunning.Operation) { 71 option (google.longrunning.operation_info) = { 72 response_type: "ProvisionLacrosResponse", 73 metadata_type: "ProvisionLacrosMetadata" 74 }; 75 } 76 77 // FetchCrashes gets a stream of all crash reports currently on the DUT. 78 // 79 // The stream returned may split up a crash over multiple 80 // `FetchCrashesResponse` protos. See the definition of that proto for 81 // details. 82 // 83 // This call is read-only: it doesn't delete the crashes that it reads. 84 rpc FetchCrashes(FetchCrashesRequest) returns (stream FetchCrashesResponse); 85 86 // CreateFakeOmaha starts a fake Omaha service on TLS and exposes the 87 // listened port to the DUT. 88 rpc CreateFakeOmaha(CreateFakeOmahaRequest) returns (FakeOmaha); 89 // DeleteFakeOmaha deletes the specified fake Omaha resource created by 90 // CreateFakeOmaha. 91 rpc DeleteFakeOmaha(DeleteFakeOmahaRequest) returns (google.protobuf.Empty); 92} 93 94message ExecDutCommandRequest { 95 // name is the resource name for the DUT. 96 // The DUT name is passed to the RTD when the RTD is started. 97 // It is not specified whether the name is the DUT hostname. 98 string name = 1; 99 // command is the command to run. 100 // If this contains no slashes, it is resolved using PATH. 101 // If this starts with /, it is used as an absolute path to the 102 // program to run. 103 // Otherwise, this is treated as a path relative to the working 104 // directory. 105 string command = 2; 106 // args are the arguments to pass to the command. 107 repeated string args = 3; 108 // stdin is passed to the command as the program's stdin. 109 // The stream does not support seeking. 110 // An empty bytes is not treated specially; if the command reads 111 // from stdin, it will receive zero bytes. 112 bytes stdin = 4; 113 // stdout indicates how to handle the command's stdout. 114 Output stdout = 5; 115 // stderr indicates how to handle the command's stderr. 116 Output stderr = 6; 117} 118message ExecDutCommandResponse { 119 message ExitInfo { 120 // status provides information about how the command process 121 // terminated. 122 // 123 // If the command failed to start, status is set to an arbitrary 124 // non-zero value. 125 // 126 // If signaled is set, status is set to the signal that caused 127 // the command to terminate. 128 // 129 // Otherwise, status is set to the exit status of the process. 130 // Exit statuses outside of 0 to 255 inclusive are not supported; 131 // they will be mapped to an arbitrary non-zero value. 132 // 133 // status is zero if and only if the process was successfully 134 // started and exited with a zero status. 135 int32 status = 1; 136 // signaled indicates whether the command exited due to a signal. 137 // If set, status contains the signal. 138 bool signaled = 2; 139 // started indicates whether the command was started. 140 bool started = 3; 141 // error_message provides a human readable explanation for some errors. 142 // This MUST NOT be inspected by programs. 143 string error_message = 4; 144 } 145 // exit_info contains exit information. 146 // This is set when the command has exited or failed to start. 147 // This is set on the last message in the response stream. 148 ExitInfo exit_info = 1; 149 // stdout contains the shell command's stdout output since the last 150 // response in the stream. 151 // The implementation MAY batch or delay output to later 152 // responses in the stream. 153 bytes stdout = 2; 154 // stderr contains the shell command's stderr output since the last 155 // response in the stream. 156 // The implementation MAY batch or delay output to later 157 // responses in the stream. 158 bytes stderr = 3; 159} 160 161// Output enumeration for ExecDutCommandRequest. 162enum Output { 163 // OUTPUT_PIPE means to collect output and return it. 164 OUTPUT_PIPE = 0; 165 // OUTPUT_STDOUT is a special value for stderr which means to merge stderr 166 // into stdout. 167 OUTPUT_STDOUT = 1; 168} 169 170message ProvisionDutRequest { 171 // name is the resource name for the DUT. 172 // The DUT name is passed to the RTD when the RTD is started. 173 // It is not specified whether the name is the DUT hostname. 174 string name = 1; 175 176 // TODO(crbug.com/1155247) Deprecate this nested message and replace with 177 // top level ChromeOsImage. 178 message ChromeOSImage { 179 oneof path_oneof { 180 // gs_path_prefix is the GS path to where kernel, rootfs, and stateful 181 // images are located. If DLCs are to be provisioned, it must be a GS path 182 // that also has the dlc directory. 183 // Only gs://chromeos-image-archive bucket is supported. 184 // For example the format should be: 185 // - gs://chromeos-image-archive/eve-release/R86-13380.0.0 186 string gs_path_prefix = 1; 187 } 188 } 189 // image specifies the ChromeOS image with which to provision the DUT. 190 ChromeOSImage image = 2; 191 192 // Reference DLCs developer documentation: 193 // https://source.corp.google.com/chromeos_public/src/platform2/dlcservice/docs/developer.md 194 message DLCSpec { 195 // id is the DLC ID which is a unique identifier. 196 // The DLC ID must follow a specific format that can be found in the DLC 197 // developer doc below. 198 string id = 1; 199 } 200 // dlc_specs specifies which DLCs to install on the DUT after provisioning. 201 repeated DLCSpec dlc_specs = 3; 202 // preserve_stateful specifies whether the stateful partition should be preserved during 203 // provisioning. If preserve_stateful is not set to true, the stateful partition is 204 // block-level wiped and reset during provisioning. 205 bool preserve_stateful = 4; 206} 207 208message ProvisionDutResponse { 209 // When the status code is other than OK, details in Status message should be 210 // parsed for ErrorInfo message with the following Reasons as the reason. 211 enum Reason { 212 // status code: INVALID_ARGUMENT 213 REASON_INVALID_REQUEST = 0; 214 // status code: FAILED_PRECONDITION 215 REASON_DUT_UNREACHABLE_PRE_PROVISION = 1; 216 // status code: FAILED_PRECONDITION 217 REASON_DOWNLOADING_IMAGE_FAILED = 2; 218 // status code: DEADLINE_EXCEEDED 219 REASON_PROVISIONING_TIMEDOUT = 3; 220 // status code: ABORTED 221 REASON_PROVISIONING_FAILED = 4; 222 // status code: ABORTED 223 REASON_DUT_UNREACHABLE_POST_PROVISION = 5; 224 } 225} 226 227message ProvisionDutMetadata { 228} 229 230message ProvisionLacrosRequest { 231 // name is the resource name for the DUT. 232 // The DUT name is passed to the RTD when the RTD is started. 233 // It is not specified whether the name is the DUT hostname. 234 string name = 1; 235 236 message LacrosImage { 237 oneof path_oneof { 238 // gs_path_prefix is the GS path prefix to where Lacros is located. 239 string gs_path_prefix = 1; 240 } 241 } 242 // image specifies the Lacros image with which to provision the DUT. 243 LacrosImage image = 2; 244} 245 246message ProvisionLacrosResponse { 247 // When the status code is other than OK, details in Status message should be 248 // parsed for ErrorInfo message with the following Reasons as the reason. 249 enum Reason { 250 // Failed as the ProvisionLacros request is invalid. 251 REASON_INVALID_REQUEST = 0; 252 // Failed to connect to the DUT prior to provisioning Lacros. 253 REASON_DUT_UNREACHABLE_PRE_PROVISION = 1; 254 // Failed to download the Lacros image or a timeout during download. 255 REASON_DOWNLOADING_IMAGE_FAILED = 2; 256 // Failed due to a timeout during the main Lacros provisioning. 257 // Excludes timeout during other steps. 258 REASON_PROVISIONING_TIMEDOUT = 3; 259 // General failure in Lacros provisioning. 260 REASON_PROVISIONING_FAILED = 4; 261 } 262} 263 264message ProvisionLacrosMetadata { 265} 266 267message FetchCrashesRequest { 268 // dut is the resource name for the DUT from which to fetch crashes. 269 // The DUT name is passed to the RTD when the RTD is started. 270 // It is not specified whether the name is the DUT hostname. 271 string dut = 1; 272 // If true, fetch the core file. 273 // For uploads to the crash server, that should generally be false. 274 // If the crash file is likely to be used for manual debugging (e.g. on 275 // a manually-invoked test suite run), this might be true. 276 // Coredumps can be extremely large (even gigabytes), so if resource usage 277 // is a concern, this should probably be false. 278 bool fetch_core = 2; 279} 280 281// When this response is streamed, the first proto with a given crash ID will 282// always contain the CrashInfo. 283// Files and core dumps (if present) may be streamed. If they are, 284// subsequent protos with the same crash ID will follow, each containing a chunk 285// of file/coredump. To reassemble these, concatenate the bytes received from 286// each subsequent proto with a matching crash_id (concatenate blobs that have 287// matching crash_ids and keys). 288// Additional crashes may be reported in the same stream with a new crash ID. 289message FetchCrashesResponse { 290 // Crash id. unique only within responses to a single FetchCrashes request. 291 // Used to assemble multiple streamed |FetchCrashesResponse| protos into a 292 // single crash report. 293 int64 crash_id = 1; 294 oneof data { 295 // Full details of crash report. 296 CrashInfo crash = 2; 297 // Misc file (e.g. minidump, large binary log, etc) 298 CrashBlob blob = 3; 299 // Coredump. Present iff fetch_core was true in FetchCrashesRequest and 300 // the crash has a coredump. (kernel warnings, for example, do not have 301 // one). 302 bytes core = 4; 303 } 304} 305 306// The data in this proto matches the metadata from crash-reporter's meta files. 307// Sender::CreateCrashFormData puts this data into crash upload POST requests. 308// (See src/platform2/crash-reporter/crash_sender_util.cc.) 309// The names in this proto MUST match the names that crash-reporter uses so 310// that, when crashes are uploaded to the crash server, they are interpreted 311// as they are when crash-reporter uploads them. 312// Similarly, when this proto is converted into a POST request to send to the 313// crash server, the names must not be altered. 314message CrashInfo { 315 // Name of executable that crashed (e.g. "chrome") 316 string exec_name = 1; 317 // Product name (e.g. "Chrome_ChromeOS" or "ChromeOS") 318 string prod = 2; 319 // Product version (e.g. "12345.0.0") 320 string ver = 3; 321 // Crash signature (may not be populated for all crashes) 322 string sig = 4; 323 // The name of the integration test that was running when this crash 324 // happened, if any. 325 string in_progress_integration_test = 5; 326 // The name of the collector (e.g. chrome_collector, arc_collector) 327 string collector = 6; 328 // Additional key-value pairs of metadata (e.g. "crash_loop_mode = true"). 329 // These should be included in any POSTs to the crash server in a standard 330 // POST form, as seen in CreateCrashFormData. 331 // (despite the fact that this message is a subfield, it should be a flat 332 // structure in any POSTs). 333 repeated CrashMetadata fields = 7; 334} 335 336// Arbitrary text-only key-value pair corresponding to the key-value pairs in 337// crash report metadata files. 338message CrashMetadata { 339 // This value is a UTF8, human-readable, description of the data. 340 string key = 1; 341 // The value will be a human-readable string (e.g. "12345.0.0"), which must 342 // be valid UTF-8. 343 string text = 2; 344}; 345 346// Arbitrary non-UTF8 key-value pair from crash report metadata files. 347message CrashBlob { 348 // This value is a UTF8, human-readable, description of the data. 349 // This should be passed as the 'name' to the crash server. 350 // For instance, upload_file_fake_payload 351 string key = 1; 352 // The value is a blob (e.g. a file from sysfs or a minidump), which need 353 // not be valid UTF-8, and may be large. 354 bytes blob = 2; 355 // The basename of the file. Must be specified as the filename in data 356 // uploaded to the crash server. 357 // e.g. foo_binary.20201027.102345.0.dmp 358 string filename = 3; 359}; 360 361message ChromeOsImage { 362 oneof path_oneof { 363 // gs_path_prefix is the GS path to where the payloads are located. For 364 // example the format MAY be: 365 // gs://chromeos-image-archive/eve-release/R86-13380.0.0 366 string gs_path_prefix = 1; 367 } 368} 369 370message FakeOmaha { 371 // name is the resource name of the fake Omaha service. 372 // Format: fakeOmaha/{fake-omaha-id} 373 // The implementation MUST set it after creating the fake Omaha service. 374 // Clients SHOULD NOT set it. 375 string name = 1; 376 // dut is the resource name for the DUT. 377 // The DUT name is passed to the RTD when the RTD is started. 378 // It is not specified whether the name is the DUT hostname. 379 string dut = 2; 380 381 // target_build is the ChromeOS build that the fake Omaha service will serve 382 // payloads for. 383 ChromeOsImage target_build = 3; 384 385 message Payload { 386 enum Type { 387 TYPE_UNSPECIFIED = 0; 388 FULL = 1; 389 DELTA = 2; 390 } 391 // id is the id of the payload. It MAY be "ROOTFS" or a DLC id, etc. 392 string id = 1; 393 // type is the payload type, e.g. TYPE_FULL or TYPE_DELTA. 394 Type type = 2; 395 } 396 // payloads is the payloads can be served by the fake Omaha service. 397 repeated Payload payloads = 4; 398 // exposed_via_proxy indicates that the fake Omaha service is exposed to a 399 // DUT via a proxy server, instead of exposing to the DUT directly. So the 400 // service exposing won't be impacted by rebooting the DUT, disconnecting the 401 // DUT network, etc. 402 bool exposed_via_proxy = 5; 403 // critical_update instructs the fake Omaha created that the update is 404 // critical if set. 405 bool critical_update = 6; 406 // return_noupdate_starting indicates from which update check to start returning noupdate. 407 // It MUST be 0 or greater. 408 // When set to 0 (the default value), disables returning noupdate. 409 // If set to positive N, returns noupdate for the Nth check and for every 410 // check thereafter. 411 // For example, if set to 1, returns noupdate starting from the first check, 412 // i.e., always returns noupdate. 413 int32 return_noupdate_starting = 7; 414 // omaha_url is the current fake Omaha service URL which is reachable from 415 // the specified DUT. 416 // The URL can be used as input of the update engine client of the DUT. 417 // The implementation MUST set it after creating the fake Omaha service. 418 // Clients SHOULD NOT set it. 419 string omaha_url = 8; 420} 421 422message CreateFakeOmahaRequest { 423 // fake_omaha is the fake omaha service to be created. 424 FakeOmaha fake_omaha = 1; 425} 426 427message DeleteFakeOmahaRequest { 428 // The resource name of the fake Omaha service to stop. 429 // Format: fakeOmahaServices/{fake-omaha-id} 430 string name = 1; 431} 432