Skip to content

Ruby integration tests #147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Aug 30, 2022
Merged

Conversation

drdrsh
Copy link
Collaborator

@drdrsh drdrsh commented Aug 26, 2022

We use 4 separate instances of Postgres and use pg_stat_statements to validate Pgcat's routing decisions.

This contains some convenience classes that allows us to control the Pgcat process under test, apply toxics to communication with database and count queries on Postgres side.

Comment on lines 5 to 19
describe "Miscellaneous" do
let(:proxies) { Helpers::Pgcat.single_shard_setup("sharded_db", 5) }

describe "Clients closing connection in the middle of transaction" do
it "sends a rollback to the server" do
conn = PG::connect(proxies.main.connection_string("sharded_db", "sharding_user"))
conn.async_exec("SET SERVER ROLE to 'primary'")
conn.async_exec("BEGIN")
proxies.primary.begin_counting_queries
conn.close
sleep 0.5
# ROLLBACK, DISCARD ALL, SET application_name
expect(proxies.primary.end_counting_queries).to eq(3)
end
end
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be difficult to verify by looking at stats or logs of the main process because we don't increment stats for recovery ROLLBACK.

Putting another proxy between the database and pgcat and inspecting its logs will give us an idea what is actually being sent by the main Pgcat process

@drdrsh drdrsh marked this pull request as ready for review August 26, 2022 17:33
@drdrsh drdrsh closed this Aug 30, 2022
@drdrsh drdrsh reopened this Aug 30, 2022
Copy link
Contributor

@levkk levkk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet!

@levkk levkk merged commit d48c04a into postgresml:main Aug 30, 2022
jmeagher pushed a commit to jmeagher/pgcat that referenced this pull request Feb 17, 2023
Exit with failure codes if configs are bad (postgresml#146)
Move autoreloader to own tokio task (postgresml#148)
Ruby integration tests (postgresml#147)
Allow running integration tests with coverage locally (postgresml#151)
Log Address information in connection create/drop (postgresml#154)
Better handling for checkout errors during extended protocol messages (postgresml#155)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants