| 66 | |
| 67 | @pytest.fixture |
| 68 | def mock_st2cluster() -> tuple[int, int, int]: |
| 69 | sock1: socket.socket |
| 70 | sock2: socket.socket |
| 71 | sock3: socket.socket |
| 72 | with ( |
| 73 | closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock1, |
| 74 | closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock2, |
| 75 | closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock3, |
| 76 | ): |
| 77 | socks = (sock1, sock2, sock3) |
| 78 | for sock in socks: |
| 79 | sock.bind(("127.0.0.1", 0)) |
| 80 | sock.listen(1) |
| 81 | ports = tuple(sock.getsockname()[1] for sock in socks) |
| 82 | yield ports |
| 83 | |
| 84 | |
| 85 | # Warning this requires that st2cluster be running |