Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

TestTestgresCommon - unified tests for local and remote#216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
26 commits
Select commitHold shift + click to select a range
5488ecd
TestTestgresCommon - unified tests for local and remote
dmitry-lipetskMar 12, 2025
a6edd3a
TestTestgresCommon is updated
dmitry-lipetskMar 12, 2025
3c055af
TestTestgresCommon is updated
dmitry-lipetskMar 13, 2025
188b3b2
TestTestgresCommon is updated
dmitry-lipetskMar 13, 2025
9b137ca
Merge branch 'master' into D20250312_002--TestTestgresCommon
dmitry-lipetskMar 13, 2025
9bddc3b
Merge branch 'master' into D20250312_002--TestTestgresCommon
dmitry-lipetskMar 14, 2025
75f0326
Merge branch 'master' into D20250312_002--TestTestgresCommon
dmitry-lipetskMar 16, 2025
292b403
TestTestgresCommon is updated
dmitry-lipetskMar 16, 2025
0fb22e8
PostgresNode_Base is added
dmitry-lipetskMar 16, 2025
2e5bd9d
test_simple_remote.py is cleaned
dmitry-lipetskMar 16, 2025
7f89186
Merge branch 'master' into D20250312_002--TestTestgresCommon
dmitry-lipetskMar 16, 2025
48fd887
Formatting (flake8)
dmitry-lipetskMar 16, 2025
bf28a1a
Formatting
dmitry-lipetskMar 17, 2025
f64dd60
PostgresNode_Base is updated (documentation)
dmitry-lipetskMar 17, 2025
490130e
PostgresNode is updated (documentation)
dmitry-lipetskMar 17, 2025
ff9b7bc
PostgresNode_Base::_prefix is removed
dmitry-lipetskMar 17, 2025
9e1979f
PostgresNode::clean is corrected
dmitry-lipetskMar 17, 2025
3e9cad1
node_base.py is updated
dmitry-lipetskMar 17, 2025
12fa7f2
node_base.py is updated
dmitry-lipetskMar 17, 2025
cef7982
node.py is updated
dmitry-lipetskMar 17, 2025
61feb2c
NodeApp::make_empty is updated
dmitry-lipetskMar 17, 2025
84a51c7
PostgresNode::cleanup is fixed
dmitry-lipetskMar 17, 2025
f7f915d
PostgresNode::cleanup is updated (flake8)
dmitry-lipetskMar 17, 2025
882b8ec
PostgresNode_Base::clone_with_new_name_and_base_dir is added
dmitry-lipetskMar 17, 2025
e8e392e
PostgresNode is updated (comment)
dmitry-lipetskMar 17, 2025
06287f2
Merge remote-tracking branch 'origin/D20250316_003--PostgresNode_Base…
dmitry-lipetskMar 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
TestTestgresCommon is updated
New tests are added: - test_auto_name - test_file_tail - test_isolation_levels
  • Loading branch information
@dmitry-lipetsk
dmitry-lipetsk committedMar 12, 2025
commita6edd3a60bdcf8598e6d71d38faf5b36a60cb49d
56 changes: 0 additions & 56 deletionstests/test_simple.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,7 +34,6 @@

from ..testgres import \
NodeStatus, \
IsolationLevel, \
get_new_node

from ..testgres import \
Expand All@@ -49,7 +48,6 @@
# NOTE: those are ugly imports
from ..testgres import bound_ports
from ..testgres.utils import PgVer, parse_pg_version
from ..testgres.utils import file_tail
from ..testgres.node import ProcessProxy


Expand DownExpand Up@@ -953,60 +951,6 @@ def test_unix_sockets(self):
r.execute('select 1')
r.safe_psql('select 1')

def test_auto_name(self):
with get_new_node().init(allow_streaming=True).start() as m:
with m.replicate().start() as r:
# check that nodes are running
assert (m.status())
assert (r.status())

# check their names
assert (m.name != r.name)
assert ('testgres' in m.name)
assert ('testgres' in r.name)

def test_file_tail(self):
s1 = "the quick brown fox jumped over that lazy dog\n"
s2 = "abc\n"
s3 = "def\n"

with tempfile.NamedTemporaryFile(mode='r+', delete=True) as f:
sz = 0
while sz < 3 * 8192:
sz += len(s1)
f.write(s1)
f.write(s2)
f.write(s3)

f.seek(0)
lines = file_tail(f, 3)
assert (lines[0] == s1)
assert (lines[1] == s2)
assert (lines[2] == s3)

f.seek(0)
lines = file_tail(f, 1)
assert (lines[0] == s3)

def test_isolation_levels(self):
with get_new_node().init().start() as node:
with node.connect() as con:
# string levels
con.begin('Read Uncommitted').commit()
con.begin('Read Committed').commit()
con.begin('Repeatable Read').commit()
con.begin('Serializable').commit()

# enum levels
con.begin(IsolationLevel.ReadUncommitted).commit()
con.begin(IsolationLevel.ReadCommitted).commit()
con.begin(IsolationLevel.RepeatableRead).commit()
con.begin(IsolationLevel.Serializable).commit()

