-
Notifications
You must be signed in to change notification settings - Fork 193
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
EKS Upgrade Testing Plan: Step 3: Establish automation connectivity between vets-api & Postgres/RDS #74637
Comments
Here are some ideas on how to test the Postgres connection in the rails console.
This tests whether the connection to the database is currently open and active.
irb(main):014* ProductDirectory::TeamMember.transaction do
irb(main):015* first = ProductDirectory::TeamMember.first
irb(main):016* first.update(first_name: 'nothing')
irb(main):017* raise ActiveRecord::Rollback # Forces a rollback
irb(main):018> end I then ran |
@rmtolmach On top of adding these checks, we will want to automate calling the endpoint (we were thinking of extending /v0/status or maybe make a new endpoint) but we will want to have automation in place to call this endpoint and report back any failures. I could see a synthetic, cronjob, k8s healthcheck, etc. I could also see breaking this ticket up into two pieces 1) Getting the check in place 2) automating the check and reporting failures |
For step 3 in my previous comment, I've tried it in vets-api console. Looks good. And per Lindsey's comment in Slack, I created a user first and then updated it before rolling back. This is because we could be testing this against an empty database. irb(main):016* UserAccount.transaction do
irb(main):017* icn = "abc123"
irb(main):018* UserAccount.create!(icn:)
irb(main):019* user = UserAccount.find_by(icn:)
irb(main):020* user.update(icn:"xyz789")
irb(main):021* raise ActiveRecord::Rollback
irb(main):022> end
2024-04-30 17:28:34.170502 D [94213:12160 log_subscriber.rb:167] ActiveRecord::Base -- TRANSACTION (0.1ms) BEGIN
2024-04-30 17:28:34.172003 D [94213:12160 log_subscriber.rb:167] ActiveRecord::Base -- UserAccount Exists? (1.7ms) SELECT 1 AS one FROM "user_accounts" WHERE "user_accounts"."icn" = $1 LIMIT $2 [["icn", "abc123"], ["LIMIT", 1]]
2024-04-30 17:28:34.172750 D [94213:12160 log_subscriber.rb:167] ActiveRecord::Base -- UserAccount Create (0.3ms) INSERT INTO "user_accounts" ("icn", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["icn", "abc123"], ["created_at", "2024-04-30 21:28:34.172192"], ["updated_at", "2024-04-30 21:28:34.172192"]]
2024-04-30 17:28:34.173240 D [94213:12160 log_subscriber.rb:167] ActiveRecord::Base -- UserAccount Load (0.1ms) SELECT "user_accounts".* FROM "user_accounts" WHERE "user_accounts"."icn" = $1 LIMIT $2 [["icn", "abc123"], ["LIMIT", 1]]
2024-04-30 17:28:34.173802 D [94213:12160 log_subscriber.rb:167] ActiveRecord::Base -- UserAccount Exists? (0.1ms) SELECT 1 AS one FROM "user_accounts" WHERE "user_accounts"."icn" = $1 AND "user_accounts"."id" != $2 LIMIT $3 [["icn", "xyz789"], ["id", "e550e650-4a9f-403b-8042-15e3125a7246"], ["LIMIT", 1]]
2024-04-30 17:28:34.174386 D [94213:12160 log_subscriber.rb:167] ActiveRecord::Base -- UserAccount Update (0.2ms) UPDATE "user_accounts" SET "icn" = $1, "updated_at" = $2 WHERE "user_accounts"."id" = $3 [["icn", "xyz789"], ["updated_at", "2024-04-30 21:28:34.173934"], ["id", "e550e650-4a9f-403b-8042-15e3125a7246"]]
2024-04-30 17:28:34.174678 D [94213:12160 log_subscriber.rb:167] ActiveRecord::Base -- TRANSACTION (0.1ms) ROLLBACK
=> nil
irb(main):023> |
Rake task that tests the three scenarios for postgres connectivity: file on my branch. Alternatively, here's the diff for easier commenting. @LindseySaari I'm having trouble understanding how a new endpoint fits in with all of this. I might need to meet with you to get it explained. |
Per @RachalCassity ActiveRecord::Base.connection.active? |
|
I made some changes to the PR: I abandoned the rake task and moved the logic into a controller and returned true or false, so when we hit v0/status, it returns true/false.
I added a validation step that can be done after merge into dev. |
Validation: {"git_revision":"4707c1ad030687f440a91f31df4b7eda02bc6877","db_url":null,"postgres_up":true} Per Rachal's suggestion, I changes the logging to be at the Closing. |
Vets-API is undergoing an EKS upgrade. As part of the process, it is necessary to conduct comprehensive testing on various components of Vets-API to ensure seamless functionality and performance during the upgrade.
From the EKS Testing Proposal:
This ticket covers step three of testing plan linked in the doc above–Establish automation connectivity between vets-api and Postgres/RDS
NOTE: Make sure that this testing is coordinated with @ph-One in the Infra team prior to testing.
Tasks
Things to consider:
Success Metrics
Acceptance Criteria
Validation
postgres_up
key and value.The text was updated successfully, but these errors were encountered: