Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
966c6c1a
提交
966c6c1a
authored
10月 08, 2015
作者:
Thomas Mueller Graf
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix test cases for Windows
上级
278e6e81
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
43 行增加
和
31 行删除
+43
-31
TestConcurrentLinkedList.java
h2/src/test/org/h2/test/store/TestConcurrentLinkedList.java
+2
-0
TestMVStore.java
h2/src/test/org/h2/test/store/TestMVStore.java
+41
-31
没有找到文件。
h2/src/test/org/h2/test/store/TestConcurrentLinkedList.java
浏览文件 @
966c6c1a
...
@@ -117,6 +117,7 @@ public class TestConcurrentLinkedList extends TestBase {
...
@@ -117,6 +117,7 @@ public class TestConcurrentLinkedList extends TestBase {
@Override
@Override
public
void
call
()
{
public
void
call
()
{
while
(!
stop
)
{
while
(!
stop
)
{
Thread
.
yield
();
if
(
size
.
get
()
<
10
)
{
if
(
size
.
get
()
<
10
)
{
test
.
add
(
counter
.
getAndIncrement
());
test
.
add
(
counter
.
getAndIncrement
());
size
.
getAndIncrement
();
size
.
getAndIncrement
();
...
@@ -126,6 +127,7 @@ public class TestConcurrentLinkedList extends TestBase {
...
@@ -126,6 +127,7 @@ public class TestConcurrentLinkedList extends TestBase {
};
};
task
.
execute
();
task
.
execute
();
for
(
int
i
=
0
;
i
<
1000000
;)
{
for
(
int
i
=
0
;
i
<
1000000
;)
{
Thread
.
yield
();
Integer
x
=
test
.
peekFirst
();
Integer
x
=
test
.
peekFirst
();
if
(
x
==
null
)
{
if
(
x
==
null
)
{
continue
;
continue
;
...
...
h2/src/test/org/h2/test/store/TestMVStore.java
浏览文件 @
966c6c1a
...
@@ -434,16 +434,9 @@ public class TestMVStore extends TestBase {
...
@@ -434,16 +434,9 @@ public class TestMVStore extends TestBase {
assertEquals
(
"1"
,
header
.
get
(
"format"
).
toString
());
assertEquals
(
"1"
,
header
.
get
(
"format"
).
toString
());
header
.
put
(
"formatRead"
,
"1"
);
header
.
put
(
"formatRead"
,
"1"
);
header
.
put
(
"format"
,
"2"
);
header
.
put
(
"format"
,
"2"
);
forceWriteStoreHeader
(
s
);
MVMap
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
);
MVMap
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
);
// this is to ensure the file header is overwritten
forceWriteStoreHeader
(
s
);
// the header is written at least every 20 commits
for
(
int
i
=
0
;
i
<
30
;
i
++)
{
m
.
put
(
0
,
"Hello World "
+
i
);
s
.
commit
();
if
(
i
>
5
)
{
s
.
setRetentionTime
(
0
);
}
}
m
.
put
(
0
,
"Hello World"
);
m
.
put
(
0
,
"Hello World"
);
s
.
close
();
s
.
close
();
try
{
try
{
...
@@ -531,7 +524,7 @@ public class TestMVStore extends TestBase {
...
@@ -531,7 +524,7 @@ public class TestMVStore extends TestBase {
if
(
exRef
.
get
()
!=
null
)
{
if
(
exRef
.
get
()
!=
null
)
{
break
;
break
;
}
}
Thread
.
sleep
(
10
);
sleep
(
10
);
}
}
Throwable
e
=
exRef
.
get
();
Throwable
e
=
exRef
.
get
();
assertTrue
(
e
!=
null
);
assertTrue
(
e
!=
null
);
...
@@ -627,7 +620,7 @@ public class TestMVStore extends TestBase {
...
@@ -627,7 +620,7 @@ public class TestMVStore extends TestBase {
FileUtils
.
delete
(
fileName
);
FileUtils
.
delete
(
fileName
);
}
}
private
void
testWriteDelay
()
throws
InterruptedException
{
private
void
testWriteDelay
()
{
String
fileName
=
getBaseDir
()
+
"/"
+
getTestName
();
String
fileName
=
getBaseDir
()
+
"/"
+
getTestName
();
FileUtils
.
delete
(
fileName
);
FileUtils
.
delete
(
fileName
);
MVStore
s
;
MVStore
s
;
...
@@ -678,7 +671,7 @@ public class TestMVStore extends TestBase {
...
@@ -678,7 +671,7 @@ public class TestMVStore extends TestBase {
if
(
diff
>
1000
)
{
if
(
diff
>
1000
)
{
fail
();
fail
();
}
}
Thread
.
sleep
(
10
);
sleep
(
10
);
}
}
s
.
closeImmediately
();
s
.
closeImmediately
();
...
@@ -764,15 +757,7 @@ public class TestMVStore extends TestBase {
...
@@ -764,15 +757,7 @@ public class TestMVStore extends TestBase {
int
format
=
Integer
.
parseInt
(
header
.
get
(
"format"
).
toString
());
int
format
=
Integer
.
parseInt
(
header
.
get
(
"format"
).
toString
());
assertEquals
(
1
,
format
);
assertEquals
(
1
,
format
);
header
.
put
(
"format"
,
Integer
.
toString
(
format
+
1
));
header
.
put
(
"format"
,
Integer
.
toString
(
format
+
1
));
// this is to ensure the file header is overwritten
forceWriteStoreHeader
(
s
);
// the header is written at least every 20 commits
for
(
int
i
=
0
;
i
<
30
;
i
++)
{
if
(
i
>
5
)
{
s
.
setRetentionTime
(
0
);
}
m
.
put
(
10
,
100
*
i
);
s
.
commit
();
}
s
.
close
();
s
.
close
();
try
{
try
{
openStore
(
fileName
).
close
();
openStore
(
fileName
).
close
();
...
@@ -904,23 +889,44 @@ public class TestMVStore extends TestBase {
...
@@ -904,23 +889,44 @@ public class TestMVStore extends TestBase {
long
creationTime
=
(
Long
)
m
.
get
(
"created"
);
long
creationTime
=
(
Long
)
m
.
get
(
"created"
);
assertTrue
(
Math
.
abs
(
time
-
creationTime
)
<
100
);
assertTrue
(
Math
.
abs
(
time
-
creationTime
)
<
100
);
m
.
put
(
"test"
,
"123"
);
m
.
put
(
"test"
,
"123"
);
MVMap
<
Integer
,
Integer
>
map
=
s
.
openMap
(
"test"
);
forceWriteStoreHeader
(
s
);
s
.
close
();
s
=
openStore
(
fileName
);
Object
test
=
s
.
getStoreHeader
().
get
(
"test"
);
assertFalse
(
test
==
null
);
assertEquals
(
"123"
,
test
.
toString
());
s
.
close
();
}
private
static
void
forceWriteStoreHeader
(
MVStore
s
)
{
MVMap
<
Integer
,
Integer
>
map
=
s
.
openMap
(
"dummy"
);
map
.
put
(
10
,
100
);
map
.
put
(
10
,
100
);
// this is to ensure the file header is overwritten
// this is to ensure the file header is overwritten
// the header is written at least every 20 commits
// the header is written at least every 20 commits
for
(
int
i
=
0
;
i
<
30
;
i
++)
{
for
(
int
i
=
0
;
i
<
30
;
i
++)
{
if
(
i
>
5
)
{
if
(
i
>
5
)
{
s
.
setRetentionTime
(
0
);
s
.
setRetentionTime
(
0
);
// ensure that the next save time is different,
// so that blocks can be reclaimed
// (on Windows, resolution is 10 ms)
sleep
(
1
);
}
}
map
.
put
(
10
,
110
);
map
.
put
(
10
,
110
);
s
.
commit
();
s
.
commit
();
}
}
s
.
close
();
s
.
removeMap
(
map
);
s
=
openStore
(
fileName
);
s
.
commit
();
Object
test
=
s
.
getStoreHeader
().
get
(
"test"
);
}
assertFalse
(
test
==
null
);
assertEquals
(
"123"
,
test
.
toString
());
private
static
void
sleep
(
long
ms
)
{
s
.
close
();
// on Windows, need to sleep in some cases,
// mainly because the milliseconds resolution of
// System.currentTimeMillis is 10 ms.
try
{
Thread
.
sleep
(
ms
);
}
catch
(
InterruptedException
e
)
{
// ignore
}
}
}
private
void
testFileHeaderCorruption
()
throws
Exception
{
private
void
testFileHeaderCorruption
()
throws
Exception
{
...
@@ -939,7 +945,7 @@ public class TestMVStore extends TestBase {
...
@@ -939,7 +945,7 @@ public class TestMVStore extends TestBase {
}
}
FileStore
fs
=
s
.
getFileStore
();
FileStore
fs
=
s
.
getFileStore
();
long
size
=
fs
.
getFile
().
size
();
long
size
=
fs
.
getFile
().
size
();
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
for
(
int
i
=
0
;
i
<
10
0
;
i
++)
{
map
=
s
.
openMap
(
"test"
+
i
);
map
=
s
.
openMap
(
"test"
+
i
);
s
.
removeMap
(
map
);
s
.
removeMap
(
map
);
s
.
commit
();
s
.
commit
();
...
@@ -1387,10 +1393,11 @@ public class TestMVStore extends TestBase {
...
@@ -1387,10 +1393,11 @@ public class TestMVStore extends TestBase {
m
=
s
.
openMap
(
"data"
);
m
=
s
.
openMap
(
"data"
);
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
if
(
i
%
4
!=
0
)
{
if
(
i
%
4
!=
0
)
{
sleep
(
2
);
m
.
remove
(
i
);
m
.
remove
(
i
);
s
.
commit
();
}
}
}
}
s
.
commit
();
assertTrue
(
s
.
compact
(
100
,
50
*
1024
));
assertTrue
(
s
.
compact
(
100
,
50
*
1024
));
s
.
close
();
s
.
close
();
long
len2
=
FileUtils
.
size
(
fileName
);
long
len2
=
FileUtils
.
size
(
fileName
);
...
@@ -1762,6 +1769,7 @@ public class TestMVStore extends TestBase {
...
@@ -1762,6 +1769,7 @@ public class TestMVStore extends TestBase {
m
=
s
.
openMap
(
"data"
);
m
=
s
.
openMap
(
"data"
);
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
sleep
(
1
);
boolean
result
=
s
.
compact
(
50
,
50
*
1024
);
boolean
result
=
s
.
compact
(
50
,
50
*
1024
);
if
(!
result
)
{
if
(!
result
)
{
break
;
break
;
...
@@ -1790,6 +1798,7 @@ public class TestMVStore extends TestBase {
...
@@ -1790,6 +1798,7 @@ public class TestMVStore extends TestBase {
FileUtils
.
delete
(
fileName
);
FileUtils
.
delete
(
fileName
);
long
initialLength
=
0
;
long
initialLength
=
0
;
for
(
int
j
=
0
;
j
<
20
;
j
++)
{
for
(
int
j
=
0
;
j
<
20
;
j
++)
{
sleep
(
2
);
MVStore
s
=
openStore
(
fileName
);
MVStore
s
=
openStore
(
fileName
);
s
.
setRetentionTime
(
0
);
s
.
setRetentionTime
(
0
);
MVMap
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
);
MVMap
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
);
...
@@ -1831,6 +1840,7 @@ public class TestMVStore extends TestBase {
...
@@ -1831,6 +1840,7 @@ public class TestMVStore extends TestBase {
FileUtils
.
delete
(
fileName
);
FileUtils
.
delete
(
fileName
);
long
initialLength
=
0
;
long
initialLength
=
0
;
for
(
int
j
=
0
;
j
<
20
;
j
++)
{
for
(
int
j
=
0
;
j
<
20
;
j
++)
{
sleep
(
2
);
MVStore
s
=
openStore
(
fileName
);
MVStore
s
=
openStore
(
fileName
);
s
.
setRetentionTime
(
0
);
s
.
setRetentionTime
(
0
);
MVMap
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
);
MVMap
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
);
...
@@ -1848,7 +1858,7 @@ public class TestMVStore extends TestBase {
...
@@ -1848,7 +1858,7 @@ public class TestMVStore extends TestBase {
initialLength
=
len
;
initialLength
=
len
;
}
else
{
}
else
{
assertTrue
(
"len: "
+
len
+
" initial: "
+
initialLength
+
" j: "
+
j
,
assertTrue
(
"len: "
+
len
+
" initial: "
+
initialLength
+
" j: "
+
j
,
len
<=
initialLength
*
2
);
len
<=
initialLength
*
5
);
}
}
}
}
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论