# check wrong level
with pytest.raises(expected_exception=QueryException):
con.begin('Garbage').commit()

def test_ports_management(self):
assert bound_ports is not None
assert type(bound_ports) == set # noqa: E721
Expand Down
58 changes: 1 addition & 57 deletionstests/test_simple_remote.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,8 +34,7 @@
pop_config, testgres_config

from ..testgres import \
NodeStatus, \
IsolationLevel
NodeStatus

from ..testgres import \
get_bin_path, \
Expand All@@ -49,7 +48,6 @@
# NOTE: those are ugly imports
from ..testgres import bound_ports
from ..testgres.utils import PgVer
from ..testgres.utils import file_tail
from ..testgres.node import ProcessProxy


Expand DownExpand Up@@ -1025,60 +1023,6 @@ def test_unix_sockets(self):
assert (res_exec == [(1,)])
assert (res_psql == b'1\n')

def test_auto_name(self):
with __class__.helper__get_node().init(allow_streaming=True).start() as m:
with m.replicate().start() as r:
# check that nodes are running
assert (m.status())
assert (r.status())

# check their names
assert (m.name != r.name)
assert ('testgres' in m.name)
assert ('testgres' in r.name)

def test_file_tail(self):
s1 = "the quick brown fox jumped over that lazy dog\n"
s2 = "abc\n"
s3 = "def\n"

with tempfile.NamedTemporaryFile(mode='r+', delete=True) as f:
sz = 0
while sz < 3 * 8192:
sz += len(s1)
f.write(s1)
f.write(s2)
f.write(s3)

f.seek(0)
lines = file_tail(f, 3)
assert (lines[0] == s1)
assert (lines[1] == s2)
assert (lines[2] == s3)

f.seek(0)
lines = file_tail(f, 1)
assert (lines[0] == s3)

def test_isolation_levels(self):
with __class__.helper__get_node().init().start() as node:
with node.connect() as con:
# string levels
con.begin('Read Uncommitted').commit()
con.begin('Read Committed').commit()
con.begin('Repeatable Read').commit()
con.begin('Serializable').commit()

# enum levels
con.begin(IsolationLevel.ReadUncommitted).commit()
con.begin(IsolationLevel.ReadCommitted).commit()
con.begin(IsolationLevel.RepeatableRead).commit()
con.begin(IsolationLevel.Serializable).commit()

# check wrong level
with pytest.raises(expected_exception=QueryException):
con.begin('Garbage').commit()

def test_ports_management(self):
assert bound_ports is not None
assert type(bound_ports) == set # noqa: E721
Expand Down
60 changes: 60 additions & 0 deletionstests/test_testgres_common.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,9 @@
from ..testgres.node import PgVer
from ..testgres.node import PostgresNode
from ..testgres.utils import get_pg_version2
from ..testgres.utils import file_tail
from ..testgres import ProcessType
from ..testgres import IsolationLevel
from ..testgres import TestgresException
from ..testgres import StartNodeException
from ..testgres import QueryException
Expand All@@ -15,6 +17,7 @@
import six
import logging
import time
import tempfile


class TestTestgresCommon:
Expand DownExpand Up@@ -186,6 +189,63 @@ def test_exceptions(self):
str(ExecUtilException('msg', 'cmd', 1, 'out'))
str(QueryException('msg', 'query'))

def test_auto_name(self, os_ops: OsOperations):
assert isinstance(os_ops, OsOperations)

with __class__.helper__get_node(os_ops).init(allow_streaming=True).start() as m:
with m.replicate().start() as r:
# check that nodes are running
assert (m.status())
assert (r.status())

# check their names
assert (m.name != r.name)
assert ('testgres' in m.name)
assert ('testgres' in r.name)

def test_file_tail(self):
s1 = "the quick brown fox jumped over that lazy dog\n"
s2 = "abc\n"
s3 = "def\n"

with tempfile.NamedTemporaryFile(mode='r+', delete=True) as f:
sz = 0
while sz < 3 * 8192:
sz += len(s1)
f.write(s1)
f.write(s2)
f.write(s3)

f.seek(0)
lines = file_tail(f, 3)
assert (lines[0] == s1)
assert (lines[1] == s2)
assert (lines[2] == s3)

f.seek(0)
lines = file_tail(f, 1)
assert (lines[0] == s3)

def test_isolation_levels(self, os_ops: OsOperations):
assert isinstance(os_ops, OsOperations)
with __class__.helper__get_node(os_ops).init().start() as node:
with node.connect() as con:
# string levels
con.begin('Read Uncommitted').commit()
con.begin('Read Committed').commit()
con.begin('Repeatable Read').commit()
con.begin('Serializable').commit()

# enum levels
con.begin(IsolationLevel.ReadUncommitted).commit()
con.begin(IsolationLevel.ReadCommitted).commit()
con.begin(IsolationLevel.RepeatableRead).commit()
con.begin(IsolationLevel.Serializable).commit()

# check wrong level
with pytest.raises(expected_exception=QueryException):
con.begin('Garbage').commit()

@staticmethod
def helper__get_node(os_ops: OsOperations, name=None):
assert isinstance(os_ops, OsOperations)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp