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
87d3fac5
Commit
87d3fac5
authored
6 years ago
by
Jorrit Schaap
Browse files
Options
Downloads
Patches
Plain Diff
SW-415
: use dbcredentials and envvar LSMR_DBCREDENTIALS to fire up a test django postgres server
parent
9cacedcb
No related branches found
No related tags found
1 merge request
!87
Lsmr epic
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
SAS/LSMR/bin/lsmr_testdatabase
+21
-6
21 additions, 6 deletions
SAS/LSMR/bin/lsmr_testdatabase
SAS/LSMR/test/CMakeLists.txt
+3
-1
3 additions, 1 deletion
SAS/LSMR/test/CMakeLists.txt
SAS/LSMR/test/postgres_testrunner.py
+12
-5
12 additions, 5 deletions
SAS/LSMR/test/postgres_testrunner.py
with
36 additions
and
12 deletions
SAS/LSMR/bin/lsmr_testdatabase
100644 → 100755
+
21
−
6
View file @
87d3fac5
...
@@ -18,13 +18,28 @@
...
@@ -18,13 +18,28 @@
# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>.
# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>.
# Script to run a temporary postgres instance for easy functional testing
# Script to
create, setup, and
run a temporary postgres instance for easy functional testing
echo
"---"
#defaults
echo
"! This is for testing only! Database is not persistent!"
CREDENTIALS
=
"lsmr_test"
echo
"---"
# Parse args:
while
getopts
"C:h"
opt
;
do
case
${
opt
}
in
C
)
CREDENTIALS
=
${
OPTARG
}
;;
h
)
echo
"usage: lsmr_testdatabase [OPTIONS]"
echo
" where options are:"
echo
" -C <credentials-name> the name of the credentials in ~/.lofar/dbcredentials. default=
$CREDENTIALS
"
exit
0
;;
esac
done
DIR
=
"
$(
cd
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
"
&&
pwd
)
"
echo
"!!! This is for testing only! Database is not persistent !!!"
echo
"Using credentials=
$CREDENTIALS
"
# the lsmr django settings module reads this environment variable when available to determine the used database.
export
LSMR_DBCREDENTIALS
=
$CREDENTIALS
/usr/bin/env python3
${
LOFARROOT
}
/../SAS/LSMR/test/postgres_testrunner.py
DIR
=
"
$(
cd
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
"
&&
pwd
)
"
\ No newline at end of file
/usr/bin/env python3
$DIR
/../lib
*
/python
*
/site-packages/lofar/sas/lsmr/test/postgres_testrunner.py
This diff is collapsed.
Click to expand it.
SAS/LSMR/test/CMakeLists.txt
+
3
−
1
View file @
87d3fac5
...
@@ -20,4 +20,6 @@ set(_py_files
...
@@ -20,4 +20,6 @@ set(_py_files
__init__.py
__init__.py
postgres_testrunner.py
postgres_testrunner.py
)
)
file
(
COPY
${
_py_files
}
DESTINATION
${
CMAKE_CURRENT_BINARY_DIR
}
)
python_install
(
${
_py_files
}
\ No newline at end of file
DESTINATION lofar/sas/lsmr/test
)
This diff is collapsed.
Click to expand it.
SAS/LSMR/test/postgres_testrunner.py
+
12
−
5
View file @
87d3fac5
...
@@ -105,14 +105,21 @@ class PostgresqlTestRunner(DiscoverRunner):
...
@@ -105,14 +105,21 @@ class PostgresqlTestRunner(DiscoverRunner):
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
"""
"""
Start Django test database and keep it alive until interrupted
Start Django test database and keep it alive until interrupted.
It will use the database credentials found in ~/.lofar/dbcredentials
for the name found in environment variable LSMR_DBCREDENTIALS, or
'
lsmr
'
if the env var is not set.
See also settings.py and the lsmr_testdatabase script for usage.
"""
"""
pg
=
create_test_Postgres_from_django_settings
()
pg
=
create_test_Postgres_from_django_settings
()
name
=
DATABASES
[
'
default
'
][
'
NAME
'
]
create_project_db
(
pg
,
DATABASES
[
'
default
'
][
'
NAME
'
])
create_project_db
(
pg
,
name
)
print
(
"
Started Postgres server for lsmr django: dbname=%s user=%s host=%s port=%s PID=%s
"
%
(
print
(
"
Started Postgres server according to settings.py details with PID %s
"
%
pg
.
server_pid
)
DATABASES
[
'
default
'
][
'
NAME
'
],
DATABASES
[
'
default
'
][
'
USER
'
],
DATABASES
[
'
default
'
][
'
HOST
'
],
DATABASES
[
'
default
'
][
'
PORT
'
],
pg
.
server_pid
))
print
(
"
Waiting for your interrupt to stop it.
"
)
print
(
"
Waiting for your interrupt to stop it.
"
)
while
True
:
while
True
:
time
.
sleep
(
1
)
time
.
sleep
(
1
)
...
...
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