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
5c01b8c0
Commit
5c01b8c0
authored
6 years ago
by
Nicolas KAROLAK
Browse files
Options
Downloads
Patches
Plain Diff
change(test_postgresql): output and format
parent
e1ed8a76
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/test_postgresql.py
+13
-12
13 additions, 12 deletions
tests/test_postgresql.py
with
13 additions
and
12 deletions
tests/test_postgresql.py
+
13
−
12
View file @
5c01b8c0
...
...
@@ -298,10 +298,10 @@ def check_ha(db_conn: dict, errors: int = 0) -> int:
node_host
=
nodes
[
node
][
"
host
"
]
node_port
=
nodes
[
node
][
"
port
"
]
if
not
check_listen
(
node_host
,
node_port
):
u
.
error
(
"
C
annot bind {}:{}
"
.
format
(
node_host
,
node_port
))
u
.
error
(
"
c
annot bind {}:{}
"
.
format
(
node_host
,
node_port
))
errors
+=
1
else
:
u
.
success
(
"
C
an bind {}:{}
"
.
format
(
node_host
,
node_port
))
u
.
success
(
"
c
an bind {}:{}
"
.
format
(
node_host
,
node_port
))
# check fenced
print
(
"
Checking cluster state:
"
)
...
...
@@ -320,10 +320,10 @@ def check_ha(db_conn: dict, errors: int = 0) -> int:
standby
[
"
port
"
]
=
54322
status
,
info
=
check_replication
(
primary
,
standby
)
if
not
status
:
u
.
error
(
"
C
annot replicate between primary/standby ({})
"
.
format
(
info
))
u
.
error
(
"
c
annot replicate between primary/standby ({})
"
.
format
(
info
))
errors
+=
1
else
:
u
.
success
(
"
C
an replicate between primary/standby ({})
"
.
format
(
info
))
u
.
success
(
"
c
an replicate between primary/standby ({})
"
.
format
(
info
))
return
errors
...
...
@@ -346,20 +346,20 @@ def check_local(db_conn: dict, errors: int = 0) -> int:
# check listen
print
(
"
Checking local PostgreSQL node:
"
)
if
not
check_listen
(
host
,
port
):
u
.
error
(
"
C
annot connect to {}:{}
"
.
format
(
host
,
port
))
u
.
error
(
"
c
annot connect to {}:{}
"
.
format
(
host
,
port
))
errors
+=
1
else
:
u
.
success
(
"
C
an connect to {}:{}
"
.
format
(
host
,
port
))
u
.
success
(
"
c
an connect to {}:{}
"
.
format
(
host
,
port
))
# check read
print
(
"
Checking read operation:
"
)
read_query
=
"
SELECT 1;
"
status
,
info
=
check_psql
(
db_conn
,
read_query
)
if
not
status
:
u
.
error
(
"
C
annot read from {}@{}:{} ({})
"
.
format
(
user
,
host
,
port
,
info
))
u
.
error
(
"
c
annot read from {}@{}:{} ({})
"
.
format
(
user
,
host
,
port
,
info
))
errors
+=
1
else
:
u
.
success
(
"
C
an read from {}@{}:{}
"
.
format
(
user
,
host
,
port
))
u
.
success
(
"
c
an read from {}@{}:{}
"
.
format
(
user
,
host
,
port
))
# check write
print
(
"
Checking write operation:
"
)
...
...
@@ -367,10 +367,10 @@ def check_local(db_conn: dict, errors: int = 0) -> int:
write_query
=
"
CREATE TABLE es_test_{} (id serial PRIMARY KEY);
"
.
format
(
rand
)
status
,
info
=
check_psql
(
db_conn
,
write_query
)
if
not
status
:
u
.
error
(
"
C
annot write on {}@{}:{} ({})
"
.
format
(
user
,
host
,
port
,
info
))
u
.
error
(
"
c
annot write on {}@{}:{} ({})
"
.
format
(
user
,
host
,
port
,
info
))
errors
+=
1
else
:
u
.
success
(
"
C
an write on {}@{}:{}
"
.
format
(
user
,
host
,
port
))
u
.
success
(
"
c
an write on {}@{}:{}
"
.
format
(
user
,
host
,
port
))
# remove test table
check_psql
(
db_conn
,
"
DROP TABLE es_test_{};
"
.
format
(
rand
))
...
...
@@ -393,11 +393,12 @@ def main():
db_conn
.
update
({
"
password
"
:
db_pass
})
# determine if HA setup and run according tests
print
(
"
Checking availibility mode:
"
)
if
is_ha
(
db_port
):
print
(
"
T
his setup is using a HA database
"
)
u
.
info
(
"
t
his setup is using a HA database
"
)
errors
=
check_ha
(
db_conn
)
else
:
print
(
"
T
his setup is using a local database
"
)
u
.
info
(
"
t
his setup is using a local 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