tests: Allow closed rpc handler in assert_start_raises_init_error #14413

pull ken2812221 wants to merge 1 commits into bitcoin:master from ken2812221:test-uacomment-log changing 1 files +3 −1
  1. ken2812221 commented at 5:59 AM on October 6, 2018: contributor

    The rpc handler may be unregistered when http server haven't been closed yet. So it may be allowable to get -342 non-JSON HTTP response with \'%i %s\' from server (503 Service Unavailable)

    See https://ci.appveyor.com/project/DrahtBot/bitcoin/build/master.2001. It shows "Rejecting request while shutting down" between "RPC stopped" and "Stopped HTTP server"

  2. fanquake added the label Tests on Oct 6, 2018
  3. ken2812221 force-pushed on Oct 6, 2018
  4. ken2812221 force-pushed on Oct 6, 2018
  5. practicalswift commented at 11:54 AM on October 7, 2018: contributor

    Concept ACK

    I've seen this in AppVeyor. Thanks for addressing!

  6. ryanofsky commented at 2:17 AM on October 8, 2018: member

    Code change seems reasonable, but I don't understand the issue.

    What would cause the RPC handler to become unregistered while the test framework is in wait_for_rpc_connection? Why would the nodes be getting shut down if the test framework isn't shutting them down?

  7. in test/functional/test_framework/test_node.py:193 in aee1f81989 outdated
     186 | @@ -187,7 +187,11 @@ def wait_for_rpc_connection(self):
     187 |                  if e.errno != errno.ECONNREFUSED:  # Port not yet open?
     188 |                      raise  # unknown IO error
     189 |              except JSONRPCException as e:  # Initialization phase
     190 | -                if e.error['code'] != -28:  # RPC in warmup?
     191 | +                if e.error['code'] == -28:  # RPC in warmup?
     192 | +                    pass
     193 | +                elif e.error['code'] == -342: # RPC handler unregistered, but http server haven't been stopped yet.
     194 | +                    raise FailedToStartError(self._node_msg(e.error['message']))
    


    MarcoFalke commented at 2:22 AM on October 8, 2018:

    Maybe just pass this on as well? This way we'd make sure to always have an exit code as opposed to randomly this message or an exit code due to the racyness.


    ryanofsky commented at 2:49 AM on October 8, 2018:

    Would it be good to call self.process.wait() here and include the exit code in the exception, so this is more similar to the previous FailedToStartError exception above?


    ken2812221 commented at 3:45 AM on October 8, 2018:

    Sure, fixed


    ken2812221 commented at 3:47 AM on October 8, 2018:

    I would prefer @MarcoFalke's method, then we don't have to raise it here again.

  8. MarcoFalke commented at 2:23 AM on October 8, 2018: member

    @ryanofsky If the node can't initialize itself shuts down itself without having the test framework shut it down.

  9. in test/functional/test_framework/test_node.py:192 in aee1f81989 outdated
     186 | @@ -187,7 +187,11 @@ def wait_for_rpc_connection(self):
     187 |                  if e.errno != errno.ECONNREFUSED:  # Port not yet open?
     188 |                      raise  # unknown IO error
     189 |              except JSONRPCException as e:  # Initialization phase
     190 | -                if e.error['code'] != -28:  # RPC in warmup?
     191 | +                if e.error['code'] == -28:  # RPC in warmup?
     192 | +                    pass
     193 | +                elif e.error['code'] == -342: # RPC handler unregistered, but http server haven't been stopped yet.
    


    ryanofsky commented at 2:47 AM on October 8, 2018:

    I think this comment is confusing without mentioning why the server is shutting down. Maybe change it to something like:

    # Service unavailable, RPC server started but is shutting down due to error
    

    ken2812221 commented at 3:46 AM on October 8, 2018:

    Comment added

  10. ryanofsky commented at 2:59 AM on October 8, 2018: member

    @ryanofsky If the node can't initialize itself shuts down itself without having the test framework shut it down.

    Thanks. I didn't realize assert_start_raises_init_error would wait for RPCs to be ready. But I guess it needs to in order to call shut down the node when the error doesn't trigger.

  11. ken2812221 force-pushed on Oct 8, 2018
  12. tests: Allow closed http server in assert_start_raises_init_error 62c304ea48
  13. ken2812221 force-pushed on Oct 8, 2018
  14. MarcoFalke commented at 4:15 AM on October 8, 2018: member

    utACK 62c304ea481d474bc87d950e21907b8b05134fe7

  15. ryanofsky commented at 4:25 AM on October 8, 2018: member

    utACK 62c304ea481d474bc87d950e21907b8b05134fe7

  16. MarcoFalke referenced this in commit ab660c8e50 on Oct 8, 2018
  17. MarcoFalke merged this on Oct 8, 2018
  18. MarcoFalke closed this on Oct 8, 2018

  19. ken2812221 deleted the branch on Oct 8, 2018
  20. codablock referenced this in commit 60819e9c3d on Oct 16, 2019
  21. codablock referenced this in commit b923e34373 on Oct 16, 2019
  22. codablock referenced this in commit 21d33dd56d on Oct 17, 2019
  23. barrystyle referenced this in commit 4ac4e8ff3c on Jan 22, 2020
  24. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-20 09:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me