[Tarantool-patches] [PATCH 1/2] test: fix test output on latest Tarantool

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Fri May 21 22:26:45 MSK 2021


Hi! Thanks for the review!

On 19.05.2021 23:50, Yaroslav Dynnikov wrote:
> HI, Vlad
> 
> Thanks for the patch.
> Find one comment below.
> 
> On Thu, 13 May 2021 at 14:07, Vladislav Shpilevoy <v.shpilevoy at tarantool.org <mailto:v.shpilevoy at tarantool.org>> wrote:
> 
>     Duplicate key error at insertion into a space on the latest
>     Tarantool changed its message and it broke of the tests. The patch
>     updates the test so it checks only the needed part of the message
>     and does not depend on Tarantool version anymore.
>     ---
>      test/storage/storage.result   | 8 +++++---
>      test/storage/storage.test.lua | 3 ++-
>      2 files changed, 7 insertions(+), 4 deletions(-)
> 
>     diff --git a/test/storage/storage.result b/test/storage/storage.result
>     index 2c9784a..d18b7f8 100644
>     --- a/test/storage/storage.result
>     +++ b/test/storage/storage.result
>     @@ -179,10 +179,12 @@ vshard.storage.buckets_info()
>          status: active
>          id: 1
>      ...
>     -vshard.storage.bucket_force_create(1) -- error
>     +ok, err = vshard.storage.bucket_force_create(1)
>      ---
>     -- null
>     -- Duplicate key exists in unique index 'pk' in space '_bucket'
>     +...
>     +assert(not ok and err.message:match("Duplicate key exists"))
>     +---
>     +- Duplicate key exists
>      ...
>      vshard.storage.bucket_force_drop(1)
>      ---
>     diff --git a/test/storage/storage.test.lua b/test/storage/storage.test.lua
>     index 33f0498..97558f6 100644
>     --- a/test/storage/storage.test.lua
>     +++ b/test/storage/storage.test.lua
>     @@ -56,7 +56,8 @@ vshard.storage.sync(100500)
>      vshard.storage.buckets_info()
>      vshard.storage.bucket_force_create(1)
>      vshard.storage.buckets_info()
>     -vshard.storage.bucket_force_create(1) -- error
>     +ok, err = vshard.storage.bucket_force_create(1)
>     +assert(not ok and "err.message:match("Duplicate key exists))
> 
> 
> I'd suggest splitting the check in two:
> 
> 1. ok -- should be false
> 2. Then check the message matches.
> 
> Assertions usually don't provide useful errors.

In the core we try to use assertions more, because this makes the
tests easier to read. You can see right away what are the target
points of the test. This is kind of a simulation of tap tests.

I consider vshard be "half-core", so I decided to use assertions
here as well.


More information about the Tarantool-patches mailing list