Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
argotest
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Reis
argotest
Commits
fd233bbb
Commit
fd233bbb
authored
Jan 09, 2019
by
Valentin Reis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updating the tests to allow CSV logging (+ reformatting)
parent
50ffa445
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
27 deletions
+50
-27
argo/src/Argo/Args.hs
argo/src/Argo/Args.hs
+2
-2
argo/src/Argo/Stack.hs
argo/src/Argo/Stack.hs
+0
-2
argotk/argotk.hs
argotk/argotk.hs
+48
-23
No files found.
argo/src/Argo/Args.hs
View file @
fd233bbb
...
@@ -52,8 +52,8 @@ behaviorOption = option behavior
...
@@ -52,8 +52,8 @@ behaviorOption = option behavior
instance
Default
StackArgs
where
instance
Default
StackArgs
where
def
=
StackArgs
def
=
StackArgs
{
app
=
AppName
"
echo
"
{
app
=
AppName
"
ls
"
,
args
=
AppArgs
[
"foobar"
]
,
args
=
AppArgs
[]
,
containerName
=
ContainerName
"testContainer"
,
containerName
=
ContainerName
"testContainer"
,
workingDirectory
=
WorkingDirectory
"_output"
,
workingDirectory
=
WorkingDirectory
"_output"
,
manifestDir
=
ManifestDir
"manifests"
,
manifestDir
=
ManifestDir
"manifests"
...
...
argo/src/Argo/Stack.hs
View file @
fd233bbb
...
@@ -176,7 +176,6 @@ cmdListenPowerI (ContainerName cn) pb =
...
@@ -176,7 +176,6 @@ cmdListenPowerI (ContainerName cn) pb =
data
StackOutput
=
data
StackOutput
=
FoundMessage
FoundMessage
|
MessageNotFound
|
Died
StackI
ExitCode
|
Died
StackI
ExitCode
data
StackI
=
Daemon
|
Run
|
Listen
|
Progress
|
Power
deriving
(
Show
)
data
StackI
=
Daemon
|
Run
|
Listen
|
Progress
|
Power
deriving
(
Show
)
...
@@ -211,7 +210,6 @@ runStack a@StackArgs {..} = do
...
@@ -211,7 +210,6 @@ runStack a@StackArgs {..} = do
out
<-
liftIO
$
waitAnyCancel
asyncs
out
<-
liftIO
$
waitAnyCancel
asyncs
return
$
case
snd
out
of
return
$
case
snd
out
of
(
_
,
Left
PatternMatched
)
->
FoundMessage
(
_
,
Left
PatternMatched
)
->
FoundMessage
(
Run
,
Right
(
ExitSuccess
,
_
,
_
))
->
MessageNotFound
(
stacki
,
Right
(
e
,
_
,
_
)
)
->
Died
stacki
e
(
stacki
,
Right
(
e
,
_
,
_
)
)
->
Died
stacki
e
where
where
tupleToAsync
tupleToAsync
...
...
argotk/argotk.hs
View file @
fd233bbb
...
@@ -17,15 +17,10 @@ opts :: StackArgs -> Parser (Shell ())
...
@@ -17,15 +17,10 @@ opts :: StackArgs -> Parser (Shell ())
opts
sa
=
hsubparser
opts
sa
=
hsubparser
(
command
"clean"
(
command
"clean"
(
info
(
pure
$
clean
sa
)
(
progDesc
"Clean sockets, logfiles."
))
(
info
(
pure
$
clean
sa
)
(
progDesc
"Clean sockets, logfiles."
))
<>
commandTest
DaemonOnly
<>
(
mconcat
$
fmap
commandTest
[(
minBound
::
TestType
)
..
])
<>
commandTest
DaemonAndApp
<>
commandTest
TestHello
<>
commandTest
TestListen
<>
commandTest
TestPerfwrapper
<>
commandTest
TestPower
<>
commandTests
[
TestHello
,
TestListen
,
TestPerfwrapper
]
<>
commandTests
[
TestHello
,
TestListen
,
TestPerfwrapper
]
"tests"
"tests"
"Run
all
tests"
"Run
hardware-independent CI
tests"
<>
help
<>
help
"Type of test to run. There are extensive options under each action,
\
"Type of test to run. There are extensive options under each action,
\
\
but be careful, these do not all have the same defaults. The default
\
\
but be careful, these do not all have the same defaults. The default
\
...
@@ -40,10 +35,18 @@ opts sa = hsubparser
...
@@ -40,10 +35,18 @@ opts sa = hsubparser
commandTests
ttypes
cmdStr
descStr
=
commandTests
ttypes
cmdStr
descStr
=
command
cmdStr
$
info
(
pure
$
mapM_
(
doTest
sa
)
ttypes
)
(
progDesc
descStr
)
command
cmdStr
$
info
(
pure
$
mapM_
(
doTest
sa
)
ttypes
)
(
progDesc
descStr
)
data
TestType
=
DaemonOnly
|
DaemonAndApp
|
TestHello
|
TestListen
|
TestPerfwrapper
|
TestPower
deriving
Show
data
TestType
=
DaemonOnly
|
DaemonAndApp
|
CsvLogs
|
TestHello
|
TestListen
|
TestPerfwrapper
|
TestPower
deriving
(
Enum
,
Bounded
,
Show
)
data
TestSpec
=
TestSpec
data
TestSpec
=
TestSpec
{
stackArgsUpdate
::
StackArgs
->
StackArgs
{
stackArgsUpdate
::
StackArgs
->
StackArgs
,
isTest
::
IsTest
,
description
::
String
}
,
description
::
String
}
doTest
::
StackArgs
->
TestType
->
Shell
()
doTest
::
StackArgs
->
TestType
->
Shell
()
...
@@ -57,7 +60,7 @@ doOverridenTest ttype = doSpec spec where spec = configureTest ttype
...
@@ -57,7 +60,7 @@ doOverridenTest ttype = doSpec spec where spec = configureTest ttype
doSpec
::
TestSpec
->
StackArgs
->
Shell
()
doSpec
::
TestSpec
->
StackArgs
->
Shell
()
doSpec
spec
stackArgs
=
do
doSpec
spec
stackArgs
=
do
printTest
$
T
.
pack
$
description
spec
printTest
$
T
.
pack
$
description
spec
fullStack
stackArgs
fullStack
(
isTest
spec
)
stackArgs
printSuccess
"Test Successful."
printSuccess
"Test Successful."
configureTest
::
TestType
->
TestSpec
configureTest
::
TestType
->
TestSpec
...
@@ -65,11 +68,24 @@ configureTest = \case
...
@@ -65,11 +68,24 @@ configureTest = \case
DaemonOnly
->
TestSpec
DaemonOnly
->
TestSpec
{
stackArgsUpdate
=
\
sa
->
sa
{
daemon
=
daemonBehavior
}
{
stackArgsUpdate
=
\
sa
->
sa
{
daemon
=
daemonBehavior
}
,
description
=
"Set up and launch the daemon in synchronous mode."
,
description
=
"Set up and launch the daemon in synchronous mode."
,
isTest
=
IsTest
False
}
}
DaemonAndApp
->
TestSpec
DaemonAndApp
->
TestSpec
{
stackArgsUpdate
=
\
sa
->
sa
{
daemon
=
daemonBehavior
,
cmdrun
=
runBehavior
,
cmdlistenprogress
=
JustRun
(
StdOutLog
"progress.csv"
)
(
StdErrLog
"progress.log"
)
,
cmdlistenpower
=
JustRun
(
StdOutLog
"power.csv"
)
(
StdErrLog
"power.log"
)
}
,
description
=
"Set up and start daemon, run a command in a container."
,
isTest
=
IsTest
False
}
CsvLogs
->
TestSpec
{
stackArgsUpdate
=
\
sa
->
{
stackArgsUpdate
=
\
sa
->
sa
{
daemon
=
daemonBehavior
,
cmdrun
=
runBehavior
}
sa
{
daemon
=
daemonBehavior
,
cmdrun
=
runBehavior
}
,
description
=
"Set up and start daemon, run a command in a container."
,
description
=
"Set up and start daemon, run a command in a container."
,
isTest
=
IsTest
False
}
}
TestHello
->
TestSpec
TestHello
->
TestSpec
{
stackArgsUpdate
=
\
sa
->
sa
{
stackArgsUpdate
=
\
sa
->
sa
...
@@ -82,6 +98,7 @@ configureTest = \case
...
@@ -82,6 +98,7 @@ configureTest = \case
}
}
,
description
=
"1: Setup stack and check that a hello world app sends
\
,
description
=
"1: Setup stack and check that a hello world app sends
\
\
message back to cmd."
\
message back to cmd."
,
isTest
=
IsTest
True
}
}
TestListen
->
TestSpec
TestListen
->
TestSpec
{
stackArgsUpdate
=
\
sa
->
sa
{
stackArgsUpdate
=
\
sa
->
sa
...
@@ -93,6 +110,7 @@ configureTest = \case
...
@@ -93,6 +110,7 @@ configureTest = \case
}
}
,
description
=
"2: Setup stack and check that argo-perf-wrapper sends
\
,
description
=
"2: Setup stack and check that argo-perf-wrapper sends
\
\
at least one message to the daemon."
\
at least one message to the daemon."
,
isTest
=
IsTest
True
}
}
TestPerfwrapper
->
TestSpec
TestPerfwrapper
->
TestSpec
{
stackArgsUpdate
=
\
sa
->
sa
{
stackArgsUpdate
=
\
sa
->
sa
...
@@ -106,6 +124,7 @@ configureTest = \case
...
@@ -106,6 +124,7 @@ configureTest = \case
,
description
=
"3: Setup stack and check that argo-perf-wrapper sends
\
,
description
=
"3: Setup stack and check that argo-perf-wrapper sends
\
\
at least one *performance* message to cmd listen through the
\
\
at least one *performance* message to cmd listen through the
\
\
daemon."
\
daemon."
,
isTest
=
IsTest
True
}
}
TestPower
->
TestSpec
TestPower
->
TestSpec
{
stackArgsUpdate
=
\
sa
->
sa
{
stackArgsUpdate
=
\
sa
->
sa
...
@@ -118,28 +137,34 @@ configureTest = \case
...
@@ -118,28 +137,34 @@ configureTest = \case
,
description
=
"4: Setup stack and check that argo-perf-wrapper sends
\
,
description
=
"4: Setup stack and check that argo-perf-wrapper sends
\
\
at least one *power* message to cmd listen through the
\
\
at least one *power* message to cmd listen through the
\
\
daemon."
\
daemon."
,
isTest
=
IsTest
True
}
}
where
where
msg
=
"someComplicatedMessage"
msg
=
"someComplicatedMessage"
daemonBehavior
=
JustRun
(
StdOutLog
"daemon_out.log"
)
(
StdErrLog
"daemon_err.log"
)
daemonBehavior
=
runBehavior
=
JustRun
(
StdOutLog
"cmd_run_out.log"
)
(
StdErrLog
"cmd_run_err.log"
)
JustRun
(
StdOutLog
"daemon_out.log"
)
(
StdErrLog
"daemon_err.log"
)
runBehavior
=
JustRun
(
StdOutLog
"cmd_run_out.log"
)
(
StdErrLog
"cmd_run_err.log"
)
listentestBehavior
t
=
SucceedTestOnMessage
listentestBehavior
t
=
SucceedTestOnMessage
t
t
(
StdOutLog
"cmd_listen_out.log"
)
(
StdOutLog
"cmd_listen_out.log"
)
(
StdErrLog
"cmd_listen_err.log"
)
(
StdErrLog
"cmd_listen_err.log"
)
fullStack
::
StackArgs
->
Shell
()
newtype
IsTest
=
IsTest
Bool
fullStack
a
@
StackArgs
{
..
}
=
runStack
a
>>=
\
case
FoundMessage
->
printSuccess
"Found message!
\n
"
fullStack
::
IsTest
->
StackArgs
->
Shell
()
MessageNotFound
->
printError
"Message not found.
\n
"
>>
exit
(
ExitFailure
1
)
fullStack
(
IsTest
b
)
a
@
StackArgs
{
..
}
=
runStack
a
>>=
\
case
Died
stacki
ExitSuccess
->
FoundMessage
->
printSuccess
"Found message!
\n
"
printError
(
repr
stacki
<>
" died before a message could be found.
\n
"
)
Died
stacki
errorcode
->
if
b
>>
exit
(
ExitFailure
1
)
then
Died
stacki
(
ExitFailure
errcode
)
->
printError
printError
(
repr
stacki
(
repr
stacki
<>
"`daemon` died unexpectedly with error code.
\n
"
<>
" died before a message could be found:"
<>
repr
errcode
<>
repr
errorcode
)
<>
"
\n
"
)
>>
exit
(
ExitFailure
1
)
else
exit
(
ExitSuccess
)
clean
::
StackArgs
->
Shell
()
clean
::
StackArgs
->
Shell
()
clean
StackArgs
{
..
}
=
cleanLeftovers
workingDirectory
clean
StackArgs
{
..
}
=
cleanLeftovers
workingDirectory
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment