-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(snapshot): major improvements (#15350)
# Analyses Snapshot Improvements GitHub cannot handle the diff so review locally. - [x] change the package name from app-testing -> analyses-snapshot-testing - [x] add 2.18 protocols - [x] add 2.19 protocols - [x] add snapshots for the newly added protocols (2.18, 2.19, Protocol Library Protocols) - [x] alter all snapshots now that custom labware only shows up in the snapshot if the protocol has custom labware - [x] remove the use of .env - [x] improve Makefile and define all environment variables explicitly there - [x] re-write README - [x] create a custom snapshot extension - [x] replace parts of strings that cause unnecessary diffs like traceback line and moduleId exposed in a detail string - [x] add back key as it should not change - [x] replace the value of all uuid fields with the string 'UUID' - [x] replace the value of all timestamp fields with 'TIMESTAMP'
- Loading branch information
Showing
384 changed files
with
2,395,470 additions
and
262,862 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Analyses Generation and Snapshot Testing | ||
|
||
## Setup | ||
|
||
1. Follow the instructions in [DEV_SETUP.md](../DEV_SETUP.md) | ||
1. `cd analyses-snapshot-testing` | ||
1. use pyenv to install python 3.12 and set it as the local python version for this directory | ||
1. `make setup` | ||
1. Have docker installed and ready | ||
|
||
## Concepts | ||
|
||
- If working locally the branch you have checked out is the test code/snapshots you are working with. | ||
- In CI this is the `SNAPSHOT_REF`. This is the branch or tag of the test code/snapshots that analyses generated will be compared to. | ||
- The `ANALYSIS_REF` is the branch or tag that you want analyses generated from. | ||
|
||
## Running the tests locally | ||
|
||
- Compare the current branch snapshots to analyses generated from the edge branch | ||
- `make build-opentrons-analysis ANALYSIS_REF=edge` this builds a docker image named and tagged `opentrons-analysis:edge` | ||
- this pulls the latest edge every time it builds! | ||
- `make snapshot-test ANALYSIS_REF=edge` | ||
- This runs the test. The test: | ||
- Spins up a container from the `opentrons-analysis:edge` image. ANALYSIS_REF=edge specifies the image to use. | ||
- Analyses as .json files are generated for all protocols defined in [protocols.py](./automation/data/protocols.py) and [protocols_with_overrides.py](./automation/data/protocols_with_overrides.py) | ||
- the test compares the generated analyses to the snapshots in the [./tests/**snapshots**/](./tests/__snapshots__/) directory | ||
|
||
## Updating the snapshots | ||
|
||
- Assuming you have already built the `opentrons-analysis:edge` image | ||
- `make snapshot-test-update ANALYSIS_REF=edge` | ||
- This will update the snapshots in the [./tests/**snapshots**/](./tests/__snapshots__/) directory with the analyses generated from the edge branch | ||
|
||
## Running the tests against specific protocols | ||
|
||
> We are omitting ANALYSIS_REF=edge because we can, it is the default in the Makefile | ||
- `make snapshot-test PROTOCOL_NAMES=Flex_S_v2_19_Illumina_DNA_PCR_Free OVERRIDE_PROTOCOL_NAMES=none` | ||
- `make snapshot-test PROTOCOL_NAMES=none OVERRIDE_PROTOCOL_NAMES=Flex_X_v2_18_NO_PIPETTES_Overrides_BadTypesInRTP` | ||
- `make snapshot-test PROTOCOL_NAMES="Flex_S_v2_19_Illumina_DNA_PCR_Free,OT2_S_v2_18_P300M_P20S_HS_TC_TM_SmokeTestV3" OVERRIDE_PROTOCOL_NAMES=none` |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
54 changes: 54 additions & 0 deletions
54
analyses-snapshot-testing/automation/data/protocol_registry.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from typing import Optional | ||
|
||
from automation.data.protocol import Protocol | ||
from automation.data.protocol_with_overrides import ProtocolWithOverrides | ||
from automation.data.protocols import Protocols | ||
from automation.data.protocols_with_overrides import ProtocolsWithOverrides | ||
|
||
ALL_PROTOCOLS = "all" | ||
|
||
|
||
class ProtocolRegistry: | ||
def __init__(self, protocol_names: str = ALL_PROTOCOLS, override_protocol_names: str = ALL_PROTOCOLS) -> None: | ||
self.protocols: Protocols = Protocols() | ||
self.protocols_with_overrides: ProtocolsWithOverrides = ProtocolsWithOverrides() | ||
self.protocol_names = protocol_names | ||
self.override_protocol_names = override_protocol_names | ||
self.protocols_to_test: Optional[list[Protocol]] = self._what_protocols() | ||
|
||
def _what_protocols(self) -> Optional[list[Protocol]]: | ||
protocols_to_test: list[Protocol] = [] | ||
|
||
if self.protocol_names.lower() == ALL_PROTOCOLS: | ||
protocols_to_test.extend(self.all_defined_protocols()) | ||
elif self.protocol_names.lower() == "none": | ||
pass | ||
else: | ||
for protocol_name in [x.strip() for x in self.protocol_names.split(",")]: | ||
protocol: Protocol = getattr(self.protocols, protocol_name) # raises | ||
protocols_to_test.append(protocol) | ||
|
||
if self.override_protocol_names.lower() == ALL_PROTOCOLS: | ||
protocols_to_test.extend(self.all_defined_protocols_with_overrides()) | ||
elif self.override_protocol_names.lower() == "none": | ||
pass | ||
else: | ||
for protocol_with_overrides__name in [x.strip() for x in self.override_protocol_names.split(",")]: | ||
protocol_with_overrides: ProtocolWithOverrides = getattr( | ||
self.protocols_with_overrides, protocol_with_overrides__name | ||
) # raises | ||
if protocol_with_overrides.protocols is not None: | ||
protocols_to_test.extend(protocol_with_overrides.protocols) | ||
if protocols_to_test == []: | ||
return None | ||
return protocols_to_test | ||
|
||
def all_defined_protocols(self) -> list[Protocol]: | ||
return [getattr(self.protocols, prop) for prop in dir(self.protocols) if "__" not in prop] | ||
|
||
def all_defined_protocols_with_overrides(self) -> list[Protocol]: | ||
protocols_with_overrides = [ | ||
getattr(self.protocols_with_overrides, prop) for prop in dir(self.protocols_with_overrides) if "__" not in prop | ||
] | ||
# Flatten the list of lists into a single list of protocols | ||
return [protocol for protocol_with_overrides in protocols_with_overrides for protocol in protocol_with_overrides.protocols] |
File renamed without changes.
Oops, something went wrong.