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

Make integration_spec randomizable #296

Merged

Conversation

ellnix
Copy link
Collaborator

@ellnix ellnix commented Sep 28, 2023

Pull Request

Related issue

Fixes #115

PR checklist

Please check if your PR fulfills the following requirements:

  • Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • Have you read the contributing guidelines?
  • Have you made sure that the title is accurate and descriptive of the changes?

Notes (please read)

  • The behavior and methodology of the tests was left untouched wherever possible
  • Issue Allow tests randomization  #115 instructs to create a PR for each fixed file but spec/integration_spec.rb was the only file with any issues, so this PR should fix the whole suite
  • Issue Allow tests randomization  #115 does not fully instruct whether randomized testing should actually be enabled in the repo, so I left it disabled
  • I ran the suite ~40 times after fixing everything (probably another ~40 times while fixing it) so there could still be issues I did not spot. My rationale was that the tests should ideally be refactored before (or while) going through them line by line and trying to spot any more errors.

@ellnix ellnix force-pushed the make-integration-spec-randomizable branch from 72ee63f to 9ada396 Compare November 1, 2023 17:05
Copy link

codecov bot commented Nov 1, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (fc40e59) 88.73% compared to head (8547b03) 89.04%.

❗ Current head 8547b03 differs from pull request most recent head 8b3afd3. Consider uploading reports for the commit 8b3afd3 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #296      +/-   ##
==========================================
+ Coverage   88.73%   89.04%   +0.30%     
==========================================
  Files          10       10              
  Lines         657      657              
==========================================
+ Hits          583      585       +2     
+ Misses         74       72       -2     

see 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

brunoocasali
brunoocasali previously approved these changes Nov 3, 2023
Copy link
Member

@brunoocasali brunoocasali left a comment

Choose a reason for hiding this comment

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

I will approve the changes @ellnix thanks for taking care of them!

I sent some comments but i think you can address them later!

@@ -365,6 +372,7 @@
@products_in_database = Product.all

Product.reindex!(MeiliSearch::Rails::IndexSettings::DEFAULT_BATCH_SIZE, true)
sleep 5
Copy link
Member

Choose a reason for hiding this comment

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

👀

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh no, the rebase thought this PR wanted to add the sleep back, I probably have the same problem in all the other PRs I rebased...

Comment on lines +460 to +461
Product.index.add_documents!(@palmpre.attributes.merge(id: -1))
expect { Product.search('pal').to_json }.not_to raise_error
Product.index.delete_document!(-1)
Copy link
Member

Choose a reason for hiding this comment

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

I would recommend to use the xUnit structure whenever possible

Copy link
Member

Choose a reason for hiding this comment

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

But you can do it later :)

@@ -668,8 +687,7 @@
describe 'Kaminari' do
before(:all) do
require 'kaminari'
MeiliSearch::Rails.configuration = { meilisearch_url: ENV.fetch('MEILISEARCH_HOST', 'http://127.0.0.1:7700'),
Copy link
Member

Choose a reason for hiding this comment

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

I guess that was not needed, good catch!

Movie.clear_index!(true)

10.times { Movie.create(title: Faker::Movie.title) }

Movie.reindex!(MeiliSearch::Rails::IndexSettings::DEFAULT_BATCH_SIZE, true)
sleep 5
Copy link
Member

Choose a reason for hiding this comment

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

Since this PR #292 was merged, I guess you'll try to remove it later right?!

spec/integration_spec.rb Show resolved Hide resolved
spec/support/active_record_classes.rb Show resolved Hide resolved
@brunoocasali brunoocasali added the maintenance Anything related to maintenance (CI, tests, refactoring...) label Nov 3, 2023
@ellnix ellnix force-pushed the make-integration-spec-randomizable branch from 4eac729 to 20fe6d8 Compare November 3, 2023 17:31
@ellnix ellnix mentioned this pull request Nov 3, 2023
10 tasks
@ellnix ellnix force-pushed the make-integration-spec-randomizable branch from 20fe6d8 to 8b3afd3 Compare November 3, 2023 18:22
@ellnix
Copy link
Collaborator Author

ellnix commented Nov 3, 2023

@brunoocasali Rebased, and I think I addressed all of the feedback.

Copy link
Member

@brunoocasali brunoocasali left a comment

Choose a reason for hiding this comment

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

LGTM!

@ellnix
Copy link
Collaborator Author

ellnix commented Nov 6, 2023

bors merge

meili-bors bot added a commit that referenced this pull request Nov 6, 2023
296: Make integration_spec randomizable r=ellnix a=ellnix

# Pull Request

## Related issue
Fixes #115 

## PR checklist
Please check if your PR fulfills the following requirements:
- [X] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
- [X] Have you read the contributing guidelines?
- [X] Have you made sure that the title is accurate and descriptive of the changes?

# Notes (please read)
- The behavior and methodology of the tests was left untouched wherever possible
- Issue #115 instructs to create a PR for each fixed file but `spec/integration_spec.rb` was the only file with any issues, so this PR should fix the whole suite
- Issue #115 does not fully instruct whether randomized testing should actually be enabled in the repo, so I left it disabled
- I ran the suite ~40 times after fixing everything (probably another ~40 times while fixing it) so there could still be issues I did not spot. My rationale was that the tests should ideally be refactored before (or while) going through them line by line and trying to spot any more errors.

Co-authored-by: ellnix <[email protected]>
Copy link
Contributor

meili-bors bot commented Nov 6, 2023

Build failed:

@ellnix
Copy link
Collaborator Author

ellnix commented Nov 6, 2023

bors merge

@meili-bors meili-bors bot merged commit baf99c0 into meilisearch:main Nov 6, 2023
10 checks passed
@ellnix ellnix mentioned this pull request Feb 27, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Anything related to maintenance (CI, tests, refactoring...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow tests randomization
2 participants