Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Make shard optional #219

Merged
merged 1 commit into from
Sep 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion graphql/accessor_shard_cache.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local json = require('json')
local shard = require('shard')
local utils = require('graphql.utils')
local shard = utils.optional_require('shard')
local request_batch = require('graphql.request_batch')
local accessor_shard_index_info = require('graphql.accessor_shard_index_info')

Expand Down
1 change: 1 addition & 0 deletions test/extra/no_shard/shard.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
error('shard should not be mandatory dependency')
35 changes: 35 additions & 0 deletions test/extra/shard_optional.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env tarantool

-- https://github.com/tarantool/graphql/issues/218

local fio = require('fio')
local tap = require('tap')

-- require in-repo version of graphql/ sources despite current working directory
local cur_dir = fio.abspath(debug.getinfo(1).source:match("@?(.*/)")
:gsub('/./', '/'):gsub('/+$', ''))
package.path =
cur_dir .. '/../../?/init.lua' .. ';' ..
cur_dir .. '/../../?.lua' .. ';' ..
package.path

-- require no_shard/shard.lua instead of the real shard module
package.path =
cur_dir .. '/no_shard/?/init.lua' .. ';' ..
cur_dir .. '/no_shard/?.lua' .. ';' ..
package.path

local graphql = require('graphql')
local testdata = require('test.testdata.common_testdata')

local test = tap.test('optional shard')
test:plan(1)

box.cfg{wal_mode='none'}

local cfg = testdata.get_test_metadata()
cfg.accessor = 'space'
local ok = pcall(graphql.new, cfg)
test:ok(ok, 'shard is optional')

os.exit(test:check() == true and 0 or 1)
4 changes: 2 additions & 2 deletions test/test_utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ local log = require('log')
local yaml = require('yaml')
local avro_schema = require('avro_schema')
local digest = require('digest')
local shard = require('shard')
local utils = require('graphql.utils')
local shard = utils.optional_require('shard')
local graphql = require('graphql')
local multirunner = require('test.common.multirunner')
local utils = require('graphql.utils')
local test_run = utils.optional_require('test_run')
test_run = test_run and test_run.new()

Expand Down