Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
FlockLab 1 - deprecated
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
TEC
P
Public
FlockLab
FlockLab 1 - deprecated
Commits
e14814aa
Commit
e14814aa
authored
Apr 26, 2019
by
Reto Da Forno
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shell tool updated, now supports test result fetching via https and webdav
parent
c5596371
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
160 additions
and
21 deletions
+160
-21
tools/fetchtest.sh
tools/fetchtest.sh
+12
-1
tools/shell-tool/flocklab
tools/shell-tool/flocklab
+148
-20
No files found.
tools/fetchtest.sh
View file @
e14814aa
#!/bin/bash
#
# Fetches the results of a FlockLab test.
# Usage:
# ./fetchtest.sh [test_id]
#
# This script requires a webdav client (e.g. cadaver)
# Store your FlockLab login credentials in the file .netrc in your home directory as follows:
# default
# login [your_username]
# password [your_password]
dav_site
=
'https://www.flocklab.ethz.ch/user/webdav'
dav_client
=
/usr/bin/cadaver
scratch
=
/tmp/flocklab_tmp
...
...
@@ -59,5 +70,5 @@ rmdir $scratch/$1
rmdir
--ignore-fail-on-non-empty
$scratch
cd
$path
else
echo
"
Please specify test id
"
echo
"
please specify a test ID
"
fi
tools/shell-tool/flocklab
View file @
e14814aa
#!/bin/bash
#
# $Id$
# ------------------------------
# Command line tool for FlockLab
# v1.1
#
# command line tool for Flocklab
# usage:
#
# -v <testconfig.xml>: validate
# -v <testconfig.xml>: validate
# -c <testconfig.xml>: create
# -a <testid>: abort
# -d <testid>: delete
# -g <testid>: get via https
# -f <testid>: fetch via webdav
# -h: display help
#
# your FlockLab login credentials need to be stored in .flocklabauth in your home directory as follows:
# USER=[your_username]
# PASSWORD=[your_password]
#
# if you want to be able to download your test results (-f), your credentials need to be stored in .netrc in your home directory:
# default
# login [your_username]
# password [your_password]
#
# note: if you use the .netrc file, you don't need the .flocklabauth file
# ------------------------------
DEST
=
/tmp
EXTRACT
=
1
SERVER_URL
=
https://www.flocklab.ethz.ch/user
CURL_PARAMS
=
-s
if
[
-f
.flocklabauth
]
CURL_PARAMS
=
-sS
FLAUTH_FILE
=
.flocklabauth
NETRC_FILE
=
$HOME
/.netrc
DAV_URL
=
https://www.flocklab.ethz.ch/user/webdav
DAV_CLIENT
=
cadaver
if
[
-f
$FLAUTH_FILE
]
then
source
./.flocklabauth
else
if
[
-f
$HOME
/.flocklabauth
]
then
source
$HOME
/.flocklabauth
fi
source
./
$FLAUTH_FILE
elif
[
-f
$HOME
/
$FLAUTH_FILE
]
then
source
$HOME
/
$FLAUTH_FILE
elif
[
-f
$NETRC_FILE
]
then
#echo "using credentials from .netrc file"
while
read
-r
LINE
;
do
if
[[
"
${
LINE
,,
}
"
==
*
"login"
*
]]
then
USER
=
$(
echo
$LINE
|
awk
'{print $2}'
)
elif
[[
"
${
LINE
,,
}
"
==
*
"password"
*
]]
then
PASSWORD
=
$(
echo
$LINE
|
awk
'{print $2}'
)
fi
done
<
"
$NETRC_FILE
"
fi
# if .netrc file does not exist, create it
if
[
!
-f
$NETRC_FILE
]
then
echo
"default
login
$USER
password
$PASSWORD
"
>
$NETRC_FILE
chmod
600
$NETRC_FILE
echo
".netrc file created"
fi
usage
()
{
cat
<<
EOF
command line tool for
flocklab
command line tool for
FlockLab (https://flocklab.ethz.ch)
usage:
$0
options
usage:
$0
[OPTION]
OPTIONS:
-v <testconfig.xml>: validate
-c <testconfig.xml>: create
-a <testid>: abort
-d <testid>: delete
-v <testconfig.xml>: validate test config
-c <testconfig.xml>: create / schedule new test
-a <testid>: abort test
-d <testid>: delete test
-g <testid>: get test results (via https)
-f <testid>: fetch test results (via webdav)
EOF
}
...
...
@@ -41,12 +86,55 @@ password()
{
cat
<<
EOF
Wrong username / password
please check your settings in
.flocklabauth
please check your settings in
$FLAUTH_FILE
EOF
}
fetchtest
()
{
TESTID
=
$OPTARG
if
[
!
-d
$DEST
]
then
mkdir
$DEST
fi
if
[
-d
$DEST
/
$TESTID
]
then
echo
"Error: directory
$DEST
/
$TESTID
already exists"
exit
fi
mkdir
$DEST
/
$TESTID
$DAV_CLIENT
>
$DEST
/
$TESTID
/dav.log 2>&1
<<
EOF
open
$DAV_URL
get
$TESTID
/testconfiguration.xml
$DEST
/
$TESTID
/testconfiguration.xml
get
$TESTID
/results.tar.gz
$DEST
/
$TESTID
/
$TESTID
.tar.gz
exit
EOF
if
[
`
sed
'/^\(404\|500\)/!d'
$DEST
/
$TESTID
/dav.log |
wc
-l
`
-gt
0
]
then
echo
"Error occured while fetching data:"
cat
$DEST
/
$TESTID
/dav.log
rm
-rf
$DEST
/
$TESTID
else
echo
"Downloaded data to
$DEST
/
$TESTID
"
if
[
$EXTRACT
-gt
0
]
then
tar
-xvzf
$DEST
/
$TESTID
/
$TESTID
.tar.gz
-C
$DEST
if
[
$?
-eq
0
]
then
rm
$DEST
/
$TESTID
/
$TESTID
.tar.gz
fi
fi
rm
$DEST
/
$TESTID
/dav.log
fi
}
if
[
"$#"
-lt
1
]
then
usage
exit
fi
while
getopts
“v:c:a:d:” OPTION
while
getopts
“v:c:a:d:
f:g:h
” OPTION
do
case
$OPTION
in
v
)
...
...
@@ -109,7 +197,7 @@ do
echo
'There were connection problems contacting the FlockLab server '
$SERVER_URL
fi
;;
d
)
d
)
RESPONSE
=
`
curl
$CURL_PARAMS
-o
-
-F
username
=
"
$USER
"
-F
password
=
"
$PASSWORD
"
-F
removeit
=
"Remove test"
-F
testid
=
$OPTARG
$SERVER_URL
/test_delete.php
`
if
[
$?
-eq
0
]
then
...
...
@@ -129,6 +217,46 @@ do
echo
'There were connection problems contacting the FlockLab server '
$SERVER_URL
fi
;;
g
)
echo
"Fetching results for test
$OPTARG
..."
OUTFILE
=
$DEST
/
$OPTARG
.tar.gz
RESPONSE
=
`
curl
-o
-
$CURL_PARAMS
-X
POST
-H
"Content-Type: application/x-www-form-urlencoded"
-d
"testid=
${
OPTARG
}
&query=get&username=
${
USER
}
&password=
${
PASSWORD
}
"
$SERVER_URL
/login.php
-o
$OUTFILE
$SERVER_URL
/result_download_archive.php
`
FILESIZE
=
`
stat
--printf
=
"%s"
$OUTFILE
`
if
[
$FILESIZE
-lt
1000
]
then
OUTFILECONT
=
`
cat
$OUTFILE
`
if
[[
"
$OUTFILECONT
"
==
*
"error"
*
]]
then
ERRORMSG
=
`
echo
${
OUTFILECONT
:1:-1
}
|
awk
-F
':'
'{print $3}'
`
echo
"Failed: "
$ERRORMSG
rm
exit
1
fi
fi
echo
"Results saved as "
$OUTFILE
if
[
$EXTRACT
-gt
0
]
then
tar
-xvzf
$OUTFILE
-C
$DEST
if
[
$?
-eq
0
]
then
rm
$OUTFILE
fi
fi
;;
f
)
which
$DAV_CLIENT
>>
/dev/null
if
[[
$?
!=
0
]]
then
echo
'WebDAV client '
$DAV_CLIENT
' not found!'
exit
1
fi
echo
"Fetching results for test
$OPTARG
..."
fetchtest
;;
h
)
usage
exit
;;
?
)
usage
exit
...
...
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