Skip to content
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

Add Job that removes old SchemaContract::Validation records #16771

Merged
merged 11 commits into from
May 20, 2024

Conversation

Tonksthebear
Copy link
Contributor

Summary

Schema contract testing creates records that have limited usefulness beyond the initial few days. This adds a job that removes old records from the database

Related issue(s)

department-of-veterans-affairs/va-mobile-app#8177

Testing done

Add test that ensures the job does the correct thing

Screenshots

Note: Optional

What areas of the site does it impact?

(Describe what parts of the site are impacted andifcode touched other areas)

Acceptance criteria

  • I fixed|updated|added unit tests and integration tests for each feature (if applicable).
  • No error nor warning in the console.
  • Events are being sent to the appropriate logging solution
  • Documentation has been updated (link to documentation)
  • No sensitive information (i.e. PII/credentials/internal URLs/etc.) is captured in logging, hardcoded, or specs
  • Feature/bug has a monitor built into Datadog or Grafana (if applicable)
  • If app impacted requires authentication, did you login to a local build and verify all authenticated routes work as expected
  • I added a screenshot of the developed feature

Requested Feedback

(OPTIONAL)What should the reviewers know in addition to the above. Is there anything specific you wish the reviewer to assist with. Do you have any concerns with this PR, why?

@va-vsp-bot
Copy link
Collaborator

Error: A file (or its parent directories) does not have a CODEOWNERS entry. Please update the .github/CODEOWNERS file and add the entry for the Offending file: app/sidekiq/schema_contract/delete_validation_records_job.rb

@va-vsp-bot
Copy link
Collaborator

Error: A file (or its parent directories) does not have a CODEOWNERS entry. Please update the .github/CODEOWNERS file and add the entry for the Offending file: app/sidekiq/schema_contract/delete_validation_records_job.rb

@va-vsp-bot
Copy link
Collaborator

Error: A file (or its parent directories) does not have a CODEOWNERS entry. Please update the .github/CODEOWNERS file and add the entry for the Offending file: app/sidekiq/schema_contract/delete_validation_records_job.rb

@va-vsp-bot
Copy link
Collaborator

Error: A file (or its parent directories) does not have a CODEOWNERS entry. Please update the .github/CODEOWNERS file and add the entry for the Offending file: app/sidekiq/schema_contract/delete_validation_records_job.rb

@va-vfs-bot va-vfs-bot temporarily deployed to delete-old-validation-records/main/main May 15, 2024 18:33 Inactive
@va-vsp-bot
Copy link
Collaborator

Error: A file (or its parent directories) does not have a CODEOWNERS entry. Please update the .github/CODEOWNERS file and add the entry for the Offending file: spec/models/schema_contract/validation_initiator_spec.rb

@Tonksthebear Tonksthebear marked this pull request as ready for review May 16, 2024 16:32
@Tonksthebear Tonksthebear requested review from a team as code owners May 16, 2024 16:32
@va-vfs-bot va-vfs-bot temporarily deployed to delete-old-validation-records/main/main May 16, 2024 16:39 Inactive
@Tonksthebear
Copy link
Contributor Author

I wasn't sure who to put as the code owners. The whole SchemaContract modules are meant to be available to everyone in vets-api so whichever group would be in charge of a cross-team module should be in charge I would think? Happy to change it to whoever is best if I chose the wrong teams

Copy link
Contributor

@kpethtel kpethtel left a comment

Choose a reason for hiding this comment

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

Couple of small suggestions about the specs, but this looks good. IDK how i got away without making the codeowners change. Maybe they tightened up the CI after I did this.

@@ -77,5 +77,21 @@
end.not_to raise_error
end
end

context 'when records exist that are over a month old' do
Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest making two changes:

  • I think this should go in spec/sidekiq/schema_contract/delete_validation_records_job_spec.rb. Doing this will unfortunately be another addition to the codeowners file.
  • rather than check for a change in the records count, I would explicitly check after the perform to ensure that the remaining record is the one we want.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. I was avoiding making a new file but you're right, it should be done properly. I made the changes

@va-vsp-bot
Copy link
Collaborator

Error: A file (or its parent directories) does not have a CODEOWNERS entry. Please update the .github/CODEOWNERS file and add the entry for the Offending file: spec/sidekiq/schema_contract/delete_validation_records_job_spec.rb

@va-vfs-bot va-vfs-bot temporarily deployed to delete-old-validation-records/main/main May 16, 2024 23:04 Inactive
kpethtel
kpethtel previously approved these changes May 17, 2024
Copy link
Contributor

@kpethtel kpethtel left a comment

Choose a reason for hiding this comment

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

Thanks for creating the new spec file.

end

context 'when records exist that are over a month old' do
before do
Copy link
Contributor

Choose a reason for hiding this comment

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

I would generally recommend using let over ivars in rspec. For a case like this, you could use let! to achieve the same effect as a before block.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, didn't know let! would do what I wanted. I did let and it didn't work, so TIL. Changed!

rjohnson2011
rjohnson2011 previously approved these changes May 17, 2024
@Tonksthebear Tonksthebear dismissed stale reviews from rjohnson2011 and kpethtel via 693ebfd May 17, 2024 18:32
Copy link
Contributor

@kpethtel kpethtel left a comment

Choose a reason for hiding this comment

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

👍

@Tonksthebear Tonksthebear merged commit a979e1a into master May 20, 2024
19 checks passed
@Tonksthebear Tonksthebear deleted the delete-old-validation-records branch May 20, 2024 19:07
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.

None yet

6 participants