Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
a20e1b41
Commit
a20e1b41
authored
Feb 02, 2005
by
joreland@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ndb -
add abort to multi op test case
parent
4ece8ae4
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
234 additions
and
139 deletions
+234
-139
ndb/include/ndbapi/NdbConnection.hpp
ndb/include/ndbapi/NdbConnection.hpp
+1
-1
ndb/test/include/HugoOperations.hpp
ndb/test/include/HugoOperations.hpp
+2
-0
ndb/test/ndbapi/testOperations.cpp
ndb/test/ndbapi/testOperations.cpp
+163
-77
ndb/test/src/HugoOperations.cpp
ndb/test/src/HugoOperations.cpp
+7
-0
ndb/test/src/HugoTransactions.cpp
ndb/test/src/HugoTransactions.cpp
+61
-61
No files found.
ndb/include/ndbapi/NdbConnection.hpp
View file @
a20e1b41
...
@@ -688,7 +688,7 @@ private:
...
@@ -688,7 +688,7 @@ private:
void
remove_list
(
NdbOperation
*&
head
,
NdbOperation
*
);
void
remove_list
(
NdbOperation
*&
head
,
NdbOperation
*
);
void
define_scan_op
(
NdbIndexScanOperation
*
);
void
define_scan_op
(
NdbIndexScanOperation
*
);
friend
int
runOperations
(
class
NDBT_Context
*
,
class
NDBT_Step
*
)
;
friend
class
HugoOperations
;
};
};
inline
inline
...
...
ndb/test/include/HugoOperations.hpp
View file @
a20e1b41
...
@@ -31,6 +31,8 @@ public:
...
@@ -31,6 +31,8 @@ public:
NdbConnection
*
getTransaction
();
NdbConnection
*
getTransaction
();
void
refresh
();
void
refresh
();
void
setTransactionId
(
Uint64
);
int
pkInsertRecord
(
Ndb
*
,
int
pkInsertRecord
(
Ndb
*
,
int
recordNo
,
int
recordNo
,
int
numRecords
=
1
,
int
numRecords
=
1
,
...
...
ndb/test/ndbapi/testOperations.cpp
View file @
a20e1b41
...
@@ -103,6 +103,10 @@ OperationTestCase matrix[] = {
...
@@ -103,6 +103,10 @@ OperationTestCase matrix[] = {
<< " failed on line " << __LINE__ << endl; \
<< " failed on line " << __LINE__ << endl; \
abort(); return NDBT_FAILED; }
abort(); return NDBT_FAILED; }
#define C3(b) if (!(b)) { \
g_err << "ERR: failed on line " << __LINE__ << endl; \
return NDBT_FAILED; }
int
int
runOp
(
HugoOperations
&
hugoOps
,
runOp
(
HugoOperations
&
hugoOps
,
Ndb
*
pNdb
,
Ndb
*
pNdb
,
...
@@ -326,18 +330,122 @@ generate(Vector<int>& out, size_t len)
...
@@ -326,18 +330,122 @@ generate(Vector<int>& out, size_t len)
}
}
}
}
static
const
Uint32
DUMMY
=
0
;
static
const
Uint32
ROW
=
1
;
int
int
runOperations
(
NDBT_Context
*
ctx
,
NDBT_Step
*
step
)
verify_other
(
NDBT_Context
*
ctx
,
Ndb
*
pNdb
,
int
seq
,
OPS
latest
,
bool
initial_row
,
bool
commit
)
{
Uint32
no_wait
=
NdbOperation
::
LM_CommittedRead
*
ctx
->
getProperty
(
"NoWait"
,
(
Uint32
)
1
);
for
(
size_t
j
=
no_wait
;
j
<
3
;
j
++
)
{
HugoOperations
other
(
*
ctx
->
getTab
());
C3
(
other
.
startTransaction
(
pNdb
)
==
0
);
C3
(
other
.
pkReadRecord
(
pNdb
,
ROW
,
1
,
(
NdbOperation
::
LockMode
)
j
)
==
0
);
int
tmp
=
other
.
execute_Commit
(
pNdb
);
if
(
seq
==
0
){
if
(
j
==
NdbOperation
::
LM_CommittedRead
)
{
C3
(
initial_row
?
tmp
==
0
&&
other
.
verifyUpdatesValue
(
0
)
==
0
:
tmp
==
626
);
}
else
{
C3
(
tmp
==
266
);
}
}
else
if
(
commit
)
{
switch
(
latest
){
case
o_INS
:
case
o_UPD
:
C3
(
tmp
==
0
&&
other
.
verifyUpdatesValue
(
seq
)
==
0
);
break
;
case
o_DEL
:
C3
(
tmp
==
626
);
break
;
case
o_DONE
:
abort
();
}
}
else
{
// rollback
C3
(
initial_row
?
tmp
==
0
&&
other
.
verifyUpdatesValue
(
0
)
==
0
:
tmp
==
626
);
}
}
return
NDBT_OK
;
}
int
verify_savepoint
(
NDBT_Context
*
ctx
,
Ndb
*
pNdb
,
int
seq
,
OPS
latest
,
Uint64
transactionId
)
{
{
const
Uint32
DUMMY
=
0
;
bool
initial_row
=
(
seq
==
0
)
&&
latest
==
o_INS
;
const
Uint32
ROW
=
1
;
for
(
size_t
j
=
0
;
j
<
3
;
j
++
)
{
const
NdbOperation
::
LockMode
lm
=
(
NdbOperation
::
LockMode
)
j
;
HugoOperations
same
(
*
ctx
->
getTab
());
C3
(
same
.
startTransaction
(
pNdb
)
==
0
);
same
.
setTransactionId
(
transactionId
);
// Cheat
/**
* Increase savepoint to <em>k</em>
*/
for
(
size_t
l
=
1
;
l
<=
seq
;
l
++
)
{
C3
(
same
.
pkReadRecord
(
pNdb
,
DUMMY
,
1
,
lm
)
==
0
);
// Read dummy row
C3
(
same
.
execute_NoCommit
(
pNdb
)
==
0
);
g_info
<<
"savepoint: "
<<
l
<<
endl
;
}
g_info
<<
"op("
<<
seq
<<
"): "
<<
" lock mode "
<<
lm
<<
endl
;
C3
(
same
.
pkReadRecord
(
pNdb
,
ROW
,
1
,
lm
)
==
0
);
// Read real row
int
tmp
=
same
.
execute_Commit
(
pNdb
);
if
(
seq
==
0
)
{
if
(
initial_row
)
{
C3
(
tmp
==
0
&&
same
.
verifyUpdatesValue
(
0
)
==
0
);
}
else
{
C3
(
tmp
==
626
);
}
}
else
{
switch
(
latest
){
case
o_INS
:
case
o_UPD
:
C3
(
tmp
==
0
&&
same
.
verifyUpdatesValue
(
seq
)
==
0
);
break
;
case
o_DEL
:
C3
(
tmp
==
626
);
break
;
case
o_DONE
:
abort
();
}
}
}
return
NDBT_OK
;
}
int
runOperations
(
NDBT_Context
*
ctx
,
NDBT_Step
*
step
)
{
int
tmp
;
int
tmp
;
Ndb
*
pNdb
=
GETNDB
(
step
);
Ndb
*
pNdb
=
GETNDB
(
step
);
Uint32
seqNo
=
ctx
->
getProperty
(
"Sequence"
,
(
Uint32
)
0
);
Uint32
seqNo
=
ctx
->
getProperty
(
"Sequence"
,
(
Uint32
)
0
);
Uint32
no_wait
=
NdbOperation
::
LM_CommittedRead
*
Uint32
commit
=
ctx
->
getProperty
(
"Commit"
,
(
Uint32
)
1
);
ctx
->
getProperty
(
"NoWait"
,
(
Uint32
)
1
);
if
(
seqNo
==
0
)
if
(
seqNo
==
0
)
{
{
...
@@ -355,8 +463,8 @@ runOperations(NDBT_Context* ctx, NDBT_Step* step)
...
@@ -355,8 +463,8 @@ runOperations(NDBT_Context* ctx, NDBT_Step* step)
C3
(
hugoOps
.
execute_Commit
(
pNdb
)
==
0
);
C3
(
hugoOps
.
execute_Commit
(
pNdb
)
==
0
);
}
}
const
bool
inital_row
=
(
seq
[
0
]
!=
o_INS
);
const
bool
init
i
al_row
=
(
seq
[
0
]
!=
o_INS
);
if
(
inital_row
)
if
(
init
i
al_row
)
{
{
HugoOperations
hugoOps
(
*
ctx
->
getTab
());
HugoOperations
hugoOps
(
*
ctx
->
getTab
());
C3
(
hugoOps
.
startTransaction
(
pNdb
)
==
0
);
C3
(
hugoOps
.
startTransaction
(
pNdb
)
==
0
);
...
@@ -389,79 +497,35 @@ runOperations(NDBT_Context* ctx, NDBT_Step* step)
...
@@ -389,79 +497,35 @@ runOperations(NDBT_Context* ctx, NDBT_Step* step)
/**
/**
* Verify other transaction
* Verify other transaction
*/
*/
for
(
size_t
j
=
no_wait
;
j
<
3
;
j
++
)
if
(
verify_other
(
ctx
,
pNdb
,
0
,
seq
[
0
],
initial_row
,
commit
)
!=
NDBT_OK
)
{
return
NDBT_FAILED
;
HugoOperations
other
(
*
ctx
->
getTab
());
C3
(
other
.
startTransaction
(
pNdb
)
==
0
);
C3
(
other
.
pkReadRecord
(
pNdb
,
ROW
,
1
,
(
NdbOperation
::
LockMode
)
j
)
==
0
);
tmp
=
other
.
execute_Commit
(
pNdb
);
if
(
j
==
NdbOperation
::
LM_CommittedRead
)
{
C3
(
inital_row
?
tmp
==
0
&&
other
.
verifyUpdatesValue
(
0
)
==
0
:
tmp
==
626
);
}
else
{
C3
(
tmp
==
266
);
}
}
/**
/**
* Verify savepoint read
* Verify savepoint read
*/
*/
Uint64
transactionId
=
trans1
.
getTransaction
()
->
getTransactionId
();
Uint64
transactionId
=
trans1
.
getTransaction
()
->
getTransactionId
();
for
(
size_t
k
=
0
;
k
<=
i
+
1
;
k
++
)
{
for
(
size_t
j
=
0
;
j
<
3
;
j
++
)
{
const
NdbOperation
::
LockMode
lm
=
(
NdbOperation
::
LockMode
)
j
;
HugoOperations
same
(
*
ctx
->
getTab
());
C3
(
same
.
startTransaction
(
pNdb
)
==
0
);
same
.
getTransaction
()
->
setTransactionId
(
transactionId
);
// Cheat
/**
for
(
size_t
k
=
0
;
k
<=
i
+
1
;
k
++
)
* Increase savepoint to <em>k</em>
*/
for
(
size_t
l
=
1
;
l
<=
k
;
l
++
)
{
{
C3
(
same
.
pkReadRecord
(
pNdb
,
DUMMY
,
1
,
lm
)
==
0
);
// Read dummy row
if
(
verify_savepoint
(
ctx
,
pNdb
,
k
,
C3
(
same
.
execute_NoCommit
(
pNdb
)
==
0
);
k
>
0
?
seq
[
k
-
1
]
:
initial_row
?
o_INS
:
o_DONE
,
g_info
<<
"savepoint: "
<<
l
<<
endl
;
transactionId
)
!=
NDBT_OK
)
return
NDBT_FAILED
;
}
}
}
g_info
<<
"op("
<<
k
<<
", "
<<
i
<<
"): "
if
(
commit
)
<<
" lock mode "
<<
lm
<<
endl
;
C3
(
same
.
pkReadRecord
(
pNdb
,
ROW
,
1
,
lm
)
==
0
);
// Read real row
tmp
=
same
.
execute_Commit
(
pNdb
);
if
(
k
==
0
)
{
if
(
inital_row
)
{
C3
(
tmp
==
0
&&
same
.
verifyUpdatesValue
(
0
)
==
0
);
}
else
{
{
C3
(
tmp
==
626
);
C3
(
trans1
.
execute_Commit
(
pNdb
)
==
0
);
}
}
}
else
else
{
{
switch
(
seq
[
k
-
1
]){
C3
(
trans1
.
execute_Rollback
(
pNdb
)
==
0
);
case
o_INS
:
case
o_UPD
:
C3
(
tmp
==
0
&&
same
.
verifyUpdatesValue
(
k
)
==
0
);
break
;
case
o_DEL
:
C3
(
tmp
==
626
);
break
;
case
o_DONE
:
abort
();
}
}
}
}
}
}
if
(
verify_other
(
ctx
,
pNdb
,
seq
.
size
(),
seq
.
back
(),
C3
(
trans1
.
execute_Commit
(
pNdb
)
==
0
);
initial_row
,
commit
)
!=
NDBT_OK
)
return
NDBT_FAILED
;
return
NDBT_OK
;
return
NDBT_OK
;
}
}
...
@@ -495,16 +559,38 @@ main(int argc, const char** argv){
...
@@ -495,16 +559,38 @@ main(int argc, const char** argv){
}
}
}
}
BaseString
n1
;
n1
.
append
(
name
);
n1
.
append
(
"_COMMIT"
);
NDBT_TestCaseImpl1
*
pt
=
new
NDBT_TestCaseImpl1
(
&
ts
,
NDBT_TestCaseImpl1
*
pt
=
new
NDBT_TestCaseImpl1
(
&
ts
,
name
.
c_str
()
+
1
,
""
);
n1
.
c_str
()
+
1
,
""
);
pt
->
setProperty
(
"Sequence"
,
tmp
[
i
]);
pt
->
addInitializer
(
new
NDBT_Initializer
(
pt
,
"runClearTable"
,
runClearTable
));
pt
->
addStep
(
new
NDBT_ParallelStep
(
pt
,
"run"
,
runOperations
));
pt
->
addFinalizer
(
new
NDBT_Finalizer
(
pt
,
"runClearTable"
,
runClearTable
));
ts
.
addTest
(
pt
);
name
.
append
(
"_ABORT"
);
pt
=
new
NDBT_TestCaseImpl1
(
&
ts
,
name
.
c_str
()
+
1
,
""
);
pt
->
setProperty
(
"Sequence"
,
tmp
[
i
]);
pt
->
setProperty
(
"Sequence"
,
tmp
[
i
]);
pt
->
setProperty
(
"Commit"
,
(
Uint32
)
0
);
pt
->
addInitializer
(
new
NDBT_Initializer
(
pt
,
pt
->
addInitializer
(
new
NDBT_Initializer
(
pt
,
"runClearTable"
,
"runClearTable"
,
runClearTable
));
runClearTable
));
pt
->
addStep
(
new
NDBT_ParallelStep
(
pt
,
pt
->
addStep
(
new
NDBT_ParallelStep
(
pt
,
name
.
c_str
()
+
1
,
"run"
,
runOperations
));
runOperations
));
pt
->
addFinalizer
(
new
NDBT_Finalizer
(
pt
,
pt
->
addFinalizer
(
new
NDBT_Finalizer
(
pt
,
...
...
ndb/test/src/HugoOperations.cpp
View file @
a20e1b41
...
@@ -32,6 +32,13 @@ int HugoOperations::startTransaction(Ndb* pNdb){
...
@@ -32,6 +32,13 @@ int HugoOperations::startTransaction(Ndb* pNdb){
return
NDBT_OK
;
return
NDBT_OK
;
}
}
void
HugoOperations
::
setTransactionId
(
Uint64
id
){
if
(
pTrans
!=
NULL
){
pTrans
->
setTransactionId
(
id
);
}
}
int
HugoOperations
::
closeTransaction
(
Ndb
*
pNdb
){
int
HugoOperations
::
closeTransaction
(
Ndb
*
pNdb
){
if
(
pTrans
!=
NULL
){
if
(
pTrans
!=
NULL
){
...
...
ndb/test/src/HugoTransactions.cpp
View file @
a20e1b41
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment