From 1ee62c2545d864dadcbb4872c8e49c9265107c4f Mon Sep 17 00:00:00 2001 From: Bruno Bernardo Date: Wed, 11 Jun 2025 13:44:45 +0200 Subject: [PATCH 1/3] Resto/test: use a fresh port in [chunked_output] To avoid "address in use error" (Unix.EADDRINUSE). Cf. e.g. - https://gitlab.com/tezos/tezos/-/jobs/10305372500 - https://gitlab.com/tezos/tezos/-/jobs/10314232776 - https://gitlab.com/tezos/tezos/-/jobs/10299176046 --- resto/test/chunked_output_integration_test.ml | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/resto/test/chunked_output_integration_test.ml b/resto/test/chunked_output_integration_test.ml index 61fba94f9dd6..c4e45d2972aa 100644 --- a/resto/test/chunked_output_integration_test.ml +++ b/resto/test/chunked_output_integration_test.ml @@ -155,21 +155,28 @@ let directory = in dir -let port = 8001 +(* copy-pasted from tezt/lib_tezos/port.ml *) +(* TODO port resto tests to Tezt *) +let fresh_port () = + let dummy_socket = Unix.(socket PF_INET SOCK_STREAM 0) in + Fun.protect ~finally:(fun () -> Unix.close dummy_socket) @@ fun () -> + Unix.bind dummy_socket Unix.(ADDR_INET (inet_addr_loopback, 0)) ; + let addr = Unix.getsockname dummy_socket in + match addr with ADDR_INET (_, port) -> port | _ -> assert false -let uri = "http://localhost:8001" +let uri port = "http://localhost:" ^ string_of_int port let is_ok_result r v = match r with `Ok (Some w) -> assert (v = w) | _ -> assert false -let child () = +let child port = let module Client = Resto_cohttp_client.Client.Make (Encoding) (Resto_cohttp_client.Client.OfCohttp (Cohttp_lwt_unix.Client)) in let logger = Client.full_logger Format.err_formatter in - let base = Uri.of_string uri in + let base = port |> uri |> Uri.of_string in let media_types = media_types 1 in let open Lwt.Infix in Client.call_service media_types ~base ~logger get_foo_bar () () () @@ -185,7 +192,7 @@ let child () = module Server = Resto_cohttp_server.Server.Make (Encoding) (Logger) -let parent pid chunk_size = +let parent pid port chunk_size = let media_types = media_types chunk_size in Server.init_and_launch ~media_types directory (`TCP (`Port port)) >>= fun () -> @@ -194,13 +201,14 @@ let parent pid chunk_size = | _ -> assert false let test_one_size chunk_size = + let port = fresh_port () in match Lwt_unix.fork () with | 0 -> ( match Lwt_unix.fork () with | 0 -> Lwt_unix.sleep 2.0 (* leave time for the server to start *) - >>= fun () -> child () - | pid -> parent pid chunk_size) + >>= fun () -> child port + | pid -> parent pid port chunk_size) | pid -> ( Lwt_unix.waitpid [] pid >>= function | _, WEXITED 0 -> Lwt.return () -- GitLab From 1b95feb2f3ce23e50a4222a945df6737ed4fd196 Mon Sep 17 00:00:00 2001 From: Bruno Bernardo Date: Tue, 17 Jun 2025 09:23:06 +0200 Subject: [PATCH 2/3] Resto/test: reuse address quickly in [chunked_output] --- resto/test/chunked_output_integration_test.ml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/resto/test/chunked_output_integration_test.ml b/resto/test/chunked_output_integration_test.ml index c4e45d2972aa..8026917e121f 100644 --- a/resto/test/chunked_output_integration_test.ml +++ b/resto/test/chunked_output_integration_test.ml @@ -155,10 +155,12 @@ let directory = in dir -(* copy-pasted from tezt/lib_tezos/port.ml *) +(* copy-pasted from tezt/lib_tezos/port.ml + use SO_REUSEADDR *) (* TODO port resto tests to Tezt *) let fresh_port () = let dummy_socket = Unix.(socket PF_INET SOCK_STREAM 0) in + (* allows rebinding to a port that is in TIME_WAIT *) + Unix.setsockopt dummy_socket Unix.SO_REUSEADDR true ; Fun.protect ~finally:(fun () -> Unix.close dummy_socket) @@ fun () -> Unix.bind dummy_socket Unix.(ADDR_INET (inet_addr_loopback, 0)) ; let addr = Unix.getsockname dummy_socket in -- GitLab From fe83f6729e78a2ccda94948832f6e4814c7d3ba3 Mon Sep 17 00:00:00 2001 From: Bruno Bernardo Date: Tue, 17 Jun 2025 10:04:40 +0200 Subject: [PATCH 3/3] CI: [resto.unit-] times out after 10 min When there is no issue, this job runs in < 1 min. --- .gitlab/ci/pipelines/before_merging.yml | 4 ++-- .gitlab/ci/pipelines/merge_train.yml | 4 ++-- .gitlab/ci/pipelines/schedule_extended_test.yml | 4 ++-- ci/bin/code_verification.ml | 1 + 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.gitlab/ci/pipelines/before_merging.yml b/.gitlab/ci/pipelines/before_merging.yml index 8e6e63b94059..a7b2f0e97d03 100644 --- a/.gitlab/ci/pipelines/before_merging.yml +++ b/.gitlab/ci/pipelines/before_merging.yml @@ -3513,7 +3513,7 @@ resto.unit:x86_64: - oc.build_x86_64-exp-dev-extra dependencies: - oc.docker:ci:amd64 - timeout: 60 minutes + timeout: 10 minutes before_script: - . ./scripts/ci/datadog_send_job_info.sh - eval $(opam env) @@ -3537,7 +3537,7 @@ resto.unit:arm64: - oc.build_arm64-exp-dev-extra dependencies: - oc.docker:ci:arm64 - timeout: 60 minutes + timeout: 10 minutes before_script: - . ./scripts/ci/datadog_send_job_info.sh - eval $(opam env) diff --git a/.gitlab/ci/pipelines/merge_train.yml b/.gitlab/ci/pipelines/merge_train.yml index e6aa7fa69a5d..b48878da82a5 100644 --- a/.gitlab/ci/pipelines/merge_train.yml +++ b/.gitlab/ci/pipelines/merge_train.yml @@ -3512,7 +3512,7 @@ resto.unit:x86_64: - oc.build_x86_64-exp-dev-extra dependencies: - oc.docker:ci:amd64 - timeout: 60 minutes + timeout: 10 minutes before_script: - . ./scripts/ci/datadog_send_job_info.sh - eval $(opam env) @@ -3536,7 +3536,7 @@ resto.unit:arm64: - oc.build_arm64-exp-dev-extra dependencies: - oc.docker:ci:arm64 - timeout: 60 minutes + timeout: 10 minutes before_script: - . ./scripts/ci/datadog_send_job_info.sh - eval $(opam env) diff --git a/.gitlab/ci/pipelines/schedule_extended_test.yml b/.gitlab/ci/pipelines/schedule_extended_test.yml index fc2453da5694..cfad5acf7540 100644 --- a/.gitlab/ci/pipelines/schedule_extended_test.yml +++ b/.gitlab/ci/pipelines/schedule_extended_test.yml @@ -2974,7 +2974,7 @@ resto.unit:x86_64: - oc.build_x86_64-exp-dev-extra dependencies: - oc.docker:ci:amd64 - timeout: 60 minutes + timeout: 10 minutes interruptible: false before_script: - . ./scripts/ci/datadog_send_job_info.sh @@ -2995,7 +2995,7 @@ resto.unit:arm64: - oc.build_arm64-exp-dev-extra dependencies: - oc.docker:ci:arm64 - timeout: 60 minutes + timeout: 10 minutes interruptible: false before_script: - . ./scripts/ci/datadog_send_job_info.sh diff --git a/ci/bin/code_verification.ml b/ci/bin/code_verification.ml index b3e80cc0fe4a..8dba9218868c 100644 --- a/ci/bin/code_verification.ml +++ b/ci/bin/code_verification.ml @@ -1247,6 +1247,7 @@ let jobs pipeline_type = ?storage ~image:Images.CI.test ~stage:Stages.test + ~timeout:(Minutes 10) ~rules: (make_rules ~changes: -- GitLab