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

tests: Fix Network.Wai.Middleware.LoggingSpec on Windows #974

Merged
merged 2 commits into from
Nov 11, 2019

Conversation

rvl
Copy link
Contributor

@rvl rvl commented Nov 7, 2019

Relates to #703.

Overview

  test/unit/Network/Wai/Middleware/LoggingSpec.hs:109:5:
  9) Network.Wai.Middleware.Logging, Logging Middleware, GET, 200, no query
       uncaught exception: IOException of type UserError
       user error (Expected exactly 3 log entries but got 1: [LogObject {loName = "request-0", loMeta = LOMeta {tstamp = 2019-11-05 04:43:05.8652477 UTC, tid = "ThreadId 13863", severity = Info, privacy = Public}, loContent = LogMessage "[GET] /get"}])

  To rerun use: --match "/Network.Wai.Middleware.Logging/Logging Middleware/GET, 200, no query/"

  test/unit/Network/Wai/Middleware/LoggingSpec.hs:117:5:
  10) Network.Wai.Middleware.Logging, Logging Middleware, GET, 200, with query
       uncaught exception: IOException of type UserError
       user error (Expected exactly 3 log entries but got 5: [LogObject {loName = "request-0", loMeta = LOMeta {tstamp = 2019-11-05 04:43:05.8652477 UTC, tid = "ThreadId 13863", severity = Info, privacy = Public}, loContent = LogMessage "200 OK in 0s"},LogObject {loName = "request-0", loMeta = LOMeta {tstamp = 2019-11-05 04:43:05.8652477 UTC, tid = "ThreadId 13863", severity = Debug, privacy = Public}, loContent = LogMessage "14"},LogObject {loName = "request-1", loMeta = LOMeta {tstamp = 2019-11-05 04:43:05.8652477 UTC, tid = "ThreadId 13863", severity = Info, privacy = Public}, loContent = LogMessage "[GET] /get?query=patate"},LogObject {loName = "request-1", loMeta = LOMeta {tstamp = 2019-11-05 04:43:05.8652477 UTC, tid = "ThreadId 13863", severity = Info, privacy = Public}, loContent = LogMessage "200 OK in 0s"},LogObject {loName = "request-1", loMeta = LOMeta {tstamp = 2019-11-05 04:43:05.8652477 UTC, tid = "ThreadId 13863", severity = Debug, privacy = Public}, loContent = LogMessage "14"}])

  To rerun use: --match "/Network.Wai.Middleware.Logging/Logging Middleware/GET, 200, with query/"

  test/unit/Network/Wai/Middleware/LoggingSpec.hs:184:13:
  11) Network.Wai.Middleware.Logging, Logging Middleware, different request ids
       Falsifiable (after 4 tests and 6 shrinks):
         NumberOfRequests 1
       expected: 1
        but got: 48

  To rerun use: --match "/Network.Wai.Middleware.Logging/Logging Middleware/different request ids/"

  test/unit/Network/Wai/Middleware/LoggingSpec.hs:198:13:
  12) Network.Wai.Middleware.Logging, Logging Middleware, correct time measures
       Falsifiable (after 1 test):
         (NumberOfRequests 5,RandomIndex 1)
       expected: 1
        but got: 0

  To rerun use: --match "/Network.Wai.Middleware.Logging/Logging Middleware/correct time measures/"

Randomized with seed 534946986

Finished in 629.7711 seconds
915 examples, 12 failures, 1 pending

C:\Users\win\cw>
  • This "fixes" the tests on windows.
  • "different request ids" test still fails

Comments

It seems like iohk-monitoring writes its logs asynchronously.
Or there is some other race condition with the TVar containing log messages.

@rvl rvl self-assigned this Nov 7, 2019
@@ -192,6 +192,7 @@ spec = describe "Logging Middleware"
, replicate (n - i) (get ctx "/get")
]
void $ mapConcurrently id reqs
threadDelay 1000000 -- let iohk-monitoring flush the logs
Copy link
Member

Choose a reason for hiding this comment

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

Hmmm. This is a threadDelay of 1s inside a property. This will take more than a minute to run :/
Can't we force-stop the monitoring switchboard here to effectively flush the logs? Or, at the very least, only add this on for Windows tests?

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 was looking for a way to get iohk-monitoring to flush logs but didn't find anything yet.
Unlike the other tests, in this case, the threadDelay is not even effective, and this test still fails.

