testgres 1.16.3__tar.gz → 1.16.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. {testgres-1.16.3/testgres.egg-info → testgres-1.16.4}/PKG-INFO +1 -1
  2. {testgres-1.16.3 → testgres-1.16.4}/src/__init__.py +1 -1
  3. {testgres-1.16.3 → testgres-1.16.4}/src/node.py +10 -1
  4. {testgres-1.16.3 → testgres-1.16.4/testgres.egg-info}/PKG-INFO +1 -1
  5. {testgres-1.16.3 → testgres-1.16.4}/tests/test_testgres_common.py +84 -1
  6. {testgres-1.16.3 → testgres-1.16.4}/LICENSE +0 -0
  7. {testgres-1.16.3 → testgres-1.16.4}/README.md +0 -0
  8. {testgres-1.16.3 → testgres-1.16.4}/pyproject.toml +0 -0
  9. {testgres-1.16.3 → testgres-1.16.4}/setup.cfg +0 -0
  10. {testgres-1.16.3 → testgres-1.16.4}/src/api.py +0 -0
  11. {testgres-1.16.3 → testgres-1.16.4}/src/backup.py +0 -0
  12. {testgres-1.16.3 → testgres-1.16.4}/src/cache.py +0 -0
  13. {testgres-1.16.3 → testgres-1.16.4}/src/config.py +0 -0
  14. {testgres-1.16.3 → testgres-1.16.4}/src/connection.py +0 -0
  15. {testgres-1.16.3 → testgres-1.16.4}/src/consts.py +0 -0
  16. {testgres-1.16.3 → testgres-1.16.4}/src/decorators.py +0 -0
  17. {testgres-1.16.3 → testgres-1.16.4}/src/defaults.py +0 -0
  18. {testgres-1.16.3 → testgres-1.16.4}/src/enums.py +0 -0
  19. {testgres-1.16.3 → testgres-1.16.4}/src/exceptions.py +0 -0
  20. {testgres-1.16.3 → testgres-1.16.4}/src/impl/file_line_reader.py +0 -0
  21. {testgres-1.16.3 → testgres-1.16.4}/src/impl/internal_node_utils.py +0 -0
  22. {testgres-1.16.3 → testgres-1.16.4}/src/impl/internal_utils.py +0 -0
  23. {testgres-1.16.3 → testgres-1.16.4}/src/impl/platforms/darwin/internal_platform_utils.py +0 -0
  24. {testgres-1.16.3 → testgres-1.16.4}/src/impl/platforms/internal_platform_utils.py +0 -0
  25. {testgres-1.16.3 → testgres-1.16.4}/src/impl/platforms/internal_platform_utils_factory.py +0 -0
  26. {testgres-1.16.3 → testgres-1.16.4}/src/impl/platforms/internal_platform_utils_provider.py +0 -0
  27. {testgres-1.16.3 → testgres-1.16.4}/src/impl/platforms/linux/internal_platform_utils.py +0 -0
  28. {testgres-1.16.3 → testgres-1.16.4}/src/impl/platforms/win32/internal_platform_utils.py +0 -0
  29. {testgres-1.16.3 → testgres-1.16.4}/src/impl/port_manager__generic.py +0 -0
  30. {testgres-1.16.3 → testgres-1.16.4}/src/impl/port_manager__generic2.py +0 -0
  31. {testgres-1.16.3 → testgres-1.16.4}/src/impl/port_manager__this_host.py +0 -0
  32. {testgres-1.16.3 → testgres-1.16.4}/src/logger.py +0 -0
  33. {testgres-1.16.3 → testgres-1.16.4}/src/node_app.py +0 -0
  34. {testgres-1.16.3 → testgres-1.16.4}/src/node_state.py +0 -0
  35. {testgres-1.16.3 → testgres-1.16.4}/src/port_manager.py +0 -0
  36. {testgres-1.16.3 → testgres-1.16.4}/src/pubsub.py +0 -0
  37. {testgres-1.16.3 → testgres-1.16.4}/src/raise_error.py +0 -0
  38. {testgres-1.16.3 → testgres-1.16.4}/src/standby.py +0 -0
  39. {testgres-1.16.3 → testgres-1.16.4}/src/utils.py +0 -0
  40. {testgres-1.16.3 → testgres-1.16.4}/testgres.egg-info/SOURCES.txt +0 -0
  41. {testgres-1.16.3 → testgres-1.16.4}/testgres.egg-info/dependency_links.txt +0 -0
  42. {testgres-1.16.3 → testgres-1.16.4}/testgres.egg-info/requires.txt +0 -0
  43. {testgres-1.16.3 → testgres-1.16.4}/testgres.egg-info/top_level.txt +0 -0
  44. {testgres-1.16.3 → testgres-1.16.4}/tests/test_api.py +0 -0
  45. {testgres-1.16.3 → testgres-1.16.4}/tests/test_config.py +0 -0
  46. {testgres-1.16.3 → testgres-1.16.4}/tests/test_os_ops_common.py +0 -0
  47. {testgres-1.16.3 → testgres-1.16.4}/tests/test_os_ops_local.py +0 -0
  48. {testgres-1.16.3 → testgres-1.16.4}/tests/test_os_ops_remote.py +0 -0
  49. {testgres-1.16.3 → testgres-1.16.4}/tests/test_raise_error.py +0 -0
  50. {testgres-1.16.3 → testgres-1.16.4}/tests/test_testgres_local.py +0 -0
  51. {testgres-1.16.3 → testgres-1.16.4}/tests/test_testgres_remote.py +0 -0
  52. {testgres-1.16.3 → testgres-1.16.4}/tests/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: testgres
3
- Version: 1.16.3
3
+ Version: 1.16.4
4
4
  Summary: Testing utility for PostgreSQL and its extensions
5
5
  Author-email: Postgres Professional <testgres@postgrespro.ru>
6
6
  License: PostgreSQL
@@ -60,7 +60,7 @@ from testgres.operations.os_ops import OsProcessController
60
60
  from testgres.operations.local_ops import LocalOperations
61
61
  from testgres.operations.remote_ops import RemoteOperations
62
62
 
63
- __version__ = "1.16.3"
63
+ __version__ = "1.16.4"
64
64
 
65
65
  __all__ = [
66
66
  "get_new_node",
@@ -95,6 +95,7 @@ except ImportError:
95
95
  InternalError = pglib.InternalError
96
96
  ProgrammingError = pglib.ProgrammingError
97
97
  OperationalError = pglib.OperationalError
98
+ InterfaceError = pglib.InterfaceError
98
99
 
99
100
 
100
101
  assert TimeoutException == QueryTimeoutException
@@ -1172,6 +1173,7 @@ class PostgresNode:
1172
1173
  QueryException,
1173
1174
  ProgrammingError,
1174
1175
  OperationalError,
1176
+ InterfaceError, # pg8000
1175
1177
  }
1176
1178
 
1177
1179
  self.poll_query_until(
@@ -1182,7 +1184,14 @@ class PostgresNode:
1182
1184
  max_attempts=max_attempts,
1183
1185
  )
1184
1186
  except: # noqa: E722
1185
- self.stop()
1187
+ state = self._get_node_state()
1188
+
1189
+ if state.node_status == NodeStatus.Running:
1190
+ assert type(state.pid) is int
1191
+ self.stop()
1192
+ else:
1193
+ self._manually_started_pm_pid = state.pid
1194
+
1186
1195
  raise
1187
1196
  return
1188
1197
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: testgres
3
- Version: 1.16.3
3
+ Version: 1.16.4
4
4
  Summary: Testing utility for PostgreSQL and its extensions
5
5
  Author-email: Postgres Professional <testgres@postgrespro.ru>
6
6
  License: PostgreSQL
@@ -127,7 +127,7 @@ class TestTestgresCommon:
127
127
  # Author: Mark G.
128
128
  assert v.major == 1
129
129
  assert v.minor == 16
130
- assert v.micro == 3
130
+ assert v.micro == 4
131
131
 
132
132
  assert str(v) == testgres_version
133
133
  return
@@ -458,6 +458,89 @@ class TestTestgresCommon:
458
458
 
459
459
  return
460
460
 
461
+ def test_failure_during_slow_start(self, node_svc: PostgresNodeService):
462
+ assert isinstance(node_svc, PostgresNodeService)
463
+
464
+ C_MAX_ATTEMPTS = 3
465
+
466
+ nAttempt = 0
467
+
468
+ while True:
469
+ assert nAttempt <= C_MAX_ATTEMPTS
470
+
471
+ if nAttempt == C_MAX_ATTEMPTS:
472
+ logging.warning("Test did not fail during wait stage.")
473
+ break
474
+
475
+ nAttempt += 1
476
+
477
+ logging.info("------------------ ATTEMPT {}".format(
478
+ nAttempt,
479
+ ))
480
+
481
+ if self.helper_step_of_failure_during_slow_start(node_svc):
482
+ break
483
+
484
+ continue
485
+ return
486
+
487
+ def helper_step_of_failure_during_slow_start(
488
+ self,
489
+ node_svc: PostgresNodeService,
490
+ ) -> bool:
491
+ assert isinstance(node_svc, PostgresNodeService)
492
+
493
+ with __class__.helper__get_node(node_svc) as node:
494
+ node.init()
495
+ assert not node.is_started
496
+ assert node.status() == NodeStatus.Stopped
497
+
498
+ bad_command = (
499
+ "if [ ! -f fail_counter ]; then echo 1 > fail_counter; set -e; sleep 5; expr 1 / 0; exit 0; fi; "
500
+ "COUNT=$(cat fail_counter); "
501
+ "if [ $COUNT -lt 3 ]; then echo $((COUNT+1)) > fail_counter; set -e; sleep 5; expr 1 / 0; exit 0; "
502
+ "else kill -6 $$; fi"
503
+ )
504
+
505
+ # Enable recovery mode to ensure Postgres calls this command
506
+ if node.version >= PgVer("12"):
507
+ node.os_ops.write(
508
+ node.os_ops.build_path(node.data_dir, "postgresql.conf"),
509
+ f"\nrestore_command = '{bad_command}'\n",
510
+ truncate=False,
511
+ )
512
+ node.os_ops.write(
513
+ node.os_ops.build_path(node.data_dir, "standby.signal"),
514
+ "",
515
+ truncate=True,
516
+ )
517
+ else:
518
+ node.os_ops.write(
519
+ node.os_ops.build_path(node.data_dir, "recovery.conf"),
520
+ f"restore_command = '{bad_command}'\n",
521
+ truncate=True,
522
+ )
523
+
524
+ with pytest.raises(expected_exception=Exception) as x:
525
+ node.slow_start(max_attempts=10)
526
+
527
+ TestServices.PrintExceptionOK(x.value)
528
+
529
+ assert not node.is_started
530
+ assert node.status() == NodeStatus.Stopped
531
+ pass
532
+
533
+ assert x is not None
534
+ assert isinstance(x.value, Exception)
535
+ assert x.value.__context__ is None
536
+
537
+ if type(x.value) is StartNodeException:
538
+ assert x.value.description == "Cannot detect postmaster pid."
539
+ return False
540
+
541
+ assert type(x.value) is QueryTimeoutException
542
+ return True
543
+
461
544
  def test_restart(self, node_svc: PostgresNodeService):
462
545
  assert isinstance(node_svc, PostgresNodeService)
463
546
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes