Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
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
RadioObservatory
LOFAR
Commits
1320bd42
Commit
1320bd42
authored
4 years ago
by
Jorrit Schaap
Browse files
Options
Downloads
Patches
Plain Diff
TMSS-189
: use RAService in RATestEnvironment
parent
5fc7bb2e
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!182
Resolve TMSS-189 (and TMSS-192)
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
SAS/ResourceAssignment/ResourceAssigner/test/ra_test_environment.py
+19
-7
19 additions, 7 deletions
...ceAssignment/ResourceAssigner/test/ra_test_environment.py
with
19 additions
and
7 deletions
SAS/ResourceAssignment/ResourceAssigner/test/ra_test_environment.py
+
19
−
7
View file @
1320bd42
...
...
@@ -31,24 +31,25 @@ from lofar.common.util import find_free_port, waitForInterrupt
from
lofar.messaging.config
import
DEFAULT_BROKER
,
DEFAULT_BUSNAME
from
lofar.common.testing.dbcredentials
import
TemporaryCredentials
from
lofar.sas.resourceassignment.database.testing.radb_common_testing
import
RADBTestDatabaseInstance
from
lofar.sas.resourceassignment.resourceassigner.resource_assigner
import
ResourceAssigner
from
lofar.sas.resourceassignment.resourceassigner.raservice
import
RAService
from
lofar.sas.resourceassignment.resourceassignmentservice.service
import
createService
as
createRADBService
class
RATestEnvironment
:
'''
Create and run a several ResourrceAssigner services in an isolated test environment
'''
def
__init__
(
self
,
exchange
:
str
=
os
.
environ
.
get
(
"
RA_EXCHANGE
"
,
DEFAULT_BUSNAME
),
broker
:
str
=
os
.
environ
.
get
(
"
RA_BROKER
"
,
DEFAULT_BROKER
)):
self
.
radb
=
RADBTestDatabaseInstance
()
self
.
resource_assigner
=
ResourceAssigner
(
radb_dbcreds
=
self
.
radb
.
dbcreds
,
exchange
=
exchange
,
broker
=
broker
)
self
.
radb_service
=
createRADBService
(
dbcreds
=
self
.
radb
.
dbcreds
,
exchange
=
exchange
,
broker
=
broker
)
self
.
ra_service
=
RAService
(
radbcreds
=
self
.
radb
.
dbcreds
,
exchange
=
exchange
,
broker
=
broker
)
def
start
(
self
):
self
.
radb
.
create
()
self
.
resource_assigner
.
open
()
# self.resource_assigner.do_assignment(0,{ 'task_type': 'observation',
# 'task_subtype': 'bfmeasurement',
# 'status': 'approved'})
self
.
radb_service
.
start_listening
()
self
.
ra_service
.
start_listening
()
def
stop
(
self
):
self
.
resource_assigner
.
close
()
self
.
ra_service
.
stop_listening
()
self
.
radb_service
.
stop_listening
()
self
.
radb
.
destroy
()
def
__enter__
(
self
):
...
...
@@ -78,7 +79,18 @@ def main():
logging
.
basicConfig
(
format
=
'
%(asctime)s %(levelname)s %(message)s
'
,
level
=
logging
.
INFO
)
from
lofar.sas.resourceassignment.resourceassigner.rarpc
import
RARPC
from
datetime
import
datetime
,
timedelta
with
RATestEnvironment
(
exchange
=
options
.
exchange
,
broker
=
options
.
broker
)
as
instance
:
with
RARPC
.
create
(
exchange
=
options
.
exchange
,
broker
=
options
.
broker
)
as
rarpc
:
rarpc
.
do_assignment
(
2000000
,
{
'
otdb_id
'
:
2000000
,
'
task_type
'
:
'
observation
'
,
'
task_subtype
'
:
'
bfmeasurement
'
,
'
status
'
:
'
approved
'
,
'
starttime
'
:
datetime
.
utcnow
()
+
timedelta
(
hours
=
1
),
'
endtime
'
:
datetime
.
utcnow
()
+
timedelta
(
hours
=
2
)})
# print some nice info for the user to use the test servers...
# use print instead of log for clean lines.
for
h
in
logging
.
root
.
handlers
:
...
...
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