Граф коммитов

61 Коммитов

Автор SHA1 Сообщение Дата
Barret Rennie f2d656a851
Cleanup completed resumed requests
The runner now will cleanup resumed requests as they are completed
(either successfully or unsucessfully). Additionally, the
`FsRequestManager` will cleanup any requests that it cannot resume.
2020-07-20 15:11:24 -04:00
Barret Rennie c24f5504cf
Clean up failed requests
If a request fails before the runner restarts, we now clean up any
downloaded files (Firefoxen, profiles, etc).
2020-07-20 15:11:24 -04:00
Barret Rennie d721ac8d49
Do not use a temporary directory for request state 2020-07-20 15:11:23 -04:00
Barret Rennie 956134e419
Update all integration tests to use a RequestManager 2020-07-20 15:11:23 -04:00
Barret Rennie 9493e0dcf8
Use the RequestManager in the RunnerProto 2020-07-20 15:11:23 -04:00
Barret Rennie 72690be455
Add RequestManager for creating and resuming requests 2020-07-20 15:06:50 -04:00
Barret Rennie b67cbed24f
Propagate errors in profile creation to recorder 2020-07-17 15:30:19 -04:00
Barret Rennie 7f5bb6596b
Allow multiline docs on message members
The
2020-07-17 15:30:18 -04:00
Barret Rennie 4ebed9f585
Fix features in libfxrecord for tokio
Adding these missing features allows `cargo test -p libfxrecord` to run
successfully.
2020-07-07 19:09:15 -04:00
Barret Rennie c74be2de74
Fix cargo clippy lints 2020-07-07 19:09:15 -04:00
Barret Rennie b1f22151ae
Use Wait instead of bool in integration tests
The previous changes that replaced the `bool` arugment in
`RecorderProto::SendResumeRequest` with a `Wait` enum did not update the
integration tests.
2020-07-07 19:03:00 -04:00
Barret Rennie b07d29ed77
Update libfxrecord to use thiserror
We are not able to fully remove `derive_more` becuase we use the Display
derive in `libfxrecord::net::message` to generate Display impls for
message kinds and the `DownloadStatus` enum.
2020-06-29 23:32:16 -04:00
Barret Rennie 8ef6d8106a
Update fxunner to use thiserror 2020-06-29 23:32:16 -04:00
Barret Rennie 853891d506
Update fxrecorder to use thiserror 2020-06-29 23:32:15 -04:00
Barret Rennie b91c0418d3
Add a --skip-idle flag to fxrecoder
This flag will instruct the recorder to not wait for the runner to
become idle before running Firefox.
2020-06-29 23:30:52 -04:00
Barret Rennie 68567c677d
Assert cpu_and_disk_idle called in integration tests
The AssertInvoked test utility ensures that, when it is dropped, if it
was supposed to be marked as invoked that it is. This is used to ensure
that `cpu_and_disk_idle` is called (or not called) during integration
tests.
2020-06-29 23:30:52 -04:00
Barret Rennie 919b346aeb
Support not waiting for idle in protocol 2020-06-29 23:30:51 -04:00
Barret Rennie 42709e024f
Rewrite integration tests 2020-06-28 21:24:11 -04:00
Barret Rennie 2452dc1236
Pass directory into RunnerProto::handle_request
We pass the working directory into `RunnerProto::handle_request` so that
we can test the contents of the temporary directory before it is
removed.
2020-06-28 21:24:11 -04:00
Barret Rennie ccc54c6e4a
Rewrite Taskcluster as a Trait and impl
What was previously the `Taskcluster` struct is now the `Taskcluster`
trait and `FirefoxCi` struct, which implements that trait. This allows
us to only require testing the HTTP requests in our unit tests and
completely mock them out in integration tests, saving on test verbosity.

The `Taskcluster` trait is generic over an `Error` type, allowing for
easier mocking. The type that was `TaskclusterError` is now
`FirefoxCiError` (as it an implementation detail).

The `RunnerProtoError` is now generic over implementations of the
`Taskcluster` trait, again for easier mocking.
2020-06-28 21:24:11 -04:00
Barret Rennie 3244aec4b0
Expose only a static interface to RunnerProto
The RunnerProto only exposed only a single method: `handle_request`.
This interface has now been made a static function, replacing the
pattern of `RunnerProto::new().handle_request()` with
`RunnerProto::handle_request`.
2020-06-28 21:24:10 -04:00
Barret Rennie 4870a145c8
Make protocol less noisy
Instead of the recorder constantly sending messages to the runner, it
now sends a single `Request` message and receives a series of responses
from the runner.

