Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
86af1cc6
提交
86af1cc6
authored
10月 01, 2013
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MVStore: additional tests
上级
5631940a
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
310 行增加
和
0 行删除
+310
-0
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+4
-0
TestKillProcessWhileWriting.java
...c/test/org/h2/test/store/TestKillProcessWhileWriting.java
+150
-0
TestRandomMapOps.java
h2/src/test/org/h2/test/store/TestRandomMapOps.java
+156
-0
没有找到文件。
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
86af1cc6
...
...
@@ -114,11 +114,13 @@ import org.h2.test.store.TestCacheLongKeyLIRS;
import
org.h2.test.store.TestConcurrent
;
import
org.h2.test.store.TestDataUtils
;
import
org.h2.test.store.TestFreeSpace
;
import
org.h2.test.store.TestKillProcessWhileWriting
;
import
org.h2.test.store.TestMVRTree
;
import
org.h2.test.store.TestMVStore
;
import
org.h2.test.store.TestMVStoreBenchmark
;
import
org.h2.test.store.TestMVTableEngine
;
import
org.h2.test.store.TestObjectDataType
;
import
org.h2.test.store.TestRandomMapOps
;
import
org.h2.test.store.TestSpinLock
;
import
org.h2.test.store.TestStreamStore
;
import
org.h2.test.store.TestTransactionStore
;
...
...
@@ -734,11 +736,13 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
new
TestConcurrent
().
runTest
(
this
);
new
TestDataUtils
().
runTest
(
this
);
new
TestFreeSpace
().
runTest
(
this
);
new
TestKillProcessWhileWriting
().
runTest
(
this
);
new
TestMVRTree
().
runTest
(
this
);
new
TestMVStore
().
runTest
(
this
);
new
TestMVStoreBenchmark
().
runTest
(
this
);
new
TestMVTableEngine
().
runTest
(
this
);
new
TestObjectDataType
().
runTest
(
this
);
new
TestRandomMapOps
().
runTest
(
this
);
new
TestSpinLock
().
runTest
(
this
);
new
TestStreamStore
().
runTest
(
this
);
new
TestTransactionStore
().
runTest
(
this
);
...
...
h2/src/test/org/h2/test/store/TestKillProcessWhileWriting.java
0 → 100644
浏览文件 @
86af1cc6
/*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License, Version
* 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: H2 Group
*/
package
org
.
h2
.
test
.
store
;
import
java.util.Random
;
import
org.h2.mvstore.MVMap
;
import
org.h2.mvstore.MVStore
;
import
org.h2.store.fs.FilePathCrypt
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.test.TestBase
;
import
org.h2.test.utils.FilePathUnstable
;
/**
* Tests the MVStore.
*/
public
class
TestKillProcessWhileWriting
extends
TestBase
{
private
String
fileName
;
private
int
seed
;
private
FilePathUnstable
fs
;
/**
* Run just this test.
*
* @param a ignored
*/
public
static
void
main
(
String
...
a
)
throws
Exception
{
TestBase
.
createCaller
().
init
().
test
();
}
@Override
public
void
test
()
throws
Exception
{
fs
=
FilePathUnstable
.
register
();
test
(
"unstable:memFS:killProcess.h3"
);
int
todo
;
// need to test with a file system splits writes into blocks of 4 KB
FilePathCrypt
.
register
();
test
(
"unstable:crypt:0007:memFS:killProcess.h3"
);
}
public
void
test
(
String
fileName
)
throws
Exception
{
for
(
seed
=
0
;
seed
<
10
;
seed
++)
{
this
.
fileName
=
fileName
;
FileUtils
.
delete
(
fileName
);
test
(
Integer
.
MAX_VALUE
);
int
max
=
Integer
.
MAX_VALUE
-
fs
.
getDiskFullCount
()
+
10
;
assertTrue
(
""
+
(
max
-
10
),
max
>
0
);
for
(
int
i
=
0
;
i
<
max
;
i
++)
{
test
(
i
);
}
}
}
private
void
test
(
int
x
)
throws
Exception
{
FileUtils
.
delete
(
fileName
);
fs
.
setDiskFullCount
(
x
);
try
{
write
();
verify
();
}
catch
(
Exception
e
)
{
if
(
x
==
Integer
.
MAX_VALUE
)
{
throw
e
;
}
fs
.
setDiskFullCount
(
0
);
verify
();
}
}
private
int
write
()
{
MVStore
s
;
MVMap
<
Integer
,
byte
[]>
m
;
s
=
new
MVStore
.
Builder
().
fileName
(
fileName
).
pageSplitSize
(
50
).
writeDelay
(
0
).
open
();
s
.
setWriteDelay
(
0
);
m
=
s
.
openMap
(
"data"
);
Random
r
=
new
Random
(
seed
);
int
op
=
0
;
try
{
for
(;
op
<
50
;
op
++)
{
int
k
=
r
.
nextInt
(
100
);
byte
[]
v
=
new
byte
[
r
.
nextInt
(
100
)
*
100
];
int
type
=
r
.
nextInt
(
10
);
switch
(
type
)
{
case
0
:
case
1
:
case
2
:
case
3
:
m
.
put
(
k
,
v
);
break
;
case
4
:
case
5
:
m
.
remove
(
k
);
break
;
case
6
:
s
.
store
();
break
;
case
7
:
s
.
compact
(
80
);
break
;
case
8
:
m
.
clear
();
break
;
case
9
:
s
.
close
();
s
=
new
MVStore
.
Builder
().
fileName
(
fileName
).
pageSplitSize
(
50
).
writeDelay
(
0
).
open
();
m
=
s
.
openMap
(
"data"
);
break
;
}
}
s
.
store
();
s
.
close
();
return
0
;
}
catch
(
Exception
e
)
{
s
.
closeImmediately
();
return
op
;
}
}
private
void
verify
()
{
MVStore
s
;
MVMap
<
Integer
,
byte
[]>
m
;
FileUtils
.
delete
(
fileName
);
s
=
new
MVStore
.
Builder
().
fileName
(
fileName
).
open
();
m
=
s
.
openMap
(
"data"
);
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
byte
[]
x
=
m
.
get
(
i
);
if
(
x
==
null
)
{
break
;
}
assertEquals
(
i
*
100
,
x
.
length
);
}
s
.
close
();
}
}
h2/src/test/org/h2/test/store/TestRandomMapOps.java
0 → 100644
浏览文件 @
86af1cc6
/*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License, Version
* 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). Initial Developer: H2 Group
*/
package
org
.
h2
.
test
.
store
;
import
java.util.Random
;
import
java.util.TreeMap
;
import
org.h2.mvstore.MVMap
;
import
org.h2.mvstore.MVStore
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.test.TestBase
;
/**
* Tests the MVStore.
*/
public
class
TestRandomMapOps
extends
TestBase
{
private
String
fileName
;
private
int
seed
;
private
int
op
;
/**
* Run just this test.
*
* @param a ignored
*/
public
static
void
main
(
String
...
a
)
throws
Exception
{
TestBase
.
createCaller
().
init
().
test
();
}
@Override
public
void
test
()
throws
Exception
{
test
(
"memFS:randomOps.h3"
);
int
todoTestConcurrentMap
;
int
todoTestMVRTreeMap
;
}
public
void
test
(
String
fileName
)
{
this
.
fileName
=
fileName
;
int
best
=
Integer
.
MAX_VALUE
;
int
bestSeed
=
0
;
Throwable
failException
=
null
;
for
(
seed
=
0
;
seed
<
1000
;
seed
++)
{
FileUtils
.
delete
(
fileName
);
Throwable
ex
=
null
;
try
{
testCase
();
continue
;
}
catch
(
Exception
e
)
{
ex
=
e
;
}
catch
(
AssertionError
e
)
{
ex
=
e
;
}
if
(
op
<
best
)
{
trace
(
seed
);
bestSeed
=
seed
;
best
=
op
;
failException
=
ex
;
}
}
if
(
failException
!=
null
)
{
throw
(
AssertionError
)
new
AssertionError
(
"seed = "
+
bestSeed
+
" op = "
+
best
).
initCause
(
failException
);
}
}
private
void
testCase
()
throws
Exception
{
FileUtils
.
delete
(
fileName
);
MVStore
s
;
MVMap
<
Integer
,
byte
[]>
m
;
s
=
new
MVStore
.
Builder
().
fileName
(
fileName
).
pageSplitSize
(
50
).
writeDelay
(
0
).
open
();
m
=
s
.
openMap
(
"data"
);
Random
r
=
new
Random
(
seed
);
op
=
0
;
int
size
=
getSize
(
10
,
100
);
TreeMap
<
Integer
,
byte
[]>
map
=
new
TreeMap
<
Integer
,
byte
[]>();
for
(;
op
<
size
;
op
++)
{
int
k
=
r
.
nextInt
(
100
);
byte
[]
v
=
new
byte
[
r
.
nextInt
(
10
)
*
10
];
int
type
=
r
.
nextInt
(
11
);
switch
(
type
)
{
case
0
:
case
1
:
case
2
:
case
3
:
log
(
op
,
k
,
v
,
"put"
);
m
.
put
(
k
,
v
);
map
.
put
(
k
,
v
);
break
;
case
4
:
case
5
:
log
(
op
,
k
,
v
,
"remove"
);
m
.
remove
(
k
);
map
.
remove
(
k
);
break
;
case
6
:
log
(
op
,
k
,
v
,
"store"
);
s
.
store
();
break
;
case
7
:
log
(
op
,
k
,
v
,
"compact"
);
s
.
compact
(
80
);
break
;
case
8
:
log
(
op
,
k
,
v
,
"clear"
);
m
.
clear
();
map
.
clear
();
break
;
case
9
:
log
(
op
,
k
,
v
,
"commit"
);
s
.
commit
();
break
;
case
10
:
log
(
op
,
k
,
v
,
"reopen"
);
s
.
commit
();
s
.
close
();
s
=
new
MVStore
.
Builder
().
fileName
(
fileName
).
pageSplitSize
(
50
).
writeDelay
(
0
).
open
();
m
=
s
.
openMap
(
"data"
);
break
;
}
assertEqualsMapValues
(
map
.
get
(
k
),
m
.
get
(
k
));
assertEquals
(
map
.
ceilingKey
(
k
),
m
.
ceilingKey
(
k
));
assertEquals
(
map
.
floorKey
(
k
),
m
.
floorKey
(
k
));
assertEquals
(
map
.
higherKey
(
k
),
m
.
higherKey
(
k
));
assertEquals
(
map
.
lowerKey
(
k
),
m
.
lowerKey
(
k
));
assertEquals
(
map
.
isEmpty
(),
m
.
isEmpty
());
if
(
map
.
size
()
!=
m
.
size
())
{
assertEquals
(
map
.
size
(),
m
.
size
());
}
}
s
.
store
();
s
.
close
();
}
private
void
assertEqualsMapValues
(
byte
[]
x
,
byte
[]
y
)
{
if
(
x
==
null
||
y
==
null
)
{
if
(
x
!=
y
)
{
assertTrue
(
x
==
y
);
}
}
else
{
assertEquals
(
x
.
length
,
y
.
length
);
}
}
private
static
void
log
(
int
op
,
int
k
,
byte
[]
v
,
String
msg
)
{
// System.out.println(op + ": " + msg + " key: " + k + " value: " + v);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论