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