Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
11e20221
提交
11e20221
authored
1月 21, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use helper method for sleeping on port in use exception in TestPgServer
上级
ce5690e6
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
31 行增加
和
22 行删除
+31
-22
TestPgServer.java
h2/src/test/org/h2/test/unit/TestPgServer.java
+31
-22
没有找到文件。
h2/src/test/org/h2/test/unit/TestPgServer.java
浏览文件 @
11e20221
...
@@ -22,6 +22,8 @@ import java.util.concurrent.ExecutionException;
...
@@ -22,6 +22,8 @@ import java.util.concurrent.ExecutionException;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.Future
;
import
java.util.concurrent.Future
;
import
org.h2.api.ErrorCode
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
import
org.h2.tools.Server
;
import
org.h2.tools.Server
;
...
@@ -45,19 +47,13 @@ public class TestPgServer extends TestBase {
...
@@ -45,19 +47,13 @@ public class TestPgServer extends TestBase {
config
.
memory
=
true
;
config
.
memory
=
true
;
config
.
mvStore
=
true
;
config
.
mvStore
=
true
;
config
.
mvcc
=
true
;
config
.
mvcc
=
true
;
// the sleeps are too mitigate "port in use" exceptions on Jenkins
// testPgAdapter() starts server by itself without a wait so run it first
testLowerCaseIdentifiers
();
Thread
.
sleep
(
100
);
testPgAdapter
();
testPgAdapter
();
Thread
.
sleep
(
100
);
testLowerCaseIdentifiers
(
);
testKeyAlias
();
testKeyAlias
();
Thread
.
sleep
(
100
);
testKeyAlias
();
testKeyAlias
();
Thread
.
sleep
(
100
);
testCancelQuery
();
testCancelQuery
();
Thread
.
sleep
(
100
);
testBinaryTypes
();
testBinaryTypes
();
Thread
.
sleep
(
100
);
testPrepareWithUnspecifiedType
();
testPrepareWithUnspecifiedType
();
}
}
...
@@ -70,10 +66,9 @@ public class TestPgServer extends TestBase {
...
@@ -70,10 +66,9 @@ public class TestPgServer extends TestBase {
"mem:pgserver;DATABASE_TO_UPPER=false"
,
"sa"
,
"sa"
);
"mem:pgserver;DATABASE_TO_UPPER=false"
,
"sa"
,
"sa"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(id int, name varchar(255))"
);
stat
.
execute
(
"create table test(id int, name varchar(255))"
);
Server
server
=
Server
.
createPgServer
(
"-baseDir"
,
getBaseDir
(),
Server
server
=
createPgServer
(
"-baseDir"
,
getBaseDir
(),
"-pgPort"
,
"5535"
,
"-pgDaemon"
,
"-key"
,
"pgserver"
,
"-pgPort"
,
"5535"
,
"-pgDaemon"
,
"-key"
,
"pgserver"
,
"mem:pgserver"
);
"mem:pgserver"
);
server
.
start
();
try
{
try
{
Connection
conn2
;
Connection
conn2
;
conn2
=
DriverManager
.
getConnection
(
conn2
=
DriverManager
.
getConnection
(
...
@@ -98,6 +93,28 @@ public class TestPgServer extends TestBase {
...
@@ -98,6 +93,28 @@ public class TestPgServer extends TestBase {
}
}
}
}
private
Server
createPgServer
(
String
...
args
)
throws
SQLException
{
Server
server
=
Server
.
createPgServer
(
args
);
int
failures
=
0
;
for
(;;)
{
try
{
server
.
start
();
return
server
;
}
catch
(
SQLException
e
)
{
// the sleeps are too mitigate "port in use" exceptions on Jenkins
if
(
e
.
getErrorCode
()
!=
ErrorCode
.
EXCEPTION_OPENING_PORT_2
||
++
failures
>
10
)
{
throw
e
;
}
println
(
"Sleeping"
);
try
{
Thread
.
sleep
(
100
);
}
catch
(
InterruptedException
e2
)
{
throw
new
RuntimeException
(
e2
);
}
}
}
}
private
void
testPgAdapter
()
throws
SQLException
{
private
void
testPgAdapter
()
throws
SQLException
{
deleteDb
(
"pgserver"
);
deleteDb
(
"pgserver"
);
Server
server
=
Server
.
createPgServer
(
Server
server
=
Server
.
createPgServer
(
...
@@ -120,9 +137,8 @@ public class TestPgServer extends TestBase {
...
@@ -120,9 +137,8 @@ public class TestPgServer extends TestBase {
return
;
return
;
}
}
Server
server
=
Server
.
createPgServer
(
Server
server
=
createPgServer
(
"-pgPort"
,
"5535"
,
"-pgDaemon"
,
"-key"
,
"pgserver"
,
"mem:pgserver"
);
"-pgPort"
,
"5535"
,
"-pgDaemon"
,
"-key"
,
"pgserver"
,
"mem:pgserver"
);
server
.
start
();
ExecutorService
executor
=
Executors
.
newSingleThreadExecutor
();
ExecutorService
executor
=
Executors
.
newSingleThreadExecutor
();
try
{
try
{
...
@@ -347,9 +363,8 @@ public class TestPgServer extends TestBase {
...
@@ -347,9 +363,8 @@ public class TestPgServer extends TestBase {
if
(!
getPgJdbcDriver
())
{
if
(!
getPgJdbcDriver
())
{
return
;
return
;
}
}
Server
server
=
Server
.
createPgServer
(
Server
server
=
createPgServer
(
"-pgPort"
,
"5535"
,
"-pgDaemon"
,
"-key"
,
"pgserver"
,
"mem:pgserver"
);
"-pgPort"
,
"5535"
,
"-pgDaemon"
,
"-key"
,
"pgserver"
,
"mem:pgserver"
);
server
.
start
();
try
{
try
{
Connection
conn
=
DriverManager
.
getConnection
(
Connection
conn
=
DriverManager
.
getConnection
(
"jdbc:postgresql://localhost:5535/pgserver"
,
"sa"
,
"sa"
);
"jdbc:postgresql://localhost:5535/pgserver"
,
"sa"
,
"sa"
);
...
@@ -375,13 +390,8 @@ public class TestPgServer extends TestBase {
...
@@ -375,13 +390,8 @@ public class TestPgServer extends TestBase {
return
;
return
;
}
}
// Sometimes the previous pg server has not finished shutting and we get
Server
server
=
createPgServer
(
// "port in use", so sleep for a bit.
Thread
.
sleep
(
100
);
Server
server
=
Server
.
createPgServer
(
"-pgPort"
,
"5535"
,
"-pgDaemon"
,
"-key"
,
"pgserver"
,
"mem:pgserver"
);
"-pgPort"
,
"5535"
,
"-pgDaemon"
,
"-key"
,
"pgserver"
,
"mem:pgserver"
);
server
.
start
();
try
{
try
{
Properties
props
=
new
Properties
();
Properties
props
=
new
Properties
();
props
.
setProperty
(
"user"
,
"sa"
);
props
.
setProperty
(
"user"
,
"sa"
);
...
@@ -437,9 +447,8 @@ public class TestPgServer extends TestBase {
...
@@ -437,9 +447,8 @@ public class TestPgServer extends TestBase {
return
;
return
;
}
}
Server
server
=
Server
.
createPgServer
(
Server
server
=
createPgServer
(
"-pgPort"
,
"5535"
,
"-pgDaemon"
,
"-key"
,
"pgserver"
,
"mem:pgserver"
);
"-pgPort"
,
"5535"
,
"-pgDaemon"
,
"-key"
,
"pgserver"
,
"mem:pgserver"
);
server
.
start
();
try
{
try
{
Properties
props
=
new
Properties
();
Properties
props
=
new
Properties
();
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论