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

Added Uniqueness test for UUID #415

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Roshankumar350
Copy link
Contributor

We tried to add Uniqueness test for UUID.

@Roshankumar350
Copy link
Contributor Author

@iCharlesHu: Please review.

@Roshankumar350
Copy link
Contributor Author

@swift-ci test

@parkera
Copy link
Member

parkera commented Mar 1, 2024

Can I get some background on why this test was added?

@parkera
Copy link
Member

parkera commented Mar 1, 2024

@swift-ci test

@Roshankumar350
Copy link
Contributor Author

Hello @parkera

Currently we have test cases for UUID are:

  • test_UUIDEquality
  • test_UUIDInvalid
  • test_UUIDuuidString
  • test_UUIDdescription
  • test_hash
  • test_AnyHashableContainingUUID
  • test_UUID_custom_mirror
  • test_UUID_Comparable

And In swift foundation library, Its defined as
A universally unique value to identify types, interfaces, and other items..

These defined test cases doesn't validate the universally unique value in test.

Hence added test_UUIDUniqueness to justify its definition.

Open for your thoughts as well. Thanks

@Roshankumar350
Copy link
Contributor Author

Hello @parkera

Waiting for your review.

Thanks.

@parkera
Copy link
Member

parkera commented Mar 11, 2024

It is of course impossible to test that it is always "universally unique" - so is, then, the purpose of this test to validate that we don't have a very basic error of always generating the same UUID 10,000 times in a row?

With the current construction of the test case, isn't it true that if we generate the same uuid 9,999 times and then 1 different it will pass? Is that a useful test case?

@Roshankumar350
Copy link
Contributor Author

Roshankumar350 commented Mar 17, 2024

Hello @parkera
Thanks for reviewing. Please checks my understanding and review.

  • It is of course impossible to test that it is always "universally unique" - so is, then, the purpose of this test to validate that we don't have a very basic error of always generating the same UUID 10,000 times in a row?

Lets say pipeline run in a day is 24 times (Assuming 1 hr per pipeline execution) I.e Constant Time C

And Lifetime of this framework is N days (Assuming N is number of days it will be maintained and consumed by client)

so each test cases in pipeline will be executed till the life time will be 
N*C = NC which is equivalent to N

Taking one random test,
say test_UUIDuuidString
https://github.com/apple/swift-foundation/blob/main/Tests/FoundationEssentialsTests/UUIDTests.swift#L36

This test cases will be executed N times and will produces same result since its value is pre-defined (Known value)

But in UUID we don’t have pre-defined values of test. Since its universally unique and will produce unique value every time.

To validate this we have agreed by definition that its universally uniques. So we can have checks till the life time of this framework that it will pass this and if it fails once, definition is no longer valid.

  • With the current construction of the test case, isn't it true that if we generate the same uuid 9,999 times and then 1 different it will pass? Is that a useful test case?

In UUID, Even if its fails once, its a failure. But I can have break in this loop to have overall failure and can have log too.

Thanks :)

@parkera
Copy link
Member

parkera commented May 30, 2024

I'm not sold on the idea of non-deterministic testing to catch failures. We will often dismiss one-off failures as some kind of external factor rather than a failure of the code under test.

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

2 participants