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:

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§

Alias
An alias from the LAVA API
Architecture
An architecture from the LAVA API
BitWidth
A bit width from the LAVA API
Core
A core from the LAVA API
Device
A device from the LAVA API.
DeviceType
A device type from the LAVA API
Group
A group in the LAVA API
Job
A job from the LAVA API
JunitEndpoint
LavaMock
A mock server that provides access to a SharedState.
Metadata
A representation of the metadata for a test case.
PaginationLimits
Pagination limits for constructing a LavaMock instance.
PopulationParams
Initial population sizes for the data in a State
ProcessorFamily
A processor family from the LAVA API
SharedState
A thin wrapper around State for shared access.
State
The data backing a mock Lava instance
Tag
A tag in the LAVA API
TestCase
A test from the LAVA API.
TestSet
A set of tests from the LAVA API.
TestSuite
A suite of tests from the LAVA API.
User
A user in the LAVA API
Worker
A worker in the LAVA API

Enums§

DeviceHealth
The health status of a Device from the LAVA API.
DeviceState
The state of a Device from the LAVA API.
JobHealth
The health (i.e. completion type) of a Job in the LAVA API
JobState
The state (i.e. progress) of a Job in the LAVA API
PassFail
A test result from the LAVA API

Functions§

junit_endpoint