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

fix: add unique constraint on test model #357

Merged
merged 2 commits into from
Jan 25, 2024

Conversation

joseph-sentry
Copy link
Contributor

@joseph-sentry joseph-sentry commented Jan 24, 2024

Purpose/Motivation

The outcome field should be an enum stored as a string.

The env field should renamed to flags_hash for clarity.

The uniqueconstraint was added to ensure that Test objects are unique according to repo, name, testsuite and flags_hash.

What does this PR do?

  • Add unique constraint on aforementioned fields on Test model
  • Create Outcome enum for TestInstance outcome field
  • Change outcome to string and use enum
  • Change env field to flags_hash field
  • Create Django migration

@codecov-staging
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@codecov-qa
Copy link

codecov-qa bot commented Jan 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (0b82da1) 96.07% compared to head (9fbcc9e) 96.07%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #357   +/-   ##
=======================================
  Coverage   96.07%   96.07%           
=======================================
  Files         631      632    +1     
  Lines       16398    16408   +10     
=======================================
+ Hits        15754    15764   +10     
  Misses        644      644           
Flag Coverage Δ
unit 96.07% <100.00%> (+<0.01%) ⬆️
unit-latest-uploader 96.07% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link

codecov-public-qa bot commented Jan 24, 2024

Codecov Report

Merging #357 (9fbcc9e) into main (0b82da1) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #357   +/-   ##
=======================================
  Coverage   96.07%   96.07%           
=======================================
  Files         631      632    +1     
  Lines       16398    16408   +10     
=======================================
+ Hits        15754    15764   +10     
  Misses        644      644           
Flag Coverage Δ
unit 96.07% <100.00%> (+<0.01%) ⬆️
unit-latest-uploader 96.07% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...ations/0014_rename_env_test_flags_hash_and_more.py 100.00% <100.00%> (ø)
reports/models.py 97.14% <100.00%> (+0.12%) ⬆️

Impacted file tree graph

Copy link

codecov bot commented Jan 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (0b82da1) 95.74% compared to head (33d9a0e) 95.75%.

Additional details and impacted files
@@           Coverage Diff           @@
##            main    #357     +/-   ##
=======================================
+ Coverage   95.74   95.75   +0.01     
=======================================
  Files        746     747      +1     
  Lines      16914   16924     +10     
=======================================
+ Hits       16194   16204     +10     
  Misses       720     720             
Flag Coverage Δ
unit 96.07% <100.00%> (+<0.01%) ⬆️
unit-latest-uploader 96.07% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Signed-off-by: joseph-sentry <joseph.sawaya@sentry.io>


class Migration(migrations.Migration):

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you pls ad the SQL code for this migration here? 🙇

# users will use flags to distinguish the same test being run
# in a different environment
# for example: the same test being run on windows vs. mac
flags_hash = models.TextField()
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh interesting, is this the same flag as a codecov flag?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a hash of the flags associated with the uploads that map to this test.

The idea is that users will use flags with their uploads to differentiate between the same test being run in a different environment (this used to be the env field but now it's the flags_hash field).

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good. I'd expect this field to be nullable too right?

@@ -224,6 +224,7 @@ class Test(models.Model):
# in this case is because we want to be able to compute/predict
# the primary key of a Test object ourselves in the processor
# so we can easily do concurrent writes to the database
# this is a hash of the repoid, name, testsuite and env
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting, so the id itself will account for the env now 👀

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i should rename it to flags_hash in the comment here as well but yes, because a test is unique on the flags_hash as well, we will include it in the hash

Signed-off-by: joseph-sentry <joseph.sawaya@sentry.io>
@joseph-sentry joseph-sentry merged commit 3caddf5 into main Jan 25, 2024
19 of 20 checks passed
@joseph-sentry joseph-sentry deleted the joseph/add-test-constraint branch January 25, 2024 20:31
Copy link

@barnett-yuxiang barnett-yuxiang left a comment

Choose a reason for hiding this comment

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

LGTM

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

3 participants