Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tarantool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
tarantool
Commits
f27e41e1
Commit
f27e41e1
authored
11 years ago
by
Konstantin Osipov
Browse files
Options
Downloads
Patches
Plain Diff
Add test coverage for start/stop from snapshot. Fix bugs it revealed.
parent
024acb38
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/box/box_lua_space.cc
+1
-1
1 addition, 1 deletion
src/box/box_lua_space.cc
test/box/alter_limits.result
+348
-38
348 additions, 38 deletions
test/box/alter_limits.result
test/box/alter_limits.test.lua
+127
-38
127 additions, 38 deletions
test/box/alter_limits.test.lua
with
476 additions
and
77 deletions
src/box/box_lua_space.cc
+
1
−
1
View file @
f27e41e1
...
...
@@ -63,7 +63,7 @@ lbox_fillspace(struct lua_State *L, struct space *space, int i)
lua_settable
(
L
,
i
);
lua_pushstring
(
L
,
"enabled"
);
lua_pushboolean
(
L
,
space
->
engine
.
state
!=
READY_NO_KEYS
);
lua_pushboolean
(
L
,
space
_index
(
space
,
0
)
!=
0
);
lua_settable
(
L
,
i
);
lua_getfield
(
L
,
i
,
"index"
);
...
...
This diff is collapsed.
Click to expand it.
test/box/alter_limits.result
+
348
−
38
View file @
f27e41e1
...
...
@@ -852,49 +852,359 @@ s:insert(3, 2)
s:drop()
---
...
-- -----------
--
--
-- space cache
-- -----------
-- - all the various kinds of reference to a dropped space
-- - iterator to index
-- index to space
-- space to index
-- variable
-- key def
-- all userdata given away to lua - think how
--
--
-- ----------------------------------------------------------------
-- SPACE CACHE: what happens to a space cache when an object is gone
-- ----------------------------------------------------------------
s = box.schema.create_space('test')
---
...
s1 = s
---
...
s:create_index('primary', 'tree')
---
...
s1.index.primary.id
---
- 0
...
primary = s1.index.primary
---
...
s.index.primary:drop()
---
...
primary.id
---
- 0
...
primary:select()
---
- error: 'No index #0 is defined in space 512'
...
-- @todo: add a test case for dangling iterator (currently no checks
-- for a dangling iterator in the code
-- ----------------------------------------------------------------
-- ----------------------------------------------------------------
-- RECOVERY: check that all indexes are correctly built
-- during recovery regardless of when they are created
-- ----------------------------------------------------------------
-- primary, secondary keys in a snapshot
s_empty = box.schema.create_space('s_empty')
---
...
s_empty:create_index('primary', 'tree', {unique = true, parts = {0, 'num'}})
---
...
s_empty:create_index('secondary', 'hash', {unique = true, parts = {1, 'num'}})
---
...
s_full = box.schema.create_space('s_full')
---
...
s_full:create_index('primary', 'tree', {unique = true, parts = {0, 'num'}})
---
...
s_full:create_index('secondary', 'hash', {unique = true, parts = {1, 'num'}})
---
...
s_full:insert(1, 1, 'a')
---
- [1, 1, 'a']
...
s_full:insert(2, 2, 'b')
---
- [2, 2, 'b']
...
s_full:insert(3, 3, 'c')
---
- [3, 3, 'c']
...
s_full:insert(4, 4, 'd')
---
- [4, 4, 'd']
...
s_full:insert(5, 5, 'e')
---
- [5, 5, 'e']
...
s_nil = box.schema.create_space('s_nil')
---
...
s_drop = box.schema.create_space('s_drop')
---
...
box.snapshot()
---
- ok
...
s_drop:drop()
---
...
s_nil:create_index('primary', 'hash', {unique=true, parts = {0, 'num'}})
---
...
s_nil:insert(1,2,3,4,5,6);
---
- [1, 2, 3, 4, 5, 6]
...
s_nil:insert(7, 8, 9, 10, 11,12)
---
- [7, 8, 9, 10, 11, 12]
...
s_nil:create_index('secondary', 'tree', {unique=false, parts = {1, 'num', 2, 'num', 3, 'num'}})
---
...
s_nil:insert(13, 14, 15, 16, 17)
---
- [13, 14, 15, 16, 17]
...
r_empty = box.schema.create_space('r_empty')
---
...
r_empty:create_index('primary', 'tree', {unique = true, parts = {0, 'num'}})
---
...
r_empty:create_index('secondary', 'hash', {unique = true, parts = {1, 'num'}})
---
...
r_full = box.schema.create_space('r_full')
---
...
r_full:create_index('primary', 'tree', {unique = true, parts = {0, 'num'}})
---
...
r_full:create_index('secondary', 'hash', {unique = true, parts = {1, 'num'}})
---
...
r_full:insert(1, 1, 'a')
---
- [1, 1, 'a']
...
r_full:insert(2, 2, 'b')
---
- [2, 2, 'b']
...
r_full:insert(3, 3, 'c')
---
- [3, 3, 'c']
...
r_full:insert(4, 4, 'd')
---
- [4, 4, 'd']
...
r_full:insert(5, 5, 'e')
---
- [5, 5, 'e']
...
s_full:create_index('multikey', 'tree', {unique = true, parts = { 1, 'num', 2, 'str'}})
---
...
s_full:insert(6, 6, 'f')
---
- [6, 6, 'f']
...
s_full:insert(7, 7, 'g')
---
- [7, 7, 'g']
...
s_full:insert(8, 8, 'h')
---
- [8, 8, 'h']
...
r_disabled = box.schema.create_space('r_disabled')
---
...
--# stop server default
--# start server default
s_empty = box.space['s_empty']
---
...
s_full = box.space['s_full']
---
...
s_nil = box.space['s_nil']
---
...
s_drop = box.space['s_drop']
---
...
r_empty = box.space['r_empty']
---
...
r_full = box.space['r_full']
---
...
r_disabled = box.space['r_disabled']
---
...
s_drop
---
- null
...
s_empty.index.primary.type
---
- TREE
...
s_full.index.primary.type
---
- TREE
...
r_empty.index.primary.type
---
- TREE
...
r_full.index.primary.type
---
- TREE
...
s_nil.index.primary.type
---
- HASH
...
s_empty.index.primary.name
---
- primary
...
s_full.index.primary.name
---
- primary
...
r_empty.index.primary.name
---
- primary
...
r_full.index.primary.name
---
- primary
...
s_nil.index.primary.name
---
- primary
...
s_empty.enabled
---
- true
...
s_full.enabled
---
- true
...
r_empty.enabled
---
- true
...
r_full.enabled
---
- true
...
s_nil.enabled
---
- true
...
r_disabled.enabled
---
- false
...
s_empty.index.secondary.name
---
- secondary
...
s_full.index.secondary.name
---
- secondary
...
r_empty.index.secondary.name
---
- secondary
...
r_full.index.secondary.name
---
- secondary
...
s_nil.index.secondary.name
---
- secondary
...
s_empty.index.primary:count(1)
---
- 0
...
s_full.index.primary:count(1)
---
- 1
...
r_empty.index.primary:count(1)
---
- 0
...
r_full.index.primary:count(1)
---
- 1
...
s_nil.index.primary:count(1)
---
- 1
...
s_empty.index.secondary:count(1)
---
- 0
...
s_full.index.secondary:count(1)
---
- 1
...
r_empty.index.secondary:count(1)
---
- 0
...
r_full.index.secondary:count(1)
---
- 1
...
s_nil.index.secondary:count(1)
---
- 0
...
s_empty.index.primary:select()
---
...
s_full.index.primary:select()
---
- [1, 1, 'a']
- [2, 2, 'b']
- [3, 3, 'c']
- [4, 4, 'd']
- [5, 5, 'e']
- [6, 6, 'f']
- [7, 7, 'g']
- [8, 8, 'h']
...
r_empty.index.primary:select()
---
...
r_full.index.primary:select()
---
- [1, 1, 'a']
- [2, 2, 'b']
- [3, 3, 'c']
- [4, 4, 'd']
- [5, 5, 'e']
...
s_nil.index.secondary:select()
---
- [1, 2, 3, 4, 5, 6]
- [7, 8, 9, 10, 11, 12]
- [13, 14, 15, 16, 17]
...
-- -- inject error at various stages of commit and see that
-- the alter has no effects
-- - test that during commit phase
-- -> inject error at commit, inject error at rollback
-- the alter has no effects
--
-- usability
--
@todo
usability
-- ---------
-- - space name in all error messages!
-- error: Duplicate key exists in unique index 1 (ugly)
--
-- triggers
-- --------
-- - test that after disabling triggers we can
-- create an empty snapshot
-- - test for run_triggers on/off
--
-- recovery
-- --------
-- - add primary key in snapshot
-- - add secondary key in snapshot
-- - add primary key in xlog
-- - add secondary key in xlog
-- - the same for an empty space and a space with data
-- - test start from a space entry added in xlog
-- - test start from a space entry dropped in xlog
-- - test enabled/disabled property for these
-- spaces and space from a snapshot
--
--
-- features
-- @todo features
--------
-- - ffi function to enable/disable space
This diff is collapsed.
Click to expand it.
test/box/alter_limits.test.lua
+
127
−
38
View file @
f27e41e1
...
...
@@ -293,49 +293,138 @@ s:insert(2, 2)
s
.
index
.
secondary
:
alter
({
unique
=
false
})
s
:
insert
(
3
,
2
)
s
:
drop
()
-- -----------
--
--
-- space cache
-- -----------
-- - all the various kinds of reference to a dropped space
-- - iterator to index
-- index to space
-- space to index
-- variable
-- key def
-- all userdata given away to lua - think how
--
--
-- ----------------------------------------------------------------
-- SPACE CACHE: what happens to a space cache when an object is gone
-- ----------------------------------------------------------------
s
=
box
.
schema
.
create_space
(
'test'
)
s1
=
s
s
:
create_index
(
'primary'
,
'tree'
)
s1
.
index
.
primary
.
id
primary
=
s1
.
index
.
primary
s
.
index
.
primary
:
drop
()
primary
.
id
primary
:
select
()
-- @todo: add a test case for dangling iterator (currently no checks
-- for a dangling iterator in the code
-- ----------------------------------------------------------------
-- ----------------------------------------------------------------
-- RECOVERY: check that all indexes are correctly built
-- during recovery regardless of when they are created
-- ----------------------------------------------------------------
-- primary, secondary keys in a snapshot
s_empty
=
box
.
schema
.
create_space
(
's_empty'
)
s_empty
:
create_index
(
'primary'
,
'tree'
,
{
unique
=
true
,
parts
=
{
0
,
'num'
}})
s_empty
:
create_index
(
'secondary'
,
'hash'
,
{
unique
=
true
,
parts
=
{
1
,
'num'
}})
s_full
=
box
.
schema
.
create_space
(
's_full'
)
s_full
:
create_index
(
'primary'
,
'tree'
,
{
unique
=
true
,
parts
=
{
0
,
'num'
}})
s_full
:
create_index
(
'secondary'
,
'hash'
,
{
unique
=
true
,
parts
=
{
1
,
'num'
}})
s_full
:
insert
(
1
,
1
,
'a'
)
s_full
:
insert
(
2
,
2
,
'b'
)
s_full
:
insert
(
3
,
3
,
'c'
)
s_full
:
insert
(
4
,
4
,
'd'
)
s_full
:
insert
(
5
,
5
,
'e'
)
s_nil
=
box
.
schema
.
create_space
(
's_nil'
)
s_drop
=
box
.
schema
.
create_space
(
's_drop'
)
box
.
snapshot
()
s_drop
:
drop
()
s_nil
:
create_index
(
'primary'
,
'hash'
,
{
unique
=
true
,
parts
=
{
0
,
'num'
}})
s_nil
:
insert
(
1
,
2
,
3
,
4
,
5
,
6
);
s_nil
:
insert
(
7
,
8
,
9
,
10
,
11
,
12
)
s_nil
:
create_index
(
'secondary'
,
'tree'
,
{
unique
=
false
,
parts
=
{
1
,
'num'
,
2
,
'num'
,
3
,
'num'
}})
s_nil
:
insert
(
13
,
14
,
15
,
16
,
17
)
r_empty
=
box
.
schema
.
create_space
(
'r_empty'
)
r_empty
:
create_index
(
'primary'
,
'tree'
,
{
unique
=
true
,
parts
=
{
0
,
'num'
}})
r_empty
:
create_index
(
'secondary'
,
'hash'
,
{
unique
=
true
,
parts
=
{
1
,
'num'
}})
r_full
=
box
.
schema
.
create_space
(
'r_full'
)
r_full
:
create_index
(
'primary'
,
'tree'
,
{
unique
=
true
,
parts
=
{
0
,
'num'
}})
r_full
:
create_index
(
'secondary'
,
'hash'
,
{
unique
=
true
,
parts
=
{
1
,
'num'
}})
r_full
:
insert
(
1
,
1
,
'a'
)
r_full
:
insert
(
2
,
2
,
'b'
)
r_full
:
insert
(
3
,
3
,
'c'
)
r_full
:
insert
(
4
,
4
,
'd'
)
r_full
:
insert
(
5
,
5
,
'e'
)
s_full
:
create_index
(
'multikey'
,
'tree'
,
{
unique
=
true
,
parts
=
{
1
,
'num'
,
2
,
'str'
}})
s_full
:
insert
(
6
,
6
,
'f'
)
s_full
:
insert
(
7
,
7
,
'g'
)
s_full
:
insert
(
8
,
8
,
'h'
)
r_disabled
=
box
.
schema
.
create_space
(
'r_disabled'
)
--# stop server default
--# start server default
s_empty
=
box
.
space
[
's_empty'
]
s_full
=
box
.
space
[
's_full'
]
s_nil
=
box
.
space
[
's_nil'
]
s_drop
=
box
.
space
[
's_drop'
]
r_empty
=
box
.
space
[
'r_empty'
]
r_full
=
box
.
space
[
'r_full'
]
r_disabled
=
box
.
space
[
'r_disabled'
]
s_drop
s_empty
.
index
.
primary
.
type
s_full
.
index
.
primary
.
type
r_empty
.
index
.
primary
.
type
r_full
.
index
.
primary
.
type
s_nil
.
index
.
primary
.
type
s_empty
.
index
.
primary
.
name
s_full
.
index
.
primary
.
name
r_empty
.
index
.
primary
.
name
r_full
.
index
.
primary
.
name
s_nil
.
index
.
primary
.
name
s_empty
.
enabled
s_full
.
enabled
r_empty
.
enabled
r_full
.
enabled
s_nil
.
enabled
r_disabled
.
enabled
s_empty
.
index
.
secondary
.
name
s_full
.
index
.
secondary
.
name
r_empty
.
index
.
secondary
.
name
r_full
.
index
.
secondary
.
name
s_nil
.
index
.
secondary
.
name
s_empty
.
index
.
primary
:
count
(
1
)
s_full
.
index
.
primary
:
count
(
1
)
r_empty
.
index
.
primary
:
count
(
1
)
r_full
.
index
.
primary
:
count
(
1
)
s_nil
.
index
.
primary
:
count
(
1
)
s_empty
.
index
.
secondary
:
count
(
1
)
s_full
.
index
.
secondary
:
count
(
1
)
r_empty
.
index
.
secondary
:
count
(
1
)
r_full
.
index
.
secondary
:
count
(
1
)
s_nil
.
index
.
secondary
:
count
(
1
)
s_empty
.
index
.
primary
:
select
()
s_full
.
index
.
primary
:
select
()
r_empty
.
index
.
primary
:
select
()
r_full
.
index
.
primary
:
select
()
s_nil
.
index
.
secondary
:
select
()
-- -- inject error at various stages of commit and see that
-- the alter has no effects
-- - test that during commit phase
-- -> inject error at commit, inject error at rollback
-- the alter has no effects
--
-- usability
--
@todo
usability
-- ---------
-- - space name in all error messages!
-- error: Duplicate key exists in unique index 1 (ugly)
--
-- triggers
-- --------
-- - test that after disabling triggers we can
-- create an empty snapshot
-- - test for run_triggers on/off
--
-- recovery
-- --------
-- - add primary key in snapshot
-- - add secondary key in snapshot
-- - add primary key in xlog
-- - add secondary key in xlog
-- - the same for an empty space and a space with data
-- - test start from a space entry added in xlog
-- - test start from a space entry dropped in xlog
-- - test enabled/disabled property for these
-- spaces and space from a snapshot
--
--
-- features
-- @todo features
--------
-- - ffi function to enable/disable space
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment