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
87081c28
Commit
87081c28
authored
Dec 18, 2018
by
Valentin Reis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a 'perfwrapper test' that runs the hello world command through
a perf-wrapper enabled container.
parent
00212f73
Pipeline
#4714
passed with stage
in 29 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
35 deletions
+37
-35
argo/src/Argo/Stack.hs
argo/src/Argo/Stack.hs
+18
-15
argotk/argotk.hs
argotk/argotk.hs
+18
-19
default.nix
default.nix
+1
-1
manifests/perfwrap.json
manifests/perfwrap.json
+0
-0
No files found.
argo/src/Argo/Stack.hs
View file @
87081c28
...
...
@@ -11,19 +11,21 @@ import System.IO ( withFile )
import
Debug.Trace
import
Filesystem.Path
(
(
</>
)
)
import
Control.Concurrent.Async
import
System.Console.ANSI
import
System.Console.ANSI
import
System.Console.ANSI.Types
(
Color
)
import
Data.Text
as
Text
hiding
(
empty
)
import
Data.Text.IO
as
Text
import
Argo.Utils
import
System.Process
as
P
hiding
(
shell
)
import
System.Process
as
P
hiding
(
shell
)
data
StackArgs
=
StackArgs
{
dargs
::
[
Text
]
--"Daemon arguments. Properly quote this."
,
app
::
Text
--"Target application call, sh+path valid"
,
workingDirectory
::
FilePath
--"Working directory."
,
manifest
::
FilePath
--"Input file, manifest."
,
manifestDir
::
FilePath
--"Manifest lookup directory"
,
manifestName
::
FilePath
--"Manifest file name"
,
cmd_out
::
FilePath
--"Output file, application stdout"
,
cmd_err
::
FilePath
--"Output file, application stderr"
,
daemon_out
::
FilePath
--"Output file, daemon stdout"
...
...
@@ -35,8 +37,9 @@ instance Default StackArgs where
def
=
StackArgs
{
dargs
=
[]
,
app
=
"echo
\"
HelloWorld
\"
"
,
workingDirectory
=
"./."
,
manifest
=
"basic.json"
,
workingDirectory
=
"_output"
,
manifestDir
=
"manifests"
,
manifestName
=
"basic.json"
,
cmd_out
=
"cmd_out.log"
,
cmd_err
=
"cmd_err.log"
,
daemon_out
=
"daemon_out.log"
...
...
@@ -45,10 +48,6 @@ instance Default StackArgs where
,
time_file
=
"time.log"
}
-- | override the output directory of the stack.
outputDir
::
FilePath
->
StackArgs
->
StackArgs
outputDir
dir
sa
=
sa
{
workingDirectory
=
dir
}
cleanLeftovers
::
FilePath
->
FilePath
...
...
@@ -69,6 +68,7 @@ cleanLeftovers wd daemon_out daemon_err cmd_out cmd_err time_file nrm_log = do
,
wd
</>
time_file
,
wd
</>
nrm_log
,
wd
</>
".argo_nodeos_config_exit_message"
,
wd
</>
"argo_nodeos_config"
]
mapM_
cleanSocket
[
"/tmp/nrm-downstream-in"
,
"/tmp/nrm-upstream-in"
]
...
...
@@ -123,7 +123,7 @@ prepareDaemonShell wd dargs daemon_out daemon_err nrm_log = do
-- | See at the bottom of this file for discussion of this function. (1)
cmdShell
::
FilePath
->
Text
->
FilePath
->
FilePath
->
Shell
()
cmdShell
manifest
app
cmd_out
cmd_err
=
do
cmdShell
manifest
app
cmd_out
cmd_err
=
shell
(
format
(
"cmd run -u toto "
%
fp
%
" "
%
s
%
" > "
%
fp
%
" 2>"
%
fp
)
manifest
...
...
@@ -167,11 +167,14 @@ runSimpleStack a@StackArgs {..} = sh $ do
nrm_log
liftIO
$
withAsync
daemonShell
$
\
daemon
->
do
kbInstallHandler
$
cancel
daemon
withAsync
(
time
$
sh
$
cmdShell
manifest
app
cmd_out
cmd_err
)
$
\
cmd
->
do
kbInstallHandler
$
cancel
daemon
>>
cancel
cmd
waitEitherCancel
daemon
cmd
>>=
\
case
Left
_
->
die
"Daemon died."
Right
(
_
,
t
)
->
writeTextFile
time_file
(
repr
t
)
withAsync
(
time
$
sh
$
cmdShell
(
manifestDir
</>
manifestName
)
app
cmd_out
cmd_err
)
$
\
cmd
->
do
kbInstallHandler
$
cancel
daemon
>>
cancel
cmd
waitEitherCancel
daemon
cmd
>>=
\
case
Left
_
->
die
"Daemon died."
Right
(
_
,
t
)
->
writeTextFile
time_file
(
repr
t
)
-- | (1)
--
...
...
argotk/argotk.hs
View file @
87081c28
...
...
@@ -17,14 +17,6 @@ import Options.Applicative
import
System.Posix.Signals
import
Control.Monad
wdOption
=
strOption
(
long
"working_directory"
<>
short
'w'
<>
metavar
"DIRECTORY"
<>
help
"Working directory. Will be used for logging."
<>
value
"./."
)
opts
::
StackArgs
->
Parser
(
IO
()
)
opts
sa
=
hsubparser
(
command
"clean"
...
...
@@ -32,7 +24,7 @@ opts sa = hsubparser
<>
command
"daemon"
(
info
(
runDaemon
sa
<$>
wdOption
)
(
pure
$
runDaemon
sa
)
(
progDesc
"Set up and launch the daemon in synchronous mode,
\
\
with properly cleaned sockets, logfiles."
...
...
@@ -41,7 +33,7 @@ opts sa = hsubparser
<>
command
"application"
(
info
(
runApp
sa
<$>
wdOption
<*>
strArgument
(
runApp
sa
<$>
strArgument
(
metavar
"COMMAND"
<>
help
"Application to run inside the container"
)
...
...
@@ -53,23 +45,30 @@ opts sa = hsubparser
(
info
(
pure
$
runHelloWorld
sa
)
(
progDesc
"Test 1: Setup stack and check that hello world app sends
\
"Test 1: Setup stack and check that
a
hello world app sends
\
\
message back to cmd."
)
)
<>
command
"perfwrapper"
(
info
(
pure
$
runHelloWorld
(
sa
{
manifestName
=
"perfwrap.json"
}))
(
progDesc
"Test 2: Setup stack and check that a hello world app sends
\
\
message back to cmd. Uses argo-perf-wrapper."
)
)
<>
help
"Type of action to run"
)
main
::
IO
()
main
=
do
manifests
<-
getEnv
"MANIFESTS"
let
sa
=
(
outputDir
"_output"
def
)
{
manifest
=
decodeString
manifests
</>
manifest
def
}
let
sa
=
def
{
manifestDir
=
decodeString
manifests
}
join
$
execParser
(
info
(
opts
sa
<**>
helper
)
idm
)
runApp
::
StackArgs
->
FilePath
->
Text
->
IO
()
runApp
sa
wd
app
=
runSimpleStack
$
outputDir
wd
(
sa
{
app
=
app
})
runApp
::
StackArgs
->
Text
->
IO
()
runApp
sa
myApp
=
runSimpleStack
$
sa
{
app
=
myApp
}
runHelloWorld
::
StackArgs
->
IO
()
runHelloWorld
a
@
StackArgs
{
..
}
=
do
...
...
@@ -92,8 +91,8 @@ runClean StackArgs {..} = sh $ cleanLeftovers workingDirectory
time_file
nrm_log
runDaemon
::
StackArgs
->
FilePath
->
IO
()
runDaemon
StackArgs
{
..
}
workingDir
=
runDaemon
::
StackArgs
->
IO
()
runDaemon
StackArgs
{
..
}
=
sh
$
prepareDaemonShell
workingDir
dargs
daemon_out
daemon_err
nrm_log
$
prepareDaemonShell
workingDir
ectory
dargs
daemon_out
daemon_err
nrm_log
>>=
liftIO
default.nix
View file @
87081c28
...
...
@@ -58,7 +58,7 @@ in rec
argotk
=
pkgs
.
stdenv
.
mkDerivation
rec
{
name
=
"env"
;
env
=
pkgs
.
buildEnv
{
name
=
name
;
paths
=
buildInputs
++
propagatedBuildInputs
;
};
src
=
./argotk
;
src
=
filterHdevTools
./argotk
;
installPhase
=
''
mkdir -p $out/bin
mkdir -p $out/share
...
...
manifests/perfwrap
per
.json
→
manifests/perfwrap.json
View file @
87081c28
File moved
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