Skip to content
Snippets Groups Projects
Commit 76f3ea76 authored by mechanik20051988's avatar mechanik20051988 Committed by Vladimir Davydov
Browse files

test: fix flaky net.box_tx_timeout.test

The problem was that when we wanted to check that
the transaction rolled back after the timeout, we
called `fiber.sleep` on the local instance, while
the timeout for transaction counted on the remote
instance. Fix the text, so now we call `fiber.sleep`
on remote server, ensuring that timeout for transaction
expires.

Closes #6586
parent 531e229e
No related branches found
No related tags found
No related merge requests found
......@@ -38,6 +38,12 @@ box.cfg({ txn_timeout = txn_timeout })
box.schema.user.grant("guest", "super")
---
...
fiber = require('fiber')
---
...
function sleep_with_timeout(timeout) fiber.sleep(timeout) end
---
...
test_run:switch("default")
---
- true
......@@ -93,7 +99,7 @@ space:select({}) -- [1]
---
- - [1]
...
fiber.sleep(txn_timeout + 0.1)
_ = test_run:eval("test", string.format("sleep_with_timeout(%f)", txn_timeout + 0.1))
---
...
space:select({}) -- []
......@@ -128,7 +134,7 @@ space:select({}) -- [1]
---
- - [1]
...
fiber.sleep(txn_timeout + 0.1)
_= test_run:eval("test", string.format("sleep_with_timeout(%f)", txn_timeout + 0.1))
---
...
space:select({}) -- []
......
......@@ -12,6 +12,8 @@ _ = s:create_index("pk")
txn_timeout = 0.5
box.cfg({ txn_timeout = txn_timeout })
box.schema.user.grant("guest", "super")
fiber = require('fiber')
function sleep_with_timeout(timeout) fiber.sleep(timeout) end
test_run:switch("default")
-- Checks for remote transactions
......@@ -35,7 +37,7 @@ stream:begin({timeout = "5"})
stream:begin()
space:replace({1})
space:select({}) -- [1]
fiber.sleep(txn_timeout + 0.1)
_ = test_run:eval("test", string.format("sleep_with_timeout(%f)", txn_timeout + 0.1))
space:select({}) -- []
space:replace({2})
fiber.yield()
......@@ -47,7 +49,7 @@ stream:commit() -- transaction was aborted by timeout
stream:begin({timeout = txn_timeout})
space:replace({1})
space:select({}) -- [1]
fiber.sleep(txn_timeout + 0.1)
_= test_run:eval("test", string.format("sleep_with_timeout(%f)", txn_timeout + 0.1))
space:select({}) -- []
space:replace({2})
fiber.yield()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment