From 924fe943813056fa2a905fe16c3aace59b5554c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Fri, 6 Sep 2024 14:53:56 +0200 Subject: [PATCH 1/6] Tezt cloud: remove trailing spaces --- tezt/lib_cloud/web.ml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tezt/lib_cloud/web.ml b/tezt/lib_cloud/web.ml index d1fa5c8a5435..8d717e441caa 100644 --- a/tezt/lib_cloud/web.ml +++ b/tezt/lib_cloud/web.ml @@ -89,7 +89,7 @@ let debugging ~agents = {| ```bash %s -``` +``` |} (string_vm_command agent) in @@ -102,9 +102,9 @@ let debugging ~agents = in Printf.sprintf {| -## %s +## %s Connect on the VM: -%s +%s Connect on the Docker: %s -- GitLab From 799d1bbf5b971a2616d3ab34d8df9729c19fa76f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Thir=C3=A9?= Date: Tue, 3 Sep 2024 18:25:35 +0200 Subject: [PATCH 2/6] Tezt/Cloud: Add a way to plug services deployed by the scenario --- tezt/lib_cloud/cloud.ml | 5 +++++ tezt/lib_cloud/cloud.mli | 2 ++ tezt/lib_cloud/tezt_cloud.mli | 2 ++ tezt/lib_cloud/web.ml | 28 ++++++++++++++++++++++++---- tezt/lib_cloud/web.mli | 3 +++ 5 files changed, 36 insertions(+), 4 deletions(-) diff --git a/tezt/lib_cloud/cloud.ml b/tezt/lib_cloud/cloud.ml index 9b10442deb9e..e00d49a40b2e 100644 --- a/tezt/lib_cloud/cloud.ml +++ b/tezt/lib_cloud/cloud.ml @@ -611,3 +611,8 @@ let add_prometheus_source t ?metric_path ~job_name targets = in let targets = List.map prometheus_target targets in Prometheus.add_source prometheus ?metric_path ~job_name targets + +let add_service t service = + match t.website with + | None -> Lwt.return_unit + | Some web -> Web.add_service web ~agents:t.agents ~service diff --git a/tezt/lib_cloud/cloud.mli b/tezt/lib_cloud/cloud.mli index 01b3425513c3..e770fe76c305 100644 --- a/tezt/lib_cloud/cloud.mli +++ b/tezt/lib_cloud/cloud.mli @@ -33,3 +33,5 @@ type target = {agent : Agent.t; port : int; app_name : string} val add_prometheus_source : t -> ?metric_path:string -> job_name:string -> target list -> unit Lwt.t + +val add_service : t -> string * int -> unit Lwt.t diff --git a/tezt/lib_cloud/tezt_cloud.mli b/tezt/lib_cloud/tezt_cloud.mli index 52c14e467f6b..4deee36bdf15 100644 --- a/tezt/lib_cloud/tezt_cloud.mli +++ b/tezt/lib_cloud/tezt_cloud.mli @@ -80,6 +80,8 @@ module Cloud : sig points to scrap. Each point can have a name defined by [app_name]. *) val add_prometheus_source : t -> ?metric_path:string -> job_name:string -> target list -> unit Lwt.t + + val add_service : t -> string * int -> unit Lwt.t end (** [register ~tags] register a set of jobs that can be used for setting diff --git a/tezt/lib_cloud/web.ml b/tezt/lib_cloud/web.ml index 8d717e441caa..3fc090385b5a 100644 --- a/tezt/lib_cloud/web.ml +++ b/tezt/lib_cloud/web.ml @@ -10,6 +10,7 @@ type t = { dir : string; monitoring : bool; prometheus : bool; + mutable services : (string * int) list; } let pp_docker_image fmt = function @@ -157,14 +158,29 @@ let grafana ~agents = Format.asprintf "# Grafana\n [Grafana dashboard](http://%s:3000)\n" domain else "Grafana disabled. Use `--grafana` to activate it.\n" -let markdown_content ~agents = +let service ~agents (name, port) = + let domain = + match Env.mode with + | `Orchestrator -> + Proxy.get_agent agents |> Agent.point |> Option.get |> fst + | `Host | `Localhost | `Cloud -> "localhost" + in + Format.asprintf + "# %s\n [%s](http://%s:%d)\n" + (String.capitalize_ascii name) + (String.lowercase_ascii name) + domain + port + +let markdown_content ~agents ~services = [ configuration ~agents; grafana ~agents; prometheus ~agents; monitoring ~agents; - debugging ~agents; ] + @ List.map (service ~agents) services + @ [debugging ~agents] |> String.concat "\n" let index dir = dir // "index.md" @@ -172,7 +188,7 @@ let index dir = dir // "index.md" let write t ~agents = (* The content is formatted in markdown and will be rendered in html via pandoc. *) - let content = markdown_content ~agents in + let content = markdown_content ~agents ~services:t.services in let dir = t.dir in let index = index dir in Base.with_open_out index (fun oc -> output_string oc content) ; @@ -190,6 +206,10 @@ let write t ~agents = "-s"; ] +let add_service t ~agents ~service = + t.services <- service :: t.services ; + write t ~agents + let run () = let* () = Process.run "mkdir" ["-p"; Filename.get_temp_dir_name () // "website"] @@ -210,7 +230,7 @@ let run () = Filename.dirname index; ] in - Lwt.return {process; dir; monitoring; prometheus} + Lwt.return {process; dir; monitoring; prometheus; services = []} let start ~agents = let* t = run () in diff --git a/tezt/lib_cloud/web.mli b/tezt/lib_cloud/web.mli index 7aaea7e4c614..b0c79e8b2844 100644 --- a/tezt/lib_cloud/web.mli +++ b/tezt/lib_cloud/web.mli @@ -20,3 +20,6 @@ val push_metric : t -> ?labels:(string * string) list -> name:string -> float -> unit val write : t -> agents:Agent.t List.t -> unit Lwt.t + +val add_service : + t -> agents:Agent.t List.t -> service:string * int -> unit Lwt.t -- GitLab From eda71ec3b85c59560ed1fee9e35e4c8c8904675b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Fri, 6 Sep 2024 18:21:42 +0200 Subject: [PATCH 3/6] Tezt cloud: generalize web service --- tezt/lib_cloud/cloud.ml | 4 ++-- tezt/lib_cloud/cloud.mli | 2 +- tezt/lib_cloud/tezt_cloud.mli | 2 +- tezt/lib_cloud/web.ml | 21 ++++++++------------- tezt/lib_cloud/web.mli | 5 +++-- 5 files changed, 15 insertions(+), 19 deletions(-) diff --git a/tezt/lib_cloud/cloud.ml b/tezt/lib_cloud/cloud.ml index e00d49a40b2e..54fbaa16fd18 100644 --- a/tezt/lib_cloud/cloud.ml +++ b/tezt/lib_cloud/cloud.ml @@ -612,7 +612,7 @@ let add_prometheus_source t ?metric_path ~job_name targets = let targets = List.map prometheus_target targets in Prometheus.add_source prometheus ?metric_path ~job_name targets -let add_service t service = +let add_service t ~name ~url = match t.website with | None -> Lwt.return_unit - | Some web -> Web.add_service web ~agents:t.agents ~service + | Some web -> Web.add_service web ~agents:t.agents {name; url} diff --git a/tezt/lib_cloud/cloud.mli b/tezt/lib_cloud/cloud.mli index e770fe76c305..525588811559 100644 --- a/tezt/lib_cloud/cloud.mli +++ b/tezt/lib_cloud/cloud.mli @@ -34,4 +34,4 @@ type target = {agent : Agent.t; port : int; app_name : string} val add_prometheus_source : t -> ?metric_path:string -> job_name:string -> target list -> unit Lwt.t -val add_service : t -> string * int -> unit Lwt.t +val add_service : t -> name:string -> url:string -> unit Lwt.t diff --git a/tezt/lib_cloud/tezt_cloud.mli b/tezt/lib_cloud/tezt_cloud.mli index 4deee36bdf15..c49a64229c7a 100644 --- a/tezt/lib_cloud/tezt_cloud.mli +++ b/tezt/lib_cloud/tezt_cloud.mli @@ -81,7 +81,7 @@ module Cloud : sig val add_prometheus_source : t -> ?metric_path:string -> job_name:string -> target list -> unit Lwt.t - val add_service : t -> string * int -> unit Lwt.t + val add_service : t -> name:string -> url:string -> unit Lwt.t end (** [register ~tags] register a set of jobs that can be used for setting diff --git a/tezt/lib_cloud/web.ml b/tezt/lib_cloud/web.ml index 3fc090385b5a..7ec9c1ce1b3f 100644 --- a/tezt/lib_cloud/web.ml +++ b/tezt/lib_cloud/web.ml @@ -5,12 +5,14 @@ (* *) (*****************************************************************************) +type service = {name : string; url : string} + type t = { process : Process.t; dir : string; monitoring : bool; prometheus : bool; - mutable services : (string * int) list; + mutable services : service list; } let pp_docker_image fmt = function @@ -158,19 +160,12 @@ let grafana ~agents = Format.asprintf "# Grafana\n [Grafana dashboard](http://%s:3000)\n" domain else "Grafana disabled. Use `--grafana` to activate it.\n" -let service ~agents (name, port) = - let domain = - match Env.mode with - | `Orchestrator -> - Proxy.get_agent agents |> Agent.point |> Option.get |> fst - | `Host | `Localhost | `Cloud -> "localhost" - in +let service {name; url} = Format.asprintf - "# %s\n [%s](http://%s:%d)\n" + "# %s\n [%s](%s)\n" (String.capitalize_ascii name) (String.lowercase_ascii name) - domain - port + url let markdown_content ~agents ~services = [ @@ -179,7 +174,7 @@ let markdown_content ~agents ~services = prometheus ~agents; monitoring ~agents; ] - @ List.map (service ~agents) services + @ List.map service services @ [debugging ~agents] |> String.concat "\n" @@ -206,7 +201,7 @@ let write t ~agents = "-s"; ] -let add_service t ~agents ~service = +let add_service t ~agents service = t.services <- service :: t.services ; write t ~agents diff --git a/tezt/lib_cloud/web.mli b/tezt/lib_cloud/web.mli index b0c79e8b2844..87a955564558 100644 --- a/tezt/lib_cloud/web.mli +++ b/tezt/lib_cloud/web.mli @@ -21,5 +21,6 @@ val push_metric : val write : t -> agents:Agent.t List.t -> unit Lwt.t -val add_service : - t -> agents:Agent.t List.t -> service:string * int -> unit Lwt.t +type service = {name : string; url : string} + +val add_service : t -> agents:Agent.t List.t -> service -> unit Lwt.t -- GitLab From 71d2791557dd97debc837cc475114fd772b8c255 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Fri, 6 Sep 2024 18:22:53 +0200 Subject: [PATCH 4/6] Tezt cloud: manual rewrite of the web page --- tezt/lib_cloud/cloud.ml | 11 ++++++----- tezt/lib_cloud/cloud.mli | 2 ++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tezt/lib_cloud/cloud.ml b/tezt/lib_cloud/cloud.ml index 54fbaa16fd18..787173141ca5 100644 --- a/tezt/lib_cloud/cloud.ml +++ b/tezt/lib_cloud/cloud.ml @@ -583,13 +583,14 @@ let agents t = let get_configuration = Agent.configuration +let write_website t = + match t.website with + | None -> Lwt.return_unit + | Some website -> Web.write website ~agents:t.agents + let set_agent_name t agent name = Agent.set_name agent name ; - let* () = - match t.website with - | None -> Lwt.return_unit - | Some website -> Web.write website ~agents:t.agents - in + let* () = write_website t in match t.prometheus with | None -> Lwt.return_unit | Some prometheus -> Prometheus.reload prometheus diff --git a/tezt/lib_cloud/cloud.mli b/tezt/lib_cloud/cloud.mli index 525588811559..ca2e92859f25 100644 --- a/tezt/lib_cloud/cloud.mli +++ b/tezt/lib_cloud/cloud.mli @@ -27,6 +27,8 @@ val get_configuration : Agent.t -> Configuration.t val push_metric : t -> ?labels:(string * string) list -> name:string -> float -> unit +val write_website : t -> unit Lwt.t + val set_agent_name : t -> Agent.t -> string -> unit Lwt.t type target = {agent : Agent.t; port : int; app_name : string} -- GitLab From 716cbdc954d7110b3b7f151d8ed184fb29d5ad1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Fri, 6 Sep 2024 18:23:18 +0200 Subject: [PATCH 5/6] Tezt cloud: add an Explorus service --- tezt/tests/cloud/dal.ml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tezt/tests/cloud/dal.ml b/tezt/tests/cloud/dal.ml index 046c5bc5231a..52c23d9fc2a0 100644 --- a/tezt/tests/cloud/dal.ml +++ b/tezt/tests/cloud/dal.ml @@ -1260,6 +1260,14 @@ let init_bootstrap_and_activate_protocol cloud (configuration : configuration) ~node:bootstrap_node in let* () = Node.wait_for_ready bootstrap_node in + let* () = + Cloud.add_service + cloud + ~name:"Explorus" + ~url: + (sf "http://explorus.io?network=%s" (Node.rpc_endpoint bootstrap_node)) + in + let* () = Cloud.write_website cloud in let* client = Client.init ~endpoint:(Node bootstrap_node) () in let* baker_accounts = Client.stresstest_gen_keys -- GitLab From 78ac438b4aa051c520e4f9784a21a233674abff1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Fri, 6 Sep 2024 16:27:16 +0200 Subject: [PATCH 6/6] Tezt cloud: pass `--cors-origin='*'` This is needed for Explorus when the L1 node is not on localhost. --- tezt/tests/cloud/dal.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tezt/tests/cloud/dal.ml b/tezt/tests/cloud/dal.ml index 52c23d9fc2a0..666a6b1bc0e4 100644 --- a/tezt/tests/cloud/dal.ml +++ b/tezt/tests/cloud/dal.ml @@ -213,7 +213,7 @@ module Node = struct match data_dir with | None -> let* node = Node.Agent.create ~name agent in - let* () = Node.config_init node [] in + let* () = Node.config_init node [Cors_origin "*"] in let* () = match dal_config with | None -> Lwt.return_unit -- GitLab