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
c5ba3df4
Commit
c5ba3df4
authored
5 years ago
by
Jorrit Schaap
Browse files
Options
Downloads
Patches
Plain Diff
TMSS: added 'host' option to tmss_test_environment
parent
4f6e4ef6
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
SAS/TMSS/docker-compose-scu199.yml
+1
-1
1 addition, 1 deletion
SAS/TMSS/docker-compose-scu199.yml
SAS/TMSS/test/test_utils.py
+8
-4
8 additions, 4 deletions
SAS/TMSS/test/test_utils.py
with
9 additions
and
5 deletions
SAS/TMSS/docker-compose-scu199.yml
+
1
−
1
View file @
c5ba3df4
...
@@ -6,7 +6,7 @@ services:
...
@@ -6,7 +6,7 @@ services:
restart
:
on-failure
restart
:
on-failure
env_file
:
env_file
:
-
./.env
-
./.env
command
:
bash -c 'source /opt/lofar/lofarinit.sh && tmss_test_environment -p 8008'
command
:
bash -c 'source /opt/lofar/lofarinit.sh &&
ALLOWED_HOSTS=*
tmss_test_environment
-H 0.0.0.0
-p 8008'
ports
:
ports
:
-
"
8008:8008"
-
"
8008:8008"
testprovider
:
testprovider
:
...
...
This diff is collapsed.
Click to expand it.
SAS/TMSS/test/test_utils.py
+
8
−
4
View file @
c5ba3df4
...
@@ -113,16 +113,17 @@ class TMSSPostgresTestMixin(PostgresTestMixin):
...
@@ -113,16 +113,17 @@ class TMSSPostgresTestMixin(PostgresTestMixin):
class
TMSSDjangoServerInstance
():
class
TMSSDjangoServerInstance
():
'''
Creates a running django TMSS server at the requested port with the requested database credentials.
'''
Creates a running django TMSS server at the requested port with the requested database credentials.
'''
'''
def
__init__
(
self
,
db_dbcreds_id
:
str
=
"
TMSS
"
,
ldap_dbcreds_id
:
str
=
"
TMSS_LDAP
"
,
port
:
int
=
8000
):
def
__init__
(
self
,
db_dbcreds_id
:
str
=
"
TMSS
"
,
ldap_dbcreds_id
:
str
=
"
TMSS_LDAP
"
,
host
:
str
=
'
127.0.0.1
'
,
port
:
int
=
8000
):
self
.
_db_dbcreds_id
=
db_dbcreds_id
self
.
_db_dbcreds_id
=
db_dbcreds_id
self
.
_ldap_dbcreds_id
=
ldap_dbcreds_id
self
.
_ldap_dbcreds_id
=
ldap_dbcreds_id
self
.
host
=
host
self
.
port
=
port
self
.
port
=
port
self
.
_server_process
=
None
self
.
_server_process
=
None
@property
@property
def
address
(
self
):
def
address
(
self
):
'''
:returns the address and port of the django server
'''
'''
:returns the address and port of the django server
'''
return
"
127.0.0.1:%d
"
%
self
.
port
return
"
%s:%d
"
%
(
self
.
host
,
self
.
port
)
@property
@property
def
url
(
self
):
def
url
(
self
):
...
@@ -240,11 +241,12 @@ class TMSSDjangoServerInstance():
...
@@ -240,11 +241,12 @@ class TMSSDjangoServerInstance():
class
TMSSTestEnvironment
:
class
TMSSTestEnvironment
:
'''
Create and run a test django TMSS server against a newly created test database and a test ldap server (and cleanup automagically)
'''
'''
Create and run a test django TMSS server against a newly created test database and a test ldap server (and cleanup automagically)
'''
def
__init__
(
self
,
preferred_django_port
:
int
=
8000
):
def
__init__
(
self
,
host
:
str
=
'
127.0.0.1
'
,
preferred_django_port
:
int
=
8000
):
self
.
ldap_server
=
TestLDAPServer
(
user
=
'
test
'
,
password
=
'
test
'
)
self
.
ldap_server
=
TestLDAPServer
(
user
=
'
test
'
,
password
=
'
test
'
)
self
.
database
=
TMSSTestDatabaseInstance
()
self
.
database
=
TMSSTestDatabaseInstance
()
self
.
django_server
=
TMSSDjangoServerInstance
(
db_dbcreds_id
=
self
.
database
.
dbcreds_id
,
self
.
django_server
=
TMSSDjangoServerInstance
(
db_dbcreds_id
=
self
.
database
.
dbcreds_id
,
ldap_dbcreds_id
=
self
.
ldap_server
.
dbcreds_id
,
ldap_dbcreds_id
=
self
.
ldap_server
.
dbcreds_id
,
host
=
host
,
port
=
find_free_port
(
preferred_django_port
))
port
=
find_free_port
(
preferred_django_port
))
def
start
(
self
):
def
start
(
self
):
...
@@ -310,13 +312,15 @@ def main_test_environment():
...
@@ -310,13 +312,15 @@ def main_test_environment():
parser
=
OptionParser
(
'
%prog [options]
'
,
parser
=
OptionParser
(
'
%prog [options]
'
,
description
=
'
setup/run/teardown a full TMSS test environment including a fresh and isolated database, LDAP server and DJANGO REST server.
'
)
description
=
'
setup/run/teardown a full TMSS test environment including a fresh and isolated database, LDAP server and DJANGO REST server.
'
)
parser
.
add_option
(
"
-H
"
,
"
--host
"
,
dest
=
"
host
"
,
type
=
"
string
"
,
default
=
'
127.0.0.1
'
,
help
=
"
expose the TMSS Django REST API via this host. [default=%default]
"
)
parser
.
add_option
(
"
-p
"
,
"
--port
"
,
dest
=
"
port
"
,
type
=
"
int
"
,
default
=
find_free_port
(
8000
),
parser
.
add_option
(
"
-p
"
,
"
--port
"
,
dest
=
"
port
"
,
type
=
"
int
"
,
default
=
find_free_port
(
8000
),
help
=
"
try to use this port for the DJANGO REST API. If not available, then a random free port is used and logged. [default=%default]
"
)
help
=
"
try to use this port for the DJANGO REST API. If not available, then a random free port is used and logged. [default=%default]
"
)
(
options
,
args
)
=
parser
.
parse_args
()
(
options
,
args
)
=
parser
.
parse_args
()
logging
.
basicConfig
(
format
=
'
%(asctime)s %(levelname)s %(message)s
'
,
level
=
logging
.
INFO
)
logging
.
basicConfig
(
format
=
'
%(asctime)s %(levelname)s %(message)s
'
,
level
=
logging
.
INFO
)
with
TMSSTestEnvironment
(
preferred_django_port
=
options
.
port
)
as
instance
:
with
TMSSTestEnvironment
(
host
=
options
.
host
,
preferred_django_port
=
options
.
port
)
as
instance
:
# print some nice info for the user to use the test servers...
# print some nice info for the user to use the test servers...
# use print instead of log for clean lines.
# use print instead of log for clean lines.
for
h
in
logging
.
root
.
handlers
:
for
h
in
logging
.
root
.
handlers
:
...
...
This diff is collapsed.
Click to expand it.
Jorrit Schaap
@schaap
mentioned in commit
a25f7368
·
5 years ago
mentioned in commit
a25f7368
mentioned in commit a25f7368443f38299ea5b70fed748f708547398b
Toggle commit list
Jorrit Schaap
@schaap
mentioned in commit
562b3482
·
5 years ago
mentioned in commit
562b3482
mentioned in commit 562b34820e93d8792c22e8fa04c64cedd08441b7
Toggle commit list
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