Crate lava_api_mock
source ·Expand description
This crate provides a set of types for constructing mock servers providing the LAVA REST API with generated data.
Overview
The main types in a Lava database have types in this crate:
Alias
Architecture
BitWidth
Core
Device
DeviceType
Group
Job
ProcessorFamily
Tag
TestCase
TestSet
TestSuite
User
Worker
There is a container type State
which implements
Context
from the
persian-rug
crate. All types are
GeneratableWithPersianRug
and BuildableWithPersianRug
which are from the boulder
crate.
LavaMock
Most users will want to base their tests around LavaMock
,
which is a django-query
derived server, which
provides all of the v0.2 query REST endpoints of a standard Lava
server. See the documentation for details of its limitations. The
data it serves comes from a SharedState
(a synchronised
wrapper over a State
) which can both be populated with default
data as a starting point, and also updated on the fly to simulate
whatever update pattern is desired.
Example:
use futures::stream::TryStreamExt;
use lava_api_mock::{LavaMock, PaginationLimits, PopulationParams, SharedState};
use lava_api::Lava;
// Make the mock server
let limits = PaginationLimits::new();
let population = PopulationParams::new();
let mock = LavaMock::new(SharedState::new_populated(population), limits).await;
// Make the Lava client for reading back data from the server
let lava = Lava::new(&mock.uri(), None).expect("failed to make lava client");
// Read back the devices using the Lava client
let mut ld = lava.devices();
while let Some(device) = ld
.try_next()
.await
.expect("failed to read devices from server")
{
println!("Got device {:?}", device);
}
Structs
- An alias from the LAVA API
- An architecture from the LAVA API
- A bit width from the LAVA API
- A core from the LAVA API
- A device from the LAVA API.
- A device type from the LAVA API
- A group in the LAVA API
- A job from the LAVA API
- A mock server that provides access to a
SharedState
. - A representation of the metadata for a test case.
- Pagination limits for constructing a
LavaMock
instance. - Initial population sizes for the data in a
State
- A processor family from the LAVA API
- A thin wrapper around
State
for shared access. - The data backing a mock Lava instance
- A tag in the LAVA API
- A test from the LAVA API.
- A set of tests from the LAVA API.
- A suite of tests from the LAVA API.
- A user in the LAVA API
- A worker in the LAVA API
Enums
- The health status of a
Device
from the LAVA API. - The state of a
Device
from the LAVA API. - The health (i.e. completion type) of a
Job
in the LAVA API - The state (i.e. progress) of a
Job
in the LAVA API - A test result from the LAVA API