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

DEBUG mode broke tests #430

Merged
merged 1 commit into from
Nov 7, 2022
Merged

Conversation

miry
Copy link
Contributor

@miry miry commented Oct 11, 2022

In debug mode there is an unexpected exception for tests.
THe function to print semaphores could not access to the resource and raise exception.
The observability should not produces exceptions and ignore errors.

$ DEBUG=1 bundle exec rake clean build
$ DEBUG=1 bundle exec ruby -Itest test/resource_test.rb -n test_destroy

# Running:

[pid=1345][semian] semaphore values lock: 1, tickets: 0 configured: 0, registered workers: 0
[pid=1345][semian] semaphore values lock: 0, tickets: 0 configured: 0, registered workers: 1
F

Finished in 0.001262s, 792.3403 runs/s, 792.3403 assertions/s.

  1) Failure:
TestResource#test_destroy [test/resource_test.rb:393]:
[Semian::SyscallError] exception expected, not
Class: <Semian::InternalError>
Message: <"error getting value of SI_SEM_LOCK for sem 131097, errno: 22 (Invalid argument)">
---Backtrace---
test/resource_test.rb:394:in `acquire'
test/resource_test.rb:394:in `block in test_destroy'
---------------

Solution

Disable DEBUG mode for containers, as it is produced unreliable tests.
In debug function handle exceptions, to not produces errors.

@miry miry self-assigned this Oct 11, 2022
@miry miry added the Semian label Oct 11, 2022
@miry miry changed the title DEBUG mode broke tests WIP: DEBUG mode broke tests Oct 11, 2022
@miry miry force-pushed the handle-exceptions-debug-message branch 3 times, most recently from 1d77500 to 90bc064 Compare October 16, 2022 10:28
@miry miry changed the title WIP: DEBUG mode broke tests DEBUG mode broke tests Oct 16, 2022
@miry miry marked this pull request as ready for review October 16, 2022 10:29
@miry miry requested review from casperisfine, a team, jgaskins, michaelnugent and AbdulRahmanAlHamali and removed request for a team October 16, 2022 10:29
@miry miry force-pushed the handle-exceptions-debug-message branch from 90bc064 to 6b7b445 Compare October 16, 2022 10:31
resource.acquire {}
end
assert_equal("semop() failed, errno: 22 (Invalid argument)", exception.message)
Copy link
Contributor

Choose a reason for hiding this comment

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

Generally speaking it's a good idea to use assert_includes or assert_match when testing error messages, because did_you_mean error_highlight etc might augment the error message.

In debug mode there is an unexpected exception for tests.
THe function to print semaphores could not access to the resource and raise exception.
The observability should not produces exceptions and ignore errors.

```shell
$ DEBUG=1 bundle exec rake clean build
$ DEBUG=1 bundle exec ruby -Itest test/resource_test.rb -n test_destroy

[pid=1345][semian] semaphore values lock: 1, tickets: 0 configured: 0, registered workers: 0
[pid=1345][semian] semaphore values lock: 0, tickets: 0 configured: 0, registered workers: 1
F

Finished in 0.001262s, 792.3403 runs/s, 792.3403 assertions/s.

  1) Failure:
TestResource#test_destroy [test/resource_test.rb:393]:
[Semian::SyscallError] exception expected, not
Class: <Semian::InternalError>
Message: <"error getting value of SI_SEM_LOCK for sem 131097, errno: 22 (Invalid argument)">
---Backtrace---
test/resource_test.rb:394:in `acquire'
test/resource_test.rb:394:in `block in test_destroy'
---------------
```

Disable DEBUG mode for containers, as it is produced unreliable tests.
In debug function handle exceptions, to not produces errors.
@miry miry force-pushed the handle-exceptions-debug-message branch from 6b7b445 to f4e8120 Compare November 7, 2022 18:49
@miry miry merged commit f4e8120 into Shopify:master Nov 7, 2022
@miry miry deleted the handle-exceptions-debug-message branch November 30, 2022 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants