diff --git a/tezt/lib_cloud/cloud.ml b/tezt/lib_cloud/cloud.ml index 9b10442deb9ec8c5fbebba831885d93904391901..787173141ca549714003263eb76c9d5ff39ba22a 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 @@ -611,3 +612,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 ~name ~url = + match t.website with + | None -> Lwt.return_unit + | 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 01b3425513c3e8eac09bcb09c17173d024824cba..ca2e92859f252258724432652c06db6bbfe7652a 100644 --- a/tezt/lib_cloud/cloud.mli +++ b/tezt/lib_cloud/cloud.mli @@ -27,9 +27,13 @@ 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} val add_prometheus_source : t -> ?metric_path:string -> job_name:string -> target list -> 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 52c14e467f6bba0ddfbbe2072654f44380cbd969..c49a64229c7af6d1aa429b7a45f376ae71dc741b 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 -> 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 d1fa5c8a543564d777c78d54cfa45ee156692df4..7ec9c1ce1b3fb8a6c19c4c3014744d49b18b7f49 100644 --- a/tezt/lib_cloud/web.ml +++ b/tezt/lib_cloud/web.ml @@ -5,11 +5,14 @@ (* *) (*****************************************************************************) +type service = {name : string; url : string} + type t = { process : Process.t; dir : string; monitoring : bool; prometheus : bool; + mutable services : service list; } let pp_docker_image fmt = function @@ -89,7 +92,7 @@ let debugging ~agents = {| ```bash %s -``` +``` |} (string_vm_command agent) in @@ -102,9 +105,9 @@ let debugging ~agents = in Printf.sprintf {| -## %s +## %s Connect on the VM: -%s +%s Connect on the Docker: %s @@ -157,14 +160,22 @@ 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 {name; url} = + Format.asprintf + "# %s\n [%s](%s)\n" + (String.capitalize_ascii name) + (String.lowercase_ascii name) + url + +let markdown_content ~agents ~services = [ configuration ~agents; grafana ~agents; prometheus ~agents; monitoring ~agents; - debugging ~agents; ] + @ List.map service services + @ [debugging ~agents] |> String.concat "\n" let index dir = dir // "index.md" @@ -172,7 +183,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 +201,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 +225,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 7aaea7e4c6148977fe5845b5449e06762387d9e1..87a955564558e50f45dcfcef22d11bc38d2bfb3e 100644 --- a/tezt/lib_cloud/web.mli +++ b/tezt/lib_cloud/web.mli @@ -20,3 +20,7 @@ val push_metric : t -> ?labels:(string * string) list -> name:string -> float -> unit val write : t -> agents:Agent.t List.t -> unit Lwt.t + +type service = {name : string; url : string} + +val add_service : t -> agents:Agent.t List.t -> service -> unit Lwt.t diff --git a/tezt/tests/cloud/dal.ml b/tezt/tests/cloud/dal.ml index 046c5bc5231adca5f3b3b189ee30fb5bc96ca536..666a6b1bc0e42a5ee7b5b034e26a47fb1254a0b1 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 @@ -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