Copy link
Member

Choose a reason for hiding this comment

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

I see. I'd suggest to not spend too much time on this and a possible remedy for this one might be to disable it on windows. This is testing precise timing and interleaving of log requests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes good idea. I have made this particular spec pending (only on windows), and changed the other threadDelay so that it is only used on Windows.

@rvl rvl force-pushed the rvl/703/middleware-spec-windows branch from bb71881 to 6b73020 Compare November 11, 2019 03:13
@KtorZ
Copy link
Member

KtorZ commented Nov 11, 2019

bors r+

iohk-bors bot added a commit that referenced this pull request Nov 11, 2019
974: tests: Fix Network.Wai.Middleware.LoggingSpec on Windows r=KtorZ a=rvl

Relates to #703.

# Overview

```
  test/unit/Network/Wai/Middleware/LoggingSpec.hs:109:5:
  9) Network.Wai.Middleware.Logging, Logging Middleware, GET, 200, no query
       uncaught exception: IOException of type UserError
       user error (Expected exactly 3 log entries but got 1: [LogObject {loName = "request-0", loMeta = LOMeta {tstamp = 2019-11-05 04:43:05.8652477 UTC, tid = "ThreadId 13863", severity = Info, privacy = Public}, loContent = LogMessage "[GET] /get"}])

  To rerun use: --match "/Network.Wai.Middleware.Logging/Logging Middleware/GET, 200, no query/"

  test/unit/Network/Wai/Middleware/LoggingSpec.hs:117:5:
  10) Network.Wai.Middleware.Logging, Logging Middleware, GET, 200, with query
       uncaught exception: IOException of type UserError
       user error (Expected exactly 3 log entries but got 5: [LogObject {loName = "request-0", loMeta = LOMeta {tstamp = 2019-11-05 04:43:05.8652477 UTC, tid = "ThreadId 13863", severity = Info, privacy = Public}, loContent = LogMessage "200 OK in 0s"},LogObject {loName = "request-0", loMeta = LOMeta {tstamp = 2019-11-05 04:43:05.8652477 UTC, tid = "ThreadId 13863", severity = Debug, privacy = Public}, loContent = LogMessage "14"},LogObject {loName = "request-1", loMeta = LOMeta {tstamp = 2019-11-05 04:43:05.8652477 UTC, tid = "ThreadId 13863", severity = Info, privacy = Public}, loContent = LogMessage "[GET] /get?query=patate"},LogObject {loName = "request-1", loMeta = LOMeta {tstamp = 2019-11-05 04:43:05.8652477 UTC, tid = "ThreadId 13863", severity = Info, privacy = Public}, loContent = LogMessage "200 OK in 0s"},LogObject {loName = "request-1", loMeta = LOMeta {tstamp = 2019-11-05 04:43:05.8652477 UTC, tid = "ThreadId 13863", severity = Debug, privacy = Public}, loContent = LogMessage "14"}])

  To rerun use: --match "/Network.Wai.Middleware.Logging/Logging Middleware/GET, 200, with query/"

  test/unit/Network/Wai/Middleware/LoggingSpec.hs:184:13:
  11) Network.Wai.Middleware.Logging, Logging Middleware, different request ids
       Falsifiable (after 4 tests and 6 shrinks):
         NumberOfRequests 1
       expected: 1
        but got: 48

  To rerun use: --match "/Network.Wai.Middleware.Logging/Logging Middleware/different request ids/"

  test/unit/Network/Wai/Middleware/LoggingSpec.hs:198:13:
  12) Network.Wai.Middleware.Logging, Logging Middleware, correct time measures
       Falsifiable (after 1 test):
         (NumberOfRequests 5,RandomIndex 1)
       expected: 1
        but got: 0

  To rerun use: --match "/Network.Wai.Middleware.Logging/Logging Middleware/correct time measures/"

Randomized with seed 534946986

Finished in 629.7711 seconds
915 examples, 12 failures, 1 pending

C:\Users\win\cw>
```

- This "fixes" the tests on windows.
- "different request ids" test still fails

# Comments

It seems like iohk-monitoring writes its logs asynchronously.
Or there is some other race condition with the TVar containing log messages.


