Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
cb92b7ca
Commit
cb92b7ca
authored
14 years ago
by
brinn
Browse files
Options
Downloads
Patches
Plain Diff
add: test case with a hanging process which creates lots of output on stdout
SVN: 18673
parent
367d95d1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
common/sourceTest/java/ch/systemsx/cisd/common/process/ProcessExecutionHelperTest.java
+31
-10
31 additions, 10 deletions
...temsx/cisd/common/process/ProcessExecutionHelperTest.java
with
31 additions
and
10 deletions
common/sourceTest/java/ch/systemsx/cisd/common/process/ProcessExecutionHelperTest.java
+
31
−
10
View file @
cb92b7ca
...
@@ -52,17 +52,17 @@ public class ProcessExecutionHelperTest
...
@@ -52,17 +52,17 @@ public class ProcessExecutionHelperTest
private
static
final
long
WATCHDOG_WAIT_MILLIS
=
1000L
;
private
static
final
long
WATCHDOG_WAIT_MILLIS
=
1000L
;
private
static
final
Logger
machineLog
=
private
static
final
Logger
machineLog
=
LogFactory
.
getLogger
(
LogCategory
.
MACHINE
,
LogFactory
.
getLogger
(
LogCategory
.
MACHINE
,
ProcessExecutionHelperTest
.
class
);
ProcessExecutionHelperTest
.
class
);
private
static
final
Logger
operationLog
=
private
static
final
Logger
operationLog
=
LogFactory
.
getLogger
(
LogCategory
.
OPERATION
,
LogFactory
.
getLogger
(
LogCategory
.
OPERATION
,
ProcessExecutionHelperTest
.
class
);
ProcessExecutionHelperTest
.
class
);
private
static
final
File
unitTestRootDirectory
=
private
static
final
File
unitTestRootDirectory
=
new
File
(
"targets"
+
File
.
separator
new
File
(
"targets"
+
File
.
separator
+
"unit-test-wd"
);
+
"unit-test-wd"
);
private
static
final
File
workingDirectory
=
private
static
final
File
workingDirectory
=
new
File
(
unitTestRootDirectory
,
new
File
(
unitTestRootDirectory
,
"ProcessExecutionHelperTest"
);
"ProcessExecutionHelperTest"
);
private
File
createExecutable
(
String
name
,
String
...
lines
)
throws
IOException
,
private
File
createExecutable
(
String
name
,
String
...
lines
)
throws
IOException
,
InterruptedException
InterruptedException
...
@@ -92,6 +92,12 @@ public class ProcessExecutionHelperTest
...
@@ -92,6 +92,12 @@ public class ProcessExecutionHelperTest
+
(
millisToSleep
/
1000.0f
),
"exit 0"
);
+
(
millisToSleep
/
1000.0f
),
"exit 0"
);
}
}
private
File
createExecutableEndlessLoop
(
String
name
)
throws
IOException
,
InterruptedException
{
return
createExecutable
(
name
,
"#! /bin/sh"
,
"n=1; while [ 1 ]; do echo $n; n=$(($n+1)); done"
);
}
@BeforeClass
@BeforeClass
public
void
init
()
public
void
init
()
{
{
...
@@ -278,6 +284,21 @@ public class ProcessExecutionHelperTest
...
@@ -278,6 +284,21 @@ public class ProcessExecutionHelperTest
assertEquals
(
sleepyMessage
,
result
.
getOutput
().
get
(
0
));
assertEquals
(
sleepyMessage
,
result
.
getOutput
().
get
(
0
));
}
}
@Test
(
groups
=
{
"requires_unix"
,
"slow"
})
public
void
testHangingExecLotsOfOutputOnStdOut
()
throws
Exception
{
final
File
dummyExec
=
createExecutableEndlessLoop
(
"iHang.sh"
);
final
ProcessResult
result
=
ProcessExecutionHelper
.
run
(
Arrays
.
asList
(
dummyExec
.
getAbsolutePath
()),
operationLog
,
machineLog
,
WATCHDOG_WAIT_MILLIS
);
assertTrue
(
result
.
isTimedOut
());
assertFalse
(
result
.
isOK
());
assertTrue
(
Integer
.
toString
(
result
.
getOutput
().
size
()),
result
.
getOutput
().
size
()
>
100
);
assertEquals
(
Integer
.
toString
(
result
.
getOutput
().
size
()),
result
.
getOutput
().
get
(
result
.
getOutput
().
size
()
-
1
));
}
@Test
(
groups
=
@Test
(
groups
=
{
"requires_unix"
,
"slow"
})
{
"requires_unix"
,
"slow"
})
public
void
testTryExecutionReadProcessOutput
()
throws
Exception
public
void
testTryExecutionReadProcessOutput
()
throws
Exception
...
@@ -312,8 +333,8 @@ public class ProcessExecutionHelperTest
...
@@ -312,8 +333,8 @@ public class ProcessExecutionHelperTest
operationLog
,
machineLog
);
operationLog
,
machineLog
);
result
.
log
();
result
.
log
();
assertFalse
(
result
.
isRun
());
assertFalse
(
result
.
isRun
());
assertTrue
(
result
.
getStartupFailureMessage
(),
result
.
getStartupFailureMessage
().
indexOf
(
assertTrue
(
result
.
getStartupFailureMessage
(),
"some_non_existent_executable"
)
>=
0
);
result
.
getStartupFailureMessage
().
indexOf
(
"some_non_existent_executable"
)
>=
0
);
}
}
@Test
(
groups
=
@Test
(
groups
=
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment