From f21f5123231d38d90b2db4b65eb7ff5a622fbbb2 Mon Sep 17 00:00:00 2001 From: Ivan Ivanov Date: Wed, 15 Jan 2025 12:56:30 +0200 Subject: [PATCH] Fix issues with string/atom mix in changeset --- lib/sanbase/discord_bot/ai_server.ex | 2 +- .../metric/registry/change_suggestion.ex | 4 +- lib/sanbase/metric/registry/permissions.ex | 30 ++++ lib/sanbase/metric/registry/sync.ex | 26 ++- lib/sanbase/metric/registry/sync_schema.ex | 7 +- lib/sanbase/transfers/erc20_transfers.ex | 2 - ...omponents.ex => admin_forms_components.ex} | 0 .../available_metrics_components.ex | 36 +++++ ...metric_registry_change_suggestions_live.ex | 15 +- .../metric_registry_index_live.ex | 40 +++-- .../metric_registry_show_live.ex | 2 + .../metric_registry_sync_live.ex | 50 ++++-- .../metric_registry_sync_run_details_live.ex | 26 +++ .../metric_registry_sync_runs_live.ex | 152 ++++++++++++++++++ lib/sanbase_web/router.ex | 2 + mix.exs | 1 + mix.lock | 2 + .../metric_registry_sync_test.exs | 6 +- .../metric_registry/metric_registry_test.exs | 2 +- 19 files changed, 355 insertions(+), 50 deletions(-) create mode 100644 lib/sanbase/metric/registry/permissions.ex rename lib/sanbase_web/components/admin/{user_submission_admin_components.ex => admin_forms_components.ex} (100%) create mode 100644 lib/sanbase_web/live/metric_registry/metric_registry_sync_run_details_live.ex create mode 100644 lib/sanbase_web/live/metric_registry/metric_registry_sync_runs_live.ex diff --git a/lib/sanbase/discord_bot/ai_server.ex b/lib/sanbase/discord_bot/ai_server.ex index 4c5be8dea..1c66a4852 100644 --- a/lib/sanbase/discord_bot/ai_server.ex +++ b/lib/sanbase/discord_bot/ai_server.ex @@ -32,7 +32,7 @@ defmodule Sanbase.DiscordBot.AiServer do end # current version of bot - def answer(question, discord_metadata \\ %{}) do + def answer(question, discord_metadata) when is_map(discord_metadata) do url = "#{ai_server_url()}/question" route_blacklist = diff --git a/lib/sanbase/metric/registry/change_suggestion.ex b/lib/sanbase/metric/registry/change_suggestion.ex index 590b80f4e..cf5d9ff49 100644 --- a/lib/sanbase/metric/registry/change_suggestion.ex +++ b/lib/sanbase/metric/registry/change_suggestion.ex @@ -160,7 +160,9 @@ defmodule Sanbase.Metric.Registry.ChangeSuggestion do # After change suggestion is applied, put the metric in a unverified state and mark # is as not synced. Someone needs to manually verify the metric after it is tested. # When the data is synced between stage and prod, the sync status will be updated. - # Note: Keep the keys as strings, not atoms, so the map is not mixed + + # Convert all keys to strings so we don't get error if atom keys come from some caller + params = Map.new(params, fn {k, v} -> {to_string(k), v} end) params = Map.merge(params, %{"is_verified" => false, "sync_status" => "not_synced"}) case Registry.changeset(registry, params) do diff --git a/lib/sanbase/metric/registry/permissions.ex b/lib/sanbase/metric/registry/permissions.ex new file mode 100644 index 000000000..8875d10ac --- /dev/null +++ b/lib/sanbase/metric/registry/permissions.ex @@ -0,0 +1,30 @@ +defmodule Sanbase.Metric.Registry.Permissions do + def can?(:create, _) do + # Will depend on the user roles as well + deployment_env() == "stage" or (deployment_env() == "dev" and not aws_db_url?()) + end + + def can?(:edit, _) do + # Will depend on the user roles as well + deployment_env() == "stage" or (deployment_env() == "dev" and not aws_db_url?()) + end + + def can?(:start_sync, _) do + # Will depend on the user roles as well + deployment_env() == "stage" or (deployment_env() == "dev" and not aws_db_url?()) + end + + def can?(:apply_change_suggestions, _) do + # Will depend on the user roles + true + end + + defp deployment_env() do + Sanbase.Utils.Config.module_get(Sanbase, :deployment_env) + end + + defp aws_db_url?() do + db_url = System.get_env("DATABASE_URL") + is_binary(db_url) and db_url =~ "aws" + end +end diff --git a/lib/sanbase/metric/registry/sync.ex b/lib/sanbase/metric/registry/sync.ex index 9ce89da3f..0dafd0feb 100644 --- a/lib/sanbase/metric/registry/sync.ex +++ b/lib/sanbase/metric/registry/sync.ex @@ -4,15 +4,33 @@ defmodule Sanbase.Metric.Registry.Sync do source of truth. """ + alias Hex.Solver.Registry alias Sanbase.Metric.Registry alias Sanbase.Utils.Config + import Sanbase.Utils.ErrorHandling, only: [changeset_errors_string: 1] require Logger def by_uuid(uuid), do: Registry.SyncSchema.by_uuid(uuid) + def cancel_run(uuid) do + case Registry.SyncSchema.by_uuid(uuid) do + {:ok, sync} -> + case Registry.SyncSchema.update_status(sync, "cancelled", "Manually canceled") do + {:ok, sync} -> + {:ok, sync} + + {:error, %Ecto.Changeset{} = changeset} -> + {:error, "Failed to cancel the sync. Error: #{changeset_errors_string(changeset)}"} + end + + {:error, _} -> + {:error, "Sync not found"} + end + end + @doc ~s""" - TODO + Start a sync that will sync the not synced metrics from stage to prod """ @spec sync(list(non_neg_integer())) :: :ok def sync(metric_registry_ids) when is_list(metric_registry_ids) do @@ -55,6 +73,10 @@ defmodule Sanbase.Metric.Registry.Sync do end end + def last_syncs(limit) do + Registry.SyncSchema.last_syncs(limit) + end + # Private functions defp send_sync_completed_confirmation(url) do @@ -95,7 +117,7 @@ defmodule Sanbase.Metric.Registry.Sync do end defp start_sync(sync) do - url = get_sync_target_url() |> IO.inspect() + url = get_sync_target_url() json = %{ "sync_uuid" => sync.uuid, diff --git a/lib/sanbase/metric/registry/sync_schema.ex b/lib/sanbase/metric/registry/sync_schema.ex index 534e61e9b..9beaa7d21 100644 --- a/lib/sanbase/metric/registry/sync_schema.ex +++ b/lib/sanbase/metric/registry/sync_schema.ex @@ -16,7 +16,12 @@ defmodule Sanbase.Metric.Registry.SyncSchema do def changeset(%__MODULE__{} = sync, attrs) do sync |> cast(attrs, [:uuid, :content, :status, :errors]) - |> validate_inclusion(:status, ["scheduled", "executing", "completed", "failed"]) + |> validate_inclusion(:status, ["scheduled", "executing", "completed", "failed", "cancelled"]) + end + + def last_syncs(limit) do + from(sync in __MODULE__, order_by: [desc: sync.id], limit: ^limit) + |> Sanbase.Repo.all() end def create(content) do diff --git a/lib/sanbase/transfers/erc20_transfers.ex b/lib/sanbase/transfers/erc20_transfers.ex index f10d4ec75..37681eec6 100644 --- a/lib/sanbase/transfers/erc20_transfers.ex +++ b/lib/sanbase/transfers/erc20_transfers.ex @@ -9,8 +9,6 @@ defmodule Sanbase.Transfers.Erc20Transfers do alias Sanbase.ClickhouseRepo alias Sanbase.Project - alias Sanbase.Utils.Config - defguard is_non_neg_integer(int) when is_integer(int) and int > 0 @spec top_wallet_transfers( diff --git a/lib/sanbase_web/components/admin/user_submission_admin_components.ex b/lib/sanbase_web/components/admin/admin_forms_components.ex similarity index 100% rename from lib/sanbase_web/components/admin/user_submission_admin_components.ex rename to lib/sanbase_web/components/admin/admin_forms_components.ex diff --git a/lib/sanbase_web/components/available_metrics_components.ex b/lib/sanbase_web/components/available_metrics_components.ex index 24ba141f9..2281c7a8f 100644 --- a/lib/sanbase_web/components/available_metrics_components.ex +++ b/lib/sanbase_web/components/available_metrics_components.ex @@ -3,6 +3,42 @@ defmodule SanbaseWeb.AvailableMetricsComponents do alias SanbaseWeb.CoreComponents + attr(:phx_click, :string, required: true) + attr(:display_text, :string, required: true) + attr(:class, :string, required: false, default: nil) + attr(:rest, :global, doc: "the arbitrary HTML attributes to add to the flash container") + + def event_button(assigns) do + ~H""" + + """ + end + + attr :href, :string, required: true + attr :text, :string, required: true + attr :icon, :string, required: false, default: nil + + def link_button(assigns) do + ~H""" + <.link + href={@href} + class="text-gray-900 bg-white hover:bg-gray-100 border border-gray-200 font-medium rounded-lg text-sm px-5 py-2.5 text-center inline-flex items-center gap-x-2" + > + + {@text} + + """ + end + @doc ~s""" The styled button is used to link to documentation and to link to the details page. Supports icons on the left side. diff --git a/lib/sanbase_web/live/metric_registry/metric_registry_change_suggestions_live.ex b/lib/sanbase_web/live/metric_registry/metric_registry_change_suggestions_live.ex index 78c3a9194..bbb125b53 100644 --- a/lib/sanbase_web/live/metric_registry/metric_registry_change_suggestions_live.ex +++ b/lib/sanbase_web/live/metric_registry/metric_registry_change_suggestions_live.ex @@ -2,6 +2,7 @@ defmodule SanbaseWeb.MetricRegistryChangeSuggestionsLive do use SanbaseWeb, :live_view alias SanbaseWeb.AdminFormsComponents + alias Sanbase.Metric.Registry.Permissions alias Sanbase.Metric.Registry.ChangeSuggestion alias SanbaseWeb.AvailableMetricsComponents @@ -9,8 +10,11 @@ defmodule SanbaseWeb.MetricRegistryChangeSuggestionsLive do def mount(_params, _session, socket) do {:ok, socket - |> assign(:rows, list_all_submissions()) - |> assign(:form, to_form(%{}))} + |> assign( + page_title: "Metric Registry Change Requests", + rows: list_all_submissions(), + form: to_form(%{}) + )} end @impl true @@ -40,7 +44,11 @@ defmodule SanbaseWeb.MetricRegistryChangeSuggestionsLive do <:col :let={row} label="Notes">{row.notes} <:col :let={row} label="Submitted By">{row.submitted_by} <:action :let={row}> - <.action_buttons form={@form} row={row} /> + <.action_buttons + :if={Permissions.can?(:apply_change_suggestions, [])} + form={@form} + row={row} + /> @@ -62,7 +70,6 @@ defmodule SanbaseWeb.MetricRegistryChangeSuggestionsLive do class="flex flex-col lg:flex-row space-y-2 lg:space-y-0 md:space-x-2" > - <.action_button value="approved" text="Approve" diff --git a/lib/sanbase_web/live/metric_registry/metric_registry_index_live.ex b/lib/sanbase_web/live/metric_registry/metric_registry_index_live.ex index c75ba9b7e..8aa54e920 100644 --- a/lib/sanbase_web/live/metric_registry/metric_registry_index_live.ex +++ b/lib/sanbase_web/live/metric_registry/metric_registry_index_live.ex @@ -1,9 +1,11 @@ defmodule SanbaseWeb.MetricRegistryIndexLive do use SanbaseWeb, :live_view - import SanbaseWeb.AvailableMetricsDescription + alias Sanbase.Metric.Registry.Permissions alias SanbaseWeb.AvailableMetricsComponents + import SanbaseWeb.AvailableMetricsDescription + @impl true def mount(_params, _session, socket) do metrics = Sanbase.Metric.Registry.all() @@ -11,6 +13,7 @@ defmodule SanbaseWeb.MetricRegistryIndexLive do {:ok, socket |> assign( + page_title: "Metric Registry", show_verified_changes_modal: false, visible_metrics_ids: Enum.map(metrics, & &1.id), metrics: metrics, @@ -97,8 +100,15 @@ defmodule SanbaseWeb.MetricRegistryIndexLive do popover_target="popover-metric-details" popover_target_text={get_popover_text(%{key: "Metric Details"})} > - <.action_button text="Show" href={~p"/admin2/metric_registry/show/#{row.id}"} /> - <.action_button text="Edit" href={~p"/admin2/metric_registry/edit/#{row.id}"} /> + + @@ -264,18 +274,20 @@ defmodule SanbaseWeb.MetricRegistryIndexLive do ~H"""
- <.action_button + - <.action_button + - <.action_button + - <.icon :if={@icon} name={@icon} /> - {@text} - - """ - end - attr :phx_click, :string, required: true attr :text, :string, required: true attr :count, :integer, required: false, default: nil diff --git a/lib/sanbase_web/live/metric_registry/metric_registry_show_live.ex b/lib/sanbase_web/live/metric_registry/metric_registry_show_live.ex index e13931cb1..5414e02ff 100644 --- a/lib/sanbase_web/live/metric_registry/metric_registry_show_live.ex +++ b/lib/sanbase_web/live/metric_registry/metric_registry_show_live.ex @@ -4,6 +4,7 @@ defmodule SanbaseWeb.MetricRegistryShowLive do import SanbaseWeb.CoreComponents import SanbaseWeb.AvailableMetricsDescription + alias Sanbase.Metric.Registry.Permissions alias SanbaseWeb.AvailableMetricsComponents @impl true @@ -34,6 +35,7 @@ defmodule SanbaseWeb.MetricRegistryShowLive do /> Enum.filter(&(&1.sync_status == "not_synced" and &1.is_verified == true)) - - not_syncable_metrics = - metrics - |> Enum.filter(&(&1.sync_status == "not_synced" and &1.is_verified == false)) + {syncable_metrics, not_syncable_metrics} = get_syncs_data() {:ok, socket @@ -42,7 +34,14 @@ defmodule SanbaseWeb.MetricRegistrySyncLive do href={~p"/admin2/metric_registry"} icon="hero-arrow-uturn-left" /> + +
+
<.phx_click_button text="Select All" @@ -109,11 +108,22 @@ defmodule SanbaseWeb.MetricRegistrySyncLive do ids = socket.assigns.metric_ids_to_sync |> Enum.to_list() case Sanbase.Metric.Registry.Sync.sync(ids) do - {:ok, data} -> {:ok, data} - {:error, error} -> {:error, error} + {:ok, data} -> + Process.sleep(5000) + {syncable_metrics, not_syncable_metrics} = get_syncs_data() + + {:noreply, + socket + |> put_flash(:info, "Sucessfully initiated sync of #{length(ids)} metrics") + |> assign( + syncable_metrics: syncable_metrics, + non_syncable_metrics: not_syncable_metrics, + metric_ids_to_sync: Enum.map(syncable_metrics, & &1.id) |> MapSet.new() + )} + + {:error, error} -> + {:noreply, socket |> put_flash(:error, "Error syncing metrics: #{error}")} end - - {:noreply, socket} end def handle_event("update_should_sync", %{"metric_registry_id" => id} = params, socket) do @@ -138,6 +148,20 @@ defmodule SanbaseWeb.MetricRegistrySyncLive do {:noreply, assign(socket, metric_ids_to_sync: MapSet.new())} end + defp get_syncs_data() do + metrics = Sanbase.Metric.Registry.all() + + syncable_metrics = + metrics + |> Enum.filter(&(&1.sync_status == "not_synced" and &1.is_verified == true)) + + not_syncable_metrics = + metrics + |> Enum.filter(&(&1.sync_status == "not_synced" and &1.is_verified == false)) + + {syncable_metrics, not_syncable_metrics} + end + defp metric_names(assigns) do ~H"""
diff --git a/lib/sanbase_web/live/metric_registry/metric_registry_sync_run_details_live.ex b/lib/sanbase_web/live/metric_registry/metric_registry_sync_run_details_live.ex new file mode 100644 index 000000000..de5329785 --- /dev/null +++ b/lib/sanbase_web/live/metric_registry/metric_registry_sync_run_details_live.ex @@ -0,0 +1,26 @@ +defmodule SanbaseWeb.MetricRegistrySyncRunDetailsLive do + use SanbaseWeb, :live_view + + @impl true + def mount(%{"uuid" => sync_uuid}, _session, socket) do + {:ok, sync} = + Sanbase.Metric.Registry.Sync.by_uuid(sync_uuid) + + sync = sync |> Map.update!(:content, &Jason.decode!/1) + + {:ok, + socket + |> assign(sync: sync)} + end + + @impl true + def render(assigns) do + ~H""" +
+
+ {Jason.encode!(metric, pretty: true)} +
+
+ """ + end +end diff --git a/lib/sanbase_web/live/metric_registry/metric_registry_sync_runs_live.ex b/lib/sanbase_web/live/metric_registry/metric_registry_sync_runs_live.ex new file mode 100644 index 000000000..b6c3c89fc --- /dev/null +++ b/lib/sanbase_web/live/metric_registry/metric_registry_sync_runs_live.ex @@ -0,0 +1,152 @@ +defmodule SanbaseWeb.MetricRegistrySyncRunsLive do + use SanbaseWeb, :live_view + + alias SanbaseWeb.AvailableMetricsComponents + + @impl true + def mount(_params, _session, socket) do + syncs = + Sanbase.Metric.Registry.Sync.last_syncs(20) + |> Enum.map(fn sync -> Map.update!(sync, :content, &Jason.decode!/1) end) + + {:ok, + socket + |> assign(syncs: syncs, page_title: "Past Metric Registry Sync Runs")} + end + + @impl true + def render(assigns) do + ~H""" +
+
+
+ Showing the last {length(@syncs)} syncs +
+
+
+ +
+ <.table id="metrics_registry_sync_runs" rows={@syncs}> + <:col :let={row} label="Datetime"> + {row.inserted_at} + + + <:col :let={row} label="Status"> +
+ {row.status} + + <.icon name="hero-exclamation-circle" /> Executing for too long! + ({rough_duration_since(row.inserted_at)}) + +
+ + + <:col :let={row} label="No. Metrics Synced"> + {length(row.content)} + + + <:col :let={row} label="Metrics Synced"> + <.list_synced_metrics content={row.content} /> + + + <:col :let={row}> + + + + + + end + +
+ """ + end + + @impl true + def handle_event("cancel_run", %{"sync-uuid" => sync_uuid}, socket) do + case Sanbase.Metric.Registry.Sync.cancel_run(sync_uuid) do + {:ok, sync} -> + syncs = + socket.assigns.syncs + |> Enum.map(&if &1.uuid == sync.uuid, do: sync, else: &1) + + {:noreply, + socket + |> put_flash(:info, "Sucessfully cancelled a long-running sync") + |> assign(:syncs, syncs)} + + {:error, error} -> + {:noreply, + socket + |> put_flash(:error, error)} + end + end + + defp execution_too_long?(status, inserted_at) do + status == "executing" and + NaiveDateTime.diff(NaiveDateTime.utc_now(), inserted_at, :second) > 60 + end + + defp rough_duration_since(%NaiveDateTime{} = ndt) do + seconds = NaiveDateTime.diff(NaiveDateTime.utc_now(), ndt, :second) + + cond do + seconds < 3600 -> + "#{div(seconds, 60)} minutes" + + seconds < 86400 -> + "#{div(seconds, 3600)} hours" + + true -> + days = div(seconds, 86400) + hours = div(rem(seconds, 86400), 3600) + "#{days} days" <> if(hours == 0, do: "", else: " #{hours} hours") + end + end + + attr :phx_click, :string, required: true + attr :text, :string, required: true + attr :count, :integer, required: false, default: nil + attr :class, :string, required: true + attr :phx_disable_with, :string, required: false, default: nil + + defp phx_click_button(assigns) do + ~H""" + + """ + end + + defp list_synced_metrics(assigns) do + ~H""" +
+ {Enum.map(@content, & &1["metric"]) |> Enum.join(", ")} +
+ """ + end +end diff --git a/lib/sanbase_web/router.ex b/lib/sanbase_web/router.ex index 386c43165..8ae26ece4 100644 --- a/lib/sanbase_web/router.ex +++ b/lib/sanbase_web/router.ex @@ -88,6 +88,8 @@ defmodule SanbaseWeb.Router do live("/metric_registry/edit/:id", MetricRegistryFormLive, :edit) live("/metric_registry/new", MetricRegistryFormLive, :new) live("/metric_registry/sync", MetricRegistrySyncLive, :new) + live("/metric_registry/sync_runs", MetricRegistrySyncRunsLive, :new) + live("/metric_registry/sync/:uuid", MetricRegistrySyncRunDetailsLive, :new) end scope "/" do diff --git a/mix.exs b/mix.exs index e8b09ac8b..743117aeb 100644 --- a/mix.exs +++ b/mix.exs @@ -134,6 +134,7 @@ defmodule Sanbase.Mixfile do {:remote_ip, "~> 1.0"}, {:rexbug, ">= 1.0.0"}, {:rustler, "~> 0.24"}, + {:scribe, "~> 0.11"}, {:sentry, "~> 10.0"}, {:stream_data, "~> 1.1", only: :test, override: true}, {:stripity_stripe, "~> 3.2"}, diff --git a/mix.lock b/mix.lock index dec26bdf9..4e302cb6c 100644 --- a/mix.lock +++ b/mix.lock @@ -107,6 +107,7 @@ "oban": {:hex, :oban, "2.18.3", "1608c04f8856c108555c379f2f56bc0759149d35fa9d3b825cb8a6769f8ae926", [:mix], [{:ecto_sql, "~> 3.10", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:ecto_sqlite3, "~> 0.9", [hex: :ecto_sqlite3, repo: "hexpm", optional: true]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.16", [hex: :postgrex, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "36ca6ca84ef6518f9c2c759ea88efd438a3c81d667ba23b02b062a0aa785475e"}, "observer_cli": {:hex, :observer_cli, "1.8.1", "edfe0c0f983631961599326f239f6e99750aba7387515002b1284dcfe7fcd6d2", [:mix, :rebar3], [{:recon, "~> 2.5.6", [hex: :recon, repo: "hexpm", optional: false]}], "hexpm", "a3cd6300dd8290ade93d688fbd79c872e393b01256309dd7a653feb13c434fb4"}, "octo_fetch": {:hex, :octo_fetch, "0.4.0", "074b5ecbc08be10b05b27e9db08bc20a3060142769436242702931c418695b19", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~> 1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm", "cf8be6f40cd519d7000bb4e84adcf661c32e59369ca2827c4e20042eda7a7fc6"}, + "pane": {:hex, :pane, "0.5.0", "9151be55a29c1ef3f772ceabc33bc4aa00d32846c93350416af9fe7470af7dc5", [:mix], [], "hexpm", "71ad875092bff3c249195881a56df836ca5f9f2dcd668a21dd2b1b5d9549b7b9"}, "parse_trans": {:hex, :parse_trans, "3.4.2", "c352ddc1a0d5e54f9b1654d45f9c432eef76f9cea371c55ddff769ef688fdb74", [:rebar3], [], "hexpm", "4c25347de3b7c35732d32e69ab43d1ceee0beae3f3b3ade1b59cbd3dd224d9ca"}, "peep": {:hex, :peep, "3.3.0", "ece8c38f0e3cfeecf8739d377c228c7e2b34d947f6b4817a183be37c88b94ebe", [:mix], [{:nimble_options, "~> 1.1", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:plug, "~> 1.16", [hex: :plug, repo: "hexpm", optional: true]}, {:telemetry_metrics, "~> 1.0", [hex: :telemetry_metrics, repo: "hexpm", optional: false]}], "hexpm", "19c84bf78c4eee97cb0df33d4ea628e93b6ab148ee19c289c499d1d62b3e78cb"}, "phoenix": {:hex, :phoenix, "1.7.18", "5310c21443514be44ed93c422e15870aef254cf1b3619e4f91538e7529d2b2e4", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:phoenix_template, "~> 1.0", [hex: :phoenix_template, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.7", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:websock_adapter, "~> 0.5.3", [hex: :websock_adapter, repo: "hexpm", optional: false]}], "hexpm", "1797fcc82108442a66f2c77a643a62980f342bfeb63d6c9a515ab8294870004e"}, @@ -136,6 +137,7 @@ "rustler": {:hex, :rustler, "0.35.1", "ec81961ef9ee833d721dafb4449cab29b16b969a3063a842bb9e3ea912f6b938", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:req, "~> 0.5", [hex: :req, repo: "hexpm", optional: false]}, {:toml, "~> 0.6", [hex: :toml, repo: "hexpm", optional: false]}], "hexpm", "3713b2e70e68ec2bfa8291dfd9cb811fe64a770f254cd9c331f8b34fa7989115"}, "rustler_precompiled": {:hex, :rustler_precompiled, "0.8.2", "5f25cbe220a8fac3e7ad62e6f950fcdca5a5a5f8501835d2823e8c74bf4268d5", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:rustler, "~> 0.23", [hex: :rustler, repo: "hexpm", optional: true]}], "hexpm", "63d1bd5f8e23096d1ff851839923162096364bac8656a4a3c00d1fff8e83ee0a"}, "salsa20": {:hex, :salsa20, "1.0.4", "404cbea1fa8e68a41bcc834c0a2571ac175580fec01cc38cc70c0fb9ffc87e9b", [:mix], [], "hexpm", "745ddcd8cfa563ddb0fd61e7ce48d5146279a2cf7834e1da8441b369fdc58ac6"}, + "scribe": {:hex, :scribe, "0.11.0", "6cbeea62486f682fec02b7064b0d2f764fa9749a3c0460feaf48b85b9f572682", [:mix], [{:pane, "~> 0.2", [hex: :pane, repo: "hexpm", optional: false]}], "hexpm", "fff15704b6a400125b4200b0bc052e589e831092991140ddb178cc0deb0e7885"}, "sentry": {:hex, :sentry, "10.8.1", "aa45309785e1521416225adb16e0b4d8b957578804527f3c7babb6fefbc5e456", [:mix], [{:hackney, "~> 1.8", [hex: :hackney, repo: "hexpm", optional: true]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: true]}, {:nimble_options, "~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:nimble_ownership, "~> 0.3.0 or ~> 1.0", [hex: :nimble_ownership, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.6", [hex: :phoenix, repo: "hexpm", optional: true]}, {:phoenix_live_view, "~> 0.20 or ~> 1.0", [hex: :phoenix_live_view, repo: "hexpm", optional: true]}, {:plug, "~> 1.6", [hex: :plug, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm", "495b3cdadad90ba72eef973aa3dec39b3b8b2a362fe87e2f4ef32133ac3b4097"}, "sleeplocks": {:hex, :sleeplocks, "1.1.3", "96a86460cc33b435c7310dbd27ec82ca2c1f24ae38e34f8edde97f756503441a", [:rebar3], [], "hexpm", "d3b3958552e6eb16f463921e70ae7c767519ef8f5be46d7696cc1ed649421321"}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.7", "354c321cf377240c7b8716899e182ce4890c5938111a1296add3ec74cf1715df", [:make, :mix, :rebar3], [], "hexpm", "fe4c190e8f37401d30167c8c405eda19469f34577987c76dde613e838bbc67f8"}, diff --git a/test/sanbase/metric_registry/metric_registry_sync_test.exs b/test/sanbase/metric_registry/metric_registry_sync_test.exs index 6f7097fc9..77714debd 100644 --- a/test/sanbase/metric_registry/metric_registry_sync_test.exs +++ b/test/sanbase/metric_registry/metric_registry_sync_test.exs @@ -2,9 +2,9 @@ defmodule Sanbase.MetricRegistrySyncTest do use SanbaseWeb.ConnCase alias Sanbase.Metric.Registry - test "syncing", context do - Req.post("http://localhost:4000/sync_metric_registry?secret=secret_only_on_prod") + @moduletag capture_log: true + test "syncing", _context do [m1_id, m2_id] = create_sync_requirements() {:ok, m1} = Registry.by_id(m1_id) @@ -15,7 +15,7 @@ defmodule Sanbase.MetricRegistrySyncTest do assert {:ok, %{status: "executing", uuid: uuid}} = Registry.Sync.sync([m1_id, m2_id]) - Process.sleep(1000) + Process.sleep(100) assert {:ok, %{status: "completed", uuid: ^uuid}} = Registry.Sync.by_uuid(uuid) {:ok, m1} = Registry.by_id(m1_id) diff --git a/test/sanbase/metric_registry/metric_registry_test.exs b/test/sanbase/metric_registry/metric_registry_test.exs index e31c25d3b..80d432201 100644 --- a/test/sanbase/metric_registry/metric_registry_test.exs +++ b/test/sanbase/metric_registry/metric_registry_test.exs @@ -1,4 +1,4 @@ -dsefmodule Sanbase.MetricRegistyTest do +defmodule Sanbase.MetricRegistyTest do use Sanbase.DataCase import ExUnit.CaptureLog