Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
picodata
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
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
picodata
Commits
11d8a371
Commit
11d8a371
authored
1 year ago
by
Georgy Moshkin
Browse files
Options
Downloads
Patches
Plain Diff
test: test dml for global user-defined spaces
parent
320952c9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!538
Feat/dml global
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/int/test_dml.py
+186
-0
186 additions, 0 deletions
test/int/test_dml.py
with
186 additions
and
0 deletions
test/int/test_dml.py
0 → 100644
+
186
−
0
View file @
11d8a371
from
conftest
import
Cluster
def
test_global_space_dml_catchup_by_log
(
cluster
:
Cluster
):
# Leader
i1
=
cluster
.
add_instance
(
wait_online
=
True
,
replicaset_id
=
"
r1
"
)
# For quorum
i2
=
cluster
.
add_instance
(
wait_online
=
True
,
replicaset_id
=
"
r1
"
)
# For quorum
i3
=
cluster
.
add_instance
(
wait_online
=
True
,
replicaset_id
=
"
r1
"
)
# Catcher-upper replicaset master
i4
=
cluster
.
add_instance
(
wait_online
=
True
,
replicaset_id
=
"
r2
"
)
# Catcher-upper replicaset follower
i5
=
cluster
.
add_instance
(
wait_online
=
True
,
replicaset_id
=
"
r2
"
)
index
=
i1
.
ddl_create_space
(
dict
(
id
=
812
,
name
=
"
candy
"
,
format
=
[
dict
(
name
=
"
id
"
,
type
=
"
unsigned
"
,
is_nullable
=
False
),
dict
(
name
=
"
kind
"
,
type
=
"
string
"
,
is_nullable
=
False
),
dict
(
name
=
"
kilos
"
,
type
=
"
number
"
,
is_nullable
=
False
),
],
primary_key
=
[
dict
(
field
=
"
id
"
)],
distribution
=
dict
(
kind
=
"
global
"
),
),
)
i2
.
raft_wait_index
(
index
,
3
)
# Some dml
index
=
i1
.
cas
(
"
insert
"
,
"
candy
"
,
[
1
,
"
marshmallow
"
,
2.7
])
i1
.
raft_wait_index
(
index
,
3
)
index
=
i1
.
cas
(
"
insert
"
,
"
candy
"
,
[
2
,
"
milk chocolate
"
,
6.9
])
i1
.
raft_wait_index
(
index
,
3
)
i2
.
raft_wait_index
(
index
,
3
)
i3
.
raft_wait_index
(
index
,
3
)
i4
.
raft_wait_index
(
index
,
3
)
i5
.
raft_wait_index
(
index
,
3
)
# Dml applied ok
expected_tuples
=
[
[
1
,
"
marshmallow
"
,
2.7
],
[
2
,
"
milk chocolate
"
,
6.9
],
]
assert
i1
.
call
(
"
box.space.candy:select
"
)
==
expected_tuples
assert
i2
.
call
(
"
box.space.candy:select
"
)
==
expected_tuples
assert
i3
.
call
(
"
box.space.candy:select
"
)
==
expected_tuples
assert
i4
.
call
(
"
box.space.candy:select
"
)
==
expected_tuples
assert
i5
.
call
(
"
box.space.candy:select
"
)
==
expected_tuples
# These will be catching up
i4
.
terminate
()
i5
.
terminate
()
# More DML
index
=
i1
.
cas
(
"
replace
"
,
"
candy
"
,
[
2
,
"
dark chocolate
"
,
13.37
])
i1
.
raft_wait_index
(
index
,
3
)
index
=
i1
.
cas
(
"
delete
"
,
"
candy
"
,
[
1
])
i1
.
raft_wait_index
(
index
,
3
)
index
=
i1
.
cas
(
"
insert
"
,
"
candy
"
,
[
3
,
"
ice cream
"
,
0.3
])
i1
.
raft_wait_index
(
index
,
3
)
i2
.
raft_wait_index
(
index
,
3
)
i3
.
raft_wait_index
(
index
,
3
)
# Dml applied ok again
expected_tuples
=
[
[
2
,
"
dark chocolate
"
,
13.37
],
[
3
,
"
ice cream
"
,
0.3
],
]
assert
i1
.
call
(
"
box.space.candy:select
"
)
==
expected_tuples
assert
i2
.
call
(
"
box.space.candy:select
"
)
==
expected_tuples
assert
i3
.
call
(
"
box.space.candy:select
"
)
==
expected_tuples
# Master catch up by log
i4
.
start
()
i4
.
wait_online
()
assert
i4
.
call
(
"
box.space.candy:select
"
)
==
expected_tuples
# Follower catch up by log
i5
.
start
()
i5
.
wait_online
()
assert
i5
.
call
(
"
box.space.candy:select
"
)
==
expected_tuples
# Master boot by log
i6
=
cluster
.
add_instance
(
wait_online
=
True
,
replicaset_id
=
"
r3
"
)
assert
i6
.
call
(
"
box.space.candy:select
"
)
==
expected_tuples
# Follower boot by log
i7
=
cluster
.
add_instance
(
wait_online
=
True
,
replicaset_id
=
"
r3
"
)
assert
i7
.
call
(
"
box.space.candy:select
"
)
==
expected_tuples
def
test_global_space_dml_catchup_by_snapshot
(
cluster
:
Cluster
):
# Leader
i1
=
cluster
.
add_instance
(
wait_online
=
True
,
replicaset_id
=
"
r1
"
)
# For quorum
i2
=
cluster
.
add_instance
(
wait_online
=
True
,
replicaset_id
=
"
r1
"
)
# For quorum
i3
=
cluster
.
add_instance
(
wait_online
=
True
,
replicaset_id
=
"
r1
"
)
# Catcher-upper replicaset master
i4
=
cluster
.
add_instance
(
wait_online
=
True
,
replicaset_id
=
"
r2
"
)
# Catcher-upper replicaset follower
i5
=
cluster
.
add_instance
(
wait_online
=
True
,
replicaset_id
=
"
r2
"
)
index
=
i1
.
ddl_create_space
(
dict
(
id
=
812
,
name
=
"
candy
"
,
format
=
[
dict
(
name
=
"
id
"
,
type
=
"
unsigned
"
,
is_nullable
=
False
),
dict
(
name
=
"
kind
"
,
type
=
"
string
"
,
is_nullable
=
False
),
dict
(
name
=
"
kilos
"
,
type
=
"
number
"
,
is_nullable
=
False
),
],
primary_key
=
[
dict
(
field
=
"
id
"
)],
distribution
=
dict
(
kind
=
"
global
"
),
),
)
i2
.
raft_wait_index
(
index
,
3
)
# Some dml
index
=
i1
.
cas
(
"
insert
"
,
"
candy
"
,
[
1
,
"
marshmallow
"
,
2.7
])
i1
.
raft_wait_index
(
index
,
3
)
index
=
i1
.
cas
(
"
insert
"
,
"
candy
"
,
[
2
,
"
milk chocolate
"
,
6.9
])
i1
.
raft_wait_index
(
index
,
3
)
i2
.
raft_wait_index
(
index
,
3
)
i3
.
raft_wait_index
(
index
,
3
)
i4
.
raft_wait_index
(
index
,
3
)
i5
.
raft_wait_index
(
index
,
3
)
# Dml applied ok
expected_tuples
=
[
[
1
,
"
marshmallow
"
,
2.7
],
[
2
,
"
milk chocolate
"
,
6.9
],
]
assert
i1
.
call
(
"
box.space.candy:select
"
)
==
expected_tuples
assert
i2
.
call
(
"
box.space.candy:select
"
)
==
expected_tuples
assert
i3
.
call
(
"
box.space.candy:select
"
)
==
expected_tuples
assert
i4
.
call
(
"
box.space.candy:select
"
)
==
expected_tuples
assert
i5
.
call
(
"
box.space.candy:select
"
)
==
expected_tuples
# These will be catching up
i4
.
terminate
()
i5
.
terminate
()
# More DML
index
=
i1
.
cas
(
"
replace
"
,
"
candy
"
,
[
2
,
"
dark chocolate
"
,
13.37
])
i1
.
raft_wait_index
(
index
,
3
)
index
=
i1
.
cas
(
"
delete
"
,
"
candy
"
,
[
1
])
i1
.
raft_wait_index
(
index
,
3
)
index
=
i1
.
cas
(
"
insert
"
,
"
candy
"
,
[
3
,
"
ice cream
"
,
0.3
])
i1
.
raft_wait_index
(
index
,
3
)
i2
.
raft_wait_index
(
index
,
3
)
i3
.
raft_wait_index
(
index
,
3
)
# Dml applied ok again
expected_tuples
=
[
[
2
,
"
dark chocolate
"
,
13.37
],
[
3
,
"
ice cream
"
,
0.3
],
]
assert
i1
.
call
(
"
box.space.candy:select
"
)
==
expected_tuples
assert
i2
.
call
(
"
box.space.candy:select
"
)
==
expected_tuples
assert
i3
.
call
(
"
box.space.candy:select
"
)
==
expected_tuples
# Compact raft log to trigger snapshot generation
i1
.
raft_compact_log
()
i2
.
raft_compact_log
()
i3
.
raft_compact_log
()
# Master catch up by snapshot
i4
.
start
()
i4
.
wait_online
()
assert
i4
.
call
(
"
box.space.candy:select
"
)
==
expected_tuples
# Follower catch up by snapshot
i5
.
start
()
i5
.
wait_online
()
assert
i5
.
call
(
"
box.space.candy:select
"
)
==
expected_tuples
# Master boot by snapshot
i6
=
cluster
.
add_instance
(
wait_online
=
True
,
replicaset_id
=
"
r3
"
)
assert
i6
.
call
(
"
box.space.candy:select
"
)
==
expected_tuples
# Follower boot by snapshot
i7
=
cluster
.
add_instance
(
wait_online
=
True
,
replicaset_id
=
"
r3
"
)
assert
i7
.
call
(
"
box.space.candy:select
"
)
==
expected_tuples
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