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
ae373312
Commit
ae373312
authored
Dec 07, 2018
by
Valentin Reis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit.
parents
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
205 additions
and
0 deletions
+205
-0
default.nix
default.nix
+40
-0
manifests/basic.json
manifests/basic.json
+39
-0
test.hs
test.hs
+126
-0
No files found.
default.nix
0 → 100644
View file @
ae373312
{
argopkgs-src
?
(
builtins
.
fetchGit
https://xgitlab.cels.anl.gov/argo/argopkgs.git
)
,
nrm-src
?
(
builtins
.
fetchGit
https://xgitlab.cels.anl.gov/argo/nrm.git
)
}:
let
argopkgs
=
import
argopkgs-src
{};
nrm
=
argopkgs
.
nodelevel
.
nrm
.
overrideAttrs
(
old
:
{
src
=
nrm-src
;
});
containers
=
argopkgs
.
nodelevel
.
containers
;
amg
=
argopkgs
.
applications
.
nrm
.
amg
;
hpkgs
=
(
p
:
with
p
;[
turtle
optparse-generic
interpolatedstring-perl6
managed
]);
hpkgsPrecommit
=
(
p
:
with
p
;[
turtle
optparse-generic
interpolatedstring-perl6
managed
(
argopkgs
.
haskell
.
lib
.
doJailbreak
panpipe
)
]);
in
{
test1
=
argopkgs
.
stdenv
.
mkDerivation
{
src
=
./.
;
name
=
"nrm-experimental-dev-environment"
;
buildInputs
=
[
containers
amg
nrm
(
argopkgs
.
haskellPackages
.
ghcWithPackages
hpkgs
)
];
};
pre-commit
=
argopkgs
.
stdenv
.
mkDerivation
{
name
=
"pre-commit"
;
src
=
./.
;
buildInputs
=
[
(
argopkgs
.
haskellPackages
.
ghcWitPackages
hpkgsPrecommit
)
];
};
}
manifests/basic.json
0 → 100644
View file @
ae373312
{
"acKind"
:
"ImageManifest"
,
"acVersion"
:
"0.6.0"
,
"name"
:
"test"
,
"app"
:
{
"isolators"
:
[
{
"name"
:
"argo/scheduler"
,
"value"
:
{
"policy"
:
"SCHED_OTHER"
,
"priority"
:
"0"
}
},
{
"name"
:
"argo/container"
,
"value"
:
{
"cpus"
:
"1"
,
"mems"
:
"1"
}
},
{
"name"
:
"argo/perfwrapper"
,
"value"
:
{
"enabled"
:
"0"
}
},
{
"name"
:
"argo/power"
,
"value"
:
{
"enabled"
:
"0"
,
"profile"
:
"0"
,
"policy"
:
"NONE"
,
"damper"
:
"0.1"
,
"slowdown"
:
"1.1"
}
}
]
}
}
test.hs
0 → 100755
View file @
ae373312
#!
/
usr
/
bin
/
env
nix
-
shell
#!
nix
-
shell
default
.
nix
-
i
runhaskell
-
A
test1
{-# LANGUAGE RecordWildCards
, LambdaCase
, OverloadedStrings
, DataKinds
, DeriveGeneric
, FlexibleInstances
, OverloadedStrings
, TypeOperators #-}
import
Turtle
import
Prelude
hiding
(
FilePath
)
import
Options.Applicative
import
Options.Generic
import
System.IO
(
withFile
)
import
Debug.Trace
import
Filesystem.Path
((
</>
))
import
Control.Concurrent.Async
import
System.Console.ANSI
import
System.Console.ANSI.Types
(
Color
)
import
System.Posix.Signals
printInfo
format
=
printf
(
"Info:"
%
format
)
printWarning
format
=
colorShell
Yellow
.
printf
(
"Warning:"
%
format
)
printError
format
=
colorShell
Red
.
printf
(
"Error:"
%
format
)
colorShell
::
Color
->
Shell
()
->
Shell
()
colorShell
color
s
=
setC
color
*>
s
*>
setC
White
where
setC
c
=
liftIO
$
setSGR
[
SetColor
Foreground
Dull
c
]
myWhich
str
=
which
str
>>=
\
case
(
Just
p
)
->
printInfo
(
"Found "
%
fp
%
" at "
%
fp
%
"
\n
"
)
str
p
>>
return
p
Nothing
->
die
(
format
(
"Argo `"
%
fp
%
"` not in $PATH."
)
str
)
data
Args
w
=
Args
{
dargs
::
w
:::
Text
<?>
"Daemon arguments. Properly quote this."
,
app
::
w
:::
FilePath
<?>
"Input file, target application script"
,
manifest
::
w
:::
FilePath
<?>
"Input file, manifest."
,
app_out
::
w
:::
FilePath
<?>
"Output file, application stdout"
,
app_err
::
w
:::
FilePath
<?>
"Output file, application stderr"
,
daemon_out
::
w
:::
FilePath
<?>
"Output file, daemon stdout"
,
daemon_err
::
w
:::
FilePath
<?>
"Output file, daemon stderr"
,
log_progress
::
w
:::
FilePath
<?>
"Output file, daemon progress log"
,
log_hardwareprogress
::
w
:::
FilePath
<?>
"Output file, daemon hardware progress log"
,
log_power
::
w
:::
FilePath
<?>
"Output file, daemon power log"
,
time_file
::
w
:::
FilePath
<?>
"Output file, application runtime"
}
deriving
(
Generic
)
instance
ParseRecord
(
Args
Wrapped
)
removeSocket
::
FilePath
->
Shell
()
removeSocket
socketPath
=
do
foundSocket
<-
(
testfile
socketPath
)
when
foundSocket
$
do
printError
(
"found stale socket at "
%
fp
%
".."
)
socketPath
shell
(
format
(
"sudo rm -f "
%
fp
)
socketPath
)
empty
>>=
\
case
ExitSuccess
->
colorShell
Green
$
printf
(
" Successfully removed.
\n
"
)
ExitFailure
n
->
colorShell
Red
$
die
(
"Failed to remove stale socket."
<>
repr
n
)
cleanLog
::
FilePath
->
Shell
()
cleanLog
logPath
=
do
foundSocket
<-
(
testfile
logPath
)
when
foundSocket
$
do
printWarning
(
"found stale log at "
%
fp
%
".. "
)
logPath
shell
(
format
(
"sudo rm -f "
%
fp
)
logPath
)
empty
>>=
\
case
ExitSuccess
->
colorShell
Green
$
printf
(
"Successfully removed.
\n
"
)
ExitFailure
n
->
die
(
"Failed to remove stale log file."
<>
repr
n
)
printInfo
(
"Using log file "
%
fp
%
"
\n
"
)
logPath
main
::
IO
()
main
=
sh
$
do
Args
{
..
}
<-
unwrapRecord
"minimal Argo benchmarking tool"
--Cleaning
mapM_
cleanLog
[
daemon_out
,
daemon_err
,
app_out
,
app_err
,
time_file
,
log_progress
,
log_hardwareprogress
,
log_power
]
mapM_
removeSocket
[
"/tmp/nrm-downstream-in"
,
"/tmp/nrm-upstream-in"
]
--Retrieving binaries,setting suid bits and perms
confPath
<-
myWhich
"argo_nodeos_config"
daemonPath
<-
myWhich
"daemon"
tempDirPath
<-
mktempdir
"/tmp"
"argo-expe"
let
confPath'
=
tempDirPath
</>
"argo_nodeos_config"
cp
confPath
confPath'
printInfo
(
"Copied the configurator to "
%
fp
%
"
\n
"
)
confPath'
shell
(
format
(
"sudo chown root:root "
%
fp
)
confPath'
)
empty
>>=
\
case
ExitSuccess
->
printInfo
"Chowned argo_nodeos_config to root:root.
\n
"
ExitFailure
n
->
die
(
"Failed to set argo_nodeos_config permissions "
<>
repr
n
)
shell
(
format
(
"sudo chmod u+sw "
%
fp
)
confPath'
)
empty
>>=
\
case
ExitSuccess
->
printInfo
"Set the suid bit.
\n
"
ExitFailure
n
->
die
(
"Setting suid bit failed with exit code "
<>
repr
n
)
--Cleaning the config, running the daemon
shell
(
format
(
fp
%
" --clean_config=kill_content:true"
)
confPath'
)
empty
>>=
\
case
ExitSuccess
->
printInfo
"Cleaned the argo config.
\n
"
ExitFailure
n
->
do
liftIO
$
printInfo
(
"Contents of argo_nodeos_config_exit_message:
\n
"
)
view
$
cat
[
"./argo_nodeos_config_exit_message"
]
die
(
"Clean config failed with exit code "
<>
repr
n
)
printInfo
"Running the daemon.
\n
"
export
"ARGO_NODEOS_CONFIG"
(
format
fp
confPath'
)
let
daemon
=
inshell
(
format
(
fp
%
" "
%
s
%
" --log_hardwareprogress="
%
fp
%
" --log_progress="
%
fp
%
" --log_power="
%
fp
%
" >"
%
fp
%
" 2>"
%
fp
)
daemonPath
dargs
log_hardwareprogress
log_progress
log_power
daemon_out
daemon_err
)
empty
daemonAsync
<-
fork
$
sh
$
daemon
printInfo
"Daemon is running.
\n
"
let
handler
=
do
sh
$
printInfo
"Interrupted. Killing daemon..."
cancel
daemonAsync
sh
$
inshell
"pkill daemon"
empty
sh
$
colorShell
Green
$
printf
"Killed daemon.
\n
"
liftIO
$
installHandler
keyboardSignal
(
Catch
handler
)
Nothing
--Running the app
printInfo
"Launching the application through cmd.
\n
"
(
_
,
t
)
<-
time
$
shell
(
format
(
"cmd run -u toto "
%
fp
%
" "
%
fp
%
" > "
%
fp
%
" 2>"
%
fp
)
manifest
app
app_out
app_err
)
empty
>>=
\
case
ExitSuccess
->
printInfo
"cmd has exited successfuly.
\n
"
ExitFailure
n
->
die
(
"cmd failed with exit code "
<>
repr
n
<>
" . The application logs are at "
<>
repr
app_out
<>
" "
<>
repr
app_err
)
liftIO
$
writeTextFile
time_file
(
repr
t
)
--Cleanup
printInfo
"Killing the daemon.
\n
"
liftIO
$
cancel
daemonAsync
inshell
"pkill daemon"
empty
printInfo
"Daemon killed.
\n
"
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