Tests will be fixed in a later commit.

Received profiles, prefs, and Firefox builds are not presently persisted
through restarts. This will be fixed in an upcoming patch.

The protocol docs no longer match what happens, so they've been removed
for now.
2020-06-28 21:24:06 -04:00
Barret Rennie 54483275ae
Document the WaitForIdle protocol phase 2020-06-28 21:14:51 -04:00
Barret Rennie 55fe2c23b6
Document legacy IO counter requirement for fxrunner 2020-06-28 21:14:51 -04:00
Barret Rennie 83aa038edf
Wait for disk and CPU to become idle on fxrunner
As part of the protocol, fxrecorder will now wait for fxrunner's cpu and
disk to become idle before it starts Firefox.
2020-06-28 21:14:50 -04:00
Barret Rennie 151adeaa17
Split out integration tests mocks into a module 2020-06-28 21:14:50 -04:00
Barret Rennie e3f6b27753
Parameterize RunnerProtoError over ShutdownProvider
Instead of being generic over `S: Error + 'static`, the
`RunnerProtoError` type is now generic over `S: ShutdownProvider` and we
can use `S::Error` inside its definition, instead of instantiating it
from the `RunnerProto<S>` with `S::Error` directly.

This is a little cleaner and more readable, but does have a side effect
that requires `ShutdownProvider: Debug`.

This is in preparation for adding another generic parameter to
`RunnerProtoError`, making it generic over errors from the
`PerfProvider`. Without this change, it would require being generic over
both of the `PerfProvider`'s error types (`PerfProvider::DiskIoError`
and `PerfProvider::CpuTimeError`), making the types longer and messier.
2020-06-28 21:14:50 -04:00
Barret Rennie ad51b08f31
Implement disk and CPU performance API
We can now wait for the disk and CPU to settle out to acceptable levels
for our performance tests. LIke the `ShutdownProvider` API, the
`PerformanceProvider` API is implemented as a trait so that it can be
replaced for integration tests.
2020-06-28 21:14:39 -04:00
Barret Rennie e713725461
Rename libfxrunner::shutdown to libfxrunner::osapi
The `shutdown` module has been lightly refactored into an `osapi`
module. The error utilities (`WindowsError` and `get_last_error`) have
been refactored into the `osapi::error` module and the `Handle` API has
been refactored into the `osapi::handle` module.
2020-06-25 01:22:04 -04:00
Barret Rennie af6c815e80
Document the SendPrefs phase 2020-06-25 01:20:34 -04:00
Barret Rennie ebb89065fd
Send prefs from the recorder to the runner
The recorder now accepts prefs via the command-line, which will be sent
to the runner. If a profile was sent to the runner, that profile's
`user.js` will be appended with these new prefs. Otherwise, a new
profile will be used and these prefs will be written to that profile's
`user.js` instead.
2020-06-25 01:20:32 -04:00
Barret Rennie 7f0485bc70
Document the SendProfile phase 2020-06-25 01:20:28 -04:00
Barret Rennie d771f8362d
Send a profile from the recorder to the runner
The recorder can now specify a zipped Firefox profile for the runner to
use when running Firefox, which will be transferred from the recorder to
the runner.
2020-06-25 01:20:22 -04:00
Barret Rennie 5cc0de6cde
Add documentation for the DownloadBuild phase 2020-06-24 19:50:11 -04:00
Barret Rennie 66d61ecd99
Extract downloaded archives
The build artifacts from Taskcluster are zip archives, which are now
extracted as part of the download.
2020-06-24 19:50:10 -04:00
Barret Rennie 3795da5556
Request build downloads from Taskcluster
The recorder will now request the runner download a specific build of
Firefox. A Taskcluster task ID for a build task is accepted by the
recorder on the command-line, which is used to determine the task to
download.
2020-06-24 19:50:07 -04:00
Barret Rennie e217c1820e
Add an API for interacting with Taskcluster
The runner now has an API for interacting with Taskcluster. Network
requests are run against a local server during unit tests so that they
do not require Internet access (or a valid Taskcluster setup) to run.
2020-06-24 19:17:49 -04:00
Barret Rennie ab1c20557d
Add high-level documentation about the protocol 2020-06-23 21:44:14 -04:00
Barret Rennie e61b0c7493
Thorougly test integration between runner and recorder
The interface between the `RunnerProto` and `RecorderProto` has been
more thoroughly tested for the handshake protocol. The infrastructure
added to accomplish this should make adding more tests easier as more of
the protocol is implemented.
2020-06-23 21:44:14 -04:00
Barret Rennie 73961e96c3
Use the Windows shutdown implementation when restarting
The fxrunner has a `--skip-restart` flag that is only provided in debug
builds that allows it to skip doing an actual restart for local
development and testing.
2020-06-23 21:44:14 -04:00
Barret Rennie 1f24929893
Request a restart from the runner
fxrecorder will now request fxrunner to restart, wait, and re-connect.
This is accomplished with a exponential-backoff retrying algorithm.
The runner doesn't actually restart yet; instead, it just disconnects
from the recorder and sleeps for a duration.
2020-06-23 21:44:09 -04:00
Barret Rennie 482f734a54
Implement shutdown using the Windows API
This is implemented as a trait so that it can be swapped out for a mock
version in integration tests that does not require a full restart.
2020-06-23 21:39:36 -04:00
Barret Rennie fd965997a5
Add an integration test for the handshake 2020-06-16 00:24:19 -04:00
Barret Rennie fb0966ec71
Mark code sample in config.rs as text
This code sample is an command to find the name of the video device,
but `cargo test` was interpreting as a test. This was never caught until
now because there haven't been tests.
2020-06-16 00:24:19 -04:00
Barret Rennie 4d8cd85394
Split fxrunner and fxrecorder into lib and bin
The main implementations of both fxrecorder and fxrunner have been split
into libraries which the binaries call into. This will enable
integration tests between the protocols.
2020-06-16 00:24:18 -04:00
Barret Rennie be29d2c9f2
Handshake between the runner and recorder
The runner and recorder are now networked. The runner sets up a TCP
server and listens for incoming connections. The recorder connects to
the runner.

