this repo has no description
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Refactor sandbox cluster path configuration

garrison ab2a48ea c7521973

+21 -15
+6 -12
lib/sandbox.ex
··· 38 38 # Starting a distributed cluster is sim-only for now 39 39 assert Sim.simulated?() 40 40 41 - in_memory? = Keyword.get(opts, :in_memory?, false) 42 - cluster_path = case in_memory? do 43 - true -> :memory 44 - false -> "/cluster" 45 - end 41 + cluster_path = Keyword.get(opts, :path, :memory) 42 + in_memory? = cluster_path == :memory 43 + if cluster_path != :memory, do: assert(is_binary(cluster_path)) 46 44 47 45 coordinators = Enum.map(0..(num_coordinators - 1), fn i -> 48 46 # TODO: name should include cluster name ··· 77 75 String.to_atom("coordinator-#{i}") 78 76 end) 79 77 80 - in_memory? = Keyword.get(opts, :in_memory?, false) 81 - cluster_path = case in_memory? do 82 - true -> :memory 83 - false -> "/cluster" 84 - end 78 + cluster_path = Keyword.get(opts, :path, :memory) 79 + in_memory? = cluster_path == :memory 80 + if cluster_path != :memory, do: assert(is_binary(cluster_path)) 85 81 86 82 coordinators 87 83 |> Enum.with_index() ··· 109 105 110 106 coordinators = 111 107 if Keyword.get(opts, :distributed) do 112 - opts = Keyword.put(opts, :in_memory?, false) 113 108 init_distributed_cluster(num_coordinators, opts) 114 109 else 115 - opts = Keyword.put(opts, :in_memory?, true) 116 110 init_local_cluster(num_coordinators, opts) 117 111 end 118 112
+15 -3
test/hobbes_test.exs
··· 30 30 } 31 31 32 32 def sim_opts(opts) when is_list(opts) do 33 - {preset, opts} = Keyword.pop(opts, :preset, :default) 33 + {preset_name, opts} = Keyword.pop(opts, :preset, :default) 34 + 35 + simulated? = Keyword.get(opts, :simulated, @simulated) 36 + default_cluster_path = case simulated? do 37 + true -> "/hobbes_test_cluster" 38 + false -> :memory 39 + end 40 + 41 + preset = Map.fetch!(@cluster_presets, preset_name) 42 + preset = Keyword.put(preset, :path, default_cluster_path) 34 43 35 44 Keyword.merge([ 36 45 simulated: @simulated, 37 46 full_log: false, 38 47 count: @count, 39 48 seed: @seed, 40 - cluster_opts: Map.fetch!(@cluster_presets, preset), 41 - ], opts) 49 + cluster_opts: preset, 50 + ], opts, &merge/3) 42 51 end 52 + 53 + defp merge(:cluster_opts, k1, k2) when is_list(k1) and is_list(k2), do: Keyword.merge(k1, k2) 54 + defp merge(_key, _v1, v2), do: v2 43 55 end 44 56 45 57 defmodule ModelWorkloadTest do