Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pykat
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
finesse
pykat
Commits
82cfc3e4
Commit
82cfc3e4
authored
11 years ago
by
Daniel Brown
Browse files
Options
Downloads
Patches
Plain Diff
setting up for parallel processing of tests, defaults of 3/4 the number of cores available
parent
bbc7deb7
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.txt
+17
-0
17 additions, 0 deletions
README.txt
pykat/testing/test.py
+93
-59
93 additions, 59 deletions
pykat/testing/test.py
pykat/testing/web_server.py
+1
-1
1 addition, 1 deletion
pykat/testing/web_server.py
with
111 additions
and
60 deletions
README.txt
+
17
−
0
View file @
82cfc3e4
...
...
@@ -7,3 +7,20 @@ Aims to provide a Python toolset for automating more complex tasks
as well as providing a GUI for manipulating and viewing simulation
setups.
====================
Finesse Test Server
====================
A Flask based website that runs the Finesse test suites is included in PyKat. This can
be hosted in Apache or run as a development server for quick testing on a system.
Prerequistes:
Flask
Numpy
Command to start server:
python -m pykat.test.web_server --path=[path to create website] --port=[HTTP port] --git-bin=[path to git binary]
The website can then be accessed by: http://localhost:[port]
This diff is collapsed.
Click to expand it.
pykat/testing/test.py
+
93
−
59
View file @
82cfc3e4
...
...
@@ -4,6 +4,8 @@ from threading import Thread, Lock
from
time
import
sleep
from
optparse
import
OptionParser
import
os
import
multiprocessing
from
multiprocessing
import
Pool
,
Queue
import
subprocess
as
sub
import
numpy
as
np
import
difflib
...
...
@@ -17,6 +19,58 @@ from datetime import datetime
from
pykat.testing
import
utils
import
sys
,
traceback
import
stat
import
math
def
initProcess
(
dkats
):
#print "init!!!", dkats
global
done_kats
done_kats
=
dkats
def
run_kat_file
(
item
):
#print os.getpid(),"getting kat...",item["kat"]
global
done_kats
kat
=
item
[
"
kat
"
]
suite
=
item
[
"
suite
"
]
FINESSE_EXE
=
item
[
"
FINESSE_EXE
"
]
SUITE_PATH
=
item
[
"
SUITE_PATH
"
]
SUITE_OUTPUT_DIR
=
item
[
"
SUITE_OUTPUT_DIR
"
]
basename
=
os
.
path
.
splitext
(
kat
)[
0
]
if
item
[
"
run_fast
"
]
and
(
'
map
'
in
open
(
kat
).
read
()):
print
"
skipping
"
+
kat
else
:
exp
=
None
try
:
start
=
time
.
time
()
out
,
err
=
utils
.
runcmd
([
FINESSE_EXE
,
"
--noheader
"
,
kat
],
cwd
=
SUITE_PATH
)
OUT_FILE
=
os
.
path
.
join
(
SUITE_PATH
,
basename
+
"
.out
"
)
LOG_FILE
=
os
.
path
.
join
(
SUITE_PATH
,
basename
+
"
.log
"
)
f_in
=
open
(
LOG_FILE
,
'
rb
'
)
f_out
=
gzip
.
open
(
LOG_FILE
+
"
.gz
"
,
'
wb
'
)
f_out
.
writelines
(
f_in
)
f_out
.
close
()
f_in
.
close
()
shutil
.
move
(
OUT_FILE
,
SUITE_OUTPUT_DIR
)
shutil
.
move
(
LOG_FILE
+
"
.gz
"
,
SUITE_OUTPUT_DIR
)
except
utils
.
RunException
as
e
:
print
"
STDERR:
"
+
e
.
out
print
"
STDOUT:
"
+
e
.
err
print
"
Error running
"
+
kat
+
"
:
"
+
e
.
err
exp
=
e
finally
:
done_kats
.
value
+=
1
return
[
time
.
time
()
-
start
,
suite
,
kat
,
exp
]
class
DiffException
(
Exception
):
def
__init__
(
self
,
msg
,
outfile
):
...
...
@@ -27,13 +81,14 @@ class FinesseTestProcess(Thread):
def
__init__
(
self
,
TEST_DIR
,
BASE_DIR
,
test_commit
,
run_fast
=
False
,
kats
=
{},
test_id
=
"
0
"
,
git_bin
=
""
,
emails
=
""
,
nobuild
=
False
,
*
args
,
**
kqwargs
):
git_bin
=
""
,
emails
=
""
,
nobuild
=
False
,
pool_size
=
int
(
multiprocessing
.
cpu_count
()
*
3.0
/
4.0
),
*
args
,
**
kqwargs
):
self
.
queue_time
=
None
self
.
status
=
""
self
.
built
=
False
self
.
total_kats
=
0
self
.
done_kats
=
0
self
.
done_kats
=
multiprocessing
.
Value
(
'
i
'
,
0
)
self
.
git_commit
=
""
self
.
test_id
=
-
1
self
.
finished_test
=
False
...
...
@@ -45,6 +100,11 @@ class FinesseTestProcess(Thread):
self
.
diffFound
=
False
self
.
diffing
=
False
if
pool_size
<
1
:
self
.
pool_size
=
1
else
:
self
.
pool_size
=
pool_size
Thread
.
__init__
(
self
)
self
.
git_commit
=
test_commit
...
...
@@ -103,25 +163,29 @@ class FinesseTestProcess(Thread):
if
self
.
total_kats
==
0
:
return
0.0
else
:
return
100.0
*
float
(
self
.
done_kats
)
/
float
(
self
.
total_kats
)
return
100.0
*
float
(
self
.
done_kats
.
value
)
/
float
(
self
.
total_kats
)
def
get_version
(
self
):
return
self
.
git_commit
def
get_progress
(
self
):
if
self
.
diffing
:
return
'
Diffing {0} out of {1} ({2} in {3})
'
.
format
(
self
.
done_kats
,
self
.
total_kats
/
2
,
self
.
running_kat
,
self
.
running_suite
)
return
'
Diffing {0} out of {1} ({2} in {3})
'
.
format
(
self
.
done_kats
.
value
,
self
.
total_kats
/
2
,
self
.
running_kat
,
self
.
running_suite
)
if
self
.
built
:
return
'
Running {0} out of {1} ({2} in {3})
'
.
format
(
self
.
done_kats
,
self
.
total_kats
/
2
,
self
.
running_kat
,
self
.
running_suite
)
return
'
Running {0} out of {1} ({2} in {3})
'
.
format
(
self
.
done_kats
.
value
,
self
.
total_kats
/
2
,
self
.
running_kat
,
self
.
running_suite
)
else
:
return
'
Building FINESSE executable
'
def
startFinesseTest
(
self
):
self
.
done_kats
.
value
=
0
if
sys
.
platform
==
"
win32
"
:
EXE
=
"
.exe
"
else
:
EXE
=
""
print
"
Using
"
,
self
.
pool_size
,
"
processes...
"
self
.
built
=
False
BUILD_PATH
=
os
.
path
.
join
(
self
.
BASE_DIR
,
"
build
"
)
...
...
@@ -140,25 +204,19 @@ class FinesseTestProcess(Thread):
shutil
.
rmtree
(
BUILD_PATH
)
print
"
Checking out finesse base...
"
utils
.
git
([
"
clone
"
,
"
git://gitmaster.atlas.aei.uni-hannover.de/finesse/
ba
se.git
"
,
BUILD_PATH
])
utils
.
git
([
"
clone
"
,
"
git://gitmaster.atlas.aei.uni-hannover.de/finesse/
fines
se.git
"
,
BUILD_PATH
])
print
"
Checking out and building develop version of finesse
"
+
self
.
git_commit
SRC_PATH
=
os
.
path
.
join
(
BUILD_PATH
,
"
src
"
)
if
sys
.
platform
==
"
win32
"
:
utils
.
runcmd
([
"
bash
"
,
"
./finesse.sh
"
,
"
--checkout
"
],
cwd
=
BUILD_PATH
)
self
.
cancelCheck
()
utils
.
git
([
"
checkout
"
,
self
.
git_commit
],
cwd
=
SRC_PATH
)
self
.
cancelCheck
()
utils
.
runcmd
([
"
bash
"
,
"
./finesse.sh
"
,
"
--build
"
],
cwd
=
BUILD_PATH
)
self
.
cancelCheck
()
else
:
utils
.
runcmd
([
"
./finesse.sh
"
,
"
--checkout
"
,
"
develop
"
],
cwd
=
BUILD_PATH
)
self
.
cancelCheck
()
utils
.
git
([
"
checkout
"
,
self
.
git_commit
],
cwd
=
SRC_PATH
)
self
.
cancelCheck
()
...
...
@@ -234,57 +292,31 @@ class FinesseTestProcess(Thread):
# multiply as we include the diffining in the percentage
# done
self
.
total_kats
*=
2
runs
=
[]
for
suite
in
self
.
kats_to_run
.
keys
():
self
.
cancelCheck
()
print
"
Running
suite:
"
+
suite
+
"
...
"
print
"
Queuing up
suite:
"
+
suite
+
"
...
"
kats
=
self
.
kats_to_run
[
suite
]
SUITE_PATH
=
os
.
path
.
join
(
self
.
TEST_DIR
,
"
kat_test
"
,
suite
)
SUITE_OUTPUT_DIR
=
os
.
path
.
join
(
OUTPUTS_DIR
,
suite
)
os
.
mkdir
(
SUITE_OUTPUT_DIR
)
self
.
running_suite
=
suite
for
kat
in
kats
:
self
.
cancelCheck
()
self
.
running_kat
=
kat
print
self
.
get_progress
()
basename
=
os
.
path
.
splitext
(
kat
)[
0
]
if
self
.
run_fast
and
(
'
map
'
in
open
(
kat
).
read
()):
print
"
skipping
"
+
kat
else
:
try
:
start
=
time
.
time
()
runs
.
append
({
'
SUITE_OUTPUT_DIR
'
:
SUITE_OUTPUT_DIR
,
'
suite
'
:
suite
,
'
run_fast
'
:
self
.
run_fast
,
'
kat
'
:
kat
,
'
FINESSE_EXE
'
:
FINESSE_EXE
,
'
SUITE_PATH
'
:
SUITE_PATH
})
out
,
err
=
utils
.
runcmd
([
FINESSE_EXE
,
"
--noheader
"
,
kat
],
cwd
=
SUITE_PATH
)
self
.
pool
=
Pool
(
initializer
=
initProcess
,
initargs
=
(
self
.
done_kats
,)
,
processes
=
self
.
pool_size
)
results
=
self
.
pool
.
imap_unordered
(
run_kat_file
,
runs
,
1
)
self
.
pool
.
close
()
OUT_FILE
=
os
.
path
.
join
(
SUITE_PATH
,
basename
+
"
.out
"
)
LOG_FILE
=
os
.
path
.
join
(
SUITE_PATH
,
basename
+
"
.log
"
)
for
result
in
results
:
f_in
=
open
(
LOG_FILE
,
'
rb
'
)
f_out
=
gzip
.
open
(
LOG_FILE
+
"
.gz
"
,
'
wb
'
)
f_out
.
writelines
(
f_in
)
f_out
.
close
()
f_in
.
close
()
shutil
.
move
(
OUT_FILE
,
SUITE_OUTPUT_DIR
)
shutil
.
move
(
LOG_FILE
+
"
.gz
"
,
SUITE_OUTPUT_DIR
)
except
utils
.
RunException
as
e
:
print
"
STDERR:
"
+
e
.
out
print
"
STDOUT:
"
+
e
.
err
print
"
Error running
"
+
kat
+
"
:
"
+
e
.
err
self
.
kat_run_exceptions
[
suite
][
kat
]
=
e
# if this happens a difference definitely is found
if
result
[
3
]
is
not
None
:
self
.
kat_run_exceptions
[
result
[
1
]][
result
[
2
]]
=
result
[
3
]
self
.
diffFound
=
True
finally
:
self
.
run_times
[
suite
][
kat
]
=
time
.
time
()
-
start
self
.
done_kats
+=
1
self
.
run_times
[
result
[
1
]][
result
[
2
]]
=
result
[
0
]
self
.
cancelCheck
()
...
...
@@ -366,7 +398,7 @@ class FinesseTestProcess(Thread):
os
.
remove
(
out_file
)
self
.
done_kats
+=
1
self
.
done_kats
.
value
+=
1
REPORT_PATH
=
os
.
path
.
join
(
self
.
BASE_DIR
,
"
reports
"
)
...
...
@@ -492,3 +524,5 @@ if __name__ == "__main__":
emails
=
options
.
emails
,
nobuild
=
options
.
nobuild
)
test
.
run
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
pykat/testing/web_server.py
+
1
−
1
View file @
82cfc3e4
...
...
@@ -32,7 +32,7 @@ def start(instance_path,port=5000, debug=True, ip="0.0.0.0", git_bin="/usr/bin/g
# need local copy of src
if
not
os
.
path
.
exists
(
os
.
path
.
join
(
app
.
instance_path
,
"
finesse_src
"
)):
print
"
finesse src folder didn
'
t exist, cloning now...
"
utils
.
git
([
"
clone
"
,
"
git://gitmaster.atlas.aei.uni-hannover.de/finesse/
src
.git
"
,
"
finesse_src
"
])
utils
.
git
([
"
clone
"
,
"
git://gitmaster.atlas.aei.uni-hannover.de/finesse/
finesse
.git
"
,
"
finesse_src
"
])
else
:
# get the latest version for logs etc.
utils
.
git
(
"
pull
"
,
cwd
=
os
.
path
.
join
(
app
.
instance_path
,
"
finesse_src
"
))
...
...
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