Skip to content

Add a simplified central object to act as porcelain for the mock#10

Draft
eds-collabora wants to merge 4 commits intocollabora:mainfrom
eds-collabora:eds/porcelain
Draft

Add a simplified central object to act as porcelain for the mock#10
eds-collabora wants to merge 4 commits intocollabora:mainfrom
eds-collabora:eds/porcelain

Conversation

@eds-collabora
Copy link
Copy Markdown
Contributor

This is a draft from the former location of lava-api; it's been parked for a long time, and may need some freshening up. There may be unaddressed feedback from previous iterations of this PR at present.

The old MR description is below, and is likely in need of cleanup.

This contains essentially one reworked full-size test, in
lava-api/src/job.rs (test_basic), plus a much smaller, specific test
in test_basic_porcelain.
The porcelain object itself is another layer on top of the lava
mock. It incorporates a SimClock, which is often what you want for
reliable, sensible testing of time behaviour (where the time is
whatever you say it is).
The main inelegancies here:

The proxy interface is optional until it isn't: there's no
disguising that once you got hold of an object, it contains proxies.

There's very limited customisation, and it bridges poorly with other
ways of constructing more customised options. It effectively
functions as a simplified mode, with no clean escapes to "advanced"
mode.

Because you do not have a context for accessing data in the shared
state, you always have to poke whatever you want to poke from within
a lambda.

The job interface is incomplete; the idea is to be able to push a job
along as desired just by calling the lifecycle methods on the
porcelain object.
Two sets of generators are maintained. The first generators are used
when calling add_job and friends, to populate the vast majority of the
fields in the job object itself. The second bank of generators (bulk_)
are used when generating large numbers of items at once. In this case,
there are no available fields from the user at all, so the generator
needs to fill in additional data (and filling in that data can have
side effects, which is why we don't fill in and overwrite).

This was previously the central object in the API, and it's still
usable as such (in a more flexible mode). But we're about to add a
simplified and more streamlined central object, so we need to rename
this one. It functions as a wiremock server object, so Server makes
sense as the new name.

Signed-off-by: Ed Smith <ed.smith@collabora.com>
This is a separate commit because it significantly improves git's
ability to reason about the rename.

Signed-off-by: Ed Smith <ed.smith@collabora.com>
The new LavaMock provides much more functionality than the previous
one (which is now called Server). It encapsulates four key objects for
creating test simply, as well as a simplified interface for creating
jobs and devices:

- The Server that provides the data.
- The SharedState which holds the mock data.
- The Clock which the mock object uses.
- A set of Generator instances to create new objects.

Signed-off-by: Ed Smith <ed.smith@collabora.com>
This shortens and simplifies many of the tests.

Signed-off-by: Ed Smith <ed.smith@collabora.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant