Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
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
Timo Ley
synapse
Commits
708d88b1
Unverified
Commit
708d88b1
authored
2 years ago
by
reivilibre
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Allow specifying the Postgres database's port when running unit tests with Postgres. (#12376)
parent
efdbcfd6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
changelog.d/12376.misc
+1
-0
1 addition, 0 deletions
changelog.d/12376.misc
docs/development/contributing_guide.md
+11
-3
11 additions, 3 deletions
docs/development/contributing_guide.md
tests/server.py
+4
-0
4 additions, 0 deletions
tests/server.py
tests/utils.py
+8
-0
8 additions, 0 deletions
tests/utils.py
with
24 additions
and
3 deletions
changelog.d/12376.misc
0 → 100644
+
1
−
0
View file @
708d88b1
Allow specifying the Postgres database's port when running unit tests with Postgres.
\ No newline at end of file
This diff is collapsed.
Click to expand it.
docs/development/contributing_guide.md
+
11
−
3
View file @
708d88b1
...
...
@@ -206,9 +206,10 @@ To do so, [configure Postgres](../postgres.md) and run `trial` with the
following environment variables matching your configuration:
-
`SYNAPSE_POSTGRES`
to anything nonempty
-
`SYNAPSE_POSTGRES_HOST`
-
`SYNAPSE_POSTGRES_USER`
-
`SYNAPSE_POSTGRES_PASSWORD`
-
`SYNAPSE_POSTGRES_HOST`
(optional if it's the default: UNIX socket)
-
`SYNAPSE_POSTGRES_PORT`
(optional if it's the default: 5432)
-
`SYNAPSE_POSTGRES_USER`
(optional if using a UNIX socket)
-
`SYNAPSE_POSTGRES_PASSWORD`
(optional if using a UNIX socket)
For example:
...
...
@@ -220,6 +221,13 @@ export SYNAPSE_POSTGRES_PASSWORD=mydevenvpassword
trial
```
You don't need to specify the host, user, port or password if your Postgres
server is set to authenticate you over the UNIX socket (i.e. if the
`psql`
command
works without further arguments).
Your Postgres account needs to be able to create databases.
## Run the integration tests ([Sytest](https://github.com/matrix-org/sytest)).
The integration tests are a more comprehensive suite of tests. They
...
...
This diff is collapsed.
Click to expand it.
tests/server.py
+
4
−
0
View file @
708d88b1
...
...
@@ -76,6 +76,7 @@ from tests.utils import (
POSTGRES_BASE_DB
,
POSTGRES_HOST
,
POSTGRES_PASSWORD
,
POSTGRES_PORT
,
POSTGRES_USER
,
SQLITE_PERSIST_DB
,
USE_POSTGRES_FOR_TESTS
,
...
...
@@ -747,6 +748,7 @@ def setup_test_homeserver(
"
host
"
:
POSTGRES_HOST
,
"
password
"
:
POSTGRES_PASSWORD
,
"
user
"
:
POSTGRES_USER
,
"
port
"
:
POSTGRES_PORT
,
"
cp_min
"
:
1
,
"
cp_max
"
:
5
,
},
...
...
@@ -786,6 +788,7 @@ def setup_test_homeserver(
database
=
POSTGRES_BASE_DB
,
user
=
POSTGRES_USER
,
host
=
POSTGRES_HOST
,
port
=
POSTGRES_PORT
,
password
=
POSTGRES_PASSWORD
,
)
db_conn
.
autocommit
=
True
...
...
@@ -833,6 +836,7 @@ def setup_test_homeserver(
database
=
POSTGRES_BASE_DB
,
user
=
POSTGRES_USER
,
host
=
POSTGRES_HOST
,
port
=
POSTGRES_PORT
,
password
=
POSTGRES_PASSWORD
,
)
db_conn
.
autocommit
=
True
...
...
This diff is collapsed.
Click to expand it.
tests/utils.py
+
8
−
0
View file @
708d88b1
...
...
@@ -35,6 +35,11 @@ LEAVE_DB = os.environ.get("SYNAPSE_LEAVE_DB", False)
POSTGRES_USER
=
os
.
environ
.
get
(
"
SYNAPSE_POSTGRES_USER
"
,
None
)
POSTGRES_HOST
=
os
.
environ
.
get
(
"
SYNAPSE_POSTGRES_HOST
"
,
None
)
POSTGRES_PASSWORD
=
os
.
environ
.
get
(
"
SYNAPSE_POSTGRES_PASSWORD
"
,
None
)
POSTGRES_PORT
=
(
int
(
os
.
environ
[
"
SYNAPSE_POSTGRES_PORT
"
])
if
"
SYNAPSE_POSTGRES_PORT
"
in
os
.
environ
else
None
)
POSTGRES_BASE_DB
=
"
_synapse_unit_tests_base_%s
"
%
(
os
.
getpid
(),)
# When debugging a specific test, it's occasionally useful to write the
...
...
@@ -55,6 +60,7 @@ def setupdb():
db_conn
=
db_engine
.
module
.
connect
(
user
=
POSTGRES_USER
,
host
=
POSTGRES_HOST
,
port
=
POSTGRES_PORT
,
password
=
POSTGRES_PASSWORD
,
dbname
=
POSTGRES_DBNAME_FOR_INITIAL_CREATE
,
)
...
...
@@ -73,6 +79,7 @@ def setupdb():
database
=
POSTGRES_BASE_DB
,
user
=
POSTGRES_USER
,
host
=
POSTGRES_HOST
,
port
=
POSTGRES_PORT
,
password
=
POSTGRES_PASSWORD
,
)
db_conn
=
LoggingDatabaseConnection
(
db_conn
,
db_engine
,
"
tests
"
)
...
...
@@ -83,6 +90,7 @@ def setupdb():
db_conn
=
db_engine
.
module
.
connect
(
user
=
POSTGRES_USER
,
host
=
POSTGRES_HOST
,
port
=
POSTGRES_PORT
,
password
=
POSTGRES_PASSWORD
,
dbname
=
POSTGRES_DBNAME_FOR_INITIAL_CREATE
,
)
...
...
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