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
93ba0dd3
Commit
93ba0dd3
authored
11 years ago
by
Daniel Brown
Browse files
Options
Downloads
Patches
Plain Diff
added watcher thread to manage returning gracefully from test exceptions and starting new tests
parent
9ee26fa6
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
pykat/testing/test.py
+6
-12
6 additions, 12 deletions
pykat/testing/test.py
pykat/testing/web/web_interface.py
+77
-30
77 additions, 30 deletions
pykat/testing/web/web_interface.py
pykat/testing/web_server.py
+8
-0
8 additions, 0 deletions
pykat/testing/web_server.py
with
91 additions
and
42 deletions
pykat/testing/test.py
+
6
−
12
View file @
93ba0dd3
...
@@ -54,7 +54,7 @@ class FinesseTestProcess(Thread):
...
@@ -54,7 +54,7 @@ class FinesseTestProcess(Thread):
def
__init__
(
self
,
TEST_DIR
,
BASE_DIR
,
git_commit
,
def
__init__
(
self
,
TEST_DIR
,
BASE_DIR
,
git_commit
,
run_fast
=
False
,
suites
=
[],
test_id
=
"
0
"
,
run_fast
=
False
,
suites
=
[],
test_id
=
"
0
"
,
git_bin
=
""
,
emails
=
""
,
nobuild
=
Fals
e
,
*
args
,
**
kqwargs
):
git_bin
=
""
,
emails
=
""
,
nobuild
=
Tru
e
,
*
args
,
**
kqwargs
):
Thread
.
__init__
(
self
)
Thread
.
__init__
(
self
)
self
.
git_commit
=
git_commit
self
.
git_commit
=
git_commit
...
@@ -104,7 +104,10 @@ class FinesseTestProcess(Thread):
...
@@ -104,7 +104,10 @@ class FinesseTestProcess(Thread):
self
.
GIT_BIN
=
git_bin
self
.
GIT_BIN
=
git_bin
def
percent_done
(
self
):
def
percent_done
(
self
):
return
100.0
*
float
(
self
.
done_files
)
/
float
(
self
.
total_files
)
if
self
.
total_kats
==
0
:
return
0.0
else
:
return
100.0
*
float
(
self
.
done_kats
)
/
float
(
self
.
total_kats
)
def
get_version
(
self
):
def
get_version
(
self
):
return
self
.
git_commit
return
self
.
git_commit
...
@@ -283,6 +286,7 @@ class FinesseTestProcess(Thread):
...
@@ -283,6 +286,7 @@ class FinesseTestProcess(Thread):
output_differences
[
suite
][
out
]
=
(
ref_arr
[
ix
],
out_arr
[
ix
],
np
.
max
(
rel_diff
))
output_differences
[
suite
][
out
]
=
(
ref_arr
[
ix
],
out_arr
[
ix
],
np
.
max
(
rel_diff
))
os
.
chdir
(
BASE_DIR
)
os
.
chdir
(
BASE_DIR
)
if
not
os
.
path
.
exists
(
"
reports
"
):
if
not
os
.
path
.
exists
(
"
reports
"
):
os
.
mkdir
(
"
reports
"
)
os
.
mkdir
(
"
reports
"
)
...
@@ -347,16 +351,6 @@ class FinesseTestProcess(Thread):
...
@@ -347,16 +351,6 @@ class FinesseTestProcess(Thread):
finally
:
finally
:
finished_test
=
True
finished_test
=
True
# once done check if any other tests need to be ran
#schedule_lock.acquire()
#if len(scheduled_tests) > 0:
# current_test = scheduled_tests.pop(0)
# current_test.start()
#else:
# current_test = None
#schedule_lock.release()
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
...
...
This diff is collapsed.
Click to expand it.
pykat/testing/web/web_interface.py
+
77
−
30
View file @
93ba0dd3
...
@@ -9,7 +9,8 @@ from flask import render_template
...
@@ -9,7 +9,8 @@ from flask import render_template
from
datetime
import
datetime
from
datetime
import
datetime
from
collections
import
namedtuple
from
collections
import
namedtuple
from
pykat.testing
import
utils
from
pykat.testing
import
utils
from
pykat.testing
import
test
as
finesse_test
import
shutil
from
pykat.testing.web
import
app
from
pykat.testing.web
import
app
import
os
import
os
...
@@ -20,11 +21,59 @@ test_id = 0
...
@@ -20,11 +21,59 @@ test_id = 0
current_test
=
None
current_test
=
None
scheduled_tests
=
[]
scheduled_tests
=
[]
schedule_lock
=
Lock
()
schedule_lock
=
Lock
()
watcher
=
None
print
"
loading web interface
"
print
"
loading web interface
"
class
FinesseProcessWatcher
(
Thread
):
process_to_watch
=
None
def
__init__
(
self
,
*
args
,
**
kqwargs
):
Thread
.
__init__
(
self
)
def
setProcessToWatch
(
self
,
process
):
print
type
(
process
)
#if type(self.process_to_watch) is not finesse_test.FinesseTestProcess:
# raise Exception("Tried to watch something which wasn't a FinesseTestProcess")
self
.
process_to_watch
=
process
def
run
(
self
):
global
schedule_lock
,
current_test
,
scheduled_tests
,
watcher
if
self
.
process_to_watch
is
None
:
return
#if type(self.process_to_watch) is not finesse_test.FinesseTestProcess:
# raise Exception("Tried to watch something which wasn't a FinesseTestProcess")
print
"
Watcher is watching
"
,
self
.
process_to_watch
self
.
process_to_watch
.
join
()
print
"
Watcher is continuing
"
# once done check if any other tests need to be ran
schedule_lock
.
acquire
()
if
len
(
scheduled_tests
)
>
0
:
print
"
Watcher starting next test
"
current_test
=
scheduled_tests
.
pop
(
0
)
watcher
=
FinesseProcessWatcher
()
watcher
.
setProcessToWatch
(
current_test
)
watcher
.
start
()
current_test
.
start
()
else
:
print
"
Watcher found no more tests to run
"
current_test
=
None
schedule_lock
.
release
()
@app.route
(
'
/
'
)
@app.route
(
'
/
'
)
def
h
ello_world
():
def
h
ome_page
():
return
render_template
(
"
finesse_test.html
"
)
return
render_template
(
"
finesse_test.html
"
)
@app.route
(
'
/finesse/start_test
'
,
methods
=
[
"
POST
"
])
@app.route
(
'
/finesse/start_test
'
,
methods
=
[
"
POST
"
])
...
@@ -38,15 +87,37 @@ def finesse_start_test():
...
@@ -38,15 +87,37 @@ def finesse_start_test():
git_commit
=
request
.
json
[
'
git_commit
'
]
git_commit
=
request
.
json
[
'
git_commit
'
]
test
=
FinesseTestProcess
(
git_commit
,
test_id
)
print
app
.
instance_path
TEST_OUTPUT_PATH
=
os
.
path
.
join
(
app
.
instance_path
,
"
tests
"
)
if
not
os
.
path
.
exists
(
TEST_OUTPUT_PATH
):
os
.
mkdir
(
TEST_OUTPUT_PATH
)
TEST_RUN_PATH
=
os
.
path
.
join
(
TEST_OUTPUT_PATH
,
str
(
test_id
))
print
TEST_RUN_PATH
if
os
.
path
.
exists
(
TEST_RUN_PATH
):
shutil
.
rmtree
(
TEST_RUN_PATH
)
os
.
mkdir
(
TEST_RUN_PATH
)
test
=
finesse_test
.
FinesseTestProcess
(
os
.
path
.
join
(
app
.
instance_path
,
"
finesse_test
"
),
TEST_RUN_PATH
,
git_commit
,
run_fast
=
False
,
suites
=
[],
test_id
=
test_id
,
emails
=
""
,
nobuild
=
True
)
# check if anything is running and if it
# check if anything is running and if it
# isn't start this test off
# isn't start this test off
if
current_test
is
None
:
if
current_test
is
None
:
print
"
running test
"
print
"
running test
"
current_test
=
test
current_test
=
test
watcher
=
FinesseProcessWatcher
()
watcher
.
setProcessToWatch
(
test
)
watcher
.
start
()
test
.
start
()
test
.
start
()
else
:
else
:
print
"
queuing test
"
print
"
queuing test
"
scheduled_tests
.
append
(
test
)
scheduled_tests
.
append
(
test
)
...
@@ -112,27 +183,3 @@ def finesse_get_log(count):
...
@@ -112,27 +183,3 @@ def finesse_get_log(count):
return
jsonify
(
logs
=
log2send
)
return
jsonify
(
logs
=
log2send
)
\ No newline at end of file
class
FinesseTestProcessRun
():
def
__init__
(
self
,
init_class
=
FinesseTestProcess
):
self
.
init_class
=
init_class
print
"
Init..
"
def
start
(
self
,
*
args
,
**
kwargs
):
print
"
Calling...
"
fjp
=
self
.
init_class
(
*
args
,
**
kwargs
)
print
'
%s threaded process beginning.
'
%
fjp
.
__class__
.
__name__
print
fjp
.
get_progress
()
fjp
.
start
()
while
fjp
.
is_alive
():
sleep
(
1
)
print
fjp
.
get_progress
()
print
fjp
.
get_progress
()
print
'
%s threaded process complete. Now exiting.
'
%
fjp
.
__class__
.
__name__
\ No newline at end of file
This diff is collapsed.
Click to expand it.
pykat/testing/web_server.py
+
8
−
0
View file @
93ba0dd3
...
@@ -20,6 +20,9 @@ def start(instance_path,port=5000, debug=True):
...
@@ -20,6 +20,9 @@ def start(instance_path,port=5000, debug=True):
from
pykat.testing.web
import
app
from
pykat.testing.web
import
app
if
(
app
.
instance_path
!=
instance_path
):
raise
Exception
(
"
Instance path of Flask app didn
'
t match the requested value
"
)
# load up the actual interface code
# load up the actual interface code
import
pykat.testing.web.web_interface
import
pykat.testing.web.web_interface
...
@@ -31,6 +34,11 @@ def start(instance_path,port=5000, debug=True):
...
@@ -31,6 +34,11 @@ def start(instance_path,port=5000, debug=True):
# get the latest version for logs etc.
# get the latest version for logs etc.
utils
.
git
(
"
--git-dir ./finesse_src/.git pull
"
)
utils
.
git
(
"
--git-dir ./finesse_src/.git pull
"
)
# need local copy of test
if
not
os
.
path
.
exists
(
"
./finesse_test
"
):
print
"
finesse test folder didn
'
t exist, cloning now...
"
utils
.
git
(
"
clone git://gitmaster.atlas.aei.uni-hannover.de/finesse/test.git finesse_test
"
)
app
.
secret_key
=
os
.
urandom
(
24
)
app
.
secret_key
=
os
.
urandom
(
24
)
app
.
run
(
debug
=
debug
,
port
=
int
(
port
))
app
.
run
(
debug
=
debug
,
port
=
int
(
port
))
...
...
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