From 60c72e784e1df748fde732cf9175fcfa55607b20 Mon Sep 17 00:00:00 2001
From: Konstantin Osipov <kostja@tarantool.org>
Date: Tue, 27 Jun 2017 16:39:56 +0300
Subject: [PATCH] test: add comments to vinyl/upsert.test, remove an extra
 box.snapshot()

gh-2520: add comments explaining the test case for gh-2520 (upsert
caching).
---
 test/vinyl/upsert.result   | 21 ++++++++++++++++-----
 test/vinyl/upsert.test.lua | 18 ++++++++++++++++--
 2 files changed, 32 insertions(+), 7 deletions(-)

diff --git a/test/vinyl/upsert.result b/test/vinyl/upsert.result
index 0d11b71db4..f6adff435e 100644
--- a/test/vinyl/upsert.result
+++ b/test/vinyl/upsert.result
@@ -694,21 +694,27 @@ s:select() --both upserts are ignored due to primary key change
 ---
 - - [1, 1]
 ...
--- gh-2520 use cache as a hint for upserts applying.
+--
+-- gh-2520 use cache as a hint when applying upserts.
+--
 old_stat = box.info.vinyl().performance["iterator"].run.lookup_count
 ---
 ...
+-- insert the first upsert
 s:upsert({100}, {{'=', 2, 200}})
 ---
 ...
+-- force a dump, the inserted upsert is now on disk
 box.snapshot()
 ---
 - ok
 ...
+-- populate the cache
 s:get{100}
 ---
 - [100]
 ...
+-- a lookup in a run was done to populate the cache
 new_stat = box.info.vinyl().performance["iterator"].run.lookup_count
 ---
 ...
@@ -719,21 +725,26 @@ new_stat - old_stat
 old_stat = new_stat
 ---
 ...
-box.snapshot()
----
-- ok
-...
+-- Add another upsert: the cached REPLACE will be used and the upsert will
+-- be applied immediately
 s:upsert({100}, {{'=', 2, 300}})
 ---
 ...
+-- force a new dump
 box.snapshot()
 ---
 - ok
 ...
+-- lookup the key
 s:get{100}
 ---
 - [100, 300]
 ...
+--
+-- since we converted upsert to replace on insert, we had to
+-- go no further than the latest dump to locate the latest
+-- value of the key
+--
 new_stat = box.info.vinyl().performance["iterator"].run.lookup_count
 ---
 ...
diff --git a/test/vinyl/upsert.test.lua b/test/vinyl/upsert.test.lua
index 1a73be48da..a1a8cccfd0 100644
--- a/test/vinyl/upsert.test.lua
+++ b/test/vinyl/upsert.test.lua
@@ -280,18 +280,32 @@ s:upsert({1, 1}, {{'+', 1, 1}})
 s:upsert({1, 1}, {{'+', 2, 1}})
 s:select() --both upserts are ignored due to primary key change
 
--- gh-2520 use cache as a hint for upserts applying.
+--
+-- gh-2520 use cache as a hint when applying upserts.
+--
 old_stat = box.info.vinyl().performance["iterator"].run.lookup_count
+-- insert the first upsert
 s:upsert({100}, {{'=', 2, 200}})
+-- force a dump, the inserted upsert is now on disk
 box.snapshot()
+-- populate the cache
 s:get{100}
+-- a lookup in a run was done to populate the cache
 new_stat = box.info.vinyl().performance["iterator"].run.lookup_count
 new_stat - old_stat
 old_stat = new_stat
-box.snapshot()
+-- Add another upsert: the cached REPLACE will be used and the upsert will
+-- be applied immediately
 s:upsert({100}, {{'=', 2, 300}})
+-- force a new dump
 box.snapshot()
+-- lookup the key
 s:get{100}
+--
+-- since we converted upsert to replace on insert, we had to
+-- go no further than the latest dump to locate the latest
+-- value of the key
+--
 new_stat = box.info.vinyl().performance["iterator"].run.lookup_count
 new_stat - old_stat
 old_stat = new_stat
-- 
GitLab