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

Commit319a9d9

Browse files
test_pg_ctl_wait_option (local, remote) is corrected
1 parent174d6e6 commit319a9d9

File tree

2 files changed

+110
-20
lines changed

2 files changed

+110
-20
lines changed

‎tests/test_simple.py

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -428,16 +428,61 @@ def test_backup_wrong_xlog_method(self):
428428
node.backup(xlog_method='wrong')
429429

430430
deftest_pg_ctl_wait_option(self):
431-
withget_new_node()asnode:
432-
node.init().start(wait=False)
433-
whileTrue:
434-
try:
435-
node.stop(wait=False)
436-
break
437-
exceptExecUtilException:
438-
# it's ok to get this exception here since node
439-
# could be not started yet
440-
pass
431+
C_MAX_ATTEMPTS=50
432+
433+
node=get_new_node()
434+
assertnode.status()==testgres.NodeStatus.Uninitialized
435+
node.init()
436+
assertnode.status()==testgres.NodeStatus.Stopped
437+
node.start(wait=False)
438+
nAttempt=0
439+
whileTrue:
440+
ifnAttempt==C_MAX_ATTEMPTS:
441+
raiseException("Could not stop node.")
442+
443+
nAttempt+=1
444+
445+
ifnAttempt>1:
446+
logging.info("Wait 1 second.")
447+
time.sleep(1)
448+
logging.info("")
449+
450+
logging.info("Try to stop node. Attempt #{0}.".format(nAttempt))
451+
452+
try:
453+
node.stop(wait=False)
454+
break
455+
exceptExecUtilExceptionase:
456+
# it's ok to get this exception here since node
457+
# could be not started yet
458+
logging.info("Node is not stopped. Exception ({0}): {1}".format(type(e).__name__,e))
459+
continue
460+
461+
logging.info("OK. Stop command was executed. Let's wait while our node will stop really.")
462+
nAttempt=0
463+
whileTrue:
464+
ifnAttempt==C_MAX_ATTEMPTS:
465+
raiseException("Could not stop node.")
466+
467+
nAttempt+=1
468+
ifnAttempt>1:
469+
logging.info("Wait 1 second.")
470+
time.sleep(1)
471+
logging.info("")
472+
473+
logging.info("Attempt #{0}.".format(nAttempt))
474+
s1=node.status()
475+
476+
ifs1==testgres.NodeStatus.Running:
477+
continue
478+
479+
ifs1==testgres.NodeStatus.Stopped:
480+
break
481+
482+
raiseException("Unexpected node status: {0}.".format(s1))
483+
484+
logging.info("OK. Node is stopped.")
485+
node.cleanup()
441486

442487
deftest_replicate(self):
443488
withget_new_node()asnode:

‎tests/test_simple_remote.py

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -499,16 +499,61 @@ def test_backup_wrong_xlog_method(self):
499499
node.backup(xlog_method='wrong')
500500

501501
deftest_pg_ctl_wait_option(self):
502-
with__class__.helper__get_node()asnode:
503-
node.init().start(wait=False)
504-
whileTrue:
505-
try:
506-
node.stop(wait=False)
507-
break
508-
exceptExecUtilException:
509-
# it's ok to get this exception here since node
510-
# could be not started yet
511-
pass
502+
C_MAX_ATTEMPTS=50
503+
504+
node=__class__.helper__get_node()
505+
assertnode.status()==testgres.NodeStatus.Uninitialized
506+
node.init()
507+
assertnode.status()==testgres.NodeStatus.Stopped
508+
node.start(wait=False)
509+
nAttempt=0
510+
whileTrue:
511+
ifnAttempt==C_MAX_ATTEMPTS:
512+
raiseException("Could not stop node.")
513+
514+
nAttempt+=1
515+
516+
ifnAttempt>1:
517+
logging.info("Wait 1 second.")
518+
time.sleep(1)
519+
logging.info("")
520+
521+
logging.info("Try to stop node. Attempt #{0}.".format(nAttempt))
522+
523+
try:
524+
node.stop(wait=False)
525+
break
526+
exceptExecUtilExceptionase:
527+
# it's ok to get this exception here since node
528+
# could be not started yet
529+
logging.info("Node is not stopped. Exception ({0}): {1}".format(type(e).__name__,e))
530+
continue
531+
532+
logging.info("OK. Stop command was executed. Let's wait while our node will stop really.")
533+
nAttempt=0
534+
whileTrue:
535+
ifnAttempt==C_MAX_ATTEMPTS:
536+
raiseException("Could not stop node.")
537+
538+
nAttempt+=1
539+
ifnAttempt>1:
540+
logging.info("Wait 1 second.")
541+
time.sleep(1)
542+
logging.info("")
543+
544+
logging.info("Attempt #{0}.".format(nAttempt))
545+
s1=node.status()
546+
547+
ifs1==testgres.NodeStatus.Running:
548+
continue
549+
550+
ifs1==testgres.NodeStatus.Stopped:
551+
break
552+
553+
raiseException("Unexpected node status: {0}.".format(s1))
554+
555+
logging.info("OK. Node is stopped.")
556+
node.cleanup()
512557

513558
deftest_replicate(self):
514559
with__class__.helper__get_node()asnode:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp