Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
envsetup
Manage
Activity
Members
Plan
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor 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
mediaserver
envsetup
Commits
8c3f03ea
Commit
8c3f03ea
authored
4 years ago
by
Stéphane Diemer
Browse files
Options
Downloads
Patches
Plain Diff
Change postgresql test to handle server with no standby db access | refs
#33528
parent
3dc585ee
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/scripts/test_postgresql.py
+4
-13
4 additions, 13 deletions
tests/scripts/test_postgresql.py
with
4 additions
and
13 deletions
tests/scripts/test_postgresql.py
+
4
−
13
View file @
8c3f03ea
...
...
@@ -44,15 +44,6 @@ def check_listen(host: str, port: int) -> bool:
return
result
==
0
def
is_ha
()
->
bool
:
"""
Check wether this setup is using higlhy-available databases.
:return: Wether it is a highly-available setup or not
:rtype: bool
"""
return
check_listen
(
"
127.0.0.1
"
,
54321
)
def
get_haproxy_conf
(
path
:
str
=
"
/etc/haproxy/haproxy.cfg
"
)
->
dict
:
"""
Get HAProxy configuration in a dictionary.
...
...
@@ -397,7 +388,7 @@ def main():
# get database configuration
db_host
=
conf
.
get
(
"
DB_HOST
"
)
if
conf
.
get
(
"
DB_HOST
"
)
else
"
127.0.0.1
"
db_port
=
54321
if
is_ha
(
)
else
5432
db_port
=
54321
if
check_listen
(
"
127.0.0.1
"
,
54321
)
else
5432
db_user
=
conf
.
get
(
"
DB_USER
"
)
if
conf
.
get
(
"
DB_USER
"
)
else
"
postgres
"
db_pass
=
conf
.
get
(
"
DB_PG_ROOT_PWD
"
)
db_conn
=
{
"
dbname
"
:
db_user
,
"
host
"
:
db_host
,
"
port
"
:
db_port
,
"
user
"
:
db_user
}
...
...
@@ -406,11 +397,11 @@ def main():
# determine if HA setup and run according tests
lg
.
log
(
"
Checking availibility mode:
"
)
if
is_ha
(
):
lg
.
info
(
"
this setup is using a
HA
database
"
)
if
check_listen
(
"
127.0.0.1
"
,
54321
)
and
check_listen
(
"
127.0.0.1
"
,
54322
):
lg
.
info
(
"
this setup is using a
master and standby
database
"
)
errors
=
check_ha
(
db_conn
)
else
:
lg
.
info
(
"
this setup is using a
local
database
"
)
lg
.
info
(
"
this setup is using a
single
database
"
)
errors
=
check_local
(
db_conn
)
if
errors
:
...
...
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