Co-authored-by: Rodney Lorrimar <[email protected]>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Nov 11, 2019

Build failed

@rvl
Copy link
Contributor Author

rvl commented Nov 11, 2019

bors r+

(Stack cache issue)

iohk-bors bot added a commit that referenced this pull request Nov 11, 2019
974: tests: Fix Network.Wai.Middleware.LoggingSpec on Windows r=rvl a=rvl

Relates to #703.

# Overview

```
  test/unit/Network/Wai/Middleware/LoggingSpec.hs:109:5:
  9) Network.Wai.Middleware.Logging, Logging Middleware, GET, 200, no query
       uncaught exception: IOException of type UserError
       user error (Expected exactly 3 log entries but got 1: [LogObject {loName = "request-0", loMeta = LOMeta {tstamp = 2019-11-05 04:43:05.8652477 UTC, tid = "ThreadId 13863", severity = Info, privacy = Public}, loContent = LogMessage "[GET] /get"}])

  To rerun use: --match "/Network.Wai.Middleware.Logging/Logging Middleware/GET, 200, no query/"

  test/unit/Network/Wai/Middleware/LoggingSpec.hs:117:5:
  10) Network.Wai.Middleware.Logging, Logging Middleware, GET, 200, with query
       uncaught exception: IOException of type UserError
       user error (Expected exactly 3 log entries but got 5: [LogObject {loName = "request-0", loMeta = LOMeta {tstamp = 2019-11-05 04:43:05.8652477 UTC, tid = "ThreadId 13863", severity = Info, privacy = Public}, loContent = LogMessage "200 OK in 0s"},LogObject {loName = "request-0", loMeta = LOMeta {tstamp = 2019-11-05 04:43:05.8652477 UTC, tid = "ThreadId 13863", severity = Debug, privacy = Public}, loContent = LogMessage "14"},LogObject {loName = "request-1", loMeta = LOMeta {tstamp = 2019-11-05 04:43:05.8652477 UTC, tid = "ThreadId 13863", severity = Info, privacy = Public}, loContent = LogMessage "[GET] /get?query=patate"},LogObject {loName = "request-1", loMeta = LOMeta {tstamp = 2019-11-05 04:43:05.8652477 UTC, tid = "ThreadId 13863", severity = Info, privacy = Public}, loContent = LogMessage "200 OK in 0s"},LogObject {loName = "request-1", loMeta = LOMeta {tstamp = 2019-11-05 04:43:05.8652477 UTC, tid = "ThreadId 13863", severity = Debug, privacy = Public}, loContent = LogMessage "14"}])

  To rerun use: --match "/Network.Wai.Middleware.Logging/Logging Middleware/GET, 200, with query/"

  test/unit/Network/Wai/Middleware/LoggingSpec.hs:184:13:
  11) Network.Wai.Middleware.Logging, Logging Middleware, different request ids
       Falsifiable (after 4 tests and 6 shrinks):
         NumberOfRequests 1
       expected: 1
        but got: 48

  To rerun use: --match "/Network.Wai.Middleware.Logging/Logging Middleware/different request ids/"

  test/unit/Network/Wai/Middleware/LoggingSpec.hs:198:13:
  12) Network.Wai.Middleware.Logging, Logging Middleware, correct time measures
       Falsifiable (after 1 test):
         (NumberOfRequests 5,RandomIndex 1)
       expected: 1
        but got: 0

  To rerun use: --match "/Network.Wai.Middleware.Logging/Logging Middleware/correct time measures/"

Randomized with seed 534946986

Finished in 629.7711 seconds
915 examples, 12 failures, 1 pending

C:\Users\win\cw>
```

- This "fixes" the tests on windows.
- "different request ids" test still fails

# Comments

It seems like iohk-monitoring writes its logs asynchronously.
Or there is some other race condition with the TVar containing log messages.


Co-authored-by: Rodney Lorrimar <[email protected]>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Nov 11, 2019

Build succeeded

@iohk-bors iohk-bors bot merged commit 6b73020 into master Nov 11, 2019
@rvl rvl deleted the rvl/703/middleware-spec-windows branch November 11, 2019 09:22
@KtorZ KtorZ added this to the Usability & Compatibility milestone Nov 12, 2019
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.

2 participants