The bulk of this change is implementing the datatypes for messages and
protocols.

The `Proto` struct represents a protocol, which provides a way to send
and receive typed messages across a TCP socket. The `RunnerProto` and
`RecorderProto` are specializations of this type that implement that
actual business logic of sending and receiving messages in a certain
order for `fxrecorder` and `fxrunner` respectively.

Messages are the actual data sent across the socket. They are encoded by
the Proto as length-prefixed JSON blobs for transfer. There are two
types of messages:

1. `RecorderMessage`, which is sent from `fxrecorder` to `fxrunner`.
2. `RunnerMessage`, which is sent from `fxrecorder` to `fxrunner`.

Each type of message implements the `Message` interface, which allows
discriminationg between them with the `Message::kind()` method (and
imposes the serialization and deserialization constraints).

Message types are generated by the `impl_message!` and
`impl_message_inner!` macros to avoid writing boilerplate for each
message type.
2020-06-11 14:27:10 -04:00
Barret Rennie 7a0ceb3ae2
Add an error message type
The `ErrorMessage` type allows for `String` error messages (or anything
that implements `Display`, e.g. `&'static str`), which is useful for
representing errors in `fxrecorder` from `fxrunner` that cannot
otherwise be serialized over the network (e.g., `std::io::Error`).
2020-06-11 14:27:09 -04:00
Barret Rennie c643fef45c
Correctly depend on tokio and futures in libfxrecord
These changes got rolled up into the tarpc patch (1125430, which has now
been reverted) instead of the previous patch (049619b), which made `run`
async.
2020-06-03 16:48:00 -04:00
Barret Rennie 4564f2ccae
Revert "Use tarpc for RPC between fxrecorder and fxrunner"
This reverts commit 11254300fd.

As it turns out, tarpc cannot do what we need to do, vis-a-vis being
able to shutdown the server cleanly without causing errors on the client
side to reboot, as well as requiring a lot of state to be `Sync` (i.e.,
behind a `Rc<Mutex<T>>` or similar) for requests that will only ever
happen sequentially.
2020-06-03 16:41:30 -04:00
Barret Rennie 11254300fd
Use tarpc for RPC between fxrecorder and fxrunner
We now use the `tarpc` crate to allow fxrecorder to communicate with
fxrunner. The protocol is defined in `libfxrecord::service` and defines
a single method: `request_restart` (which is currently a no-op).
2020-05-26 01:36:55 -04:00