From 9b5284472ee2aad3cc04d89cefdb93c9615ea44a Mon Sep 17 00:00:00 2001 From: Zack Siri Date: Thu, 12 Sep 2024 14:27:42 +0700 Subject: [PATCH 1/4] put availability update in transaction --- test/uplink/packages/instance/placement_test.exs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/uplink/packages/instance/placement_test.exs b/test/uplink/packages/instance/placement_test.exs index 5c284a8..27c55a0 100644 --- a/test/uplink/packages/instance/placement_test.exs +++ b/test/uplink/packages/instance/placement_test.exs @@ -65,11 +65,11 @@ defmodule Uplink.Packages.Instance.PlacementTest do |> Plug.Conn.resp(200, cluster_members) end) - Uplink.Cache.put({:available_nodes, placement_name}, []) - Uplink.Cache.transaction( [keys: [{:available_nodes, placement_name}]], fn -> + Uplink.Cache.put({:available_nodes, placement_name}, []) + assert {:ok, %Placement{}} = Placement.find(node_name, "spread") end ) From 9fdc05bf58f4e7ff568b22fc4b7ebfe3e6f60eb5 Mon Sep 17 00:00:00 2001 From: Zack Siri Date: Thu, 12 Sep 2024 14:31:53 +0700 Subject: [PATCH 2/4] Use stub --- test/uplink/packages/instance/placement_test.exs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/test/uplink/packages/instance/placement_test.exs b/test/uplink/packages/instance/placement_test.exs index 27c55a0..aa79cca 100644 --- a/test/uplink/packages/instance/placement_test.exs +++ b/test/uplink/packages/instance/placement_test.exs @@ -59,20 +59,15 @@ defmodule Uplink.Packages.Instance.PlacementTest do |> Plug.Conn.resp(200, existing_instances) end) - Bypass.expect_once(bypass, "GET", "/1.0/cluster/members", fn conn -> + Bypass.stub(bypass, "GET", "/1.0/cluster/members", fn conn -> conn |> Plug.Conn.put_resp_header("content-type", "application/json") |> Plug.Conn.resp(200, cluster_members) end) - Uplink.Cache.transaction( - [keys: [{:available_nodes, placement_name}]], - fn -> - Uplink.Cache.put({:available_nodes, placement_name}, []) + Uplink.Cache.put({:available_nodes, placement_name}, []) - assert {:ok, %Placement{}} = Placement.find(node_name, "spread") - end - ) + assert {:ok, %Placement{}} = Placement.find(node_name, "spread") end end end From 8ee07d66c1e099e64a38aa73a8cc1f274e7e7598 Mon Sep 17 00:00:00 2001 From: Zack Siri Date: Thu, 12 Sep 2024 14:35:11 +0700 Subject: [PATCH 3/4] Ensure availability is nil --- test/uplink/packages/instance/placement_test.exs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/uplink/packages/instance/placement_test.exs b/test/uplink/packages/instance/placement_test.exs index aa79cca..663130e 100644 --- a/test/uplink/packages/instance/placement_test.exs +++ b/test/uplink/packages/instance/placement_test.exs @@ -51,6 +51,8 @@ defmodule Uplink.Packages.Instance.PlacementTest do } do placement_name = Placement.name(node_name) + Uplink.Cache.delete({:available_nodes, placement_name}) + Bypass.expect_once(bypass, "GET", "/1.0/instances", fn conn -> assert %{"recursion" => "1", "all-projects" => _} = conn.query_params @@ -59,7 +61,7 @@ defmodule Uplink.Packages.Instance.PlacementTest do |> Plug.Conn.resp(200, existing_instances) end) - Bypass.stub(bypass, "GET", "/1.0/cluster/members", fn conn -> + Bypass.expect_once(bypass, "GET", "/1.0/cluster/members", fn conn -> conn |> Plug.Conn.put_resp_header("content-type", "application/json") |> Plug.Conn.resp(200, cluster_members) From e61d2e68517113a69480a2f367408aa85ba99a1f Mon Sep 17 00:00:00 2001 From: Zack Siri Date: Thu, 12 Sep 2024 14:38:29 +0700 Subject: [PATCH 4/4] Bump version --- mix.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mix.exs b/mix.exs index 9a3055c..3213d53 100644 --- a/mix.exs +++ b/mix.exs @@ -4,7 +4,7 @@ defmodule Uplink.MixProject do def project do [ app: :uplink, - version: "0.15.4", + version: "0.15.5", elixir: "~> 1.13", elixirc_paths: elixirc_paths(Mix.env()), start_permanent: Mix.env() == :prod,