adapt integration.sh for --backend-only (counter integration test)

This commit is contained in:
Masen Furer 2024-12-20 17:45:11 -08:00
parent 861de25be3
commit 0c49bb1301
No known key found for this signature in database
GPG Key ID: B0008AD22B3B3A95
3 changed files with 9 additions and 4 deletions

View File

@ -79,6 +79,8 @@ jobs:
run: | run: |
poetry run reflex export --backend-only poetry run reflex export --backend-only
- name: Check run --backend-only before init for counter example - name: Check run --backend-only before init for counter example
env:
WAIT_FOR_LISTENING_PORT_ARGS: --path /ping
run: | run: |
poetry run bash scripts/integration.sh ./reflex-examples/counter dev 8001 --backend-only --backend-port 8001 poetry run bash scripts/integration.sh ./reflex-examples/counter dev 8001 --backend-only --backend-port 8001
- name: Init Website for counter example - name: Init Website for counter example

View File

@ -34,4 +34,4 @@ if [ -f /proc/$pid/winpid ]; then
echo "Windows detected, passing winpid $pid to port waiter" echo "Windows detected, passing winpid $pid to port waiter"
fi fi
python scripts/wait_for_listening_port.py $check_ports --timeout=900 --server-pid "$pid" python scripts/wait_for_listening_port.py $check_ports --timeout=900 --server-pid "$pid" $WAIT_FOR_LISTENING_PORT_OPTS

View File

@ -44,9 +44,9 @@ def _wait_for_port(port, server_pid, timeout) -> Tuple[bool, str]:
time.sleep(5) time.sleep(5)
def _wait_for_http_response(port, server_pid, timeout) -> Tuple[bool, str, str]: def _wait_for_http_response(port, server_pid, timeout, path) -> Tuple[bool, str, str]:
start = time.time() start = time.time()
url = f"http://localhost:{port}" url = f"http://localhost:{port}{path}"
print(f"Waiting for up to {timeout} seconds for {url} to return HTTP response.") print(f"Waiting for up to {timeout} seconds for {url} to return HTTP response.")
while True: while True:
try: try:
@ -75,11 +75,14 @@ def main():
parser.add_argument("port", type=int, nargs="+") parser.add_argument("port", type=int, nargs="+")
parser.add_argument("--timeout", type=int, required=True) parser.add_argument("--timeout", type=int, required=True)
parser.add_argument("--server-pid", type=int) parser.add_argument("--server-pid", type=int)
parser.add_argument("--path", type=str, default="/")
args = parser.parse_args() args = parser.parse_args()
start = time.time() start = time.time()
executor = ThreadPoolExecutor(max_workers=len(args.port)) executor = ThreadPoolExecutor(max_workers=len(args.port))
futures = [ futures = [
executor.submit(_wait_for_http_response, p, args.server_pid, args.timeout) executor.submit(
_wait_for_http_response, p, args.server_pid, args.timeout, args.path
)
for p in args.port for p in args.port
] ]
base_content = None base_content = None