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

A script to identify invalid clusters in Print Holdings MongoDB #291

Merged
merged 1 commit into from
Oct 13, 2023

Conversation

mwarin
Copy link
Contributor

@mwarin mwarin commented Oct 10, 2023

Overview

What is it? A script to identify the clusters in the Print Holdings MongoDB that are invalid. Clusters are the main organizing unit in this database. I would like to run this regularly, perhaps together with the db backup.

Why is it? An invalid cluster doesn't let you save any information on it, until you make it valid. We currently don't have good insight into this, and that could become a problem. It may in fact already be a problem and we just don't know. I'm also going to be doing stuff to the schema, which is one of the ways you can end up with invalid clusters, so that's why now.

How big is it? The diff size may look big, but when you break it down it's:

  • 1 file of code: bin/cluster_validator.rb
  • 1 file of tests: spec/cluster_validator_spec.rb
  • 2 fixture files: spec/fixtures/single_cluster_invalid.json & spec/fixtures/single_cluster_valid.json

The fixture files are identical except for a single field (commitment.phase). The valid file has a 1 (valid phase), the invalid 999 (invalid phase). Why is this? Well, it's hard to make existing clusters invalid by just manipulating them, because the existing validations stop you from setting invalid values. However, data that are loaded directly into the db bypass these validations. The spec file uses the cluster-file loader to get valid/invalid clusters loaded, so it can perform tests on invalid clusters.

Instead of putting this in #286 (which is already large) I broke this out into its own PR.

What kind of feedback am I looking for?

Just a general look at the validator and it's spec. It's all new code, so there isn't any tangle.

Testing

The tests run fine on github but if you want to run them yourself it is:

  1. git clone this repo
  2. git checkout this branch
  3. Spin it up and enter its shell:
bash bin/setup/setup_dev.sh
docker-compose up -d pushgateway
docker-compose run --rm -e MONGOID_ENV=test dev bash
  1. $ bundle exec rspec spec/cluster_validator_spec.rb
  2. $ exit
  3. $ docker-compose down

@coveralls
Copy link

coveralls commented Oct 11, 2023

Coverage Status

coverage: 95.034% (+0.02%) from 95.011% when pulling 16eebf7 on cluster-validator into 65963cc on main.

@mwarin mwarin force-pushed the cluster-validator branch from 3f08b92 to f3f7a3a Compare October 12, 2023 21:54
@mwarin mwarin changed the title A script to check which clusters are invalid in Print Holdings A script to check invalid clusters in Print Holdings MongoDB Oct 13, 2023
@mwarin mwarin force-pushed the cluster-validator branch from 74af8ae to b127e08 Compare October 13, 2023 14:39
@mwarin mwarin changed the title A script to check invalid clusters in Print Holdings MongoDB A script to identify invalid clusters in Print Holdings MongoDB Oct 13, 2023
@mwarin mwarin requested review from aelkiss and moseshll October 13, 2023 14:54
@mwarin mwarin marked this pull request as ready for review October 13, 2023 14:55
bin/cluster_validator.rb Outdated Show resolved Hide resolved
Copy link
Member

@aelkiss aelkiss left a comment

Choose a reason for hiding this comment

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

Makes sense; all looks pretty straightforward. Main question is if the buffering is necessary or not.

@mwarin mwarin force-pushed the cluster-validator branch from 7cfed5a to 16eebf7 Compare October 13, 2023 19:16
@mwarin mwarin removed the request for review from moseshll October 13, 2023 19:21
@mwarin mwarin merged commit 674cfe3 into main Oct 13, 2023
@aelkiss aelkiss deleted the cluster-validator branch January 7, 2025 20:38
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.

3 participants