Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
0faa5db5
提交
0faa5db5
authored
10月 17, 2013
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix test cases
上级
c9404560
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
41 行增加
和
33 行删除
+41
-33
TestKillProcessWhileWriting.java
...c/test/org/h2/test/store/TestKillProcessWhileWriting.java
+11
-9
TestDiskFull.java
h2/src/test/org/h2/test/synth/TestDiskFull.java
+13
-7
FilePathUnstable.java
h2/src/test/org/h2/test/utils/FilePathUnstable.java
+17
-17
没有找到文件。
h2/src/test/org/h2/test/store/TestKillProcessWhileWriting.java
浏览文件 @
0faa5db5
...
...
@@ -40,29 +40,31 @@ public class TestKillProcessWhileWriting extends TestBase {
test
(
"unstable:memFS:killProcess.h3"
);
if
(
config
.
big
)
{
fs
.
setPartialWrites
(
true
);
test
(
"unstable:memFS:killProcess.h3"
);
try
{
fs
.
setPartialWrites
(
true
);
test
(
"unstable:memFS:killProcess.h3"
);
}
finally
{
fs
.
setPartialWrites
(
false
);
}
}
}
private
void
test
(
String
fileName
)
throws
Exception
{
for
(
seed
=
0
;
seed
<
10
;
seed
++)
{
this
.
fileName
=
fileName
;
fs
.
setSeed
(
seed
);
FileUtils
.
delete
(
fileName
);
test
(
Integer
.
MAX_VALUE
);
test
(
Integer
.
MAX_VALUE
,
seed
);
int
max
=
Integer
.
MAX_VALUE
-
fs
.
getDiskFullCount
()
+
10
;
assertTrue
(
""
+
(
max
-
10
),
max
>
0
);
for
(
int
i
=
0
;
i
<
max
;
i
++)
{
fs
.
setSeed
(
seed
);
test
(
i
);
test
(
i
,
seed
);
}
}
}
private
void
test
(
int
x
)
throws
Exception
{
private
void
test
(
int
x
,
int
seed
)
throws
Exception
{
FileUtils
.
delete
(
fileName
);
fs
.
setDiskFullCount
(
x
);
fs
.
setDiskFullCount
(
x
,
seed
);
try
{
write
();
verify
();
...
...
@@ -70,7 +72,7 @@ public class TestKillProcessWhileWriting extends TestBase {
if
(
x
==
Integer
.
MAX_VALUE
)
{
throw
e
;
}
fs
.
setDiskFullCount
(
0
);
fs
.
setDiskFullCount
(
0
,
seed
);
verify
();
}
}
...
...
h2/src/test/org/h2/test/synth/TestDiskFull.java
浏览文件 @
0faa5db5
...
...
@@ -33,16 +33,21 @@ public class TestDiskFull extends TestBase {
@Override
public
void
test
()
throws
Exception
{
fs
=
FilePathUnstable
.
register
();
test
(
Integer
.
MAX_VALUE
);
int
max
=
Integer
.
MAX_VALUE
-
fs
.
getDiskFullCount
()
+
10
;
for
(
int
i
=
0
;
i
<
max
;
i
++)
{
test
(
i
);
fs
.
setPartialWrites
(
true
);
try
{
test
(
Integer
.
MAX_VALUE
);
int
max
=
Integer
.
MAX_VALUE
-
fs
.
getDiskFullCount
()
+
10
;
for
(
int
i
=
0
;
i
<
max
;
i
++)
{
test
(
i
);
}
}
finally
{
fs
.
setPartialWrites
(
false
);
}
}
private
boolean
test
(
int
x
)
throws
SQLException
{
deleteDb
(
"memFS:"
,
null
);
fs
.
setDiskFullCount
(
x
);
fs
.
setDiskFullCount
(
x
,
0
);
String
url
=
"jdbc:h2:unstable:memFS:diskFull"
+
x
+
";FILE_LOCK=NO;TRACE_LEVEL_FILE=0;WRITE_DELAY=10;"
+
"LOCK_TIMEOUT=100;CACHE_SIZE=4096"
;
...
...
@@ -74,7 +79,7 @@ public class TestDiskFull extends TestBase {
}
if
(
stat
!=
null
)
{
try
{
fs
.
setDiskFullCount
(
0
);
fs
.
setDiskFullCount
(
0
,
0
);
stat
.
execute
(
"create table if not exists test(id int primary key, name varchar)"
);
stat
.
execute
(
"insert into test values(4, space(10000))"
);
stat
.
execute
(
"update test set name='Hallo' where id=3"
);
...
...
@@ -102,7 +107,7 @@ public class TestDiskFull extends TestBase {
}
}
}
fs
.
setDiskFullCount
(
0
);
fs
.
setDiskFullCount
(
0
,
0
);
try
{
conn
=
null
;
conn
=
DriverManager
.
getConnection
(
url
);
...
...
@@ -115,6 +120,7 @@ public class TestDiskFull extends TestBase {
stat
=
conn
.
createStatement
();
stat
.
execute
(
"script to 'memFS:test.sql'"
);
conn
.
close
();
return
false
;
}
...
...
h2/src/test/org/h2/test/utils/FilePathUnstable.java
浏览文件 @
0faa5db5
...
...
@@ -44,6 +44,23 @@ public class FilePathUnstable extends FilePathWrapper {
FilePath
.
register
(
INSTANCE
);
return
INSTANCE
;
}
/**
* Set the number of write operations before the disk is full, and the
* random seed (for partial writes).
*
* @param count the number of write operations (0 to never fail,
* Integer.MAX_VALUE to count the operations)
* @param seed the new seed
*/
public
void
setDiskFullCount
(
int
count
,
int
seed
)
{
diskFullOffCount
=
count
;
random
.
setSeed
(
seed
);
}
public
int
getDiskFullCount
()
{
return
diskFullOffCount
;
}
/**
* Whether partial writes are possible (writing only part of the data).
...
...
@@ -58,15 +75,6 @@ public class FilePathUnstable extends FilePathWrapper {
return
partialWrites
;
}
/**
* Set the random seed.
*
* @param seed the new seed
*/
public
void
setSeed
(
long
seed
)
{
random
.
setSeed
(
seed
);
}
/**
* Get a buffer with a subset (the head) of the data of the source buffer.
*
...
...
@@ -196,14 +204,6 @@ public class FilePathUnstable extends FilePathWrapper {
return
super
.
createTempFile
(
suffix
,
deleteOnExit
,
inTempDir
);
}
public
void
setDiskFullCount
(
int
count
)
{
diskFullOffCount
=
count
;
}
public
int
getDiskFullCount
()
{
return
diskFullOffCount
;
}
@Override
public
String
getScheme
()
{
return
"unstable"
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论