From f8063da2019d5a7f55a3f22e148099df465337f9 Mon Sep 17 00:00:00 2001 From: Alexey Romanov Date: Wed, 26 May 2021 17:59:32 +0300 Subject: [PATCH] Tests --- crud/common/utils.lua | 12 +++++++++++ test/entrypoint/srv_select.lua | 37 ++++++++++++++++++++++++++++++++ test/integration/select_test.lua | 4 ++++ 3 files changed, 53 insertions(+) diff --git a/crud/common/utils.lua b/crud/common/utils.lua index e7de9d62e..9b31db999 100644 --- a/crud/common/utils.lua +++ b/crud/common/utils.lua @@ -251,6 +251,10 @@ local function determine_enabled_features() -- since Tarantool 2.4 enabled_tarantool_features.uuids = major >= 2 and (minor > 4 or minor == 4 and patch >= 1) + + -- since Tarantool 2.6.3 / 2.7.2 / 2.8.1 + enabled_tarantool_features.jsonpath_indexes = major >= 3 or (major >= 2 and ((minor >= 6 and patch >= 3) + or (minor >= 7 and patch >= 2) or (minor >= 8 and patch >= 1) or minor >= 9)) end function utils.tarantool_supports_fieldpaths() @@ -269,6 +273,14 @@ function utils.tarantool_supports_uuids() return enabled_tarantool_features.uuids end +function utils.tarantool_supports_jsonpath_indexes() + if enabled_tarantool_features.jsonpath_indexes == nil then + determine_enabled_features() + end + + return enabled_tarantool_features.jsonpath_indexes +end + local function add_nullable_fields_recursive(operations, operations_map, space_format, tuple, id) if id < 2 or tuple[id - 1] ~= box.NULL then return operations diff --git a/test/entrypoint/srv_select.lua b/test/entrypoint/srv_select.lua index 98081b5da..56d0d3d3e 100755 --- a/test/entrypoint/srv_select.lua +++ b/test/entrypoint/srv_select.lua @@ -151,6 +151,43 @@ package.preload['customers-storage'] = function() unique = false, if_not_exists = true, }) + + if crud_utils.tarantool_supports_jsonpath_indexes() then + local cars_space = box.schema.space.create('cars', { + format = { + {name = 'id', type = 'map'}, + {name = 'bucket_id', type = 'unsigned'}, + {name = 'age', type = 'number'}, + {name = 'manufacturer', type = 'string'}, + {name = 'data', type = 'map'} + }, + if_not_exists = true, + engine = engine, + }) + + -- primary index + cars_space:create_index('id_ind', { + parts = { + {1, 'unsigned', path = 'car_id.signed'}, + }, + if_not_exists = true, + }) + + cars_space:create_index('bucket_id', { + parts = { 'bucket_id' }, + unique = false, + if_not_exists = true, + }) + + cars_space:create_index('data_index', { + parts = { + {5, 'str', path = 'car.color'}, + {5, 'str', path = 'car.model'}, + }, + unique = false, + if_not_exists = true, + }) + end end, } end diff --git a/test/integration/select_test.lua b/test/integration/select_test.lua index 1d2432162..72014b73f 100644 --- a/test/integration/select_test.lua +++ b/test/integration/select_test.lua @@ -31,7 +31,11 @@ pgroup:set_after_all(function(g) helpers.stop_cluster(g.cluster) end) pgroup:set_before_each(function(g) helpers.truncate_space_on_cluster(g.cluster, 'customers') +<<<<<<< HEAD helpers.truncate_space_on_cluster(g.cluster, 'developers') +======= + helpers.truncate_space_on_cluster(g.cluster, 'cars') +>>>>>>> 7b67809 (Tests) end)