Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F53865467
test_postgresql.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
test_postgresql.py
View Options
#!/usr/bin/env python3
# -------------------------------------------------------------
# Tests for dbserver pillar, PostgreSQL flavour
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Nasqueron
# Description: Checks for PostgreSQL pillar coherence
# License: BSD-2-Clause
# -------------------------------------------------------------
import
unittest
from
unittest_data_provider
import
data_provider
from
helpers
import
load_pillars
# -------------------------------------------------------------
# Connection keys
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MANDATORY_CONNECTION_KEYS
=
[
"db"
,
"user"
,
"ips"
,
]
OPTIONAL_CONNECTION_KEYS
=
[
"method"
,
]
ALL_CONNECTION_KEYS
=
MANDATORY_CONNECTION_KEYS
+
OPTIONAL_CONNECTION_KEYS
# -------------------------------------------------------------
# Tests
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
pillars
=
load_pillars
(
"../pillar/dbserver/"
)
class
Testinstance
(
unittest
.
TestCase
):
@staticmethod
def
provide_pillars
():
for
file_path
,
pillar
in
pillars
.
items
():
if
"dbserver_postgresql"
not
in
pillar
:
continue
yield
file_path
,
pillar
[
"dbserver_postgresql"
]
@data_provider
(
provide_pillars
)
def
test_connections
(
self
,
pillar_file_path
,
pillar
):
for
connection
in
pillar
[
"connections"
]:
for
key
in
MANDATORY_CONNECTION_KEYS
:
self
.
assertIn
(
key
,
connection
,
f
"Mandatory key missing in {pillar_file_path}"
)
for
key
in
connection
:
self
.
assertIn
(
key
,
ALL_CONNECTION_KEYS
,
f
"Unknown connection parameter in {pillar_file_path}"
,
)
self
.
assertIn
(
"/"
,
connection
[
"ips"
],
f
"Connection IP range should be in CIDR notation in {pillar_file_path}."
,
)
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Wed, Oct 14, 20:56 (22 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3826675
Default Alt Text
test_postgresql.py (1 KB)
Attached To
Mode
rOPS Nasqueron Operations
Attached
Detach File
Event Timeline
Log In to Comment