Add playback tests; test against executable servers#516
Merged
Conversation
Pylance shows a type error for passing a string into cursor.execute and other methods, which are typed expecting psycopg.sql.SQL or variants. Also, sql.SQL is typed as a Literal[string], and so type errors would occur for non-literal strings. This change pushes the # type:ignore to a single place and uses the as_sql method to convert from str -> sql.SQL.
Some message IDs are ints, this was discovered during recording/playback
This file encodes the Language Server Protocol (LSP) into pydantic models. While these classes could replace JSONRPCMessage, this refactor is left as future work. These models are used for message recording and testing purposes for now.
Also better deserialization error handling.
This allows other implementations of RPC servers, such as a queue-based server that will be used in testing.
This list of services can now be used in testing.
This allows more explicit typing for outbound messages.
This will allow us to test recorded sessions against a fresh database.
This will allow us to load known datasets into tests. Adds the pagila dataset.
This creates a testable client to send messages to a server and await messages from it. It can be used with a Queue-based message server to produce an in-process message server, and will also be able to handle running bundled EXE rpc servers for additional testing.
Use MockMessageServerClientWrapper in tests. Fixtures for loading datasets into the integration test database, along with the PlaybackDB which uses a new docker container running at port 5678 to isolate database initialization for repeatable playback testing.
This test will work against a built server as a simple smoke test to ensure it runs successfully
Also added docker-compose.recording.yml and scripts/load_test_data.sh for recording playback and loading test data into development environment.
mmcfarland
approved these changes
Feb 25, 2025
Member
mmcfarland
left a comment
There was a problem hiding this comment.
Small typos, but looks great. Ran through and executed the tests, also recorded my own new smoke test file and added passing tests. The whole thing is pretty nifty, honestly.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds way to record messages received and sent by the PGTS server, and to play back those messages to test they produce the same results.
It also enables the client wrapper around a message server to be used against an executable, which allows us to test built pgtoolsservice executables.
It also adds the concept of
Datasetsfor tests, which can be loaded into the database temporary for testing purposes. The pagila dataset is included.Also includes some refactors and improvements. See commits for individual changes.